public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Fix maint translate command
@ 2010-09-01  8:54 Pierre Muller
  2010-09-01 13:39 ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre Muller @ 2010-09-01  8:54 UTC (permalink / raw)
  To: gdb-patches

  '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);

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-09-24 11:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-01  8:54 [RFA] Fix maint translate command Pierre Muller
2010-09-01 13:39 ` Pedro Alves
2010-09-01 13:49   ` Pierre Muller
2010-09-01 15:25     ` Pedro Alves
2010-09-01 16:07       ` Pedro Alves
2010-09-14 15:14         ` [PING]RE: " Pierre Muller
2010-09-22 18:59           ` Joel Brobecker
2010-09-22 19:23             ` Pedro Alves
2010-09-24 15:55               ` Pedro Alves

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