This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Fix maint translate command
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 1 Sep 2010 10:54:40 +0200
- Subject: [RFA] Fix maint translate command
'maint translate .text 0xXXXX'
failed saying that
Unknown section .text.
This problem is due to the introduction of
the macro ALL_OBJSECTIONS (objfile, sect)
in revision 1.67 of maint.c:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/maint.c.diff?cvsroot=src&r1=text&tr1=1.66&r2=text&tr2=1.67&f=u
ALL_OBJSECTIONS is a double for loop,
thus the 'break' statement was only exiting the first loop,
but the second loop was still continuing, leading to
a false error.
Another option would be to simply revert that commit,
as the former code probably was working correctly
and is as nice as what I propose here.
Checked on x86_64-unknown-linux-gnu (Compile Farm),
no regression found.
Pierre Muller
Pascal language support maintainer for GDB
projecttype:gdb
revision:HEAD
email:muller@ics.u-strasbg.fr
2010-09-01 Pierre Muller <muller@ics.u-strasbg.fr>
* maint.c (maintenance_translate_address): Fix search of named section.
Index: src/gdb/maint.c
===================================================================
RCS file: /cvs/src/src/gdb/maint.c,v
retrieving revision 1.79
diff -u -p -r1.79 maint.c
--- src/gdb/maint.c 1 Jul 2010 15:36:16 -0000 1.79
+++ src/gdb/maint.c 1 Sep 2010 07:43:56 -0000
@@ -452,7 +452,7 @@ static void
maintenance_translate_address (char *arg, int from_tty)
{
CORE_ADDR address;
- struct obj_section *sect;
+ struct obj_section *sect, *fsect;
char *p;
struct minimal_symbol *sym;
struct objfile *objfile;
@@ -473,14 +473,26 @@ maintenance_translate_address (char *arg
while (isspace (*p))
p++; /* Skip whitespace */
- ALL_OBJSECTIONS (objfile, sect)
- {
- if (strcmp (sect->the_bfd_section->name, arg) == 0)
- break;
- }
+ fsect = NULL;
- if (!objfile)
- error (_("Unknown section %s."), arg);
+ ALL_OBJFILES (objfile)
+ {
+ ALL_OBJFILE_OSECTIONS (objfile, sect)
+ {
+ if (strcmp (sect->the_bfd_section->name, arg) == 0)
+ {
+ fsect = sect;
+ break;
+ }
+ }
+ if (fsect)
+ break;
+ }
+
+ if (!fsect)
+ error (_("Unknown section %s."), arg);
+ else
+ sect = fsect;
}
address = parse_and_eval_address (p);