OSDN Git Service

2001-02-06 Fernando Nasser <fnasser@redhat.com>
authorFernando Nasser <fnasser@redhat.com>
Wed, 7 Feb 2001 01:11:18 +0000 (01:11 +0000)
committerFernando Nasser <fnasser@redhat.com>
Wed, 7 Feb 2001 01:11:18 +0000 (01:11 +0000)
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.

gdb/gdbtk/ChangeLog
gdb/gdbtk/generic/gdbtk-cmds.c
gdb/gdbtk/library/srctextwin.itb
gdb/gdbtk/library/srcwin.itb

index 5b6cb59..73e877a 100644 (file)
@@ -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"
index 15cc701..6d5681e 100644 (file)
@@ -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)
index d3f4d4a..3bc5c9a 100644 (file)
@@ -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
index ee1aa11..711c5a3 100644 (file)
@@ -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