Re: [rfc] Print MI fullname even for non-existing files

Edjunior Barbosa Machado
2012-12-28T00:17:23Z

On 12/17/2012 04:59 PM, Jan Kratochvil wrote:
> gdb/
> 2012-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * ada-lang.c (is_known_support_routine): New variable fullname. Use
> access call to verify the symtab_to_fullname result.
> * breakpoint.c (print_breakpoint_location, update_static_tracepoint):
> Remove NULL check of symtab_to_fullname result.
> * cli/cli-cmds.c (edit_command): Likewise.
> * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
> (mi_cmd_file_list_exec_source_files): Likewise.
> * python/py-symtab.c (stpy_fullname): Likewise.
> * source.c (symtab_to_fullname): Update function comment. Rename
> variable r to fd, move it to inner block. Always provide non-NULL
> result.
> (print_source_lines_base): Remove NULL check of symtab_to_fullname
> result.
> * stack.c (print_frame): Likewise.
> * symtab.c (iterate_over_some_symtabs, find_line_symtab, sources_info):
> Likewise.
> * tracepoint.c (print_one_static_tracepoint_marker): Likewise.
>
> gdb/doc/
> 2012-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.texinfo (GDB/MI Data Manipulation) (fullname): Make it always
> present.
> (GDB/MI File Commands) (-file-list-exec-source-files): Make the
> fullname output always present.
>
> gdb/testsuite/
> 2012-12-17 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.mi/mi-fullname-deleted.exp: New file.
>

I've seen a high number of failures on gdb.base/list.exp testcase on ppc64 after
this change and noticed that gdb was segfaulting when issuing a list with
specific arguments:

$ ./gdb ./testsuite/gdb.base/list -q -ex 'list list0.h:1'
Reading symbols from /home/emachado/gdb/build/gdb/testsuite/gdb.base/list...done.
Segmentation fault (core dumped)

This seem to be due to a strcmp with a null string 'symtab->fullname' in:

if (FILENAME_CMP (symtab->fullname, symtab_to_fullname (s)) != 0)

With the patch below, this problem is fixed and gdb.base/list.exp no longer
crashes gdb. Ok?

2012-12-27 Edjunior Machado <emachado@linux.vnet.ibm.com>

* symtab.c (find_line_symtab): Update symtab->fullname before compare
full file name strings.

diff --git a/gdb/symtab.c b/gdb/symtab.c
index a39e5bf..bd6c3b4 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2547,6 +2547,9 @@ find_line_symtab (struct symtab *symtab, int line,
symtab->filename);
}

+ /* Get symbol full file name if possible. */
+ symtab_to_fullname (symtab);
+
ALL_SYMTABS (objfile, s)
{
struct linetable *l;