[PATCH v3 5/7] amd64_analyze_prologue: gradually update pc
Victor Collod
vcollod@nvidia.com
Wed Jun 24 01:28:55 GMT 2020
It makes the function easier to read, as you don't have to remember
what's the current offset from pc.
2020-06-23 Victor Collod <vcollod@nvidia.com>
* amd64-tdep.c (amd64_analyze_prologue): Gradually update pc.
---
gdb/amd64-tdep.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 17b02706e54..5c3ad505784 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2416,19 +2416,22 @@ amd64_analyze_prologue (struct gdbarch *gdbarch,
cache->saved_regs[AMD64_RBP_REGNUM] = 0;
cache->sp_offset += 8;
+ pc += 1;
+
/* If we went past the allowed bound, stop. */
- if (pc + 1 >= current_pc)
+ if (pc >= current_pc)
return current_pc;
- read_code (pc + 1, buf, 3);
+ read_code (pc, buf, 3);
/* Check for `movq %rsp, %rbp'. */
if (memcmp (buf, mov_rsp_rbp_1, 3) == 0
|| memcmp (buf, mov_rsp_rbp_2, 3) == 0)
{
+ pc += 3;
/* OK, we actually have a frame. */
cache->frameless_p = 0;
- return pc + 4;
+ return pc;
}
/* For X32, also check for `movq %esp, %ebp'. */
@@ -2437,13 +2440,14 @@ amd64_analyze_prologue (struct gdbarch *gdbarch,
if (memcmp (buf, mov_esp_ebp_1, 2) == 0
|| memcmp (buf, mov_esp_ebp_2, 2) == 0)
{
+ pc += 2;
/* OK, we actually have a frame. */
cache->frameless_p = 0;
- return pc + 3;
+ return pc;
}
}
- return pc + 1;
+ return pc;
}
/* Work around false termination of prologue - GCC PR debug/48827.
--
2.20.1
More information about the Gdb-patches
mailing list