This is the mail archive of the insight@sourceware.org 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: [PATCH] Fix gdbtk-cmds.c: get a build error


>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> I'm working on a replacement patch.

Here it is.

Ok?

Tom

2010-03-12  Tom Tromey  <tromey@redhat.com>

	* generic/gdbtk-cmds.c: Include psymtab.h, not psympriv.h.
	(struct listfiles_info): New.
	(do_listfiles): New function.
	(gdb_listfiles): Use it.

Index: generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.116
diff -u -r1.116 gdbtk-cmds.c
--- generic/gdbtk-cmds.c	12 Mar 2010 14:19:13 -0000	1.116
+++ generic/gdbtk-cmds.c	12 Mar 2010 18:26:21 -0000
@@ -27,7 +27,6 @@
 #include "inferior.h"
 #include "source.h"
 #include "symfile.h"
-#include "psympriv.h"
 #include "objfiles.h"
 #include "gdbcore.h"
 #include "demangle.h"
@@ -47,6 +46,7 @@
 #include "valprint.h"
 #include "regcache.h"
 #include "arch-utils.h"
+#include "psymtab.h"
 
 /* tcl header files includes varargs.h unless HAS_STDARG is defined,
    but gdb uses stdarg.h, so make sure HAS_STDARG is defined.  */
@@ -1104,6 +1104,42 @@
   return TCL_OK;
 }
 
+/* An object of this type is passed to do_listfiles.  */
+
+struct listfiles_info
+{
+  int *numfilesp;
+  int *files_sizep;
+  const char ***filesp;
+  int len;
+  const char *pathname;
+};
+
+/* This is a helper function for gdb_listfiles that is used via
+   map_partial_symbol_filenames.  */
+
+static void
+do_listfiles (const char *filename, const char *fullname, void *data)
+{
+  struct listfiles_info *info = data;
+
+  if (*info->numfilesp == *info->files_sizep)
+    {
+      *info->files_sizep *= 2;
+      *info->filesp = xrealloc (*info->filesp,
+				*info->files_sizep * sizeof (char *));
+    }
+
+  if (filename)
+    {
+      if (!info->len || !strncmp (info->pathname, filename, info->len)
+	  || !strcmp (filename, lbasename (filename)))
+	{
+	  (*info->filesp)[(*info->numfilesp)++] = lbasename (filename);
+	}
+    }
+}
+
 /* This implements the tcl command "gdb_listfiles"
 
 * This lists all the files in the current executible.
@@ -1134,6 +1170,7 @@
   const char **files;
   int files_size;
   int i, numfiles = 0, len = 0;
+  struct listfiles_info info;
 
   files_size = 1000;
   files = (const char **) xmalloc (sizeof (char *) * files_size);
@@ -1146,22 +1183,12 @@
   else if (objc == 2)
     pathname = Tcl_GetStringFromObj (objv[1], &len);
 
-  ALL_PSYMTABS (objfile, psymtab)
-    {
-      if (numfiles == files_size)
-	{
-	  files_size = files_size * 2;
-	  files = (const char **) xrealloc (files, sizeof (char *) * files_size);
-	}
-      if (psymtab->filename)
-	{
-	  if (!len || !strncmp (pathname, psymtab->filename, len)
-	      || !strcmp (psymtab->filename, lbasename (psymtab->filename)))
-	    {
-	      files[numfiles++] = lbasename (psymtab->filename);
-	    }
-	}
-    }
+  info.numfilesp = &numfiles;
+  info.files_sizep = &files_size;
+  info.filesp = &files;
+  info.len = len;
+  info.pathname = pathname;
+  map_partial_symbol_filenames (do_listfiles, &info);
 
   ALL_SYMTABS (objfile, symtab)
     {


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