diff options
author | Fernando Nasser <fnasser@redhat.com> | 2001-02-07 01:11:18 +0000 |
---|---|---|
committer | Fernando Nasser <fnasser@redhat.com> | 2001-02-07 01:11:18 +0000 |
commit | f7157d5ba6b94baf942633b41c39b2b56b372074 (patch) | |
tree | 379e491c0698f3ab84e36edc44a4c8f05be38a95 /gdb | |
parent | b18260f61d02080085fadf74728ad24922660343 (diff) | |
download | gdb-f7157d5ba6b94baf942633b41c39b2b56b372074.tar.gz |
2001-02-06 Fernando Nasser <fnasser@redhat.com>
Originally from Martin Hunt <hunt@redhat.com>, with modifications
* library/srcwin.itb (_name): Check for errors when invoking
gdb_find_file.
* library/srctextwin.itb (_mtime_changed, location): Ditto.
* generic/gdbtk-cmds.c (gdb_find_file_command): Better error checking.
(full_lookup_symtab): Fix misleading comment.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/gdbtk/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/gdbtk/generic/gdbtk-cmds.c | 32 | ||||
-rw-r--r-- | gdb/gdbtk/library/srctextwin.itb | 14 | ||||
-rw-r--r-- | gdb/gdbtk/library/srcwin.itb | 12 |
4 files changed, 48 insertions, 19 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index 5b6cb592e6d..73e877ae3bf 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,3 +1,12 @@ +2001-02-06 Fernando Nasser <fnasser@redhat.com> + + Originally from Martin Hunt <hunt@redhat.com>, with modifications + * library/srcwin.itb (_name): Check for errors when invoking + gdb_find_file. + * library/srctextwin.itb (_mtime_changed, location): Ditto. + * generic/gdbtk-cmds.c (gdb_find_file_command): Better error checking. + (full_lookup_symtab): Fix misleading comment. + 2001-02-04 Fernando Nasser <fnasser@redhat.com> * library/plugins/plugins.tcl: Fix typos and remove "-transient" diff --git a/gdb/gdbtk/generic/gdbtk-cmds.c b/gdb/gdbtk/generic/gdbtk-cmds.c index 15cc7019660..6d5681eeea5 100644 --- a/gdb/gdbtk/generic/gdbtk-cmds.c +++ b/gdb/gdbtk/generic/gdbtk-cmds.c @@ -1319,8 +1319,8 @@ gdb_get_function_command (clientData, interp, objc, objv) * Tcl Arguments: * filename: the file name to search for. * Tcl Result: - * The full path to the file, or an empty string if the file is not - * found. + * The full path to the file, an empty string if the file was not + * available or an error message if the file is not found in the symtab. */ static int @@ -1330,8 +1330,8 @@ gdb_find_file_command (clientData, interp, objc, objv) int objc; Tcl_Obj *CONST objv[]; { - char *filename = NULL; struct symtab *st; + char *filename; if (objc != 2) { @@ -1339,17 +1339,25 @@ gdb_find_file_command (clientData, interp, objc, objv) return TCL_ERROR; } - st = full_lookup_symtab (Tcl_GetStringFromObj (objv[1], NULL)); - if (st) - filename = st->fullname; + filename = Tcl_GetStringFromObj (objv[1], NULL); + st = full_lookup_symtab (filename); - if (filename == NULL) + /* We should always get a symtab. */ + if (!st) { - Tcl_SetStringObj ( result_ptr->obj_ptr, "File not found in symtab (2)", -1); + Tcl_SetStringObj ( result_ptr->obj_ptr, + "File not found in symtab (2)", -1); return TCL_ERROR; } - else - Tcl_SetStringObj (result_ptr->obj_ptr, filename, -1); + + /* We may not be able to open the file (not available). */ + if (!st->fullname) + { + Tcl_SetStringObj (result_ptr->obj_ptr, "", -1); + return TCL_OK; + } + + Tcl_SetStringObj (result_ptr->obj_ptr, st->fullname, -1); return TCL_OK; } @@ -4648,8 +4656,8 @@ perror_with_name_wrapper (args) /* The lookup_symtab() in symtab.c doesn't work correctly */ /* It will not work will full pathnames and if multiple */ /* source files have the same basename, it will return */ -/* the first one instead of the correct one. This version */ -/* also always makes sure symtab->fullname is set. */ +/* the first one instead of the correct one. */ +/* symtab->fullname will be NULL if the file is not available. */ static struct symtab * full_lookup_symtab (file) diff --git a/gdb/gdbtk/library/srctextwin.itb b/gdb/gdbtk/library/srctextwin.itb index d3f4d4a9637..3bc5c9a6d3b 100644 --- a/gdb/gdbtk/library/srctextwin.itb +++ b/gdb/gdbtk/library/srctextwin.itb @@ -888,9 +888,9 @@ body SrcTextWin::ClearTags {} { body SrcTextWin::_mtime_changed {filename} { global tcl_platform - set f [gdb_find_file $filename] - - if {$f == ""} { + if [catch {gdb_find_file $filename} f] { + set r 1 + } elseif {$f == ""} { set r 1 } else { if {[string compare $tcl_platform(platform) "windows"] == 0} { @@ -1198,7 +1198,13 @@ body SrcTextWin::location {tagname filename funcname line addr pc_addr lib} { if {$oldmode != "" \ && [string compare $filename $current(filename)] != 0} { - if {[gdb_find_file $filename] != ""} { + + if [catch {gdb_find_file $filename} fullname] { + dbug W "$filename: $fullname" + set fullname "" + } + + if {$fullname != ""} { set tmp $oldmode set oldmode "" $parent mode "" $tmp 0 diff --git a/gdb/gdbtk/library/srcwin.itb b/gdb/gdbtk/library/srcwin.itb index ee1aa112d45..711c5a34855 100644 --- a/gdb/gdbtk/library/srcwin.itb +++ b/gdb/gdbtk/library/srcwin.itb @@ -1,5 +1,5 @@ -# Source window for GDBtk. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# Source window for Insight. +# Copyright 1997, 1998, 1999, 2001 Red Hat # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -295,7 +295,11 @@ body SrcWin::_name {w {val ""}} { if {$val != ""} { if {![info exists _files(short,$val)]} { if {![info exists _files(full,$val)]} { - set full [gdb_find_file $val] + if [catch {gdb_find_file $val} full] { + set_status "Cannot find source file \"$val\": $full" + $_statbar.name entryset [lindex [file split $current(filename)] end] + return + } if {$full == ""} { set_status "Cannot find source file \"$val\"" $_statbar.name entryset [lindex [file split $current(filename)] end] @@ -369,6 +373,8 @@ body SrcWin::fillNameCB {} { set allfiles [gdb_listfiles] debug "gdb_listfiles returned $allfiles" foreach f $allfiles { + # FIXME: If you reactivate this code add a catch as gdb_find_file can err + # (P.S.: I don't know why this is commented out) #set fullname [gdb_find_file $f] #set _files(full,$f) $fullname #set _files(short,$fullname) $f |