From 7bcc927b94b3131adaa192e6d4cfe4d49ae78bf8 Mon Sep 17 00:00:00 2001 From: Jason Thorpe Date: Sun, 26 May 2002 22:27:01 +0000 Subject: [PATCH] * ns32k-tdep.c (ns32k_call_dummy_words, sizeof_ns32k_call_dummy_words, ns32k_fix_call_dummy): New. * config/ns32k/tm-umax.h (CALL_DUMMY_WORDS): Define as ns32k_call_dummy_words. (SIZEOF_CALL_DUMMY_WORDS): Define as sizeof_ns32k_call_dummy_words. (CALL_DUMMY, CALL_DUMMY_LENGTH, CALL_DUMMY_ADDR, CALL_DUMMY_NARGS): Remove. (FIX_CALL_DUMMY): Define as ns32k_fix_call_dummy. --- gdb/ChangeLog | 11 +++++++++++ gdb/config/ns32k/tm-umax.h | 39 +++++++++++--------------------------- gdb/ns32k-tdep.c | 39 +++++++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dba149fa395..6bff1d763c8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2002-05-26 Jason Thorpe + + * ns32k-tdep.c (ns32k_call_dummy_words, sizeof_ns32k_call_dummy_words, + ns32k_fix_call_dummy): New. + * config/ns32k/tm-umax.h (CALL_DUMMY_WORDS): Define as + ns32k_call_dummy_words. + (SIZEOF_CALL_DUMMY_WORDS): Define as sizeof_ns32k_call_dummy_words. + (CALL_DUMMY, CALL_DUMMY_LENGTH, CALL_DUMMY_ADDR, + CALL_DUMMY_NARGS): Remove. + (FIX_CALL_DUMMY): Define as ns32k_fix_call_dummy. + 2002-05-26 Jason Thorpe * ns32k-tdep.c (ns32k_breakpoint_from_pc, ns32k_frame_chain, diff --git a/gdb/config/ns32k/tm-umax.h b/gdb/config/ns32k/tm-umax.h index 8496307d509..636e9d7d70a 100644 --- a/gdb/config/ns32k/tm-umax.h +++ b/gdb/config/ns32k/tm-umax.h @@ -187,37 +187,20 @@ void ns32k_frame_init_saved_regs (struct frame_info *); extern void ns32k_push_dummy_frame (void); #define PUSH_DUMMY_FRAME ns32k_push_dummy_frame () -/* Discard from the stack the innermost frame, restoring all registers. */ - extern void ns32k_pop_frame (void); #define POP_FRAME ns32k_pop_frame () -/* This sequence of words is the instructions - enter 0xff,0 82 ff 00 - jsr @0x00010203 7f ae c0 01 02 03 - adjspd 0x69696969 7f a5 01 02 03 04 - bpt f2 - Note this is 16 bytes. */ +extern LONGEST ns32k_call_dummy_words[]; +#define CALL_DUMMY_WORDS ns32k_call_dummy_words -#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } +extern int sizeof_ns32k_call_dummy_words; +#define SIZEOF_CALL_DUMMY_WORDS sizeof_ns32k_call_dummy_words #define CALL_DUMMY_START_OFFSET 3 -#define CALL_DUMMY_LENGTH 16 -#define CALL_DUMMY_ADDR 5 -#define CALL_DUMMY_NARGS 11 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -void flip_bytes (void *ptr, int count); - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ -{ \ - int flipped; \ - flipped = fun | 0xc0000000; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ - flipped = - nargs * 4; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ -} + +struct value; +struct type; +extern void ns32k_fix_call_dummy (char *, CORE_ADDR, CORE_ADDR, int, + struct value **, struct type *, int); +#define FIX_CALL_DUMMY(dummy, pc, fun, nargs, args, type, gcc_p) \ + ns32k_fix_call_dummy ((dummy), (pc), (fun), (nargs), (args), (type), (gcc_p)) diff --git a/gdb/ns32k-tdep.c b/gdb/ns32k-tdep.c index 42c6456fabb..66bce73fec1 100644 --- a/gdb/ns32k-tdep.c +++ b/gdb/ns32k-tdep.c @@ -26,6 +26,7 @@ static int sign_extend (int value, int bits); static CORE_ADDR ns32k_get_enter_addr (CORE_ADDR); static int ns32k_localcount (CORE_ADDR enter_pc); +static void flip_bytes (void *, int); char * ns32k_register_name_32082 (int regno) @@ -203,7 +204,7 @@ sign_extend (int value, int bits) : value); } -void +static void flip_bytes (void *p, int count) { char tmp; @@ -395,7 +396,43 @@ ns32k_pop_frame (void) write_register (SP_REGNUM, fp + 8); flush_cached_frames (); } + +/* The NS32000 call dummy sequence: + + enter 0xff,0 82 ff 00 + jsr @0x00010203 7f ae c0 01 02 03 + adjspd 0x69696969 7f a5 01 02 03 04 + bpt f2 + + It is 16 bytes long. */ + +LONGEST ns32k_call_dummy_words[] = +{ + 0x7f00ff82, + 0x0201c0ae, + 0x01a57f03, + 0xf2040302 +}; +int sizeof_ns32k_call_dummy_words = sizeof (ns32k_call_dummy_words); + +#define NS32K_CALL_DUMMY_ADDR 5 +#define NS32K_CALL_DUMMY_NARGS 11 +void +ns32k_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, + struct value **args, struct type *type, int gcc_p) +{ + int flipped; + + flipped = fun | 0xc0000000; + flip_bytes (&flipped, 4); + store_unsigned_integer (dummy + NS32K_CALL_DUMMY_ADDR, 4, flipped); + + flipped = - nargs * 4; + flip_bytes (&flipped, 4); + store_unsigned_integer (dummy + NS32K_CALL_DUMMY_NARGS, 4, flipped); +} + void _initialize_ns32k_tdep (void) { -- 2.30.2