This is the mail archive of the
insight@sourceware.org
mailing list for the Insight project.
Re: [PATCH] Fix gdbtk-cmds.c: get a build error
- From: Tom Tromey <tromey at redhat dot com>
- To: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- Cc: "'Hui Zhu'" <teawater at gmail dot com>, <insight at sourceware dot org>, "'Keith Seitz'" <keiths at redhat dot com>
- Date: Fri, 12 Mar 2010 11:27:53 -0700
- Subject: Re: [PATCH] Fix gdbtk-cmds.c: get a build error
- References: <daef60381003102300q37fe4237icb942bb7aa3f16da@mail.gmail.com> <000001cac1ef$084ed8d0$18ec8a70$@muller@ics-cnrs.unistra.fr> <m3ljdxbgtr.fsf@fleche.redhat.com>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "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)
{