From: Michal Ludvig <mludvig@suse.cz>
To: GDB Patches <gdb-patches@sources.redhat.com>
Subject: [RFA] Prologue detection on x86-64
Date: Thu, 06 Mar 2003 22:56:00 -0000 [thread overview]
Message-ID: <3E67D22C.3030908@suse.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
Hi all,
the attached patch moves prologue detection from x86_64_skip_prologue()
to separate function, that could be reused later. I need this separate
function to implement unwinding of functions without debug info.
It's an almost obvious patch, I believe.
OK to commit?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
[-- Attachment #2: skip-prologue-1.diff --]
[-- Type: text/plain, Size: 2992 bytes --]
2003-03-06 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.
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.51
diff -u -p -r1.51 x86-64-tdep.c
--- x86-64-tdep.c 2 Mar 2003 04:02:25 -0000 1.51
+++ x86-64-tdep.c 6 Mar 2003 22:50:09 -0000
@@ -851,11 +851,31 @@ x86_64_frameless_function_invocation (st
return 0;
}
+/* We will handle only functions beginning with:
+ 55 pushq %rbp
+ 48 89 e5 movq %rsp,%rbp */
+#define PROLOG_BUFSIZE 4
+static 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 +883,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. */
Index: x86-64-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.h,v
retrieving revision 1.10
diff -u -p -r1.10 x86-64-tdep.h
--- x86-64-tdep.h 21 Dec 2002 21:09:58 -0000 1.10
+++ x86-64-tdep.h 6 Mar 2003 22:50:09 -0000
@@ -36,6 +36,7 @@ gdbarch_saved_pc_after_call_ftype x86_64
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);
next reply other threads:[~2003-03-06 22:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-06 22:56 Michal Ludvig [this message]
2003-03-06 23:10 ` Daniel Jacobowitz
2003-03-06 23:14 ` Michal Ludvig
[not found] ` <20030306232209.GA10007@nevyn.them.org>
2003-03-07 10:44 ` Michal Ludvig
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=3E67D22C.3030908@suse.cz \
--to=mludvig@suse.cz \
--cc=gdb-patches@sources.redhat.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