[PATCH] Fix print of value type in a corner case of finish
Antoine Tremblay
antoine.tremblay@ericsson.com
Thu Feb 26 14:11:00 GMT 2015
On 02/26/2015 08:35 AM, Pedro Alves wrote:
> It there a way to add a test?
I would need to add a test that's specific to an architecture that does
not support the struct return value...
I'll see what I can figure out..
> Also please use "const char *" for type_name, so C++
> doesn't complain. :-)
Humm not sure I understand here since type_to_string returns a char*
that needs to be freed ?
Converting to const char* would make make_cleanup complain...
How is C++ complaining ?
> Thanks,
> Pedro Alves
>
> On 02/26/2015 01:25 PM, Antoine Tremblay wrote:
>> When doing finish in a function, if gdb fails to return a value, gdb
>> also fails at printing the value type if this type is a struct.
>>
>> For example :
>>
>> (gdb) fin
>> ....
>> Value returned has type: . Cannot determine contents
>>
>> This patch fixes this by calling type_to_string to print the type
>> so that we can support these types.
>>
>> This patch returns the following example output :
>>
>> (gdb) fin
>> ....
>> Value returned has type: struct test. Cannot determine contents
>>
>> gdb/ChangeLog:
>> * gdb/infcmd.c (print_return_value): use type_to_string to print type.
>> ---
>> gdb/infcmd.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
>> index 9a1fb8d..3737b8f 100644
>> --- a/gdb/infcmd.c
>> +++ b/gdb/infcmd.c
>> @@ -1607,10 +1607,16 @@ print_return_value (struct value *function, struct type *value_type)
>> }
>> else
>> {
>> + struct cleanup *oldchain;
>> + char *type_name;
>> +
>> + type_name = type_to_string (value_type);
>> + oldchain = make_cleanup (xfree, type_name);
>> ui_out_text (uiout, "Value returned has type: ");
>> - ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
>> + ui_out_field_string (uiout, "return-type", type_name);
>> ui_out_text (uiout, ".");
>> ui_out_text (uiout, " Cannot determine contents\n");
>> + do_cleanups (oldchain);
>> }
>> }
>>
>>
More information about the Gdb-patches
mailing list