diff options
author | Keith Seitz <keiths@redhat.com> | 2003-06-27 00:29:16 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2003-06-27 00:29:16 +0000 |
commit | 03a34924fc9a87250cba1898f66303e14382b34e (patch) | |
tree | 234df69f8b414fc1a40ef1a52f3e8a3271370e93 | |
parent | 4bcbe49336389718df25b1e0c47b6b9c8257d5ea (diff) | |
download | gdb-03a34924fc9a87250cba1898f66303e14382b34e.tar.gz |
From Roland Schwingel <Roland.Schwingel@onevision.de>:
* generic/gdbtk-cmds.c (gdb_find_file_command): If filename
is already an absolute filename, try stat'ing it before searching
symtabs.
-rw-r--r-- | gdb/gdbtk/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/gdbtk/generic/gdbtk-cmds.c | 41 |
2 files changed, 38 insertions, 10 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index add51e4cc89..a9ad0a9f77a 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,3 +1,10 @@ +2003-06-26 Keith R Seitz <keiths@redhat.com> + + From Roland Schwingel <Roland.Schwingel@onevision.de>: + * generic/gdbtk-cmds.c (gdb_find_file_command): If filename + is already an absolute filename, try stat'ing it before searching + symtabs. + 2003-06-13 Martin Hunt <hunt@redhat.com> * library/prefs.tcl (load_gnome_file): Fix parsing diff --git a/gdb/gdbtk/generic/gdbtk-cmds.c b/gdb/gdbtk/generic/gdbtk-cmds.c index 7c08253acb9..8f4ba9aefcf 100644 --- a/gdb/gdbtk/generic/gdbtk-cmds.c +++ b/gdb/gdbtk/generic/gdbtk-cmds.c @@ -36,6 +36,7 @@ #include "annotate.h" #include "block.h" #include "dictionary.h" +#include "filenames.h" /* tcl header files includes varargs.h unless HAS_STDARG is defined, but gdb uses stdarg.h, so make sure HAS_STDARG is defined. */ @@ -1037,7 +1038,7 @@ gdb_find_file_command (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { struct symtab *st; - char *filename, *fullname; + char *filename, *fullname = NULL; if (objc != 2) { @@ -1046,20 +1047,40 @@ gdb_find_file_command (ClientData clientData, Tcl_Interp *interp, } filename = Tcl_GetStringFromObj (objv[1], NULL); - st = lookup_symtab (filename); - /* We should always get a symtab. */ - if (!st) + /* Shortcut: There seems to be some mess in gdb dealing with + files. While we should let gdb sort it out, it doesn't hurt + to be a little defensive here. + + If the filename is already an absolute filename, just try + to stat it. If it's not found, then ask gdb to find it for us. */ + if (IS_ABSOLUTE_PATH (filename)) { - gdbtk_set_result (interp, "File not found in symtab (2)"); - return TCL_ERROR; - } + struct stat st; + const int status = stat (filename, &st); - if (st->fullname == NULL) - fullname = symtab_to_filename (st); + if (status == 0) + { + if (S_ISREG (st.st_mode)) + fullname = filename; + } + } else - fullname = st->fullname; + { + /* Ask gdb to find the file for us. */ + st = lookup_symtab (filename); + /* We should always get a symtab. */ + if (!st) + { + gdbtk_set_result (interp, "File not found in symtab (2)"); + return TCL_ERROR; + } + + fullname = + (st->fullname == NULL ? symtab_to_filename (st) : st->fullname); + } + /* We may not be able to open the file (not available). */ if (fullname == NULL) { |