Re: [PATCH] Display full file path in MI style disassembly listing

Pedro Alves
2012-10-17T18:25:27Z

On 10/04/2012 05:09 PM, Andrew Burgess wrote:
> When producing an MI style disassembly listing we use the shorted symtab filename, rather than computing the fullname. This can make it harder for an MI consumer to figure out which file to open.
>
> The patch below tries to use the fullname when it can, and falls back to the shorter name if it can't figure out the full name.
>
> Ok to apply?

At least with breakpoints, we leave "file" to whatever is recorded in the symtab,
and output a "fullname" MI field in addition, with whatever GDB resolves as the file's
path in the filesystem using its current source location rules:

b main
&"b main\n"
~"Breakpoint 6 at 0x457ceb: file ../../src/gdb/gdb.c, line 29.\n"
=breakpoint-created,bkpt={number="6",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000457ceb",func="main",file="../../src/gdb/gdb.c",fullname="/home/pedro/gdb/mygit/src/gdb/gdb.c",line="29",times="0",original-location="main"}

I'd think it better to be consistent here.

>
> Thanks,
> Andrew
>
> gdb/ChangeLog
>
> 2012-10-04 Andrew Burhess <aburgess@broadcom.com>
>
> * source.c (print_source_lines_base): Display full file name when
> producing MI style disassembly listings.
>
> diff --git a/gdb/source.c b/gdb/source.c
> index 31e104f..2a02382 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -1298,9 +1298,19 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
> }
> else
> {
> + char *filename;
> +
> + filename = s->fullname;
> + if (filename == NULL)
> + {
> + filename = symtab_to_fullname (s);
> + if (filename == NULL)
> + filename = s->filename;
> + }
> +
> ui_out_field_int (uiout, "line", line);
> ui_out_text (uiout, "\tin ");
> - ui_out_field_string (uiout, "file", s->filename);
> + ui_out_field_string (uiout, "file", filename);
> ui_out_text (uiout, "\n");
> }
>
>

--
Pedro Alves