aboutsummaryrefslogtreecommitdiff
path: root/gdb/tramp-frame.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2004-03-24 23:14:39 +0000
committerAndrew Cagney <cagney@redhat.com>2004-03-24 23:14:39 +0000
commit1196bfdaf9becb2a90e01bec41fc18b24affad38 (patch)
tree8dd0a5d71a7a17a3d34629f3540da394c965bea0 /gdb/tramp-frame.c
parent38f443c80eac123969131b3692a773f31efa0f30 (diff)
downloadgdb-1196bfdaf9becb2a90e01bec41fc18b24affad38.zip
gdb-1196bfdaf9becb2a90e01bec41fc18b24affad38.tar.gz
gdb-1196bfdaf9becb2a90e01bec41fc18b24affad38.tar.bz2
2004-03-24 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. Use ULONGEST and correct sizeof. (tramp_frame_append): Validate the tramp frame's instructions. * Makefile.in (tramp-frame.o): Update dependencies.
Diffstat (limited to 'gdb/tramp-frame.c')
-rw-r--r--gdb/tramp-frame.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
index 7a8057e..ee3635f 100644
--- a/gdb/tramp-frame.c
+++ b/gdb/tramp-frame.c
@@ -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 @@ 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++)
+ 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)];
- CORE_ADDR insn;
- if (tramp->insn[i] == 0)
+ bfd_byte buf[sizeof (tramp->insn[0])];
+ ULONGEST insn;
+ 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,16 @@ tramp_frame_append (struct gdbarch *gdbarch,
{
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));
+ gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0]));
data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data);
unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind);