From: Elena Zannoni Date: Wed, 5 Sep 2001 23:44:44 +0000 (+0000) Subject: 2001-09-05 Elena Zannoni X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=2bf0cb65923ab3e2fafe3304af2aa95a24822cf9;p=deliverable%2Fbinutils-gdb.git 2001-09-05 Elena Zannoni * gdbarch.sh: Move include of dis-asm.h so it is generated earlier in gdbarch.h. (TARGET_PRINT_INSN): Multiarch. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. * arch-utils.c (legacy_print_insn): New function. * arch-utils.h (legacy_print_insn): Export. * cris-tdep.c (cris_delayed_get_disassembler): Use TARGET_PRINT_INSN, instead of tm_print_insn. * d10v-tdep.c (print_insn): Ditto. * d30v-tdep.c (print_insn): Ditto. * m32r-tdep.c (dump_insn): Ditto. * v850-tdep.c (v850_scan_prologue): Ditto. * mcore-tdep.c (mcore_dump_insn): Ditto. * sh-tdep.c (sh_gdbarch_init): Set print_insn gdbarch field. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 86008db44e..b23e1f6925 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2001-09-05 Elena Zannoni + + * gdbarch.sh: Move include of dis-asm.h so it is generated earlier + in gdbarch.h. + (TARGET_PRINT_INSN): Multiarch. + * gdbarch.h: Regenerate. + * gdbarch.c: Regenerate. + + * arch-utils.c (legacy_print_insn): New function. + * arch-utils.h (legacy_print_insn): Export. + + * cris-tdep.c (cris_delayed_get_disassembler): Use + TARGET_PRINT_INSN, instead of tm_print_insn. + * d10v-tdep.c (print_insn): Ditto. + * d30v-tdep.c (print_insn): Ditto. + * m32r-tdep.c (dump_insn): Ditto. + * v850-tdep.c (v850_scan_prologue): Ditto. + * mcore-tdep.c (mcore_dump_insn): Ditto. + * sh-tdep.c (sh_gdbarch_init): Set print_insn gdbarch field. + 2001-09-05 Jim Blandy * gdbtypes.h (struct type): Doc fix. diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 124281f454..f395c3e18a 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -146,6 +146,13 @@ generic_prologue_frameless_p (CORE_ADDR ip) #endif } +/* New/multi-arched targets should use the correct gdbarch field + instead of using this global pointer. */ +int +legacy_print_insn (bfd_vma vma, disassemble_info *info) +{ + return (*tm_print_insn) (vma, info); +} /* Helper functions for INNER_THAN */ diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index a273b9fd80..f2d9b8cfb2 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -47,6 +47,9 @@ extern gdbarch_return_value_on_stack_ftype generic_return_value_on_stack_not; /* Map onto old REGISTER_NAMES. */ extern char *legacy_register_name (int i); +/* Accessor for old global function pointer for disassembly. */ +extern int legacy_print_insn (bfd_vma vma, disassemble_info *info); + /* Backward compatible call_dummy_words. */ extern LONGEST legacy_call_dummy_words[]; extern int legacy_sizeof_call_dummy_words; diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 5ac2a3be20..63c83cb0a1 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -3532,7 +3532,7 @@ static int cris_delayed_get_disassembler (bfd_vma addr, disassemble_info *info) { tm_print_insn = cris_get_disassembler (exec_bfd); - return (*tm_print_insn) (addr, info); + return TARGET_PRINT_INSN (addr, info); } void diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index 0acc57d656..b0dd3bcac1 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -1239,7 +1239,7 @@ print_insn (CORE_ADDR memaddr, struct ui_file *stream) tm_print_insn_info.endian = BFD_ENDIAN_BIG; else tm_print_insn_info.endian = BFD_ENDIAN_LITTLE; - return (*tm_print_insn) (memaddr, &tm_print_insn_info); + return TARGET_PRINT_INSN (memaddr, &tm_print_insn_info); } static void diff --git a/gdb/d30v-tdep.c b/gdb/d30v-tdep.c index 5a075180f9..844fb3e013 100644 --- a/gdb/d30v-tdep.c +++ b/gdb/d30v-tdep.c @@ -1156,7 +1156,7 @@ print_insn (CORE_ADDR memaddr, struct ui_file *stream) tm_print_insn_info.endian = BFD_ENDIAN_BIG; else tm_print_insn_info.endian = BFD_ENDIAN_LITTLE; - return (*tm_print_insn) (memaddr, &tm_print_insn_info); + return TARGET_PRINT_INSN (memaddr, &tm_print_insn_info); } void diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index ced835485e..c78e82da1e 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -249,6 +249,7 @@ struct gdbarch gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr; gdbarch_addr_bits_remove_ftype *addr_bits_remove; gdbarch_software_single_step_ftype *software_single_step; + gdbarch_print_insn_ftype *print_insn; gdbarch_skip_trampoline_code_ftype *skip_trampoline_code; }; @@ -385,6 +386,7 @@ struct gdbarch startup_gdbarch = 0, 0, 0, + 0, /* startup_gdbarch() */ }; @@ -484,6 +486,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->extra_stack_alignment_needed = 1; gdbarch->convert_from_func_ptr_addr = core_addr_identity; gdbarch->addr_bits_remove = core_addr_identity; + gdbarch->print_insn = legacy_print_insn; gdbarch->skip_trampoline_code = generic_skip_trampoline_code; /* gdbarch_alloc() */ @@ -780,6 +783,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */ /* Skip verify of addr_bits_remove, invalid_p == 0 */ /* Skip verify of software_single_step, has predicate */ + /* Skip verify of print_insn, invalid_p == 0 */ /* Skip verify of skip_trampoline_code, invalid_p == 0 */ } @@ -1472,6 +1476,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "SOFTWARE_SINGLE_STEP(sig, insert_breakpoints_p)", XSTRING (SOFTWARE_SINGLE_STEP (sig, insert_breakpoints_p))); #endif +#ifdef TARGET_PRINT_INSN + fprintf_unfiltered (file, + "gdbarch_dump: %s # %s\n", + "TARGET_PRINT_INSN(vma, info)", + XSTRING (TARGET_PRINT_INSN (vma, info))); +#endif #ifdef SKIP_TRAMPOLINE_CODE fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -2210,6 +2220,13 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) (long) current_gdbarch->software_single_step /*SOFTWARE_SINGLE_STEP ()*/); #endif +#ifdef TARGET_PRINT_INSN + if (GDB_MULTI_ARCH) + fprintf_unfiltered (file, + "gdbarch_dump: TARGET_PRINT_INSN = 0x%08lx\n", + (long) current_gdbarch->print_insn + /*TARGET_PRINT_INSN ()*/); +#endif #ifdef SKIP_TRAMPOLINE_CODE if (GDB_MULTI_ARCH) fprintf_unfiltered (file, @@ -4330,6 +4347,24 @@ set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch->software_single_step = software_single_step; } +int +gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, disassemble_info *info) +{ + if (gdbarch->print_insn == 0) + internal_error (__FILE__, __LINE__, + "gdbarch: gdbarch_print_insn invalid"); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_print_insn called\n"); + return gdbarch->print_insn (vma, info); +} + +void +set_gdbarch_print_insn (struct gdbarch *gdbarch, + gdbarch_print_insn_ftype print_insn) +{ + gdbarch->print_insn = print_insn; +} + CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, CORE_ADDR pc) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index f2a10332e1..29ed020856 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -35,6 +35,8 @@ #ifndef GDBARCH_H #define GDBARCH_H +#include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */ + struct frame_info; struct value; @@ -1947,6 +1949,23 @@ extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_s #endif #endif +/* Default (function) for non- multi-arch platforms. */ +#if (!GDB_MULTI_ARCH) && !defined (TARGET_PRINT_INSN) +#define TARGET_PRINT_INSN(vma, info) (legacy_print_insn (vma, info)) +#endif + +typedef int (gdbarch_print_insn_ftype) (bfd_vma vma, disassemble_info *info); +extern int gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, disassemble_info *info); +extern void set_gdbarch_print_insn (struct gdbarch *gdbarch, gdbarch_print_insn_ftype *print_insn); +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_PRINT_INSN) +#error "Non multi-arch definition of TARGET_PRINT_INSN" +#endif +#if GDB_MULTI_ARCH +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_PRINT_INSN) +#define TARGET_PRINT_INSN(vma, info) (gdbarch_print_insn (current_gdbarch, vma, info)) +#endif +#endif + /* Default (function) for non- multi-arch platforms. */ #if (!GDB_MULTI_ARCH) && !defined (SKIP_TRAMPOLINE_CODE) #define SKIP_TRAMPOLINE_CODE(pc) (generic_skip_trampoline_code (pc)) @@ -2205,8 +2224,6 @@ extern const struct bfd_arch_info *target_architecture; /* The target-system-dependent disassembler is semi-dynamic */ -#include "dis-asm.h" /* Get defs for disassemble_info */ - extern int dis_asm_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int len, disassemble_info *info); @@ -2218,9 +2235,6 @@ extern void dis_asm_print_address (bfd_vma addr, extern int (*tm_print_insn) (bfd_vma, disassemble_info*); extern disassemble_info tm_print_insn_info; -#ifndef TARGET_PRINT_INSN -#define TARGET_PRINT_INSN(vma, info) (*tm_print_insn) (vma, info) -#endif #ifndef TARGET_PRINT_INSN_INFO #define TARGET_PRINT_INSN_INFO (&tm_print_insn_info) #endif diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 714498dee4..35dfa6db80 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -539,6 +539,7 @@ f:2:ADDR_BITS_REMOVE:CORE_ADDR:addr_bits_remove:CORE_ADDR addr:addr:::core_addr_ # FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the target can # single step. If not, then implement single step using breakpoints. F:2:SOFTWARE_SINGLE_STEP:void:software_single_step:enum target_signal sig, int insert_breakpoints_p:sig, insert_breakpoints_p::0:0 +f:2:TARGET_PRINT_INSN:int:print_insn:bfd_vma vma, disassemble_info *info:vma, info:::legacy_print_insn::0 f:2:SKIP_TRAMPOLINE_CODE:CORE_ADDR:skip_trampoline_code:CORE_ADDR pc:pc:::generic_skip_trampoline_code::0 EOF } @@ -629,6 +630,8 @@ cat <