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]
Other format: [Raw text]

Re: gdbtk: Patch for terrible slow stepping


I don't know that this message made it to the insight mailing list, so
I'm going to top post this time...

I have committed a patch to HEAD and the 6.0 branch which incorporates
your patch. (At long last! :-) I've attached the "official" version.

Thank you for your patch and your patience!
Keith

ChangeLog
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.

On Fri, 2003-05-23 at 02:38, Roland Schwingel wrote:
> Hi....
> 
> I today found this mailing list... I found a bug in gdbtk which made it 
> terribly slow using it (especially when running on cygwin).
> I posted this problem 2 days ago to the gdb mailing list. Yesterday I 
> was able to fix this problem in my own.
> 
> For details to the problem please look here:
> http://sources.redhat.com/ml/gdb/2003-05/msg00298.html
> 
> I made a patch to gdb/gdbtk/generic/gdbtk-cmds.c (based on current GDB 
> current CVS head) which I want to supply here
> now. Maybe someone can check this in, after validation?
> (Btw. the fix description I posted to standard gdb mailinglist yesterday 
> was slightly incorrect - sorry, due to technical problems I couldn't
> supply a diff yesterday. The fix here is totally correct - from my point 
> of view ;-)
> 
> This fix bypasses unneeded calls to lookup_symtab() which appears to be 
> evil slow, at least in many cases.
> 
> Thanks,
> 
> Roland
> 
> 
> ______________________________________________________________________
> 
> --- gdbtk-cmds.c	2003-05-23 09:02:15.000000000 +0200
> +++ gdbtk-cmds.c.patched	2003-05-23 11:22:29.000000000 +0200
> @@ -35,6 +35,7 @@
>  #include "top.h"
>  #include "annotate.h"
>  #include "block.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.  */
> @@ -1036,7 +1037,7 @@
>  		       int objc, Tcl_Obj *CONST objv[])
>  {
>    struct symtab *st;
> -  char *filename, *fullname;
> +  char *filename, *fullname = NULL;
>  
>    if (objc != 2)
>      {
> @@ -1045,20 +1046,36 @@
>      }
>  
>    filename = Tcl_GetStringFromObj (objv[1], NULL);
> -  st = lookup_symtab (filename);
> +  
> +  if (IS_ABSOLUTE_PATH (filename))
> +  {
> +  	 struct stat st;
> +  	 const int status = stat (filename, &st);
>  
> -  /* We should always get a symtab. */
> -  if (!st)
> +	 if (status == 0)
> +	 {
> +  		if (S_ISREG (st.st_mode))
> +  			fullname = filename;
> +	 }
> +  }
> +  
> +  if (fullname == NULL)
> +  {
> +  	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;
>      }
>  
> -  if (st->fullname == NULL)
> +  	if (st->fullname == NULL)
>      fullname = symtab_to_filename (st);
> -  else
> +  	else
>      fullname = st->fullname;
> -
> +  }
> +  
>    /* We may not be able to open the file (not available). */
>    if (fullname == NULL)
>      {
Index: generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.75
diff -u -p -r1.75 gdbtk-cmds.c
--- generic/gdbtk-cmds.c	11 Jun 2003 23:29:49 -0000	1.75
+++ generic/gdbtk-cmds.c	27 Jun 2003 00:24:00 -0000
@@ -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 client
 		       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 client
     }
 
   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)
     {

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