Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: [RFC] PPC: Skip call to __eabi in main()
Date: Mon, 21 Jul 2008 22:54:00 -0000	[thread overview]
Message-ID: <20080721155343.404977d3@mesquite.lan> (raw)

Some versions of gcc now generate a call to __eabi in main() for the
powerpc-eabi and powerpc-eabispe targets.  The patch below causes this
call to be skipped when placing a breakpoint at the first line of
main(), thus fixing quite a few failures when running the test suite.

I've tested this patch against powerpc-eabi and powerpc-eabispe
running on the simulator.

Comments?

	* rs6000-tdep.c (rs6000_skip_main_prologue): New function.
	(rs6000_gdb_arch_init): Register rs6000_skip_main_prologue.

Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.318
diff -u -p -r1.318 rs6000-tdep.c
--- rs6000-tdep.c	15 Jul 2008 18:32:06 -0000	1.318
+++ rs6000-tdep.c	21 Jul 2008 22:39:00 -0000
@@ -1769,6 +1769,32 @@ rs6000_skip_prologue (struct gdbarch *gd
   return pc;
 }
 
+/* Check that the code pointed to by PC corresponds to a call to
+   __eabi, skip it if so.  Return PC otherwise.  */
+
+CORE_ADDR
+rs6000_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+  gdb_byte buf[4];
+  unsigned long op;
+
+  if (target_read_memory (pc, buf, 4))
+    return pc;
+  op = extract_unsigned_integer (buf, 4);
+
+  if ((op & 0xfc000001) == 0x48000001)
+    {
+      CORE_ADDR displ = op & 0x03fffffc;
+      CORE_ADDR call_dest = pc + 4 + displ;
+      struct minimal_symbol *s = lookup_minimal_symbol_by_pc (call_dest);
+
+      if (s != NULL
+          && SYMBOL_LINKAGE_NAME (s) != NULL
+	  && strcmp (SYMBOL_LINKAGE_NAME (s), "__eabi") == 0)
+	pc += 4;
+    }
+  return pc;
+}
 
 /* All the ABI's require 16 byte alignment.  */
 static CORE_ADDR
@@ -3238,6 +3264,7 @@ rs6000_gdbarch_init (struct gdbarch_info
 
   set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
   set_gdbarch_in_function_epilogue_p (gdbarch, rs6000_in_function_epilogue_p);
+  set_gdbarch_skip_main_prologue (gdbarch, rs6000_skip_main_prologue);
 
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_breakpoint_from_pc (gdbarch, rs6000_breakpoint_from_pc);


             reply	other threads:[~2008-07-21 22:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-21 22:54 Kevin Buettner [this message]
2008-07-22  4:45 ` Thiago Jung Bauermann
2008-07-23  1:13   ` Kevin Buettner
2008-07-29  0:22     ` Kevin Buettner
2008-08-01 18:46       ` Luis Machado
2008-08-07  0:42         ` Kevin Buettner
2008-08-07 14:04           ` Daniel Jacobowitz
2008-08-07 15:14             ` Luis Machado
2008-08-12  0:30       ` Kevin Buettner

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=20080721155343.404977d3@mesquite.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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