This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFC] patch to fix finding sources


After considering all that Martin said and the old bug I was originally trying to fix I came with this new patch.  I have tested and it seems OK.

I have to leave now and I don't want to leave things broken, so I will check it in.

Martin, please take a look and see what you think.  It now covers both that nasty
NULL symtab case and the file not available case.


Thanks for pointing it out.




ChangeLog:

	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.


-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
Index: gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.19
diff -c -p -r1.19 gdbtk-cmds.c
*** gdbtk-cmds.c	2001/01/27 00:50:29	1.19
--- gdbtk-cmds.c	2001/02/07 00:12:08
*************** gdb_get_function_command (clientData, in
*** 1319,1326 ****
   * 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.
   */
  
  static int
--- 1319,1326 ----
   * Tcl Arguments:
   *    filename: the file name to search for.
   * Tcl Result:
!  *    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
*************** gdb_find_file_command (clientData, inter
*** 1330,1337 ****
       int objc;
       Tcl_Obj *CONST objv[];
  {
-   char *filename = NULL;
    struct symtab *st;
  
    if (objc != 2)
      {
--- 1330,1337 ----
       int objc;
       Tcl_Obj *CONST objv[];
  {
    struct symtab *st;
+   char *filename;
  
    if (objc != 2)
      {
*************** gdb_find_file_command (clientData, inter
*** 1339,1355 ****
        return TCL_ERROR;
      }
  
!   st = full_lookup_symtab (Tcl_GetStringFromObj (objv[1], NULL));
!   if (st)
!     filename = st->fullname;
  
!   if (filename == NULL)
      {
!       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);
  
    return TCL_OK;
  }
--- 1339,1363 ----
        return TCL_ERROR;
      }
  
!   filename = Tcl_GetStringFromObj (objv[1], NULL);
!   st = full_lookup_symtab (filename);
  
!   /* We should always get a symtab. */
!   if (!st)
      {
!       Tcl_SetStringObj ( result_ptr->obj_ptr,
!                          "File not found in symtab (2)", -1);
        return TCL_ERROR;
      }
! 
!   /* 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;
  }
*************** perror_with_name_wrapper (args)
*** 4648,4655 ****
  /* 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. */
  
  static struct symtab *
  full_lookup_symtab (file)
--- 4656,4663 ----
  /* 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. */
! /* symtab->fullname will be NULL if the file is not available. */
  
  static struct symtab *
  full_lookup_symtab (file)
Index: srcwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srcwin.itb,v
retrieving revision 1.11
diff -c -p -r1.11 srcwin.itb
*** srcwin.itb	2001/01/25 17:49:22	1.11
--- srcwin.itb	2001/02/07 00:40:47
***************
*** 1,5 ****
! # Source window for GDBtk.
! # Copyright 1997, 1998, 1999 Cygnus Solutions
  #
  # 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
--- 1,5 ----
! # 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
*************** body SrcWin::_name {w {val ""}} {
*** 295,301 ****
    if {$val != ""} {
      if {![info exists _files(short,$val)]} {
        if {![info exists _files(full,$val)]} {
! 	set full [gdb_find_file $val]
  	if {$full == ""} {
  	  set_status "Cannot find source file \"$val\""
  	  $_statbar.name entryset [lindex [file split $current(filename)] end]
--- 295,305 ----
    if {$val != ""} {
      if {![info exists _files(short,$val)]} {
        if {![info exists _files(full,$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]
*************** body SrcWin::fillNameCB {} {
*** 369,374 ****
--- 373,380 ----
    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
Index: srctextwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
retrieving revision 1.20
diff -c -p -r1.20 srctextwin.itb
*** srctextwin.itb	2001/01/19 16:09:10	1.20
--- srctextwin.itb	2001/02/07 00:40:47
*************** body SrcTextWin::ClearTags {} {
*** 888,896 ****
  body SrcTextWin::_mtime_changed {filename} {
    global tcl_platform
  
!   set f [gdb_find_file $filename]
! 
!   if {$f == ""} {
      set r 1
    } else {
      if {[string compare $tcl_platform(platform) "windows"] == 0} {
--- 888,896 ----
  body SrcTextWin::_mtime_changed {filename} {
    global tcl_platform
  
!   if [catch {gdb_find_file $filename} f] {
!     set r 1
!   } elseif {$f == ""} {
      set r 1
    } else {
      if {[string compare $tcl_platform(platform) "windows"] == 0} {
*************** body SrcTextWin::location {tagname filen
*** 1198,1204 ****
    
    if {$oldmode != "" \
  	&& [string compare $filename $current(filename)] != 0} {
!     if {[gdb_find_file $filename] != ""} {
        set tmp $oldmode
        set oldmode ""
        $parent mode "" $tmp 0
--- 1198,1210 ----
    
    if {$oldmode != "" \
  	&& [string compare $filename $current(filename)] != 0} {
! 
!     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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]