From: Stu Grossman Date: Thu, 17 Sep 1992 05:01:51 +0000 (+0000) Subject: * m68k-tdep.c (sun3_saved_pc_after_call): Only do trap check for X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f49925349186c131c56fecf8f19b9fd46351e3f2;p=binutils-gdb.git * m68k-tdep.c (sun3_saved_pc_after_call): Only do trap check for Suns. Rename to m68k_saved_pc_after_call. * tm-68k-noun.h, tm-sun3.h (SAVED_PC_AFTER_CALL): Use m68k_saved... instead of sun3_saved... --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5ae6458911c..5d17d86b6ab 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +Wed Sep 16 21:57:14 1992 Stu Grossman (grossman at cygnus.com) + + * m68k-tdep.c (sun3_saved_pc_after_call): Only do trap check for + Suns. Rename to m68k_saved_pc_after_call. + * tm-68k-noun.h, tm-sun3.h (SAVED_PC_AFTER_CALL): Use + m68k_saved... instead of sun3_saved... + Mon Sep 14 19:20:43 1992 Stu Grossman (grossman at cygnus.com) * energize.c (pty_to_kernel): Must check for EAGAIN as diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 240871850db..2d0428b0b0c 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -1,5 +1,5 @@ /* Target dependent code for the Motorola 68000 series. - Copyright (C) 1990 Free Software Foundation, Inc. + Copyright (C) 1990, 1992 Free Software Foundation, Inc. This file is part of GDB. @@ -19,7 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "defs.h" #include "ieee-float.h" -#include "param.h" #include "frame.h" #include "symtab.h" @@ -149,6 +148,7 @@ m68k_pop_frame () #define P_LEA_L 0x43fb #define P_MOVM_L 0x48ef #define P_FMOVM 0xf237 +#define P_TRAP 0x4e40 CORE_ADDR m68k_skip_prologue (ip) @@ -236,12 +236,12 @@ void supply_gregset (gregsetp) gregset_t *gregsetp; { - register int regno; + register int regi; register greg_t *regp = (greg_t *) gregsetp; - for (regno = 0 ; regno < R_PC ; regno++) + for (regi = 0 ; regi < R_PC ; regi++) { - supply_register (regno, (char *) (regp + regno)); + supply_register (regi, (char *) (regp + regi)); } supply_register (PS_REGNUM, (char *) (regp + R_PS)); supply_register (PC_REGNUM, (char *) (regp + R_PC)); @@ -252,7 +252,7 @@ fill_gregset (gregsetp, regno) gregset_t *gregsetp; int regno; { - int regi; + register int regi; register greg_t *regp = (greg_t *) gregsetp; extern char registers[]; @@ -260,7 +260,7 @@ int regno; { if ((regno == -1) || (regno == regi)) { - *(regp + regno) = *(int *) ®isters[REGISTER_BYTE (regi)]; + *(regp + regi) = *(int *) ®isters[REGISTER_BYTE (regi)]; } } if ((regno == -1) || (regno == PS_REGNUM)) @@ -283,11 +283,13 @@ void supply_fpregset (fpregsetp) fpregset_t *fpregsetp; { - register int regno; + register int regi; + char *from; - for (regno = FP0_REGNUM ; regno < FPC_REGNUM ; regno++) + for (regi = FP0_REGNUM ; regi < FPC_REGNUM ; regi++) { - supply_register (regno, (char *) &(fpregsetp -> f_fpregs[regno][0])); + from = (char *) &(fpregsetp -> f_fpregs[regi-FP0_REGNUM][0]); + supply_register (regi, from); } supply_register (FPC_REGNUM, (char *) &(fpregsetp -> f_pcr)); supply_register (FPS_REGNUM, (char *) &(fpregsetp -> f_psr)); @@ -314,8 +316,8 @@ int regno; if ((regno == -1) || (regno == regi)) { from = (char *) ®isters[REGISTER_BYTE (regi)]; - to = (char *) &(fpregsetp -> f_fpregs[regi][0]); - bcopy (from, to, REGISTER_RAW_SIZE (regno)); + to = (char *) &(fpregsetp -> f_fpregs[regi-FP0_REGNUM][0]); + bcopy (from, to, REGISTER_RAW_SIZE (regi)); } } if ((regno == -1) || (regno == FPC_REGNUM)) @@ -335,3 +337,57 @@ int regno; #endif /* defined (FP0_REGNUM) */ #endif /* USE_PROC_FS */ + +#ifdef GET_LONGJMP_TARGET +/* Figure out where the longjmp will land. Slurp the args out of the stack. + We expect the first arg to be a pointer to the jmp_buf structure from which + we extract the pc (JB_PC) that we will land at. The pc is copied into PC. + This routine returns true on success. */ + +int +get_longjmp_target(pc) + CORE_ADDR *pc; +{ + CORE_ADDR sp, jb_addr; + + sp = read_register(SP_REGNUM); + + if (target_read_memory(sp + SP_ARG0, /* Offset of first arg on stack */ + &jb_addr, + sizeof(CORE_ADDR))) + return 0; + + + SWAP_TARGET_AND_HOST(&jb_addr, sizeof(CORE_ADDR)); + + if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, pc, + sizeof(CORE_ADDR))) + return 0; + + SWAP_TARGET_AND_HOST(pc, sizeof(CORE_ADDR)); + + return 1; +} +#endif /* GET_LONGJMP_TARGET */ + +/* Immediately after a function call, return the saved pc before the frame + is setup. We check for the common case of being inside of a system call, + and if so, we know that Sun pushes the call # on the stack prior to doing + the trap. */ + +CORE_ADDR +m68k_saved_pc_after_call(frame) + struct frame_info *frame; +{ +#ifdef sun + int op; + + op = read_memory_integer (frame->pc, 2); + op &= 0xFFFF; + + if (op == P_TRAP) + return read_memory_integer (read_register (SP_REGNUM) + 4, 4); + else +#endif /* sun */ + return read_memory_integer (read_register (SP_REGNUM), 4); +} diff --git a/gdb/tm-68k-noun.h b/gdb/tm-68k-noun.h index d3e5e62ee12..aaaa5e97560 100644 --- a/gdb/tm-68k-noun.h +++ b/gdb/tm-68k-noun.h @@ -60,8 +60,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ struct frame_info; #endif -extern CORE_ADDR sun3_saved_pc_after_call PARAMS ((struct frame_info *)); +extern CORE_ADDR m68k_saved_pc_after_call PARAMS ((struct frame_info *)); #undef SAVED_PC_AFTER_CALL #define SAVED_PC_AFTER_CALL(frame) \ - sun3_saved_pc_after_call(frame) + m68k_saved_pc_after_call(frame) diff --git a/gdb/tm-sun3.h b/gdb/tm-sun3.h index 60606ec0cbc..875eebaa32d 100644 --- a/gdb/tm-sun3.h +++ b/gdb/tm-sun3.h @@ -61,7 +61,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ struct frame_info; #endif -extern CORE_ADDR sun3_saved_pc_after_call PARAMS ((struct frame_info *)); +extern CORE_ADDR m68k_saved_pc_after_call PARAMS ((struct frame_info *)); #define SAVED_PC_AFTER_CALL(frame) \ - sun3_saved_pc_after_call(frame) + m68k_saved_pc_after_call(frame)