Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org
Cc: pedro@codesourcery.com
Subject: [rfc] Displaced stepping with wrong entry point address
Date: Fri, 22 Aug 2008 17:49:00 -0000	[thread overview]
Message-ID: <200808221748.m7MHmkpd004832@d12av02.megacenter.de.ibm.com> (raw)

Hello,

displaced stepping caused a regression for the Cell multi-arch debugger.
This is because the default displaced_step_at_entry_point routine uses
entry_point_address to determine where to put the displaced instruction.

This is a problem when debugging a stand-alone SPU executable using the
multi-arch debugger, because entry_point_address will point to the SPU
entry point, while we need a place in PowerPC address space to execute
displaced PowerPC code.

(SPU currently does not use displaced stepping, and this probably does
not really matter, as a single SPU context is always single-threaded.)


The following patch makes the multi-arch debugger work again, by using
the AT_ENTRY auxiliary vector to find the entry point address.  This
will always point to the PowerPC-side entry point.

I'm wondering whether this fix would be good for the general case too
-- there may be situations where entry_point_address does not work
(e.g. because the main executable file could not be loaded).  The
auxiliary vector, on targets where it is present, will probably be
more reliable ...

What do you think?

Tested on powerpc-linux and powerpc64-linux.

Bye,
Ulrich


ChangeLog:

	* arch-utils.c: Include "target.h", "auxv.h" and "elf/common.h".
	(displaced_step_at_entry_point): Use AT_ENTRY auxiliary vector
	to determine entry point address.

diff -urNp src-orig/gdb/arch-utils.c src/gdb/arch-utils.c
--- src-orig/gdb/arch-utils.c	2008-08-18 02:34:56.000000000 +0200
+++ src/gdb/arch-utils.c	2008-08-18 02:37:42.288892324 +0200
@@ -32,6 +32,9 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 #include "objfiles.h"
+#include "target.h"
+#include "auxv.h"
+#include "elf/common.h"
 
 #include "version.h"
 
@@ -74,7 +77,10 @@ displaced_step_at_entry_point (struct gd
   CORE_ADDR addr;
   int bp_len;
 
-  addr = entry_point_address ();
+  /* Determine entry point from target auxiliary vector.  Fall back
+     to entry point from symbol file if not found.  */
+  if (target_auxv_search (&current_target, AT_ENTRY, &addr) <= 0)
+    addr = entry_point_address ();
 
   /* Make certain that the address points at real code, and not a
      function descriptor.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


             reply	other threads:[~2008-08-22 17:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-22 17:49 Ulrich Weigand [this message]
2008-09-04  1:49 ` [ping] " Ulrich Weigand
2008-09-04 12:15 ` [rfc] " Daniel Jacobowitz
2008-09-04 19:28   ` Ulrich Weigand
2008-09-04 19:32     ` Daniel Jacobowitz
2008-09-04 20:31       ` Ulrich Weigand
2008-09-05 14:17     ` Mark Kettenis
2008-09-05 16:19       ` [commit, spu] Do not use generic_push_dummy_code Ulrich Weigand

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=200808221748.m7MHmkpd004832@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.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