diff options
author | Mark Kettenis <kettenis@gnu.org> | 2003-12-21 23:13:59 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2003-12-21 23:13:59 +0000 |
commit | 47d264de46ebe76577ec44037d646c9050dcf2cd (patch) | |
tree | e3fcc4705e9d6c8e8c9c3751f3e30beb9e4d2322 | |
parent | d174e626b6d3e9a9b0a176fec82a50f75bedaba2 (diff) | |
download | gdb-47d264de46ebe76577ec44037d646c9050dcf2cd.zip gdb-47d264de46ebe76577ec44037d646c9050dcf2cd.tar.gz gdb-47d264de46ebe76577ec44037d646c9050dcf2cd.tar.bz2 |
* sparc-tdep.h (struct sparc_frame_cache): Rename from `struct
sparc32_frame_cache'.
(sparc_analyze_prologue, sparc_frame_cache): New prototypes.
(sparc32_frame_cache): Adjust prototype.
* sparc-tdep.c (sparc_alloc_frame_cache): Rename from
sparc32_alloc_frame_cache. Use `struct sparc_frame_cache' instead
of `struct sparc32_frame_cache'.
(sparc_analyze_prologue): Rename from sparc32_analyze_prologue.
Use `struct sparc_frame_cache' instead of `struct
sparc32_frame_cache'.
(sparc32_skip_prologue): Use `struct sparc_frame_cache' instead of
`struct sparc32_frame_cache'. Call sparc_analyze_prologue instead
of sparc32_analyze_prologue.
(sparc_frame_cache): New function with generic code from...
(sparc32_frame_cache): ...here.
(sparc32_frame_this_id, sparc32_frame_prev_register)
(sparc32_frame_base_address): Use `struct sparc_frame_cache'
instead of `struct sparc32_frame_cache'.
* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache)
(sparc32_sol2_sigtramp_frame_this_id)
(sparc32_sol2_sigtramp_frame_prev_register): Change return type to
`struct sparc_frame_cache *'.
* sparc-linux-tdep.c (sparc32_linux_sigtramp_frame_cache)
(sparc32_linux_sigtramp_frame_this_id)
(sparc32_linux_sigtramp_frame_prev_register): Change return type
to `struct sparc_frame_cache *'.
* sparc64-tdep.c (X_OP, X_RD, X_A, X_COND, X_OP2, X_IMM22, X_OP3)
(X_I, X_DISP22, X_DISP19): Remove macros.
(struct sparc64_frame_cache): Remove.
(sparc64_alloc_frame_cache, sparc64_analyze_prologue): Remove
functions.
(sparc64_skip_prologue): Use `struct sparc_frame_cache' instead of
`struct sparc64_frame_cache. Call sparc_analyze_prologue instead
of sparc64_analuze_prologue.
(sparc64_frame_this_id, sparc64_frame_prev_register,
sparc64_frame_base_address): Use `struct sparc_frame_cache'
instead of `struct sparc64_frame_cache.
(sparc64_frame_cache): Change return type to `struct
sparc_frame_cache *'. Simply call sparc_frame_cache.
-rw-r--r-- | gdb/ChangeLog | 42 | ||||
-rw-r--r-- | gdb/sparc-linux-tdep.c | 8 | ||||
-rw-r--r-- | gdb/sparc-sol2-tdep.c | 8 | ||||
-rw-r--r-- | gdb/sparc-tdep.c | 49 | ||||
-rw-r--r-- | gdb/sparc-tdep.h | 10 | ||||
-rw-r--r-- | gdb/sparc64-tdep.c | 130 |
6 files changed, 96 insertions, 151 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f93c85..a896414 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,45 @@ +2003-12-22 Mark Kettenis <kettenis@gnu.org> + + * sparc-tdep.h (struct sparc_frame_cache): Rename from `struct + sparc32_frame_cache'. + (sparc_analyze_prologue, sparc_frame_cache): New prototypes. + (sparc32_frame_cache): Adjust prototype. + * sparc-tdep.c (sparc_alloc_frame_cache): Rename from + sparc32_alloc_frame_cache. Use `struct sparc_frame_cache' instead + of `struct sparc32_frame_cache'. + (sparc_analyze_prologue): Rename from sparc32_analyze_prologue. + Use `struct sparc_frame_cache' instead of `struct + sparc32_frame_cache'. + (sparc32_skip_prologue): Use `struct sparc_frame_cache' instead of + `struct sparc32_frame_cache'. Call sparc_analyze_prologue instead + of sparc32_analyze_prologue. + (sparc_frame_cache): New function with generic code from... + (sparc32_frame_cache): ...here. + (sparc32_frame_this_id, sparc32_frame_prev_register) + (sparc32_frame_base_address): Use `struct sparc_frame_cache' + instead of `struct sparc32_frame_cache'. + * sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache) + (sparc32_sol2_sigtramp_frame_this_id) + (sparc32_sol2_sigtramp_frame_prev_register): Change return type to + `struct sparc_frame_cache *'. + * sparc-linux-tdep.c (sparc32_linux_sigtramp_frame_cache) + (sparc32_linux_sigtramp_frame_this_id) + (sparc32_linux_sigtramp_frame_prev_register): Change return type + to `struct sparc_frame_cache *'. + * sparc64-tdep.c (X_OP, X_RD, X_A, X_COND, X_OP2, X_IMM22, X_OP3) + (X_I, X_DISP22, X_DISP19): Remove macros. + (struct sparc64_frame_cache): Remove. + (sparc64_alloc_frame_cache, sparc64_analyze_prologue): Remove + functions. + (sparc64_skip_prologue): Use `struct sparc_frame_cache' instead of + `struct sparc64_frame_cache. Call sparc_analyze_prologue instead + of sparc64_analuze_prologue. + (sparc64_frame_this_id, sparc64_frame_prev_register, + sparc64_frame_base_address): Use `struct sparc_frame_cache' + instead of `struct sparc64_frame_cache. + (sparc64_frame_cache): Change return type to `struct + sparc_frame_cache *'. Simply call sparc_frame_cache. + 2003-12-15 Mark Kettenis <kettenis@gnu.org> * sparc-tdep.c (sparc32_frame_cache): Use diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c index 451c71e..aa64236 100644 --- a/gdb/sparc-linux-tdep.c +++ b/gdb/sparc-linux-tdep.c @@ -149,11 +149,11 @@ sparc32_linux_pc_in_sigtramp (CORE_ADDR pc, char *name) || strcmp ("__restore_rt", name) == 0); } -static struct sparc32_frame_cache * +static struct sparc_frame_cache * sparc32_linux_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache) { - struct sparc32_frame_cache *cache; + struct sparc_frame_cache *cache; CORE_ADDR sigcontext_addr, addr; int regnum; @@ -208,7 +208,7 @@ sparc32_linux_sigtramp_frame_this_id (struct frame_info *next_frame, void **this_cache, struct frame_id *this_id) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_linux_sigtramp_frame_cache (next_frame, this_cache); (*this_id) = frame_id_build (cache->base, cache->pc); @@ -222,7 +222,7 @@ sparc32_linux_sigtramp_frame_prev_register (struct frame_info *next_frame, CORE_ADDR *addrp, int *realnump, void *valuep) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_linux_sigtramp_frame_cache (next_frame, this_cache); trad_frame_prev_register (next_frame, cache->saved_regs, regnum, diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c index 030b972..3e3d433 100644 --- a/gdb/sparc-sol2-tdep.c +++ b/gdb/sparc-sol2-tdep.c @@ -56,11 +56,11 @@ sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name) return (name && strcmp (name, "sigacthandler") == 0); } -static struct sparc32_frame_cache * +static struct sparc_frame_cache * sparc32_sol2_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache) { - struct sparc32_frame_cache *cache; + struct sparc_frame_cache *cache; CORE_ADDR mcontext_addr, addr; int regnum; @@ -106,7 +106,7 @@ sparc32_sol2_sigtramp_frame_this_id (struct frame_info *next_frame, void **this_cache, struct frame_id *this_id) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_sol2_sigtramp_frame_cache (next_frame, this_cache); (*this_id) = frame_id_build (cache->base, cache->pc); @@ -120,7 +120,7 @@ sparc32_sol2_sigtramp_frame_prev_register (struct frame_info *next_frame, CORE_ADDR *addrp, int *realnump, void *valuep) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_sol2_sigtramp_frame_cache (next_frame, this_cache); trad_frame_prev_register (next_frame, cache->saved_regs, regnum, diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index adbc8ef..d8b83ca 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -437,13 +437,13 @@ sparc_breakpoint_from_pc (CORE_ADDR *pc, int *len) /* Allocate and initialize a frame cache. */ -static struct sparc32_frame_cache * -sparc32_alloc_frame_cache (void) +static struct sparc_frame_cache * +sparc_alloc_frame_cache (void) { - struct sparc32_frame_cache *cache; + struct sparc_frame_cache *cache; int i; - cache = FRAME_OBSTACK_ZALLOC (struct sparc32_frame_cache); + cache = FRAME_OBSTACK_ZALLOC (struct sparc_frame_cache); /* Base address. */ cache->base = 0; @@ -457,9 +457,9 @@ sparc32_alloc_frame_cache (void) return cache; } -static CORE_ADDR -sparc32_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, - struct sparc32_frame_cache *cache) +CORE_ADDR +sparc_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, + struct sparc_frame_cache *cache) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); unsigned long insn; @@ -527,7 +527,7 @@ sparc32_skip_prologue (CORE_ADDR start_pc) { struct symtab_and_line sal; CORE_ADDR func_start, func_end; - struct sparc32_frame_cache cache; + struct sparc_frame_cache cache; /* This is the preferred method, find the end of the prologue by using the debugging information. */ @@ -540,21 +540,20 @@ sparc32_skip_prologue (CORE_ADDR start_pc) return sal.end; } - return sparc32_analyze_prologue (start_pc, 0xffffffffUL, &cache); + return sparc_analyze_prologue (start_pc, 0xffffffffUL, &cache); } /* Normal frames. */ -struct sparc32_frame_cache * -sparc32_frame_cache (struct frame_info *next_frame, void **this_cache) +struct sparc_frame_cache * +sparc_frame_cache (struct frame_info *next_frame, void **this_cache) { - struct sparc32_frame_cache *cache; - struct symbol *sym; + struct sparc_frame_cache *cache; if (*this_cache) return *this_cache; - cache = sparc32_alloc_frame_cache (); + cache = sparc_alloc_frame_cache (); *this_cache = cache; /* In priciple, for normal frames, %fp (%i6) holds the frame @@ -569,7 +568,7 @@ sparc32_frame_cache (struct frame_info *next_frame, void **this_cache) if (cache->pc != 0) { CORE_ADDR addr_in_block = frame_unwind_address_in_block (next_frame); - sparc32_analyze_prologue (cache->pc, addr_in_block, cache); + sparc_analyze_prologue (cache->pc, addr_in_block, cache); } if (cache->frameless_p) @@ -580,6 +579,20 @@ sparc32_frame_cache (struct frame_info *next_frame, void **this_cache) SPARC_SP_REGNUM); } + return cache; +} + +struct sparc_frame_cache * +sparc32_frame_cache (struct frame_info *next_frame, void **this_cache) +{ + struct sparc_frame_cache *cache; + struct symbol *sym; + + if (*this_cache) + return *this_cache; + + cache = sparc_frame_cache (next_frame, this_cache); + sym = find_pc_function (cache->pc); if (sym) { @@ -602,7 +615,7 @@ static void sparc32_frame_this_id (struct frame_info *next_frame, void **this_cache, struct frame_id *this_id) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_frame_cache (next_frame, this_cache); /* This marks the outermost frame. */ @@ -618,7 +631,7 @@ sparc32_frame_prev_register (struct frame_info *next_frame, void **this_cache, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, void *valuep) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_frame_cache (next_frame, this_cache); if (regnum == SPARC32_PC_REGNUM || regnum == SPARC32_NPC_REGNUM) @@ -690,7 +703,7 @@ sparc32_frame_sniffer (struct frame_info *next_frame) static CORE_ADDR sparc32_frame_base_address (struct frame_info *next_frame, void **this_cache) { - struct sparc32_frame_cache *cache = + struct sparc_frame_cache *cache = sparc32_frame_cache (next_frame, this_cache); return cache->base; diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h index a7bdf23..f7fec22 100644 --- a/gdb/sparc-tdep.h +++ b/gdb/sparc-tdep.h @@ -120,7 +120,7 @@ enum sparc32_regnum }; -struct sparc32_frame_cache +struct sparc_frame_cache { /* Base address. */ CORE_ADDR base; @@ -136,7 +136,13 @@ struct sparc32_frame_cache struct trad_frame_saved_reg *saved_regs; }; -extern struct sparc32_frame_cache * +extern CORE_ADDR sparc_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, + struct sparc_frame_cache *cache); + +extern struct sparc_frame_cache * + sparc_frame_cache (struct frame_info *next_frame, void **this_cache); + +extern struct sparc_frame_cache * sparc32_frame_cache (struct frame_info *next_frame, void **this_cache); diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 483a63a..b3313df 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -495,91 +495,6 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch, } -struct sparc64_frame_cache -{ - /* Base address. */ - CORE_ADDR base; - CORE_ADDR pc; - - /* Do we have a frame? */ - int frameless_p; -}; - -/* Allocate and initialize a frame cache. */ - -static struct sparc64_frame_cache * -sparc64_alloc_frame_cache (void) -{ - struct sparc64_frame_cache *cache; - int i; - - cache = FRAME_OBSTACK_ZALLOC (struct sparc64_frame_cache); - - /* Base address. */ - cache->base = 0; - cache->pc = 0; - - /* Frameless until proven otherwise. */ - cache->frameless_p = 1; - - return cache; -} - -static CORE_ADDR -sparc64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc, - struct sparc64_frame_cache *cache) -{ - struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); - unsigned long insn; - int offset = 0; - int dest = -1; - - if (current_pc <= pc) - return current_pc; - - /* We have to handle to "Procedure Linkage Table" (PLT) special. On - SPARC the linker usually defines a symbol (typically - _PROCEDURE_LINKAGE_TABLE_) at the start of the .plt section. - This symbol makes us end up here with PC pointing at the start of - the PLT and CURRENT_PC probably pointing at a PLT entry. If we - would do our normal prologue analysis, we would probably conclude - that we've got a frame when in reality we don't, since the - dynamic linker patches up the first PLT with some code that - starts with a SAVE instruction. Patch up PC such that it points - at the start of our PLT entry. */ - if (tdep->plt_entry_size > 0 && in_plt_section (current_pc, NULL)) - pc = current_pc - ((current_pc - pc) % tdep->plt_entry_size); - - insn = sparc_fetch_instruction (pc); - - /* Recognize a SETHI insn and record its destination. */ - if (X_OP (insn) == 0 && X_OP2 (insn) == 0x04) - { - dest = X_RD (insn); - offset += 4; - - insn = sparc_fetch_instruction (pc + 4); - } - - /* Allow for an arithmetic operation on DEST or %g1. */ - if (X_OP (insn) == 2 && X_I (insn) - && (X_RD (insn) == 1 || X_RD (insn) == dest)) - { - offset += 4; - - insn = sparc_fetch_instruction (pc + 8); - } - - /* Check for the SAVE instruction that sets up the frame. */ - if (X_OP (insn) == 2 && X_OP3 (insn) == 0x3c) - { - cache->frameless_p = 0; - return pc + offset + 4; - } - - return pc; -} - /* Return PC of first real instruction of the function starting at START_PC. */ @@ -588,7 +503,7 @@ sparc64_skip_prologue (CORE_ADDR start_pc) { struct symtab_and_line sal; CORE_ADDR func_start, func_end; - struct sparc64_frame_cache cache; + struct sparc_frame_cache cache; /* This is the preferred method, find the end of the prologue by using the debugging information. */ @@ -601,53 +516,22 @@ sparc64_skip_prologue (CORE_ADDR start_pc) return sal.end; } - return sparc64_analyze_prologue (start_pc, 0xffffffffffffffffUL, &cache); + return sparc_analyze_prologue (start_pc, 0xffffffffffffffffUL, &cache); } /* Normal frames. */ -static struct sparc64_frame_cache * +static struct sparc_frame_cache * sparc64_frame_cache (struct frame_info *next_frame, void **this_cache) { - struct sparc64_frame_cache *cache; - - if (*this_cache) - return *this_cache; - - cache = sparc64_alloc_frame_cache (); - *this_cache = cache; - - /* In priciple, for normal frames, %fp (%i6) holds the frame - pointer, which holds the base address for the current stack - frame. */ - - cache->base = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM); - if (cache->base == 0) - return cache; - - cache->pc = frame_func_unwind (next_frame); - if (cache->pc != 0) - { - CORE_ADDR addr_in_block = frame_unwind_address_in_block (next_frame); - sparc64_analyze_prologue (cache->pc, addr_in_block, cache); - } - - if (cache->frameless_p) - { - /* We didn't find a valid frame, which means that CACHE->base - currently holds the frame pointer for our calling frame. */ - cache->base = frame_unwind_register_unsigned (next_frame, - SPARC_SP_REGNUM); - } - - return cache; + return sparc_frame_cache (next_frame, this_cache); } static void sparc64_frame_this_id (struct frame_info *next_frame, void **this_cache, struct frame_id *this_id) { - struct sparc64_frame_cache *cache = + struct sparc_frame_cache *cache = sparc64_frame_cache (next_frame, this_cache); /* This marks the outermost frame. */ @@ -663,7 +547,7 @@ sparc64_frame_prev_register (struct frame_info *next_frame, void **this_cache, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, void *valuep) { - struct sparc64_frame_cache *cache = + struct sparc_frame_cache *cache = sparc64_frame_cache (next_frame, this_cache); if (regnum == SPARC64_PC_REGNUM || regnum == SPARC64_NPC_REGNUM) @@ -729,7 +613,7 @@ sparc64_frame_sniffer (struct frame_info *next_frame) static CORE_ADDR sparc64_frame_base_address (struct frame_info *next_frame, void **this_cache) { - struct sparc64_frame_cache *cache = + struct sparc_frame_cache *cache = sparc64_frame_cache (next_frame, this_cache); /* ??? Should we take BIAS into account here? */ |