xref: /dflybsd-src/contrib/gdb-7/gdb/arch-utils.h (revision cf7f2e2d389e8012d562650bd94d7e433f449d6e)
15796c8dcSSimon Schubert /* Dynamic architecture support for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*cf7f2e2dSJohn Marino    Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2008, 2009, 2010
45796c8dcSSimon Schubert    Free Software Foundation, Inc.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This file is part of GDB.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
95796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
105796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
115796c8dcSSimon Schubert    (at your option) any later version.
125796c8dcSSimon Schubert 
135796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
145796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
155796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165796c8dcSSimon Schubert    GNU General Public License for more details.
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
195796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
205796c8dcSSimon Schubert 
215796c8dcSSimon Schubert #ifndef GDBARCH_UTILS_H
225796c8dcSSimon Schubert #define GDBARCH_UTILS_H
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert struct gdbarch;
255796c8dcSSimon Schubert struct frame_info;
265796c8dcSSimon Schubert struct minimal_symbol;
275796c8dcSSimon Schubert struct type;
285796c8dcSSimon Schubert struct gdbarch_info;
295796c8dcSSimon Schubert 
305796c8dcSSimon Schubert /* gdbarch trace variable */
315796c8dcSSimon Schubert extern int gdbarch_debug;
325796c8dcSSimon Schubert 
335796c8dcSSimon Schubert /* An implementation of gdbarch_displaced_step_copy_insn for
345796c8dcSSimon Schubert    processors that don't need to modify the instruction before
355796c8dcSSimon Schubert    single-stepping the displaced copy.
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert    Simply copy gdbarch_max_insn_length (ARCH) bytes from FROM to TO.
385796c8dcSSimon Schubert    The closure is an array of that many bytes containing the
395796c8dcSSimon Schubert    instruction's bytes, allocated with xmalloc.  */
405796c8dcSSimon Schubert extern struct displaced_step_closure *
415796c8dcSSimon Schubert   simple_displaced_step_copy_insn (struct gdbarch *gdbarch,
425796c8dcSSimon Schubert                                    CORE_ADDR from, CORE_ADDR to,
435796c8dcSSimon Schubert                                    struct regcache *regs);
445796c8dcSSimon Schubert 
455796c8dcSSimon Schubert /* Simple implementation of gdbarch_displaced_step_free_closure: Call
465796c8dcSSimon Schubert    xfree.
475796c8dcSSimon Schubert    This is appropriate for use with simple_displaced_step_copy_insn.  */
485796c8dcSSimon Schubert extern void
495796c8dcSSimon Schubert   simple_displaced_step_free_closure (struct gdbarch *gdbarch,
505796c8dcSSimon Schubert                                       struct displaced_step_closure *closure);
515796c8dcSSimon Schubert 
525796c8dcSSimon Schubert /* Default implementation of gdbarch_displaced_hw_singlestep.  */
535796c8dcSSimon Schubert extern int
545796c8dcSSimon Schubert   default_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
555796c8dcSSimon Schubert 					struct displaced_step_closure *closure);
565796c8dcSSimon Schubert 
575796c8dcSSimon Schubert /* Possible value for gdbarch_displaced_step_location:
585796c8dcSSimon Schubert    Place displaced instructions at the program's entry point,
595796c8dcSSimon Schubert    leaving space for inferior function call return breakpoints.  */
605796c8dcSSimon Schubert extern CORE_ADDR displaced_step_at_entry_point (struct gdbarch *gdbarch);
615796c8dcSSimon Schubert 
625796c8dcSSimon Schubert /* The only possible cases for inner_than. */
635796c8dcSSimon Schubert extern int core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs);
645796c8dcSSimon Schubert extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs);
655796c8dcSSimon Schubert 
665796c8dcSSimon Schubert /* Identity functions on a CORE_ADDR.  Just return the "addr".  */
675796c8dcSSimon Schubert 
685796c8dcSSimon Schubert extern CORE_ADDR core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr);
695796c8dcSSimon Schubert extern gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr_identity;
705796c8dcSSimon Schubert 
715796c8dcSSimon Schubert /* No-op conversion of reg to regnum. */
725796c8dcSSimon Schubert 
735796c8dcSSimon Schubert extern int no_op_reg_to_regnum (struct gdbarch *gdbarch, int reg);
745796c8dcSSimon Schubert 
755796c8dcSSimon Schubert /* Do nothing version of elf_make_msymbol_special. */
765796c8dcSSimon Schubert 
775796c8dcSSimon Schubert void default_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym);
785796c8dcSSimon Schubert 
795796c8dcSSimon Schubert /* Do nothing version of coff_make_msymbol_special. */
805796c8dcSSimon Schubert 
815796c8dcSSimon Schubert void default_coff_make_msymbol_special (int val, struct minimal_symbol *msym);
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert /* Version of cannot_fetch_register() / cannot_store_register() that
845796c8dcSSimon Schubert    always fails. */
855796c8dcSSimon Schubert 
865796c8dcSSimon Schubert int cannot_register_not (struct gdbarch *gdbarch, int regnum);
875796c8dcSSimon Schubert 
885796c8dcSSimon Schubert /* Legacy version of target_virtual_frame_pointer().  Assumes that
895796c8dcSSimon Schubert    there is an gdbarch_deprecated_fp_regnum and that it is the same, cooked or
905796c8dcSSimon Schubert    raw.  */
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert extern gdbarch_virtual_frame_pointer_ftype legacy_virtual_frame_pointer;
935796c8dcSSimon Schubert 
945796c8dcSSimon Schubert extern CORE_ADDR generic_skip_trampoline_code (struct frame_info *frame,
955796c8dcSSimon Schubert 					       CORE_ADDR pc);
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert extern CORE_ADDR generic_skip_solib_resolver (struct gdbarch *gdbarch,
985796c8dcSSimon Schubert 					      CORE_ADDR pc);
995796c8dcSSimon Schubert 
1005796c8dcSSimon Schubert extern int generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
1015796c8dcSSimon Schubert 					       CORE_ADDR pc, char *name);
1025796c8dcSSimon Schubert 
1035796c8dcSSimon Schubert extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc);
1045796c8dcSSimon Schubert 
1055796c8dcSSimon Schubert /* By default, registers are not convertible.  */
1065796c8dcSSimon Schubert extern int generic_convert_register_p (struct gdbarch *gdbarch, int regnum,
1075796c8dcSSimon Schubert 				       struct type *type);
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert extern int default_stabs_argument_has_addr (struct gdbarch *gdbarch,
1105796c8dcSSimon Schubert 					    struct type *type);
1115796c8dcSSimon Schubert 
1125796c8dcSSimon Schubert extern int generic_instruction_nullified (struct gdbarch *gdbarch,
1135796c8dcSSimon Schubert 					  struct regcache *regcache);
1145796c8dcSSimon Schubert 
1155796c8dcSSimon Schubert int default_remote_register_number (struct gdbarch *gdbarch,
1165796c8dcSSimon Schubert 				    int regno);
1175796c8dcSSimon Schubert 
1185796c8dcSSimon Schubert /* For compatibility with older architectures, returns
1195796c8dcSSimon Schubert    (LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
1205796c8dcSSimon Schubert    name.  */
1215796c8dcSSimon Schubert 
1225796c8dcSSimon Schubert extern int legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum);
1235796c8dcSSimon Schubert 
1245796c8dcSSimon Schubert /* Return the selected byte order, or BFD_ENDIAN_UNKNOWN if no byte
1255796c8dcSSimon Schubert    order was explicitly selected.  */
1265796c8dcSSimon Schubert extern enum bfd_endian selected_byte_order (void);
1275796c8dcSSimon Schubert 
1285796c8dcSSimon Schubert /* Return the selected architecture's name, or NULL if no architecture
1295796c8dcSSimon Schubert    was explicitly selected.  */
1305796c8dcSSimon Schubert extern const char *selected_architecture_name (void);
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert /* Initialize a ``struct info''.  Can't use memset(0) since some
1335796c8dcSSimon Schubert    default values are not zero.  "fill" takes all available
1345796c8dcSSimon Schubert    information and fills in any unspecified fields.  */
1355796c8dcSSimon Schubert 
1365796c8dcSSimon Schubert extern void gdbarch_info_init (struct gdbarch_info *info);
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert /* Similar to init, but this time fill in the blanks.  Information is
1395796c8dcSSimon Schubert    obtained from the global "set ..." options and explicitly
1405796c8dcSSimon Schubert    initialized INFO fields.  */
1415796c8dcSSimon Schubert extern void gdbarch_info_fill (struct gdbarch_info *info);
1425796c8dcSSimon Schubert 
1435796c8dcSSimon Schubert /* Return the architecture for ABFD.  If no suitable architecture
1445796c8dcSSimon Schubert    could be find, return NULL.  */
1455796c8dcSSimon Schubert 
1465796c8dcSSimon Schubert extern struct gdbarch *gdbarch_from_bfd (bfd *abfd);
1475796c8dcSSimon Schubert 
1485796c8dcSSimon Schubert /* Return "current" architecture.  If the target is running, this is the
1495796c8dcSSimon Schubert    architecture of the selected frame.  Otherwise, the "current" architecture
1505796c8dcSSimon Schubert    defaults to the target architecture.
1515796c8dcSSimon Schubert 
1525796c8dcSSimon Schubert    This function should normally be called solely by the command interpreter
1535796c8dcSSimon Schubert    routines to determine the architecture to execute a command in.  */
1545796c8dcSSimon Schubert extern struct gdbarch *get_current_arch (void);
1555796c8dcSSimon Schubert 
156*cf7f2e2dSJohn Marino extern int default_has_shared_address_space (struct gdbarch *);
157*cf7f2e2dSJohn Marino 
158*cf7f2e2dSJohn Marino extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
159*cf7f2e2dSJohn Marino 					     CORE_ADDR addr,
160*cf7f2e2dSJohn Marino 					     int *isize, char **msg);
161*cf7f2e2dSJohn Marino 
162*cf7f2e2dSJohn Marino extern void default_remote_breakpoint_from_pc (struct gdbarch *,
163*cf7f2e2dSJohn Marino 					       CORE_ADDR *pcptr, int *kindptr);
164*cf7f2e2dSJohn Marino 
165*cf7f2e2dSJohn Marino extern const char *default_auto_charset (void);
166*cf7f2e2dSJohn Marino extern const char *default_auto_wide_charset (void);
167*cf7f2e2dSJohn Marino 
1685796c8dcSSimon Schubert #endif
169