From: Tom Tromey <tromey@redhat.com>
To: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
Cc: "'Hui Zhu'" <teawater@gmail.com>, <insight@sourceware.org>,
"'Keith Seitz'" <keiths@redhat.com>
Subject: Re: [PATCH] Fix gdbtk-cmds.c: get a build error
Date: Fri, 12 Mar 2010 18:32:00 -0000 [thread overview]
Message-ID: <m3tysl9yza.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3ljdxbgtr.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 12 Mar 2010 10:17:04 -0700")
>>>>> "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)
{
next prev parent reply other threads:[~2010-03-12 18:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-12 14:19 Hui Zhu
2010-03-12 17:17 ` [PATCH] Fix " Pierre Muller
2010-03-12 18:28 ` Tom Tromey
2010-03-12 18:32 ` Tom Tromey [this message]
2010-03-15 2:20 ` Keith Seitz
2010-03-17 5:44 ` Hui Zhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3tysl9yza.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=insight@sourceware.org \
--cc=keiths@redhat.com \
--cc=pierre.muller@ics-cnrs.unistra.fr \
--cc=teawater@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).