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