aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2012-05-07 21:02:43 +0000
committerMark Kettenis <kettenis@gnu.org>2012-05-07 21:02:43 +0000
commit649e6d9245bb52c1f90fe29b29655327ad33edb6 (patch)
tree89b9cc41a3b9267e12f7efe60ffc1ef2944c9b18
parentf39c6ffde753509963229ab018b461be2600dd2a (diff)
downloadgdb-649e6d9245bb52c1f90fe29b29655327ad33edb6.zip
gdb-649e6d9245bb52c1f90fe29b29655327ad33edb6.tar.gz
gdb-649e6d9245bb52c1f90fe29b29655327ad33edb6.tar.bz2
H.J. Lu <hongjiu.lu@intel.com>
* amd64-tdep.c (amd64_analyze_prologue): Additionally check for `movl %esp, %ebp' for the X32 ABI.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/amd64-tdep.c43
2 files changed, 40 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f344547..979909a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-07 Mark Kettenis <kettenis@gnu.org>
+ H.J. Lu <hongjiu.lu@intel.com>
+
+ * amd64-tdep.c (amd64_analyze_prologue): Additionally check for
+ `movl %esp, %ebp' for the X32 ABI.
+
2012-05-07 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf_tag_name): Return const char *. Use
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 685fa48..b433e1f 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -1867,8 +1867,14 @@ amd64_analyze_stack_align (CORE_ADDR pc, CORE_ADDR current_pc,
pushq %rbp 0x55
movq %rsp, %rbp 0x48 0x89 0xe5 (or 0x48 0x8b 0xec)
- Any function that doesn't start with this sequence will be assumed
- to have no prologue and thus no valid frame pointer in %rbp. */
+ or (for the X32 ABI):
+
+ pushq %rbp 0x55
+ movl %esp, %ebp 0x89 0xe5 (or 0x8b 0xec)
+
+ Any function that doesn't start with one of these sequences will be
+ assumed to have no prologue and thus no valid frame pointer in
+ %rbp. */
static CORE_ADDR
amd64_analyze_prologue (struct gdbarch *gdbarch,
@@ -1879,6 +1885,10 @@ amd64_analyze_prologue (struct gdbarch *gdbarch,
/* There are two variations of movq %rsp, %rbp. */
static const gdb_byte mov_rsp_rbp_1[3] = { 0x48, 0x89, 0xe5 };
static const gdb_byte mov_rsp_rbp_2[3] = { 0x48, 0x8b, 0xec };
+ /* Ditto for movl %esp, %ebp. */
+ static const gdb_byte mov_esp_ebp_1[2] = { 0x89, 0xe5 };
+ static const gdb_byte mov_esp_ebp_2[2] = { 0x8b, 0xec };
+
gdb_byte buf[3];
gdb_byte op;
@@ -1900,15 +1910,30 @@ amd64_analyze_prologue (struct gdbarch *gdbarch,
if (current_pc <= pc + 1)
return current_pc;
- /* Check for `movq %rsp, %rbp'. */
read_memory (pc + 1, buf, 3);
- if (memcmp (buf, mov_rsp_rbp_1, 3) != 0
- && memcmp (buf, mov_rsp_rbp_2, 3) != 0)
- return pc + 1;
- /* OK, we actually have a frame. */
- cache->frameless_p = 0;
- return pc + 4;
+ /* Check for `movq %rsp, %rbp'. */
+ if (memcmp (buf, mov_rsp_rbp_1, 3) == 0
+ || memcmp (buf, mov_rsp_rbp_2, 3) == 0)
+ {
+ /* OK, we actually have a frame. */
+ cache->frameless_p = 0;
+ return pc + 4;
+ }
+
+ /* For X32, also check for `movq %esp, %ebp'. */
+ if (gdbarch_ptr_bit (gdbarch) == 32)
+ {
+ if (memcmp (buf, mov_esp_ebp_1, 2) == 0
+ || memcmp (buf, mov_esp_ebp_2, 2) == 0)
+ {
+ /* OK, we actually have a frame. */
+ cache->frameless_p = 0;
+ return pc + 3;
+ }
+ }
+
+ return pc + 1;
}
return pc;