public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [RFC] patch to fix finding sources
@ 2001-02-06  8:50 Martin M. Hunt
  2001-02-06  9:23 ` Fernando Nasser
  2001-02-06 17:05 ` Fernando Nasser
  0 siblings, 2 replies; 9+ messages in thread
From: Martin M. Hunt @ 2001-02-06  8:50 UTC (permalink / raw)
  To: insight

A couple weeks ago, gdb_find_file was changed to return TCL_ERROR with an
error message "File not found in symtab (2)"  when no file was found.  I
disagree with this.  I thought catch was for handling exceptions.  Also,
the error message is not used and is confusing.

Regardless, the functions which use gdb_find_file were not changed, which
causes some nasty bugs in Insight.  Attached is a patch to get things
working again.

Index: srctextwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
retrieving revision 1.20
diff -p -r1.20 srctextwin.itb
*** srctextwin.itb	2001/01/19 16:09:10	1.20
--- srctextwin.itb	2001/02/06 16:15:49
***************
*** 1,5 ****
!  # Paned text widget for source code, 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 ----
! # Paned text widget for source code, 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 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

!   set f [catch {gdb_find_file $filename} errtxt]

!   if {$f} {
      set r 1
    } else {
      if {[string compare $tcl_platform(platform) "windows"] == 0} {
Index: srcwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srcwin.itb,v
retrieving revision 1.11
diff -p -r1.11 srcwin.itb
*** srcwin.itb	2001/01/25 17:49:22	1.11
--- srcwin.itb	2001/02/06 16:15:52
***************
*** 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,302 ****
    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]
  	  return
--- 295,302 ----
    if {$val != ""} {
      if {![info exists _files(short,$val)]} {
        if {![info exists _files(full,$val)]} {
! 	set full [catch {gdb_find_file $val} errtxt ]
! 	if {$full} {
  	  set_status "Cannot find source file \"$val\""
  	  $_statbar.name entryset [lindex [file split $current(filename)] end]
  	  return

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06  8:50 [RFC] patch to fix finding sources Martin M. Hunt
@ 2001-02-06  9:23 ` Fernando Nasser
  2001-02-06 10:58   ` Fernando Nasser
  2001-02-06 17:05 ` Fernando Nasser
  1 sibling, 1 reply; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06  9:23 UTC (permalink / raw)
  To: Martin M. Hunt; +Cc: insight

"Martin M. Hunt" wrote:
> 
> A couple weeks ago, gdb_find_file was changed to return TCL_ERROR with an
> error message "File not found in symtab (2)"  when no file was found.  I
> disagree with this.  I thought catch was for handling exceptions.  Also,
> the error message is not used and is confusing.
> 

That patch does fix a reported bug as well.  The error message is identical to the existing one issued by gdb_loadfile in a similar situation (hence the (2) ) and describes "exactly" what is happening.

Returning success when the operation failed is unacceptable as it is not giving
the proper error indication.

> Regardless, the functions which use gdb_find_file were not changed, which
> causes some nasty bugs in Insight.  Attached is a patch to get things
> working again.
> 

This is a legitimate complaint.  I probably forgot to check the caller side bits
(too many branches and sandboxes around).  I will check your patch in.



P.S.: Contributions are welcome, but please do not forget the ChangeLog.




> Index: srctextwin.itb
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
> retrieving revision 1.20
> diff -p -r1.20 srctextwin.itb
> *** srctextwin.itb      2001/01/19 16:09:10     1.20
> --- srctextwin.itb      2001/02/06 16:15:49
> ***************
> *** 1,5 ****
> !  # Paned text widget for source code, 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 ----
> ! # Paned text widget for source code, 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 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
> 
> !   set f [catch {gdb_find_file $filename} errtxt]
> 
> !   if {$f} {
>       set r 1
>     } else {
>       if {[string compare $tcl_platform(platform) "windows"] == 0} {
> Index: srcwin.itb
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/srcwin.itb,v
> retrieving revision 1.11
> diff -p -r1.11 srcwin.itb
> *** srcwin.itb  2001/01/25 17:49:22     1.11
> --- srcwin.itb  2001/02/06 16:15:52
> ***************
> *** 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,302 ****
>     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]
>           return
> --- 295,302 ----
>     if {$val != ""} {
>       if {![info exists _files(short,$val)]} {
>         if {![info exists _files(full,$val)]} {
> !       set full [catch {gdb_find_file $val} errtxt ]
> !       if {$full} {
>           set_status "Cannot find source file \"$val\""
>           $_statbar.name entryset [lindex [file split $current(filename)] end]
>           return

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06  9:23 ` Fernando Nasser
@ 2001-02-06 10:58   ` Fernando Nasser
  2001-02-06 13:30     ` Martin M. Hunt
  2001-02-06 15:22     ` Fernando Nasser
  0 siblings, 2 replies; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 10:58 UTC (permalink / raw)
  To: Martin M. Hunt, insight

I have added a few bits to Martin's patch, but I don't have how to test it at the moment.  I would need Martin's help as he probably has the situation repeatable right now (which caused him to send the patch).

I have attached the patch.

-- 
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/06 18:10:50
*************** 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, 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,1354 ----
        return TCL_ERROR;
      }
  
!   filename = Tcl_GetStringFromObj (objv[1], NULL);
!   st = full_lookup_symtab (filename);
    if (st)
!     Tcl_SetStringObj (result_ptr->obj_ptr, st->fullname, -1);
!   else
      {
!       Tcl_SetStringObj ( result_ptr->obj_ptr,
!                          "File not found in symtab (2)", -1);
        return TCL_ERROR;
      }
  
    return TCL_OK;
  }
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/06 18:29:35
***************
*** 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,303 ****
    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]
  	  return
  	}
--- 295,303 ----
    if {$val != ""} {
      if {![info exists _files(short,$val)]} {
        if {![info exists _files(full,$val)]} {
! 	set full [catch {gdb_find_file $val} errtxt ]
! 	if {$full} {
! 	  set_status "Cannot find source file \"$val\": $errtxt"
  	  $_statbar.name entryset [lindex [file split $current(filename)] end]
  	  return
  	}
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/06 18:29:36
***************
*** 1,5 ****
!  # Paned text widget for source code, 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 ----
! # Paned text widget for source code, 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 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,897 ----
  body SrcTextWin::_mtime_changed {filename} {
    global tcl_platform
  
!   set f [catch {gdb_find_file $filename} errtxt]
  
!   if {$f} {
!     dbug W $errtxt
      set r 1
    } else {
      if {[string compare $tcl_platform(platform) "windows"] == 0} {

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06 10:58   ` Fernando Nasser
@ 2001-02-06 13:30     ` Martin M. Hunt
  2001-02-06 14:57       ` Fernando Nasser
  2001-02-06 15:05       ` Fernando Nasser
  2001-02-06 15:22     ` Fernando Nasser
  1 sibling, 2 replies; 9+ messages in thread
From: Martin M. Hunt @ 2001-02-06 13:30 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: insight

Sorry about the brief comments and forgetting to add the changelog into
the email.  I have more time now, so I'll explain in more detail.

gdb_find_file checks for the existance of a source file on the development
host.  It is expected that many sources (particularly to shared libraries)
will not be found.  That is why I didn't like the idea that TCL_ERROR
would be returned forcing a catch to always be used.  Then you have to
either parse the error message to determine if a warning or eror dialog is
displayed, or always ignore it.  No big deal either way...

when you call full_lookup_symtab() you get a pointer to a symtab struct.
If that pointer is NULL, it is probably an error.  If the pointer is not
null, st->fullname will be null if there if the sources are not found.
So, your code needs changed around a bit to avoid dereferencing a null
pointer.

The real problem here is probably my comment on full_lookup_symtab() that
says it always sets symtab->filename.  Maybe we need a note that it will
be set to null is the sources are not available.

If you want to test yourself, my test case is not too difficult :^)

main()
{
	printf("Hello World\n");
}

compile, run gdb, try to step into printf.

Martin


On Tue, 6 Feb 2001, Fernando Nasser wrote:

> I have added a few bits to Martin's patch, but I don't have how to test it at the moment.  I would need Martin's help as he probably has the situation repeatable right now (which caused him to send the patch).
>
> I have attached the patch.
>
> --
> Fernando Nasser
> Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
> 2323 Yonge Street, Suite #300
> Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06 13:30     ` Martin M. Hunt
@ 2001-02-06 14:57       ` Fernando Nasser
  2001-02-06 15:05       ` Fernando Nasser
  1 sibling, 0 replies; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 14:57 UTC (permalink / raw)
  To: Martin M. Hunt; +Cc: insight

"Martin M. Hunt" wrote:
> 
> If you want to test yourself, my test case is not too difficult :^)
> 
> main()
> {
>         printf("Hello World\n");
> }
> 
> compile, run gdb, try to step into printf.
> 

Nothing bad happens here.  Insight switches to assembler mode and everything is fine.

I am running on Linux.  What is your host?

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06 13:30     ` Martin M. Hunt
  2001-02-06 14:57       ` Fernando Nasser
@ 2001-02-06 15:05       ` Fernando Nasser
  1 sibling, 0 replies; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 15:05 UTC (permalink / raw)
  To: Martin M. Hunt; +Cc: insight

"Martin M. Hunt" wrote:
> 
> when you call full_lookup_symtab() you get a pointer to a symtab struct.
> If that pointer is NULL, it is probably an error.  If the pointer is not
> null, st->fullname will be null if there if the sources are not found.
> So, your code needs changed around a bit to avoid dereferencing a null
> pointer.
> 
> The real problem here is probably my comment on full_lookup_symtab() that
> says it always sets symtab->filename.  Maybe we need a note that it will
> be set to null is the sources are not available.
> 

Yes, I fell for that one:

                                         This version */
   /* also always makes sure symtab->fullname is set. */

Now looking at the code I see that it is not always true.

Please, by all means, send a patch to fix the comment.


Now that I know that I will rewrite the patch.

Thanks for the detailed explanation.

Regards,
Fernando

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06 10:58   ` Fernando Nasser
  2001-02-06 13:30     ` Martin M. Hunt
@ 2001-02-06 15:22     ` Fernando Nasser
  2001-02-06 16:10       ` Fernando Nasser
  1 sibling, 1 reply; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 15:22 UTC (permalink / raw)
  To: Martin M. Hunt, insight

Fernando Nasser wrote:
> 
> !   filename = Tcl_GetStringFromObj (objv[1], NULL);
> !   st = full_lookup_symtab (filename);
>     if (st)
> !     Tcl_SetStringObj (result_ptr->obj_ptr, st->fullname, -1);
> !   else
>       {
> !       Tcl_SetStringObj ( result_ptr->obj_ptr,
> !                          "File not found in symtab (2)", -1);
>         return TCL_ERROR;
>       }

Martin,

If the symtab (st above) is non-NULL, then st->fullname is either non-NULL or has the value of st->filename.  As this was what was used to find the symtab we can be sure that it is not NULL.

So, after all, your comment was not so wrong.  It is not true when you don't get a symtab, but in that case there is no fullname field anyway.

And the code above is perfectly safe.  We can be paranoid and add a gdb_assert() on the st->fullname field but that would be something very hard to happen.


P.S.: I still depend on you to test my patch.  I still could not reproduce it here.



-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06 15:22     ` Fernando Nasser
@ 2001-02-06 16:10       ` Fernando Nasser
  0 siblings, 0 replies; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 16:10 UTC (permalink / raw)
  To: Martin M. Hunt, insight

> If the symtab (st above) is non-NULL, then st->fullname is either
> non-NULL or has the > value of st->filename.  As this was what was
> used to find the symtab we can be sure that it is not NULL.


I take this back.  


The 
	symtab_to_filename (st);
call only *returns* either st->filename or st->fullname,
it does not set anything in the symtab so if st->fullname was NULL it remains NULL.


BTW, I updated the rest of GDB (i.e. other than the gdbtk directory) and I now see the problem.  I wonder what changed.







-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC] patch to fix finding sources
  2001-02-06  8:50 [RFC] patch to fix finding sources Martin M. Hunt
  2001-02-06  9:23 ` Fernando Nasser
@ 2001-02-06 17:05 ` Fernando Nasser
  1 sibling, 0 replies; 9+ messages in thread
From: Fernando Nasser @ 2001-02-06 17:05 UTC (permalink / raw)
  To: Martin M. Hunt; +Cc: insight

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-02-06 17:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-06  8:50 [RFC] patch to fix finding sources Martin M. Hunt
2001-02-06  9:23 ` Fernando Nasser
2001-02-06 10:58   ` Fernando Nasser
2001-02-06 13:30     ` Martin M. Hunt
2001-02-06 14:57       ` Fernando Nasser
2001-02-06 15:05       ` Fernando Nasser
2001-02-06 15:22     ` Fernando Nasser
2001-02-06 16:10       ` Fernando Nasser
2001-02-06 17:05 ` Fernando Nasser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).