aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMichal Ludvig <mludvig@suse.cz>2003-03-07 10:43:00 +0000
committerMichal Ludvig <mludvig@suse.cz>2003-03-07 10:43:00 +0000
commit6d686a84d6402b6a34670f7c34a0112928661482 (patch)
tree04b186be1ecd353b981bc30f0eb6e47d08ed74b2 /gdb
parent87d243f1ce6736ee9b540772a6f9d61fd7146204 (diff)
downloadgdb-6d686a84d6402b6a34670f7c34a0112928661482.zip
gdb-6d686a84d6402b6a34670f7c34a0112928661482.tar.gz
gdb-6d686a84d6402b6a34670f7c34a0112928661482.tar.bz2
2003-03-07 Michal Ludvig <mludvig@suse.cz>
* x86-64-tdep.c (x86_64_function_has_prologue): New function. (x86_64_skip_prologue): Move prologue detection to separate function. * x86-64-tdep.h (x86_64_function_has_prologue): New prototype.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/x86-64-tdep.c41
-rw-r--r--gdb/x86-64-tdep.h1
3 files changed, 34 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f17fda0..e249c59 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-07 Michal Ludvig <mludvig@suse.cz>
+
+ * x86-64-tdep.c (x86_64_function_has_prologue): New function.
+ (x86_64_skip_prologue): Move prologue detection to
+ separate function.
+ * x86-64-tdep.h (x86_64_function_has_prologue): New prototype.
+
2003-03-05 Andrew Cagney <cagney@redhat.com>
* d10v-tdep.c (d10v_unwind_dummy_id): New function.
diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c
index 5ba1da2..162d532 100644
--- a/gdb/x86-64-tdep.c
+++ b/gdb/x86-64-tdep.c
@@ -851,11 +851,34 @@ x86_64_frameless_function_invocation (struct frame_info *frame)
return 0;
}
+/* We will handle only functions beginning with:
+ 55 pushq %rbp
+ 48 89 e5 movq %rsp,%rbp
+ Any function that doesn't start with this sequence
+ will be assumed to have no prologue and thus no valid
+ frame pointer in %rbp. */
+#define PROLOG_BUFSIZE 4
+int
+x86_64_function_has_prologue (CORE_ADDR pc)
+{
+ int i;
+ unsigned char prolog_expect[PROLOG_BUFSIZE] = { 0x55, 0x48, 0x89, 0xe5 },
+ prolog_buf[PROLOG_BUFSIZE];
+
+ read_memory (pc, (char *) prolog_buf, PROLOG_BUFSIZE);
+
+ /* First check, whether pc points to pushq %rbp, movq %rsp,%rbp. */
+ for (i = 0; i < PROLOG_BUFSIZE; i++)
+ if (prolog_expect[i] != prolog_buf[i])
+ return 0; /* ... no, it doesn't. Nothing to skip. */
+
+ return 1;
+}
+
/* If a function with debugging information and known beginning
is detected, we will return pc of the next line in the source
code. With this approach we effectively skip the prolog. */
-#define PROLOG_BUFSIZE 4
CORE_ADDR
x86_64_skip_prologue (CORE_ADDR pc)
{
@@ -863,21 +886,9 @@ x86_64_skip_prologue (CORE_ADDR pc)
struct symtab_and_line v_sal;
struct symbol *v_function;
CORE_ADDR endaddr;
- unsigned char prolog_buf[PROLOG_BUFSIZE];
-
- /* We will handle only functions starting with: */
- static unsigned char prolog_expect[PROLOG_BUFSIZE] =
- {
- 0x55, /* pushq %rbp */
- 0x48, 0x89, 0xe5 /* movq %rsp, %rbp */
- };
- read_memory (pc, (char *) prolog_buf, PROLOG_BUFSIZE);
-
- /* First check, whether pc points to pushq %rbp, movq %rsp, %rbp. */
- for (i = 0; i < PROLOG_BUFSIZE; i++)
- if (prolog_expect[i] != prolog_buf[i])
- return pc; /* ... no, it doesn't. Nothing to skip. */
+ if (! x86_64_function_has_prologue (pc))
+ return pc;
/* OK, we have found the prologue and want PC of the first
non-prologue instruction. */
diff --git a/gdb/x86-64-tdep.h b/gdb/x86-64-tdep.h
index 6977f9b..b0b8191 100644
--- a/gdb/x86-64-tdep.h
+++ b/gdb/x86-64-tdep.h
@@ -36,6 +36,7 @@ gdbarch_saved_pc_after_call_ftype x86_64_linux_saved_pc_after_call;
gdbarch_pc_in_sigtramp_ftype x86_64_linux_in_sigtramp;
CORE_ADDR x86_64_linux_frame_chain (struct frame_info *fi);
CORE_ADDR x86_64_init_frame_pc (int fromleaf, struct frame_info *fi);
+int x86_64_function_has_prologue (CORE_ADDR pc);
void x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);