From: Andrew Cagney <cagney@gnu.org>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch/rfc] signal trampoline frames
Date: Wed, 24 Mar 2004 00:02:00 -0000 [thread overview]
Message-ID: <4060D025.6070601@gnu.org> (raw)
In-Reply-To: <20040323230930.GA23960@nevyn.them.org>
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
see attached?
>
>>> +static CORE_ADDR
>>> +tramp_frame_start (CORE_ADDR pc, const struct tramp_frame *tramp)
>>> +{
>>> + int ti;
>>> + /* Search through the trampoline for one that matches the
>>> + instruction sequence around PC. */
>>> + for (ti = 0; tramp->insn[ti] != 0; ti++)
>>> + {
>>> + CORE_ADDR func = pc - tramp->insn_size * ti;
>>> + int i;
>>> + for (i = 0; 1; i++)
>>> + {
>>> + bfd_byte buf[sizeof (LONGEST)];
>>> + CORE_ADDR insn;
>
>
> tramp->insn is a ULONGEST. Both of these should probably be ULONGEST
> also.
changed to ->insn[0]
>
>>> + if (tramp->insn[i] == 0)
>>> + return func;
>
>
> So zeros in tramp->insn mark the end of the sequence? Should document
> that, zeros are valid instructions and some bizarre architecture might
> use one as a syscall trap.
Added TRAMP_SENTINEL_INSN, it _isn't_ zero.
>>> + /* If the function has a valid symbol name, it isn't a
>>> + trampoline. */
>>> + find_pc_partial_function (pc, &name, NULL, NULL);
>>> + if (name != NULL)
>>> + return 0;
>>> + /* If the function lives in a valid section (even without a starting
>>> + point) it isn't a trampoline. */
>>> + if (find_pc_section (pc) != NULL)
>>> + return 0;
>
>
> I believe the first check is redundant to the second check; can we have
> names without sections? I may be wrong about this, remembering the
> problem on IRIX with absolute sections.
I don't know.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3634 bytes --]
2004-03-23 Andrew Cagney <cagney@redhat.com>
* tramp-frame.h (TRAMP_SENTINEL_INSN): Define, document.
* tramp-frame.c: Include "gdb_assert.h".
(tramp_frame_start): Use TRAMP_SENTINEL_INSN.
(tramp_frame_append): Assert the presence of TRAMP_SENTINEL_INSN.
* Makefile.in (tramp-frame.o): Update dependencies.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.529
diff -u -r1.529 Makefile.in
--- Makefile.in 23 Mar 2004 14:12:30 -0000 1.529
+++ Makefile.in 23 Mar 2004 23:58:05 -0000
@@ -2449,7 +2449,7 @@
$(regcache_h)
tramp-frame.o: tramp-frame.c $(defs_h) $(tramp_frame_h) $(frame_unwind_h) \
$(gdbcore_h) $(symtab_h) $(objfiles_h) $(target_h) $(trad_frame_h) \
- $(frame_base_h)
+ $(frame_base_h) $(gdb_assert_h)
typeprint.o: typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(command_h) \
$(gdbcmd_h) $(target_h) $(language_h) $(cp_abi_h) $(typeprint_h) \
Index: tramp-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/tramp-frame.c,v
retrieving revision 1.2
diff -u -r1.2 tramp-frame.c
--- tramp-frame.c 23 Mar 2004 14:12:30 -0000 1.2
+++ tramp-frame.c 23 Mar 2004 23:58:06 -0000
@@ -28,6 +28,7 @@
#include "target.h"
#include "trad-frame.h"
#include "frame-base.h"
+#include "gdb_assert.h"
struct frame_data
{
@@ -89,15 +90,15 @@
int ti;
/* Search through the trampoline for one that matches the
instruction sequence around PC. */
- for (ti = 0; tramp->insn[ti] != 0; ti++)
+ for (ti = 0; tramp->insn[ti] != TRAMP_SENTINEL_INSN; ti++)
{
CORE_ADDR func = pc - tramp->insn_size * ti;
int i;
for (i = 0; 1; i++)
{
- bfd_byte buf[sizeof (LONGEST)];
+ bfd_byte buf[sizeof (tramp->insn[0])];
CORE_ADDR insn;
- if (tramp->insn[i] == 0)
+ if (tramp->insn[i] == TRAMP_SENTINEL_INSN)
return func;
if (target_read_memory (func + i * tramp->insn_size, buf,
tramp->insn_size) != 0)
@@ -148,6 +149,15 @@
{
struct frame_data *data;
struct frame_unwind *unwinder;
+ int i;
+
+ /* Check that the instruction sequence contains a sentinel. */
+ for (i = 0; i < ARRAY_SIZE (tramp_frame->insn); i++)
+ {
+ if (tramp_frame->insn[i] == TRAMP_SENTINEL_INSN)
+ break;
+ }
+ gdb_assert (i < ARRAY_SIZE (tramp_frame->insn));
data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data);
unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind);
Index: tramp-frame.h
===================================================================
RCS file: /cvs/src/src/gdb/tramp-frame.h,v
retrieving revision 1.2
diff -u -r1.2 tramp-frame.h
--- tramp-frame.h 23 Mar 2004 14:12:30 -0000 1.2
+++ tramp-frame.h 23 Mar 2004 23:58:06 -0000
@@ -39,6 +39,10 @@
/* A trampoline descriptor. */
+/* Magic instruction that to mark the end of the signal trampoline
+ instruction sequence (zero for the moment). */
+#define TRAMP_SENTINEL_INSN ((LONGEST) -1)
+
struct tramp_frame
{
/* The trampoline's entire instruction sequence. Search for this in
@@ -47,7 +51,8 @@
one INSN_SIZE instruction. It is also assumed that TRAMP[0]
contains the first instruction of the trampoline and hence the
address of the instruction matching TRAMP[0] is the trampoline's
- "func" address. */
+ "func" address. The instruction sequence shall be terminated by
+ TRAMP_SENTINEL_INSN. */
int insn_size;
ULONGEST insn[8];
/* Initialize a trad-frame cache corresponding to the tramp-frame.
next prev parent reply other threads:[~2004-03-24 0:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-22 3:14 Andrew Cagney
2004-03-23 14:13 ` Andrew Cagney
2004-03-23 23:09 ` Daniel Jacobowitz
2004-03-24 0:02 ` Andrew Cagney [this message]
2004-03-24 17:15 ` Daniel Jacobowitz
2004-03-24 23:18 ` Andrew Cagney
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=4060D025.6070601@gnu.org \
--to=cagney@gnu.org \
--cc=drow@false.org \
--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