198944Sobrien#!/bin/sh -u 298944Sobrien 398944Sobrien# Architecture commands for GDB, the GNU debugger. 498944Sobrien# 5130803Smarcel# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 6130803Smarcel# Foundation, Inc. 7130803Smarcel# 8130803Smarcel# 998944Sobrien# This file is part of GDB. 1098944Sobrien# 1198944Sobrien# This program is free software; you can redistribute it and/or modify 1298944Sobrien# it under the terms of the GNU General Public License as published by 1398944Sobrien# the Free Software Foundation; either version 2 of the License, or 1498944Sobrien# (at your option) any later version. 1598944Sobrien# 1698944Sobrien# This program is distributed in the hope that it will be useful, 1798944Sobrien# but WITHOUT ANY WARRANTY; without even the implied warranty of 1898944Sobrien# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1998944Sobrien# GNU General Public License for more details. 2098944Sobrien# 2198944Sobrien# You should have received a copy of the GNU General Public License 2298944Sobrien# along with this program; if not, write to the Free Software 2398944Sobrien# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 2498944Sobrien 25130803Smarcel# Make certain that the script is running in an internationalized 26130803Smarcel# environment. 27130803SmarcelLANG=c ; export LANG 28130803SmarcelLC_ALL=c ; export LC_ALL 29130803Smarcel 30130803Smarcel 3198944Sobriencompare_new () 3298944Sobrien{ 3398944Sobrien file=$1 3498944Sobrien if test ! -r ${file} 3598944Sobrien then 3698944Sobrien echo "${file} missing? cp new-${file} ${file}" 1>&2 3798944Sobrien elif diff -u ${file} new-${file} 3898944Sobrien then 3998944Sobrien echo "${file} unchanged" 1>&2 4098944Sobrien else 4198944Sobrien echo "${file} has changed? cp new-${file} ${file}" 1>&2 4298944Sobrien fi 4398944Sobrien} 4498944Sobrien 4598944Sobrien 4698944Sobrien# Format of the input table 4798944Sobrienread="class level macro returntype function formal actual attrib staticdefault predefault postdefault invalid_p fmt print print_p description" 4898944Sobrien 4998944Sobriendo_read () 5098944Sobrien{ 5198944Sobrien comment="" 5298944Sobrien class="" 5398944Sobrien while read line 5498944Sobrien do 5598944Sobrien if test "${line}" = "" 5698944Sobrien then 5798944Sobrien continue 5898944Sobrien elif test "${line}" = "#" -a "${comment}" = "" 5998944Sobrien then 6098944Sobrien continue 6198944Sobrien elif expr "${line}" : "#" > /dev/null 6298944Sobrien then 6398944Sobrien comment="${comment} 6498944Sobrien${line}" 6598944Sobrien else 6698944Sobrien 6798944Sobrien # The semantics of IFS varies between different SH's. Some 6898944Sobrien # treat ``::' as three fields while some treat it as just too. 6998944Sobrien # Work around this by eliminating ``::'' .... 7098944Sobrien line="`echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g'`" 7198944Sobrien 7298944Sobrien OFS="${IFS}" ; IFS="[:]" 7398944Sobrien eval read ${read} <<EOF 7498944Sobrien${line} 7598944SobrienEOF 7698944Sobrien IFS="${OFS}" 7798944Sobrien 7898944Sobrien # .... and then going back through each field and strip out those 7998944Sobrien # that ended up with just that space character. 8098944Sobrien for r in ${read} 8198944Sobrien do 8298944Sobrien if eval test \"\${${r}}\" = \"\ \" 8398944Sobrien then 8498944Sobrien eval ${r}="" 8598944Sobrien fi 8698944Sobrien done 8798944Sobrien 8898944Sobrien case "${level}" in 8998944Sobrien 1 ) gt_level=">= GDB_MULTI_ARCH_PARTIAL" ;; 9098944Sobrien 2 ) gt_level="> GDB_MULTI_ARCH_PARTIAL" ;; 91130803Smarcel "" ) gt_level="> GDB_MULTI_ARCH_PARTIAL" ;; 9298944Sobrien * ) error "Error: bad level for ${function}" 1>&2 ; kill $$ ; exit 1 ;; 9398944Sobrien esac 9498944Sobrien 9598944Sobrien case "${class}" in 9698944Sobrien m ) staticdefault="${predefault}" ;; 9798944Sobrien M ) staticdefault="0" ;; 9898944Sobrien * ) test "${staticdefault}" || staticdefault=0 ;; 9998944Sobrien esac 10098944Sobrien 10198944Sobrien # come up with a format, use a few guesses for variables 10298944Sobrien case ":${class}:${fmt}:${print}:" in 10398944Sobrien :[vV]::: ) 10498944Sobrien if [ "${returntype}" = int ] 10598944Sobrien then 10698944Sobrien fmt="%d" 10798944Sobrien print="${macro}" 10898944Sobrien elif [ "${returntype}" = long ] 10998944Sobrien then 11098944Sobrien fmt="%ld" 11198944Sobrien print="${macro}" 11298944Sobrien fi 11398944Sobrien ;; 11498944Sobrien esac 11598944Sobrien test "${fmt}" || fmt="%ld" 11698944Sobrien test "${print}" || print="(long) ${macro}" 11798944Sobrien 118130803Smarcel case "${class}" in 119130803Smarcel F | V | M ) 120130803Smarcel case "${invalid_p}" in 12198944Sobrien "" ) 122130803Smarcel if test -n "${predefault}" 12398944Sobrien then 12498944Sobrien #invalid_p="gdbarch->${function} == ${predefault}" 125130803Smarcel predicate="gdbarch->${function} != ${predefault}" 126130803Smarcel elif class_is_variable_p 127130803Smarcel then 128130803Smarcel predicate="gdbarch->${function} != 0" 129130803Smarcel elif class_is_function_p 130130803Smarcel then 131130803Smarcel predicate="gdbarch->${function} != NULL" 13298944Sobrien fi 13398944Sobrien ;; 134130803Smarcel * ) 135130803Smarcel echo "Predicate function ${function} with invalid_p." 1>&2 136130803Smarcel kill $$ 137130803Smarcel exit 1 138130803Smarcel ;; 139130803Smarcel esac 14098944Sobrien esac 14198944Sobrien 14298944Sobrien # PREDEFAULT is a valid fallback definition of MEMBER when 14398944Sobrien # multi-arch is not enabled. This ensures that the 14498944Sobrien # default value, when multi-arch is the same as the 14598944Sobrien # default value when not multi-arch. POSTDEFAULT is 14698944Sobrien # always a valid definition of MEMBER as this again 14798944Sobrien # ensures consistency. 14898944Sobrien 14998944Sobrien if [ -n "${postdefault}" ] 15098944Sobrien then 15198944Sobrien fallbackdefault="${postdefault}" 15298944Sobrien elif [ -n "${predefault}" ] 15398944Sobrien then 15498944Sobrien fallbackdefault="${predefault}" 15598944Sobrien else 15698944Sobrien fallbackdefault="0" 15798944Sobrien fi 15898944Sobrien 15998944Sobrien #NOT YET: See gdbarch.log for basic verification of 16098944Sobrien # database 16198944Sobrien 16298944Sobrien break 16398944Sobrien fi 16498944Sobrien done 16598944Sobrien if [ -n "${class}" ] 16698944Sobrien then 16798944Sobrien true 16898944Sobrien else 16998944Sobrien false 17098944Sobrien fi 17198944Sobrien} 17298944Sobrien 17398944Sobrien 17498944Sobrienfallback_default_p () 17598944Sobrien{ 17698944Sobrien [ -n "${postdefault}" -a "x${invalid_p}" != "x0" ] \ 17798944Sobrien || [ -n "${predefault}" -a "x${invalid_p}" = "x0" ] 17898944Sobrien} 17998944Sobrien 18098944Sobrienclass_is_variable_p () 18198944Sobrien{ 18298944Sobrien case "${class}" in 18398944Sobrien *v* | *V* ) true ;; 18498944Sobrien * ) false ;; 18598944Sobrien esac 18698944Sobrien} 18798944Sobrien 18898944Sobrienclass_is_function_p () 18998944Sobrien{ 19098944Sobrien case "${class}" in 19198944Sobrien *f* | *F* | *m* | *M* ) true ;; 19298944Sobrien * ) false ;; 19398944Sobrien esac 19498944Sobrien} 19598944Sobrien 19698944Sobrienclass_is_multiarch_p () 19798944Sobrien{ 19898944Sobrien case "${class}" in 19998944Sobrien *m* | *M* ) true ;; 20098944Sobrien * ) false ;; 20198944Sobrien esac 20298944Sobrien} 20398944Sobrien 20498944Sobrienclass_is_predicate_p () 20598944Sobrien{ 20698944Sobrien case "${class}" in 20798944Sobrien *F* | *V* | *M* ) true ;; 20898944Sobrien * ) false ;; 20998944Sobrien esac 21098944Sobrien} 21198944Sobrien 21298944Sobrienclass_is_info_p () 21398944Sobrien{ 21498944Sobrien case "${class}" in 21598944Sobrien *i* ) true ;; 21698944Sobrien * ) false ;; 21798944Sobrien esac 21898944Sobrien} 21998944Sobrien 22098944Sobrien 22198944Sobrien# dump out/verify the doco 22298944Sobrienfor field in ${read} 22398944Sobriendo 22498944Sobrien case ${field} in 22598944Sobrien 22698944Sobrien class ) : ;; 22798944Sobrien 22898944Sobrien # # -> line disable 22998944Sobrien # f -> function 23098944Sobrien # hiding a function 23198944Sobrien # F -> function + predicate 23298944Sobrien # hiding a function + predicate to test function validity 23398944Sobrien # v -> variable 23498944Sobrien # hiding a variable 23598944Sobrien # V -> variable + predicate 23698944Sobrien # hiding a variable + predicate to test variables validity 23798944Sobrien # i -> set from info 23898944Sobrien # hiding something from the ``struct info'' object 23998944Sobrien # m -> multi-arch function 24098944Sobrien # hiding a multi-arch function (parameterised with the architecture) 24198944Sobrien # M -> multi-arch function + predicate 24298944Sobrien # hiding a multi-arch function + predicate to test function validity 24398944Sobrien 24498944Sobrien level ) : ;; 24598944Sobrien 24698944Sobrien # See GDB_MULTI_ARCH description. Having GDB_MULTI_ARCH >= 24798944Sobrien # LEVEL is a predicate on checking that a given method is 24898944Sobrien # initialized (using INVALID_P). 24998944Sobrien 25098944Sobrien macro ) : ;; 25198944Sobrien 25298944Sobrien # The name of the MACRO that this method is to be accessed by. 25398944Sobrien 25498944Sobrien returntype ) : ;; 25598944Sobrien 25698944Sobrien # For functions, the return type; for variables, the data type 25798944Sobrien 25898944Sobrien function ) : ;; 25998944Sobrien 26098944Sobrien # For functions, the member function name; for variables, the 26198944Sobrien # variable name. Member function names are always prefixed with 26298944Sobrien # ``gdbarch_'' for name-space purity. 26398944Sobrien 26498944Sobrien formal ) : ;; 26598944Sobrien 26698944Sobrien # The formal argument list. It is assumed that the formal 26798944Sobrien # argument list includes the actual name of each list element. 26898944Sobrien # A function with no arguments shall have ``void'' as the 26998944Sobrien # formal argument list. 27098944Sobrien 27198944Sobrien actual ) : ;; 27298944Sobrien 27398944Sobrien # The list of actual arguments. The arguments specified shall 27498944Sobrien # match the FORMAL list given above. Functions with out 27598944Sobrien # arguments leave this blank. 27698944Sobrien 27798944Sobrien attrib ) : ;; 27898944Sobrien 27998944Sobrien # Any GCC attributes that should be attached to the function 28098944Sobrien # declaration. At present this field is unused. 28198944Sobrien 28298944Sobrien staticdefault ) : ;; 28398944Sobrien 28498944Sobrien # To help with the GDB startup a static gdbarch object is 28598944Sobrien # created. STATICDEFAULT is the value to insert into that 28698944Sobrien # static gdbarch object. Since this a static object only 28798944Sobrien # simple expressions can be used. 28898944Sobrien 28998944Sobrien # If STATICDEFAULT is empty, zero is used. 29098944Sobrien 29198944Sobrien predefault ) : ;; 29298944Sobrien 29398944Sobrien # An initial value to assign to MEMBER of the freshly 29498944Sobrien # malloc()ed gdbarch object. After initialization, the 29598944Sobrien # freshly malloc()ed object is passed to the target 29698944Sobrien # architecture code for further updates. 29798944Sobrien 29898944Sobrien # If PREDEFAULT is empty, zero is used. 29998944Sobrien 30098944Sobrien # A non-empty PREDEFAULT, an empty POSTDEFAULT and a zero 30198944Sobrien # INVALID_P are specified, PREDEFAULT will be used as the 30298944Sobrien # default for the non- multi-arch target. 30398944Sobrien 30498944Sobrien # A zero PREDEFAULT function will force the fallback to call 30598944Sobrien # internal_error(). 30698944Sobrien 30798944Sobrien # Variable declarations can refer to ``gdbarch'' which will 30898944Sobrien # contain the current architecture. Care should be taken. 30998944Sobrien 31098944Sobrien postdefault ) : ;; 31198944Sobrien 31298944Sobrien # A value to assign to MEMBER of the new gdbarch object should 31398944Sobrien # the target architecture code fail to change the PREDEFAULT 31498944Sobrien # value. 31598944Sobrien 31698944Sobrien # If POSTDEFAULT is empty, no post update is performed. 31798944Sobrien 31898944Sobrien # If both INVALID_P and POSTDEFAULT are non-empty then 31998944Sobrien # INVALID_P will be used to determine if MEMBER should be 32098944Sobrien # changed to POSTDEFAULT. 32198944Sobrien 32298944Sobrien # If a non-empty POSTDEFAULT and a zero INVALID_P are 32398944Sobrien # specified, POSTDEFAULT will be used as the default for the 32498944Sobrien # non- multi-arch target (regardless of the value of 32598944Sobrien # PREDEFAULT). 32698944Sobrien 32798944Sobrien # You cannot specify both a zero INVALID_P and a POSTDEFAULT. 32898944Sobrien 329130803Smarcel # Variable declarations can refer to ``current_gdbarch'' which 330130803Smarcel # will contain the current architecture. Care should be 331130803Smarcel # taken. 33298944Sobrien 33398944Sobrien invalid_p ) : ;; 33498944Sobrien 33598944Sobrien # A predicate equation that validates MEMBER. Non-zero is 33698944Sobrien # returned if the code creating the new architecture failed to 33798944Sobrien # initialize MEMBER or the initialized the member is invalid. 33898944Sobrien # If POSTDEFAULT is non-empty then MEMBER will be updated to 33998944Sobrien # that value. If POSTDEFAULT is empty then internal_error() 34098944Sobrien # is called. 34198944Sobrien 34298944Sobrien # If INVALID_P is empty, a check that MEMBER is no longer 34398944Sobrien # equal to PREDEFAULT is used. 34498944Sobrien 34598944Sobrien # The expression ``0'' disables the INVALID_P check making 34698944Sobrien # PREDEFAULT a legitimate value. 34798944Sobrien 34898944Sobrien # See also PREDEFAULT and POSTDEFAULT. 34998944Sobrien 35098944Sobrien fmt ) : ;; 35198944Sobrien 35298944Sobrien # printf style format string that can be used to print out the 35398944Sobrien # MEMBER. Sometimes "%s" is useful. For functions, this is 35498944Sobrien # ignored and the function address is printed. 35598944Sobrien 35698944Sobrien # If FMT is empty, ``%ld'' is used. 35798944Sobrien 35898944Sobrien print ) : ;; 35998944Sobrien 36098944Sobrien # An optional equation that casts MEMBER to a value suitable 36198944Sobrien # for formatting by FMT. 36298944Sobrien 36398944Sobrien # If PRINT is empty, ``(long)'' is used. 36498944Sobrien 36598944Sobrien print_p ) : ;; 36698944Sobrien 36798944Sobrien # An optional indicator for any predicte to wrap around the 36898944Sobrien # print member code. 36998944Sobrien 37098944Sobrien # () -> Call a custom function to do the dump. 37198944Sobrien # exp -> Wrap print up in ``if (${print_p}) ... 37298944Sobrien # ``'' -> No predicate 37398944Sobrien 37498944Sobrien # If PRINT_P is empty, ``1'' is always used. 37598944Sobrien 37698944Sobrien description ) : ;; 37798944Sobrien 37898944Sobrien # Currently unused. 37998944Sobrien 38098944Sobrien *) 38198944Sobrien echo "Bad field ${field}" 38298944Sobrien exit 1;; 38398944Sobrien esac 38498944Sobriendone 38598944Sobrien 38698944Sobrien 38798944Sobrienfunction_list () 38898944Sobrien{ 38998944Sobrien # See below (DOCO) for description of each field 39098944Sobrien cat <<EOF 39198944Sobrieni:2:TARGET_ARCHITECTURE:const struct bfd_arch_info *:bfd_arch_info::::&bfd_default_arch_struct::::%s:TARGET_ARCHITECTURE->printable_name:TARGET_ARCHITECTURE != NULL 39298944Sobrien# 39398944Sobrieni:2:TARGET_BYTE_ORDER:int:byte_order::::BFD_ENDIAN_BIG 394130803Smarcel# 395130803Smarceli:2:TARGET_OSABI:enum gdb_osabi:osabi::::GDB_OSABI_UNKNOWN 39698944Sobrien# Number of bits in a char or unsigned char for the target machine. 39798944Sobrien# Just like CHAR_BIT in <limits.h> but describes the target machine. 398130803Smarcel# v:2:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0: 39998944Sobrien# 40098944Sobrien# Number of bits in a short or unsigned short for the target machine. 401130803Smarcelv:2:TARGET_SHORT_BIT:int:short_bit::::8 * sizeof (short):2*TARGET_CHAR_BIT::0 40298944Sobrien# Number of bits in an int or unsigned int for the target machine. 403130803Smarcelv:2:TARGET_INT_BIT:int:int_bit::::8 * sizeof (int):4*TARGET_CHAR_BIT::0 40498944Sobrien# Number of bits in a long or unsigned long for the target machine. 405130803Smarcelv:2:TARGET_LONG_BIT:int:long_bit::::8 * sizeof (long):4*TARGET_CHAR_BIT::0 40698944Sobrien# Number of bits in a long long or unsigned long long for the target 40798944Sobrien# machine. 408130803Smarcelv:2:TARGET_LONG_LONG_BIT:int:long_long_bit::::8 * sizeof (LONGEST):2*TARGET_LONG_BIT::0 40998944Sobrien# Number of bits in a float for the target machine. 410130803Smarcelv:2:TARGET_FLOAT_BIT:int:float_bit::::8 * sizeof (float):4*TARGET_CHAR_BIT::0 41198944Sobrien# Number of bits in a double for the target machine. 412130803Smarcelv:2:TARGET_DOUBLE_BIT:int:double_bit::::8 * sizeof (double):8*TARGET_CHAR_BIT::0 41398944Sobrien# Number of bits in a long double for the target machine. 414130803Smarcelv:2:TARGET_LONG_DOUBLE_BIT:int:long_double_bit::::8 * sizeof (long double):8*TARGET_CHAR_BIT::0 41598944Sobrien# For most targets, a pointer on the target and its representation as an 41698944Sobrien# address in GDB have the same size and "look the same". For such a 41798944Sobrien# target, you need only set TARGET_PTR_BIT / ptr_bit and TARGET_ADDR_BIT 41898944Sobrien# / addr_bit will be set from it. 41998944Sobrien# 42098944Sobrien# If TARGET_PTR_BIT and TARGET_ADDR_BIT are different, you'll probably 42198944Sobrien# also need to set POINTER_TO_ADDRESS and ADDRESS_TO_POINTER as well. 42298944Sobrien# 42398944Sobrien# ptr_bit is the size of a pointer on the target 424130803Smarcelv:2:TARGET_PTR_BIT:int:ptr_bit::::8 * sizeof (void*):TARGET_INT_BIT::0 42598944Sobrien# addr_bit is the size of a target address as represented in gdb 426130803Smarcelv:2:TARGET_ADDR_BIT:int:addr_bit::::8 * sizeof (void*):0:TARGET_PTR_BIT: 42798944Sobrien# Number of bits in a BFD_VMA for the target object file format. 428130803Smarcelv:2:TARGET_BFD_VMA_BIT:int:bfd_vma_bit::::8 * sizeof (void*):TARGET_ARCHITECTURE->bits_per_address::0 42998944Sobrien# 43098944Sobrien# One if \`char' acts like \`signed char', zero if \`unsigned char'. 431130803Smarcelv:2:TARGET_CHAR_SIGNED:int:char_signed::::1:-1:1:::: 43298944Sobrien# 433130803SmarcelF:2:TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid 434130803Smarcelf:2:TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0 435130803Smarcel# UNWIND_SP is a direct replacement for TARGET_READ_SP. 436130803SmarcelF:2:TARGET_READ_SP:CORE_ADDR:read_sp:void 43798944Sobrien# Function for getting target's idea of a frame pointer. FIXME: GDB's 43898944Sobrien# whole scheme for dealing with "frames" and "frame pointers" needs a 43998944Sobrien# serious shakedown. 440130803Smarcelf:2:TARGET_VIRTUAL_FRAME_POINTER:void:virtual_frame_pointer:CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset:pc, frame_regnum, frame_offset::0:legacy_virtual_frame_pointer::0 44198944Sobrien# 442130803SmarcelM:::void:pseudo_register_read:struct regcache *regcache, int cookednum, void *buf:regcache, cookednum, buf 443130803SmarcelM:::void:pseudo_register_write:struct regcache *regcache, int cookednum, const void *buf:regcache, cookednum, buf 44498944Sobrien# 44598944Sobrienv:2:NUM_REGS:int:num_regs::::0:-1 44698944Sobrien# This macro gives the number of pseudo-registers that live in the 44798944Sobrien# register namespace but do not get fetched or stored on the target. 44898944Sobrien# These pseudo-registers may be aliases for other registers, 44998944Sobrien# combinations of other registers, or they may be computed by GDB. 45098944Sobrienv:2:NUM_PSEUDO_REGS:int:num_pseudo_regs::::0:0::0::: 451130803Smarcel 452130803Smarcel# GDB's standard (or well known) register numbers. These can map onto 453130803Smarcel# a real register or a pseudo (computed) register or not be defined at 454130803Smarcel# all (-1). 455130803Smarcel# SP_REGNUM will hopefully be replaced by UNWIND_SP. 456130803Smarcelv:2:SP_REGNUM:int:sp_regnum::::-1:-1::0 457130803Smarcelv:2:PC_REGNUM:int:pc_regnum::::-1:-1::0 458130803Smarcelv:2:PS_REGNUM:int:ps_regnum::::-1:-1::0 45998944Sobrienv:2:FP0_REGNUM:int:fp0_regnum::::0:-1::0 46098944Sobrien# Convert stab register number (from \`r\' declaration) to a gdb REGNUM. 46198944Sobrienf:2:STAB_REG_TO_REGNUM:int:stab_reg_to_regnum:int stab_regnr:stab_regnr:::no_op_reg_to_regnum::0 46298944Sobrien# Provide a default mapping from a ecoff register number to a gdb REGNUM. 46398944Sobrienf:2:ECOFF_REG_TO_REGNUM:int:ecoff_reg_to_regnum:int ecoff_regnr:ecoff_regnr:::no_op_reg_to_regnum::0 46498944Sobrien# Provide a default mapping from a DWARF register number to a gdb REGNUM. 46598944Sobrienf:2:DWARF_REG_TO_REGNUM:int:dwarf_reg_to_regnum:int dwarf_regnr:dwarf_regnr:::no_op_reg_to_regnum::0 46698944Sobrien# Convert from an sdb register number to an internal gdb register number. 46798944Sobrienf:2:SDB_REG_TO_REGNUM:int:sdb_reg_to_regnum:int sdb_regnr:sdb_regnr:::no_op_reg_to_regnum::0 46898944Sobrienf:2:DWARF2_REG_TO_REGNUM:int:dwarf2_reg_to_regnum:int dwarf2_regnr:dwarf2_regnr:::no_op_reg_to_regnum::0 469130803Smarcelf::REGISTER_NAME:const char *:register_name:int regnr:regnr 470130803Smarcel 471130803Smarcel# REGISTER_TYPE is a direct replacement for DEPRECATED_REGISTER_VIRTUAL_TYPE. 472130803SmarcelM:2:REGISTER_TYPE:struct type *:register_type:int reg_nr:reg_nr 473130803Smarcel# REGISTER_TYPE is a direct replacement for DEPRECATED_REGISTER_VIRTUAL_TYPE. 474130803SmarcelF:2:DEPRECATED_REGISTER_VIRTUAL_TYPE:struct type *:deprecated_register_virtual_type:int reg_nr:reg_nr 475130803Smarcel# DEPRECATED_REGISTER_BYTES can be deleted. The value is computed 476130803Smarcel# from REGISTER_TYPE. 477130803Smarcelv::DEPRECATED_REGISTER_BYTES:int:deprecated_register_bytes 478130803Smarcel# If the value returned by DEPRECATED_REGISTER_BYTE agrees with the 479130803Smarcel# register offsets computed using just REGISTER_TYPE, this can be 480130803Smarcel# deleted. See: maint print registers. NOTE: cagney/2002-05-02: This 481130803Smarcel# function with predicate has a valid (callable) initial value. As a 482130803Smarcel# consequence, even when the predicate is false, the corresponding 483130803Smarcel# function works. This simplifies the migration process - old code, 484130803Smarcel# calling DEPRECATED_REGISTER_BYTE, doesn't need to be modified. 485130803SmarcelF::DEPRECATED_REGISTER_BYTE:int:deprecated_register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte 486130803Smarcel# If all registers have identical raw and virtual sizes and those 487130803Smarcel# sizes agree with the value computed from REGISTER_TYPE, 488130803Smarcel# DEPRECATED_REGISTER_RAW_SIZE can be deleted. See: maint print 489130803Smarcel# registers. 490130803SmarcelF:2:DEPRECATED_REGISTER_RAW_SIZE:int:deprecated_register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size 491130803Smarcel# If all registers have identical raw and virtual sizes and those 492130803Smarcel# sizes agree with the value computed from REGISTER_TYPE, 493130803Smarcel# DEPRECATED_REGISTER_VIRTUAL_SIZE can be deleted. See: maint print 494130803Smarcel# registers. 495130803SmarcelF:2:DEPRECATED_REGISTER_VIRTUAL_SIZE:int:deprecated_register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size 496130803Smarcel# DEPRECATED_MAX_REGISTER_RAW_SIZE can be deleted. It has been 497130803Smarcel# replaced by the constant MAX_REGISTER_SIZE. 498130803SmarcelV:2:DEPRECATED_MAX_REGISTER_RAW_SIZE:int:deprecated_max_register_raw_size 499130803Smarcel# DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE can be deleted. It has been 500130803Smarcel# replaced by the constant MAX_REGISTER_SIZE. 501130803SmarcelV:2:DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE:int:deprecated_max_register_virtual_size 502130803Smarcel 503130803Smarcel# See gdbint.texinfo, and PUSH_DUMMY_CALL. 504130803SmarcelM::UNWIND_DUMMY_ID:struct frame_id:unwind_dummy_id:struct frame_info *info:info 505130803Smarcel# Implement UNWIND_DUMMY_ID and PUSH_DUMMY_CALL, then delete 506130803Smarcel# SAVE_DUMMY_FRAME_TOS. 507130803SmarcelF:2:DEPRECATED_SAVE_DUMMY_FRAME_TOS:void:deprecated_save_dummy_frame_tos:CORE_ADDR sp:sp 508130803Smarcel# Implement UNWIND_DUMMY_ID and PUSH_DUMMY_CALL, then delete 509130803Smarcel# DEPRECATED_FP_REGNUM. 510130803Smarcelv:2:DEPRECATED_FP_REGNUM:int:deprecated_fp_regnum::::-1:-1::0 511130803Smarcel# Implement UNWIND_DUMMY_ID and PUSH_DUMMY_CALL, then delete 512130803Smarcel# DEPRECATED_TARGET_READ_FP. 513130803SmarcelF::DEPRECATED_TARGET_READ_FP:CORE_ADDR:deprecated_target_read_fp:void 514130803Smarcel 515130803Smarcel# See gdbint.texinfo. See infcall.c. New, all singing all dancing, 516130803Smarcel# replacement for DEPRECATED_PUSH_ARGUMENTS. 517130803SmarcelM::PUSH_DUMMY_CALL:CORE_ADDR:push_dummy_call:CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:func_addr, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr 518130803Smarcel# PUSH_DUMMY_CALL is a direct replacement for DEPRECATED_PUSH_ARGUMENTS. 519130803SmarcelF:2:DEPRECATED_PUSH_ARGUMENTS:CORE_ADDR:deprecated_push_arguments:int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:nargs, args, sp, struct_return, struct_addr 520130803Smarcel# DEPRECATED_USE_GENERIC_DUMMY_FRAMES can be deleted. Always true. 521130803Smarcelv::DEPRECATED_USE_GENERIC_DUMMY_FRAMES:int:deprecated_use_generic_dummy_frames:::::1::0 522130803Smarcel# Implement PUSH_RETURN_ADDRESS, and then merge in 523130803Smarcel# DEPRECATED_PUSH_RETURN_ADDRESS. 524130803SmarcelF:2:DEPRECATED_PUSH_RETURN_ADDRESS:CORE_ADDR:deprecated_push_return_address:CORE_ADDR pc, CORE_ADDR sp:pc, sp 525130803Smarcel# Implement PUSH_DUMMY_CALL, then merge in DEPRECATED_DUMMY_WRITE_SP. 526130803SmarcelF:2:DEPRECATED_DUMMY_WRITE_SP:void:deprecated_dummy_write_sp:CORE_ADDR val:val 527130803Smarcel# DEPRECATED_REGISTER_SIZE can be deleted. 528130803Smarcelv::DEPRECATED_REGISTER_SIZE:int:deprecated_register_size 529130803Smarcelv::CALL_DUMMY_LOCATION:int:call_dummy_location:::::AT_ENTRY_POINT::0 530130803Smarcel# DEPRECATED_CALL_DUMMY_START_OFFSET can be deleted. 531130803Smarcelv::DEPRECATED_CALL_DUMMY_START_OFFSET:CORE_ADDR:deprecated_call_dummy_start_offset 532130803Smarcel# DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET can be deleted. 533130803Smarcelv::DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET:CORE_ADDR:deprecated_call_dummy_breakpoint_offset 534130803Smarcel# DEPRECATED_CALL_DUMMY_LENGTH can be deleted. 535130803Smarcelv::DEPRECATED_CALL_DUMMY_LENGTH:int:deprecated_call_dummy_length 536130803Smarcel# DEPRECATED_CALL_DUMMY_WORDS can be deleted. 537130803Smarcelv::DEPRECATED_CALL_DUMMY_WORDS:LONGEST *:deprecated_call_dummy_words::::0:legacy_call_dummy_words::0:0x%08lx 538130803Smarcel# Implement PUSH_DUMMY_CALL, then delete DEPRECATED_SIZEOF_CALL_DUMMY_WORDS. 539130803Smarcelv::DEPRECATED_SIZEOF_CALL_DUMMY_WORDS:int:deprecated_sizeof_call_dummy_words::::0:legacy_sizeof_call_dummy_words::0 540130803Smarcel# DEPRECATED_FIX_CALL_DUMMY can be deleted. For the SPARC, implement 541130803Smarcel# PUSH_DUMMY_CODE and set CALL_DUMMY_LOCATION to ON_STACK. 542130803SmarcelF::DEPRECATED_FIX_CALL_DUMMY:void:deprecated_fix_call_dummy:char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, struct value **args, struct type *type, int gcc_p:dummy, pc, fun, nargs, args, type, gcc_p 543130803Smarcel# This is a replacement for DEPRECATED_FIX_CALL_DUMMY et.al. 544130803SmarcelM::PUSH_DUMMY_CODE:CORE_ADDR:push_dummy_code:CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr:sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr 545130803Smarcel# Implement PUSH_DUMMY_CALL, then delete DEPRECATED_PUSH_DUMMY_FRAME. 546130803SmarcelF:2:DEPRECATED_PUSH_DUMMY_FRAME:void:deprecated_push_dummy_frame:void:- 547130803Smarcel 548130803SmarcelF:2:DEPRECATED_DO_REGISTERS_INFO:void:deprecated_do_registers_info:int reg_nr, int fpregs:reg_nr, fpregs 549130803Smarcelm:2:PRINT_REGISTERS_INFO:void:print_registers_info:struct ui_file *file, struct frame_info *frame, int regnum, int all:file, frame, regnum, all:::default_print_registers_info::0 550130803SmarcelM:2:PRINT_FLOAT_INFO:void:print_float_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args 551130803SmarcelM:2:PRINT_VECTOR_INFO:void:print_vector_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args 55298944Sobrien# MAP a GDB RAW register number onto a simulator register number. See 55398944Sobrien# also include/...-sim.h. 554130803Smarcelf:2:REGISTER_SIM_REGNO:int:register_sim_regno:int reg_nr:reg_nr:::legacy_register_sim_regno::0 555130803SmarcelF:2:REGISTER_BYTES_OK:int:register_bytes_ok:long nr_bytes:nr_bytes 55698944Sobrienf:2:CANNOT_FETCH_REGISTER:int:cannot_fetch_register:int regnum:regnum:::cannot_register_not::0 55798944Sobrienf:2:CANNOT_STORE_REGISTER:int:cannot_store_register:int regnum:regnum:::cannot_register_not::0 55898944Sobrien# setjmp/longjmp support. 559130803SmarcelF:2:GET_LONGJMP_TARGET:int:get_longjmp_target:CORE_ADDR *pc:pc 560130803Smarcel# NOTE: cagney/2002-11-24: This function with predicate has a valid 561130803Smarcel# (callable) initial value. As a consequence, even when the predicate 562130803Smarcel# is false, the corresponding function works. This simplifies the 563130803Smarcel# migration process - old code, calling DEPRECATED_PC_IN_CALL_DUMMY(), 564130803Smarcel# doesn't need to be modified. 565130803SmarcelF::DEPRECATED_PC_IN_CALL_DUMMY:int:deprecated_pc_in_call_dummy:CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address:pc, sp, frame_address::generic_pc_in_call_dummy:generic_pc_in_call_dummy 566130803SmarcelF:2:DEPRECATED_INIT_FRAME_PC_FIRST:CORE_ADDR:deprecated_init_frame_pc_first:int fromleaf, struct frame_info *prev:fromleaf, prev 567130803SmarcelF:2:DEPRECATED_INIT_FRAME_PC:CORE_ADDR:deprecated_init_frame_pc:int fromleaf, struct frame_info *prev:fromleaf, prev 56898944Sobrien# 56998944Sobrienv:2:BELIEVE_PCC_PROMOTION:int:believe_pcc_promotion::::::: 570130803Smarcelv::BELIEVE_PCC_PROMOTION_TYPE:int:believe_pcc_promotion_type::::::: 571130803SmarcelF:2:DEPRECATED_GET_SAVED_REGISTER:void:deprecated_get_saved_register:char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval:raw_buffer, optimized, addrp, frame, regnum, lval 57298944Sobrien# 573130803Smarcel# For register <-> value conversions, replaced by CONVERT_REGISTER_P et.al. 574130803Smarcel# For raw <-> cooked register conversions, replaced by pseudo registers. 575130803SmarcelF::DEPRECATED_REGISTER_CONVERTIBLE:int:deprecated_register_convertible:int nr:nr 576130803Smarcel# For register <-> value conversions, replaced by CONVERT_REGISTER_P et.al. 577130803Smarcel# For raw <-> cooked register conversions, replaced by pseudo registers. 578130803Smarcelf:2:DEPRECATED_REGISTER_CONVERT_TO_VIRTUAL:void:deprecated_register_convert_to_virtual:int regnum, struct type *type, char *from, char *to:regnum, type, from, to:::0::0 579130803Smarcel# For register <-> value conversions, replaced by CONVERT_REGISTER_P et.al. 580130803Smarcel# For raw <-> cooked register conversions, replaced by pseudo registers. 581130803Smarcelf:2:DEPRECATED_REGISTER_CONVERT_TO_RAW:void:deprecated_register_convert_to_raw:struct type *type, int regnum, const char *from, char *to:type, regnum, from, to:::0::0 58298944Sobrien# 583130803Smarcelf:1:CONVERT_REGISTER_P:int:convert_register_p:int regnum, struct type *type:regnum, type::0:legacy_convert_register_p::0 584130803Smarcelf:1:REGISTER_TO_VALUE:void:register_to_value:struct frame_info *frame, int regnum, struct type *type, void *buf:frame, regnum, type, buf::0:legacy_register_to_value::0 585130803Smarcelf:1:VALUE_TO_REGISTER:void:value_to_register:struct frame_info *frame, int regnum, struct type *type, const void *buf:frame, regnum, type, buf::0:legacy_value_to_register::0 586130803Smarcel# 587130803Smarcelf:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, const void *buf:type, buf:::unsigned_pointer_to_address::0 58898944Sobrienf:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, void *buf, CORE_ADDR addr:type, buf, addr:::unsigned_address_to_pointer::0 58998944SobrienF:2:INTEGER_TO_ADDRESS:CORE_ADDR:integer_to_address:struct type *type, void *buf:type, buf 59098944Sobrien# 591130803SmarcelF:2:DEPRECATED_POP_FRAME:void:deprecated_pop_frame:void:- 592130803Smarcel# NOTE: cagney/2003-03-24: Replaced by PUSH_ARGUMENTS. 593130803SmarcelF:2:DEPRECATED_STORE_STRUCT_RETURN:void:deprecated_store_struct_return:CORE_ADDR addr, CORE_ADDR sp:addr, sp 594130803Smarcel 595130803Smarcel# It has been suggested that this, well actually its predecessor, 596130803Smarcel# should take the type/value of the function to be called and not the 597130803Smarcel# return type. This is left as an exercise for the reader. 598130803Smarcel 599130803SmarcelM:::enum return_value_convention:return_value:struct type *valtype, struct regcache *regcache, void *readbuf, const void *writebuf:valtype, regcache, readbuf, writebuf 600130803Smarcel 601130803Smarcel# The deprecated methods RETURN_VALUE_ON_STACK, EXTRACT_RETURN_VALUE, 602130803Smarcel# STORE_RETURN_VALUE and USE_STRUCT_CONVENTION have all been folded 603130803Smarcel# into RETURN_VALUE. 604130803Smarcel 60598944Sobrienf:2:RETURN_VALUE_ON_STACK:int:return_value_on_stack:struct type *type:type:::generic_return_value_on_stack_not::0 606130803Smarcelf:2:EXTRACT_RETURN_VALUE:void:extract_return_value:struct type *type, struct regcache *regcache, void *valbuf:type, regcache, valbuf:::legacy_extract_return_value::0 607130803Smarcelf:2:STORE_RETURN_VALUE:void:store_return_value:struct type *type, struct regcache *regcache, const void *valbuf:type, regcache, valbuf:::legacy_store_return_value::0 608130803Smarcelf:2:DEPRECATED_EXTRACT_RETURN_VALUE:void:deprecated_extract_return_value:struct type *type, char *regbuf, char *valbuf:type, regbuf, valbuf 609130803Smarcelf:2:DEPRECATED_STORE_RETURN_VALUE:void:deprecated_store_return_value:struct type *type, char *valbuf:type, valbuf 61098944Sobrienf:2:USE_STRUCT_CONVENTION:int:use_struct_convention:int gcc_p, struct type *value_type:gcc_p, value_type:::generic_use_struct_convention::0 611130803Smarcel 612130803Smarcel# As of 2004-01-17 only the 32-bit SPARC ABI has been identified as an 613130803Smarcel# ABI suitable for the implementation of a robust extract 614130803Smarcel# struct-convention return-value address method (the sparc saves the 615130803Smarcel# address in the callers frame). All the other cases so far examined, 616130803Smarcel# the DEPRECATED_EXTRACT_STRUCT_VALUE implementation has been 617130803Smarcel# erreneous - the code was incorrectly assuming that the return-value 618130803Smarcel# address, stored in a register, was preserved across the entire 619130803Smarcel# function call. 620130803Smarcel 621130803Smarcel# For the moment retain DEPRECATED_EXTRACT_STRUCT_VALUE as a marker of 622130803Smarcel# the ABIs that are still to be analyzed - perhaps this should simply 623130803Smarcel# be deleted. The commented out extract_returned_value_address method 624130803Smarcel# is provided as a starting point for the 32-bit SPARC. It, or 625130803Smarcel# something like it, along with changes to both infcmd.c and stack.c 626130803Smarcel# will be needed for that case to work. NB: It is passed the callers 627130803Smarcel# frame since it is only after the callee has returned that this 628130803Smarcel# function is used. 629130803Smarcel 630130803Smarcel#M:::CORE_ADDR:extract_returned_value_address:struct frame_info *caller_frame:caller_frame 631130803SmarcelF:2:DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS:CORE_ADDR:deprecated_extract_struct_value_address:struct regcache *regcache:regcache 632130803Smarcel 633130803SmarcelF:2:DEPRECATED_FRAME_INIT_SAVED_REGS:void:deprecated_frame_init_saved_regs:struct frame_info *frame:frame 634130803SmarcelF:2:DEPRECATED_INIT_EXTRA_FRAME_INFO:void:deprecated_init_extra_frame_info:int fromleaf, struct frame_info *frame:fromleaf, frame 63598944Sobrien# 63698944Sobrienf:2:SKIP_PROLOGUE:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip::0:0 63798944Sobrienf:2:INNER_THAN:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs::0:0 638130803Smarcelf::BREAKPOINT_FROM_PC:const unsigned char *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr:::0: 639130803SmarcelM:2:ADJUST_BREAKPOINT_ADDRESS:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr 64098944Sobrienf:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0 64198944Sobrienf:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0 642130803Smarcelv:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:::0 643130803Smarcelv:2:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:::0 64498944Sobrien# 645130803Smarcelm::REMOTE_TRANSLATE_XFER_ADDRESS:void:remote_translate_xfer_address:struct regcache *regcache, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len:regcache, gdb_addr, gdb_len, rem_addr, rem_len:::generic_remote_translate_xfer_address::0 64698944Sobrien# 647130803Smarcelv::FRAME_ARGS_SKIP:CORE_ADDR:frame_args_skip::::0:::0 648130803Smarcel# DEPRECATED_FRAMELESS_FUNCTION_INVOCATION is not needed. The new 649130803Smarcel# frame code works regardless of the type of frame - frameless, 650130803Smarcel# stackless, or normal. 651130803SmarcelF::DEPRECATED_FRAMELESS_FUNCTION_INVOCATION:int:deprecated_frameless_function_invocation:struct frame_info *fi:fi 652130803SmarcelF:2:DEPRECATED_FRAME_CHAIN:CORE_ADDR:deprecated_frame_chain:struct frame_info *frame:frame 653130803SmarcelF:2:DEPRECATED_FRAME_CHAIN_VALID:int:deprecated_frame_chain_valid:CORE_ADDR chain, struct frame_info *thisframe:chain, thisframe 654130803Smarcel# DEPRECATED_FRAME_SAVED_PC has been replaced by UNWIND_PC. Please 655130803Smarcel# note, per UNWIND_PC's doco, that while the two have similar 656130803Smarcel# interfaces they have very different underlying implementations. 657130803SmarcelF:2:DEPRECATED_FRAME_SAVED_PC:CORE_ADDR:deprecated_frame_saved_pc:struct frame_info *fi:fi 658130803SmarcelM::UNWIND_PC:CORE_ADDR:unwind_pc:struct frame_info *next_frame:next_frame 659130803SmarcelM::UNWIND_SP:CORE_ADDR:unwind_sp:struct frame_info *next_frame:next_frame 660130803Smarcel# DEPRECATED_FRAME_ARGS_ADDRESS as been replaced by the per-frame 661130803Smarcel# frame-base. Enable frame-base before frame-unwind. 662130803SmarcelF::DEPRECATED_FRAME_ARGS_ADDRESS:CORE_ADDR:deprecated_frame_args_address:struct frame_info *fi:fi::get_frame_base:get_frame_base 663130803Smarcel# DEPRECATED_FRAME_LOCALS_ADDRESS as been replaced by the per-frame 664130803Smarcel# frame-base. Enable frame-base before frame-unwind. 665130803SmarcelF::DEPRECATED_FRAME_LOCALS_ADDRESS:CORE_ADDR:deprecated_frame_locals_address:struct frame_info *fi:fi::get_frame_base:get_frame_base 666130803SmarcelF::DEPRECATED_SAVED_PC_AFTER_CALL:CORE_ADDR:deprecated_saved_pc_after_call:struct frame_info *frame:frame 667130803SmarcelF:2:FRAME_NUM_ARGS:int:frame_num_args:struct frame_info *frame:frame 66898944Sobrien# 669130803Smarcel# DEPRECATED_STACK_ALIGN has been replaced by an initial aligning call 670130803Smarcel# to frame_align and the requirement that methods such as 671130803Smarcel# push_dummy_call and frame_red_zone_size maintain correct stack/frame 672130803Smarcel# alignment. 673130803SmarcelF:2:DEPRECATED_STACK_ALIGN:CORE_ADDR:deprecated_stack_align:CORE_ADDR sp:sp 674130803SmarcelM:::CORE_ADDR:frame_align:CORE_ADDR address:address 675130803Smarcel# DEPRECATED_REG_STRUCT_HAS_ADDR has been replaced by 676130803Smarcel# stabs_argument_has_addr. 677130803SmarcelF:2:DEPRECATED_REG_STRUCT_HAS_ADDR:int:deprecated_reg_struct_has_addr:int gcc_p, struct type *type:gcc_p, type 678130803Smarcelm:::int:stabs_argument_has_addr:struct type *type:type:::default_stabs_argument_has_addr::0 679130803Smarcelv::FRAME_RED_ZONE_SIZE:int:frame_red_zone_size 68098944Sobrienv:2:PARM_BOUNDARY:int:parm_boundary 68198944Sobrien# 682130803Smarcelv:2:TARGET_FLOAT_FORMAT:const struct floatformat *:float_format::::::default_float_format (current_gdbarch)::%s:(TARGET_FLOAT_FORMAT)->name 683130803Smarcelv:2:TARGET_DOUBLE_FORMAT:const struct floatformat *:double_format::::::default_double_format (current_gdbarch)::%s:(TARGET_DOUBLE_FORMAT)->name 684130803Smarcelv:2:TARGET_LONG_DOUBLE_FORMAT:const struct floatformat *:long_double_format::::::default_double_format (current_gdbarch)::%s:(TARGET_LONG_DOUBLE_FORMAT)->name 685130803Smarcelm:::CORE_ADDR:convert_from_func_ptr_addr:CORE_ADDR addr, struct target_ops *targ:addr, targ:::convert_from_func_ptr_addr_identity::0 68698944Sobrien# On some machines there are bits in addresses which are not really 68798944Sobrien# part of the address, but are used by the kernel, the hardware, etc. 68898944Sobrien# for special purposes. ADDR_BITS_REMOVE takes out any such bits so 68998944Sobrien# we get a "real" address such as one would find in a symbol table. 69098944Sobrien# This is used only for addresses of instructions, and even then I'm 69198944Sobrien# not sure it's used in all contexts. It exists to deal with there 69298944Sobrien# being a few stray bits in the PC which would mislead us, not as some 69398944Sobrien# sort of generic thing to handle alignment or segmentation (it's 69498944Sobrien# possible it should be in TARGET_READ_PC instead). 69598944Sobrienf:2:ADDR_BITS_REMOVE:CORE_ADDR:addr_bits_remove:CORE_ADDR addr:addr:::core_addr_identity::0 696130803Smarcel# It is not at all clear why SMASH_TEXT_ADDRESS is not folded into 69798944Sobrien# ADDR_BITS_REMOVE. 69898944Sobrienf:2:SMASH_TEXT_ADDRESS:CORE_ADDR:smash_text_address:CORE_ADDR addr:addr:::core_addr_identity::0 69998944Sobrien# FIXME/cagney/2001-01-18: This should be split in two. A target method that indicates if 70098944Sobrien# the target needs software single step. An ISA method to implement it. 70198944Sobrien# 70298944Sobrien# FIXME/cagney/2001-01-18: This should be replaced with something that inserts breakpoints 70398944Sobrien# using the breakpoint system instead of blatting memory directly (as with rs6000). 70498944Sobrien# 70598944Sobrien# FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the target can 70698944Sobrien# single step. If not, then implement single step using breakpoints. 707130803SmarcelF:2:SOFTWARE_SINGLE_STEP:void:software_single_step:enum target_signal sig, int insert_breakpoints_p:sig, insert_breakpoints_p 708130803Smarcel# FIXME: cagney/2003-08-28: Need to find a better way of selecting the 709130803Smarcel# disassembler. Perhaphs objdump can handle it? 710130803Smarcelf::TARGET_PRINT_INSN:int:print_insn:bfd_vma vma, struct disassemble_info *info:vma, info:::0: 71198944Sobrienf:2:SKIP_TRAMPOLINE_CODE:CORE_ADDR:skip_trampoline_code:CORE_ADDR pc:pc:::generic_skip_trampoline_code::0 712130803Smarcel 713130803Smarcel 714130803Smarcel# If IN_SOLIB_DYNSYM_RESOLVE_CODE returns true, and SKIP_SOLIB_RESOLVER 715130803Smarcel# evaluates non-zero, this is the address where the debugger will place 716130803Smarcel# a step-resume breakpoint to get us past the dynamic linker. 717130803Smarcelm:2:SKIP_SOLIB_RESOLVER:CORE_ADDR:skip_solib_resolver:CORE_ADDR pc:pc:::generic_skip_solib_resolver::0 71898944Sobrien# For SVR4 shared libraries, each call goes through a small piece of 71998944Sobrien# trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates 720130803Smarcel# to nonzero if we are currently stopped in one of these. 72198944Sobrienf:2:IN_SOLIB_CALL_TRAMPOLINE:int:in_solib_call_trampoline:CORE_ADDR pc, char *name:pc, name:::generic_in_solib_call_trampoline::0 722130803Smarcel 723130803Smarcel# Some systems also have trampoline code for returning from shared libs. 724130803Smarcelf:2:IN_SOLIB_RETURN_TRAMPOLINE:int:in_solib_return_trampoline:CORE_ADDR pc, char *name:pc, name:::generic_in_solib_return_trampoline::0 725130803Smarcel 726130803Smarcel# Sigtramp is a routine that the kernel calls (which then calls the 727130803Smarcel# signal handler). On most machines it is a library routine that is 728130803Smarcel# linked into the executable. 729130803Smarcel# 730130803Smarcel# This macro, given a program counter value and the name of the 731130803Smarcel# function in which that PC resides (which can be null if the name is 732130803Smarcel# not known), returns nonzero if the PC and name show that we are in 733130803Smarcel# sigtramp. 734130803Smarcel# 735130803Smarcel# On most machines just see if the name is sigtramp (and if we have 736130803Smarcel# no name, assume we are not in sigtramp). 737130803Smarcel# 738130803Smarcel# FIXME: cagney/2002-04-21: The function find_pc_partial_function 739130803Smarcel# calls find_pc_sect_partial_function() which calls PC_IN_SIGTRAMP. 740130803Smarcel# This means PC_IN_SIGTRAMP function can't be implemented by doing its 741130803Smarcel# own local NAME lookup. 742130803Smarcel# 743130803Smarcel# FIXME: cagney/2002-04-21: PC_IN_SIGTRAMP is something of a mess. 744130803Smarcel# Some code also depends on SIGTRAMP_START and SIGTRAMP_END but other 745130803Smarcel# does not. 746130803Smarcelf:2:PC_IN_SIGTRAMP:int:pc_in_sigtramp:CORE_ADDR pc, char *name:pc, name:::legacy_pc_in_sigtramp::0 747130803SmarcelF:2:SIGTRAMP_START:CORE_ADDR:sigtramp_start:CORE_ADDR pc:pc 748130803SmarcelF:2:SIGTRAMP_END:CORE_ADDR:sigtramp_end:CORE_ADDR pc:pc 74998944Sobrien# A target might have problems with watchpoints as soon as the stack 75098944Sobrien# frame of the current function has been destroyed. This mostly happens 75198944Sobrien# as the first action in a funtion's epilogue. in_function_epilogue_p() 75298944Sobrien# is defined to return a non-zero value if either the given addr is one 75398944Sobrien# instruction after the stack destroying instruction up to the trailing 75498944Sobrien# return instruction or if we can figure out that the stack frame has 75598944Sobrien# already been invalidated regardless of the value of addr. Targets 75698944Sobrien# which don't suffer from that problem could just let this functionality 75798944Sobrien# untouched. 75898944Sobrienm:::int:in_function_epilogue_p:CORE_ADDR addr:addr::0:generic_in_function_epilogue_p::0 75998944Sobrien# Given a vector of command-line arguments, return a newly allocated 76098944Sobrien# string which, when passed to the create_inferior function, will be 76198944Sobrien# parsed (on Unix systems, by the shell) to yield the same vector. 76298944Sobrien# This function should call error() if the argument vector is not 76398944Sobrien# representable for this target or if this target does not support 76498944Sobrien# command-line arguments. 76598944Sobrien# ARGC is the number of elements in the vector. 76698944Sobrien# ARGV is an array of strings, one per argument. 76798944Sobrienm::CONSTRUCT_INFERIOR_ARGUMENTS:char *:construct_inferior_arguments:int argc, char **argv:argc, argv:::construct_inferior_arguments::0 76898944Sobrienf:2:ELF_MAKE_MSYMBOL_SPECIAL:void:elf_make_msymbol_special:asymbol *sym, struct minimal_symbol *msym:sym, msym:::default_elf_make_msymbol_special::0 76998944Sobrienf:2:COFF_MAKE_MSYMBOL_SPECIAL:void:coff_make_msymbol_special:int val, struct minimal_symbol *msym:val, msym:::default_coff_make_msymbol_special::0 770130803Smarcelv:2:NAME_OF_MALLOC:const char *:name_of_malloc::::"malloc":"malloc"::0:%s:NAME_OF_MALLOC 771130803Smarcelv:2:CANNOT_STEP_BREAKPOINT:int:cannot_step_breakpoint::::0:0::0 772130803Smarcelv:2:HAVE_NONSTEPPABLE_WATCHPOINT:int:have_nonsteppable_watchpoint::::0:0::0 773130803SmarcelF:2:ADDRESS_CLASS_TYPE_FLAGS:int:address_class_type_flags:int byte_size, int dwarf2_addr_class:byte_size, dwarf2_addr_class 774130803SmarcelM:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:const char *:address_class_type_flags_to_name:int type_flags:type_flags 775130803SmarcelM:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr 776130803Smarcel# Is a register in a group 777130803Smarcelm:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0 778130803Smarcel# Fetch the pointer to the ith function argument. 779130803SmarcelF::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct type *type:frame, argi, type 780130803Smarcel 781130803Smarcel# Return the appropriate register set for a core file section with 782130803Smarcel# name SECT_NAME and size SECT_SIZE. 783130803SmarcelM:::const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size 78498944SobrienEOF 78598944Sobrien} 78698944Sobrien 78798944Sobrien# 78898944Sobrien# The .log file 78998944Sobrien# 79098944Sobrienexec > new-gdbarch.log 79198944Sobrienfunction_list | while do_read 79298944Sobriendo 79398944Sobrien cat <<EOF 79498944Sobrien${class} ${macro}(${actual}) 79598944Sobrien ${returntype} ${function} ($formal)${attrib} 79698944SobrienEOF 79798944Sobrien for r in ${read} 79898944Sobrien do 79998944Sobrien eval echo \"\ \ \ \ ${r}=\${${r}}\" 80098944Sobrien done 80198944Sobrien if class_is_predicate_p && fallback_default_p 80298944Sobrien then 80398944Sobrien echo "Error: predicate function ${macro} can not have a non- multi-arch default" 1>&2 80498944Sobrien kill $$ 80598944Sobrien exit 1 80698944Sobrien fi 80798944Sobrien if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ] 80898944Sobrien then 80998944Sobrien echo "Error: postdefault is useless when invalid_p=0" 1>&2 81098944Sobrien kill $$ 81198944Sobrien exit 1 81298944Sobrien fi 81398944Sobrien if class_is_multiarch_p 81498944Sobrien then 81598944Sobrien if class_is_predicate_p ; then : 81698944Sobrien elif test "x${predefault}" = "x" 81798944Sobrien then 81898944Sobrien echo "Error: pure multi-arch function must have a predefault" 1>&2 81998944Sobrien kill $$ 82098944Sobrien exit 1 82198944Sobrien fi 82298944Sobrien fi 82398944Sobrien echo "" 82498944Sobriendone 82598944Sobrien 82698944Sobrienexec 1>&2 82798944Sobriencompare_new gdbarch.log 82898944Sobrien 82998944Sobrien 83098944Sobriencopyright () 83198944Sobrien{ 83298944Sobriencat <<EOF 83398944Sobrien/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ 83498944Sobrien 83598944Sobrien/* Dynamic architecture support for GDB, the GNU debugger. 83698944Sobrien 837130803Smarcel Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free 838130803Smarcel Software Foundation, Inc. 839130803Smarcel 84098944Sobrien This file is part of GDB. 84198944Sobrien 84298944Sobrien This program is free software; you can redistribute it and/or modify 84398944Sobrien it under the terms of the GNU General Public License as published by 84498944Sobrien the Free Software Foundation; either version 2 of the License, or 84598944Sobrien (at your option) any later version. 84698944Sobrien 84798944Sobrien This program is distributed in the hope that it will be useful, 84898944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 84998944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 85098944Sobrien GNU General Public License for more details. 85198944Sobrien 85298944Sobrien You should have received a copy of the GNU General Public License 85398944Sobrien along with this program; if not, write to the Free Software 85498944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 85598944Sobrien Boston, MA 02111-1307, USA. */ 85698944Sobrien 85798944Sobrien/* This file was created with the aid of \`\`gdbarch.sh''. 85898944Sobrien 85998944Sobrien The Bourne shell script \`\`gdbarch.sh'' creates the files 86098944Sobrien \`\`new-gdbarch.c'' and \`\`new-gdbarch.h and then compares them 86198944Sobrien against the existing \`\`gdbarch.[hc]''. Any differences found 86298944Sobrien being reported. 86398944Sobrien 86498944Sobrien If editing this file, please also run gdbarch.sh and merge any 86598944Sobrien changes into that script. Conversely, when making sweeping changes 86698944Sobrien to this file, modifying gdbarch.sh and using its output may prove 86798944Sobrien easier. */ 86898944Sobrien 86998944SobrienEOF 87098944Sobrien} 87198944Sobrien 87298944Sobrien# 87398944Sobrien# The .h file 87498944Sobrien# 87598944Sobrien 87698944Sobrienexec > new-gdbarch.h 87798944Sobriencopyright 87898944Sobriencat <<EOF 87998944Sobrien#ifndef GDBARCH_H 88098944Sobrien#define GDBARCH_H 88198944Sobrien 882130803Smarcelstruct floatformat; 883130803Smarcelstruct ui_file; 88498944Sobrienstruct frame_info; 88598944Sobrienstruct value; 88698944Sobrienstruct objfile; 88798944Sobrienstruct minimal_symbol; 888130803Smarcelstruct regcache; 889130803Smarcelstruct reggroup; 890130803Smarcelstruct regset; 891130803Smarcelstruct disassemble_info; 892130803Smarcelstruct target_ops; 89398944Sobrien 89498944Sobrienextern struct gdbarch *current_gdbarch; 89598944Sobrien 89698944Sobrien 89798944Sobrien/* If any of the following are defined, the target wasn't correctly 89898944Sobrien converted. */ 89998944Sobrien 90098944Sobrien#if (GDB_MULTI_ARCH >= GDB_MULTI_ARCH_PURE) && defined (GDB_TM_FILE) 90198944Sobrien#error "GDB_TM_FILE: Pure multi-arch targets do not have a tm.h file." 90298944Sobrien#endif 90398944SobrienEOF 90498944Sobrien 90598944Sobrien# function typedef's 90698944Sobrienprintf "\n" 90798944Sobrienprintf "\n" 90898944Sobrienprintf "/* The following are pre-initialized by GDBARCH. */\n" 90998944Sobrienfunction_list | while do_read 91098944Sobriendo 91198944Sobrien if class_is_info_p 91298944Sobrien then 91398944Sobrien printf "\n" 91498944Sobrien printf "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);\n" 91598944Sobrien printf "/* set_gdbarch_${function}() - not applicable - pre-initialized. */\n" 91698944Sobrien printf "#if (GDB_MULTI_ARCH ${gt_level}) && defined (${macro})\n" 91798944Sobrien printf "#error \"Non multi-arch definition of ${macro}\"\n" 91898944Sobrien printf "#endif\n" 919130803Smarcel printf "#if !defined (${macro})\n" 92098944Sobrien printf "#define ${macro} (gdbarch_${function} (current_gdbarch))\n" 92198944Sobrien printf "#endif\n" 92298944Sobrien fi 92398944Sobriendone 92498944Sobrien 92598944Sobrien# function typedef's 92698944Sobrienprintf "\n" 92798944Sobrienprintf "\n" 92898944Sobrienprintf "/* The following are initialized by the target dependent code. */\n" 92998944Sobrienfunction_list | while do_read 93098944Sobriendo 93198944Sobrien if [ -n "${comment}" ] 93298944Sobrien then 93398944Sobrien echo "${comment}" | sed \ 93498944Sobrien -e '2 s,#,/*,' \ 93598944Sobrien -e '3,$ s,#, ,' \ 93698944Sobrien -e '$ s,$, */,' 93798944Sobrien fi 93898944Sobrien if class_is_multiarch_p 93998944Sobrien then 94098944Sobrien if class_is_predicate_p 94198944Sobrien then 94298944Sobrien printf "\n" 94398944Sobrien printf "extern int gdbarch_${function}_p (struct gdbarch *gdbarch);\n" 94498944Sobrien fi 94598944Sobrien else 94698944Sobrien if class_is_predicate_p 94798944Sobrien then 94898944Sobrien printf "\n" 94998944Sobrien printf "#if defined (${macro})\n" 95098944Sobrien printf "/* Legacy for systems yet to multi-arch ${macro} */\n" 95198944Sobrien #printf "#if (GDB_MULTI_ARCH <= GDB_MULTI_ARCH_PARTIAL) && defined (${macro})\n" 95298944Sobrien printf "#if !defined (${macro}_P)\n" 95398944Sobrien printf "#define ${macro}_P() (1)\n" 95498944Sobrien printf "#endif\n" 95598944Sobrien printf "#endif\n" 95698944Sobrien printf "\n" 95798944Sobrien printf "extern int gdbarch_${function}_p (struct gdbarch *gdbarch);\n" 95898944Sobrien printf "#if (GDB_MULTI_ARCH ${gt_level}) && defined (${macro}_P)\n" 95998944Sobrien printf "#error \"Non multi-arch definition of ${macro}\"\n" 96098944Sobrien printf "#endif\n" 96198944Sobrien printf "#if (GDB_MULTI_ARCH ${gt_level}) || !defined (${macro}_P)\n" 96298944Sobrien printf "#define ${macro}_P() (gdbarch_${function}_p (current_gdbarch))\n" 96398944Sobrien printf "#endif\n" 96498944Sobrien fi 96598944Sobrien fi 96698944Sobrien if class_is_variable_p 96798944Sobrien then 96898944Sobrien printf "\n" 96998944Sobrien printf "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);\n" 97098944Sobrien printf "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, ${returntype} ${function});\n" 97198944Sobrien printf "#if (GDB_MULTI_ARCH ${gt_level}) && defined (${macro})\n" 97298944Sobrien printf "#error \"Non multi-arch definition of ${macro}\"\n" 97398944Sobrien printf "#endif\n" 974130803Smarcel printf "#if !defined (${macro})\n" 97598944Sobrien printf "#define ${macro} (gdbarch_${function} (current_gdbarch))\n" 97698944Sobrien printf "#endif\n" 97798944Sobrien fi 97898944Sobrien if class_is_function_p 97998944Sobrien then 98098944Sobrien printf "\n" 98198944Sobrien if [ "x${formal}" = "xvoid" ] && class_is_multiarch_p 98298944Sobrien then 98398944Sobrien printf "typedef ${returntype} (gdbarch_${function}_ftype) (struct gdbarch *gdbarch);\n" 98498944Sobrien elif class_is_multiarch_p 98598944Sobrien then 98698944Sobrien printf "typedef ${returntype} (gdbarch_${function}_ftype) (struct gdbarch *gdbarch, ${formal});\n" 98798944Sobrien else 98898944Sobrien printf "typedef ${returntype} (gdbarch_${function}_ftype) (${formal});\n" 98998944Sobrien fi 99098944Sobrien if [ "x${formal}" = "xvoid" ] 99198944Sobrien then 99298944Sobrien printf "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);\n" 99398944Sobrien else 99498944Sobrien printf "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch, ${formal});\n" 99598944Sobrien fi 99698944Sobrien printf "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, gdbarch_${function}_ftype *${function});\n" 99798944Sobrien if class_is_multiarch_p ; then : 99898944Sobrien else 99998944Sobrien printf "#if (GDB_MULTI_ARCH ${gt_level}) && defined (${macro})\n" 100098944Sobrien printf "#error \"Non multi-arch definition of ${macro}\"\n" 100198944Sobrien printf "#endif\n" 100298944Sobrien if [ "x${actual}" = "x" ] 100398944Sobrien then 1004130803Smarcel d="#define ${macro}() (gdbarch_${function} (current_gdbarch))" 1005130803Smarcel elif [ "x${actual}" = "x-" ] 1006130803Smarcel then 1007130803Smarcel d="#define ${macro} (gdbarch_${function} (current_gdbarch))" 1008130803Smarcel else 1009130803Smarcel d="#define ${macro}(${actual}) (gdbarch_${function} (current_gdbarch, ${actual}))" 1010130803Smarcel fi 1011130803Smarcel printf "#if !defined (${macro})\n" 1012130803Smarcel if [ "x${actual}" = "x" ] 1013130803Smarcel then 101498944Sobrien printf "#define ${macro}() (gdbarch_${function} (current_gdbarch))\n" 101598944Sobrien elif [ "x${actual}" = "x-" ] 101698944Sobrien then 101798944Sobrien printf "#define ${macro} (gdbarch_${function} (current_gdbarch))\n" 101898944Sobrien else 101998944Sobrien printf "#define ${macro}(${actual}) (gdbarch_${function} (current_gdbarch, ${actual}))\n" 102098944Sobrien fi 102198944Sobrien printf "#endif\n" 102298944Sobrien fi 102398944Sobrien fi 102498944Sobriendone 102598944Sobrien 102698944Sobrien# close it off 102798944Sobriencat <<EOF 102898944Sobrien 102998944Sobrienextern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); 103098944Sobrien 103198944Sobrien 103298944Sobrien/* Mechanism for co-ordinating the selection of a specific 103398944Sobrien architecture. 103498944Sobrien 103598944Sobrien GDB targets (*-tdep.c) can register an interest in a specific 103698944Sobrien architecture. Other GDB components can register a need to maintain 103798944Sobrien per-architecture data. 103898944Sobrien 103998944Sobrien The mechanisms below ensures that there is only a loose connection 104098944Sobrien between the set-architecture command and the various GDB 104198944Sobrien components. Each component can independently register their need 104298944Sobrien to maintain architecture specific data with gdbarch. 104398944Sobrien 104498944Sobrien Pragmatics: 104598944Sobrien 104698944Sobrien Previously, a single TARGET_ARCHITECTURE_HOOK was provided. It 104798944Sobrien didn't scale. 104898944Sobrien 104998944Sobrien The more traditional mega-struct containing architecture specific 105098944Sobrien data for all the various GDB components was also considered. Since 105198944Sobrien GDB is built from a variable number of (fairly independent) 105298944Sobrien components it was determined that the global aproach was not 105398944Sobrien applicable. */ 105498944Sobrien 105598944Sobrien 105698944Sobrien/* Register a new architectural family with GDB. 105798944Sobrien 105898944Sobrien Register support for the specified ARCHITECTURE with GDB. When 105998944Sobrien gdbarch determines that the specified architecture has been 106098944Sobrien selected, the corresponding INIT function is called. 106198944Sobrien 106298944Sobrien -- 106398944Sobrien 106498944Sobrien The INIT function takes two parameters: INFO which contains the 106598944Sobrien information available to gdbarch about the (possibly new) 106698944Sobrien architecture; ARCHES which is a list of the previously created 106798944Sobrien \`\`struct gdbarch'' for this architecture. 106898944Sobrien 1069130803Smarcel The INFO parameter is, as far as possible, be pre-initialized with 1070130803Smarcel information obtained from INFO.ABFD or the previously selected 1071130803Smarcel architecture. 107298944Sobrien 1073130803Smarcel The ARCHES parameter is a linked list (sorted most recently used) 1074130803Smarcel of all the previously created architures for this architecture 1075130803Smarcel family. The (possibly NULL) ARCHES->gdbarch can used to access 1076130803Smarcel values from the previously selected architecture for this 1077130803Smarcel architecture family. The global \`\`current_gdbarch'' shall not be 1078130803Smarcel used. 1079130803Smarcel 108098944Sobrien The INIT function shall return any of: NULL - indicating that it 108198944Sobrien doesn't recognize the selected architecture; an existing \`\`struct 108298944Sobrien gdbarch'' from the ARCHES list - indicating that the new 108398944Sobrien architecture is just a synonym for an earlier architecture (see 108498944Sobrien gdbarch_list_lookup_by_info()); a newly created \`\`struct gdbarch'' 108598944Sobrien - that describes the selected architecture (see gdbarch_alloc()). 108698944Sobrien 108798944Sobrien The DUMP_TDEP function shall print out all target specific values. 108898944Sobrien Care should be taken to ensure that the function works in both the 108998944Sobrien multi-arch and non- multi-arch cases. */ 109098944Sobrien 109198944Sobrienstruct gdbarch_list 109298944Sobrien{ 109398944Sobrien struct gdbarch *gdbarch; 109498944Sobrien struct gdbarch_list *next; 109598944Sobrien}; 109698944Sobrien 109798944Sobrienstruct gdbarch_info 109898944Sobrien{ 109998944Sobrien /* Use default: NULL (ZERO). */ 110098944Sobrien const struct bfd_arch_info *bfd_arch_info; 110198944Sobrien 110298944Sobrien /* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO). */ 110398944Sobrien int byte_order; 110498944Sobrien 110598944Sobrien /* Use default: NULL (ZERO). */ 110698944Sobrien bfd *abfd; 110798944Sobrien 110898944Sobrien /* Use default: NULL (ZERO). */ 110998944Sobrien struct gdbarch_tdep_info *tdep_info; 1110130803Smarcel 1111130803Smarcel /* Use default: GDB_OSABI_UNINITIALIZED (-1). */ 1112130803Smarcel enum gdb_osabi osabi; 111398944Sobrien}; 111498944Sobrien 111598944Sobrientypedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches); 111698944Sobrientypedef void (gdbarch_dump_tdep_ftype) (struct gdbarch *gdbarch, struct ui_file *file); 111798944Sobrien 111898944Sobrien/* DEPRECATED - use gdbarch_register() */ 111998944Sobrienextern void register_gdbarch_init (enum bfd_architecture architecture, gdbarch_init_ftype *); 112098944Sobrien 112198944Sobrienextern void gdbarch_register (enum bfd_architecture architecture, 112298944Sobrien gdbarch_init_ftype *, 112398944Sobrien gdbarch_dump_tdep_ftype *); 112498944Sobrien 112598944Sobrien 112698944Sobrien/* Return a freshly allocated, NULL terminated, array of the valid 112798944Sobrien architecture names. Since architectures are registered during the 112898944Sobrien _initialize phase this function only returns useful information 112998944Sobrien once initialization has been completed. */ 113098944Sobrien 113198944Sobrienextern const char **gdbarch_printable_names (void); 113298944Sobrien 113398944Sobrien 113498944Sobrien/* Helper function. Search the list of ARCHES for a GDBARCH that 113598944Sobrien matches the information provided by INFO. */ 113698944Sobrien 113798944Sobrienextern struct gdbarch_list *gdbarch_list_lookup_by_info (struct gdbarch_list *arches, const struct gdbarch_info *info); 113898944Sobrien 113998944Sobrien 114098944Sobrien/* Helper function. Create a preliminary \`\`struct gdbarch''. Perform 114198944Sobrien basic initialization using values obtained from the INFO andTDEP 114298944Sobrien parameters. set_gdbarch_*() functions are called to complete the 114398944Sobrien initialization of the object. */ 114498944Sobrien 114598944Sobrienextern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep *tdep); 114698944Sobrien 114798944Sobrien 114898944Sobrien/* Helper function. Free a partially-constructed \`\`struct gdbarch''. 114998944Sobrien It is assumed that the caller freeds the \`\`struct 115098944Sobrien gdbarch_tdep''. */ 115198944Sobrien 115298944Sobrienextern void gdbarch_free (struct gdbarch *); 115398944Sobrien 115498944Sobrien 1155130803Smarcel/* Helper function. Allocate memory from the \`\`struct gdbarch'' 1156130803Smarcel obstack. The memory is freed when the corresponding architecture 1157130803Smarcel is also freed. */ 1158130803Smarcel 1159130803Smarcelextern void *gdbarch_obstack_zalloc (struct gdbarch *gdbarch, long size); 1160130803Smarcel#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE) ((TYPE *) gdbarch_obstack_zalloc ((GDBARCH), (NR) * sizeof (TYPE))) 1161130803Smarcel#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE) ((TYPE *) gdbarch_obstack_zalloc ((GDBARCH), sizeof (TYPE))) 1162130803Smarcel 1163130803Smarcel 116498944Sobrien/* Helper function. Force an update of the current architecture. 116598944Sobrien 116698944Sobrien The actual architecture selected is determined by INFO, \`\`(gdb) set 116798944Sobrien architecture'' et.al., the existing architecture and BFD's default 116898944Sobrien architecture. INFO should be initialized to zero and then selected 116998944Sobrien fields should be updated. 117098944Sobrien 117198944Sobrien Returns non-zero if the update succeeds */ 117298944Sobrien 117398944Sobrienextern int gdbarch_update_p (struct gdbarch_info info); 117498944Sobrien 117598944Sobrien 1176130803Smarcel/* Helper function. Find an architecture matching info. 117798944Sobrien 1178130803Smarcel INFO should be initialized using gdbarch_info_init, relevant fields 1179130803Smarcel set, and then finished using gdbarch_info_fill. 1180130803Smarcel 1181130803Smarcel Returns the corresponding architecture, or NULL if no matching 1182130803Smarcel architecture was found. "current_gdbarch" is not updated. */ 1183130803Smarcel 1184130803Smarcelextern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info); 1185130803Smarcel 1186130803Smarcel 1187130803Smarcel/* Helper function. Set the global "current_gdbarch" to "gdbarch". 1188130803Smarcel 1189130803Smarcel FIXME: kettenis/20031124: Of the functions that follow, only 1190130803Smarcel gdbarch_from_bfd is supposed to survive. The others will 1191130803Smarcel dissappear since in the future GDB will (hopefully) be truly 1192130803Smarcel multi-arch. However, for now we're still stuck with the concept of 1193130803Smarcel a single active architecture. */ 1194130803Smarcel 1195130803Smarcelextern void deprecated_current_gdbarch_select_hack (struct gdbarch *gdbarch); 1196130803Smarcel 1197130803Smarcel 119898944Sobrien/* Register per-architecture data-pointer. 119998944Sobrien 120098944Sobrien Reserve space for a per-architecture data-pointer. An identifier 120198944Sobrien for the reserved data-pointer is returned. That identifer should 120298944Sobrien be saved in a local static variable. 120398944Sobrien 1204130803Smarcel The per-architecture data-pointer is either initialized explicitly 1205130803Smarcel (set_gdbarch_data()) or implicitly (by INIT() via a call to 1206130803Smarcel gdbarch_data()). 120798944Sobrien 1208130803Smarcel Memory for the per-architecture data shall be allocated using 1209130803Smarcel gdbarch_obstack_zalloc. That memory will be deleted when the 1210130803Smarcel corresponding architecture object is deleted. 1211130803Smarcel 121298944Sobrien When a previously created architecture is re-selected, the 121398944Sobrien per-architecture data-pointer for that previous architecture is 1214130803Smarcel restored. INIT() is not re-called. 121598944Sobrien 121698944Sobrien Multiple registrarants for any architecture are allowed (and 121798944Sobrien strongly encouraged). */ 121898944Sobrien 121998944Sobrienstruct gdbarch_data; 122098944Sobrien 122198944Sobrientypedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch); 1222130803Smarcelextern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init); 122398944Sobrienextern void set_gdbarch_data (struct gdbarch *gdbarch, 122498944Sobrien struct gdbarch_data *data, 122598944Sobrien void *pointer); 122698944Sobrien 1227130803Smarcelextern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *); 122898944Sobrien 122998944Sobrien 1230130803Smarcel 123198944Sobrien/* Register per-architecture memory region. 123298944Sobrien 123398944Sobrien Provide a memory-region swap mechanism. Per-architecture memory 123498944Sobrien region are created. These memory regions are swapped whenever the 123598944Sobrien architecture is changed. For a new architecture, the memory region 123698944Sobrien is initialized with zero (0) and the INIT function is called. 123798944Sobrien 123898944Sobrien Memory regions are swapped / initialized in the order that they are 123998944Sobrien registered. NULL DATA and/or INIT values can be specified. 124098944Sobrien 124198944Sobrien New code should use register_gdbarch_data(). */ 124298944Sobrien 124398944Sobrientypedef void (gdbarch_swap_ftype) (void); 1244130803Smarcelextern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init); 1245130803Smarcel#define DEPRECATED_REGISTER_GDBARCH_SWAP(VAR) deprecated_register_gdbarch_swap (&(VAR), sizeof ((VAR)), NULL) 124698944Sobrien 124798944Sobrien 124898944Sobrien 124998944Sobrien/* Set the dynamic target-system-dependent parameters (architecture, 125098944Sobrien byte-order, ...) using information found in the BFD */ 125198944Sobrien 125298944Sobrienextern void set_gdbarch_from_file (bfd *); 125398944Sobrien 125498944Sobrien 125598944Sobrien/* Initialize the current architecture to the "first" one we find on 125698944Sobrien our list. */ 125798944Sobrien 125898944Sobrienextern void initialize_current_architecture (void); 125998944Sobrien 126098944Sobrien/* gdbarch trace variable */ 126198944Sobrienextern int gdbarch_debug; 126298944Sobrien 126398944Sobrienextern void gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file); 126498944Sobrien 126598944Sobrien#endif 126698944SobrienEOF 126798944Sobrienexec 1>&2 126898944Sobrien#../move-if-change new-gdbarch.h gdbarch.h 126998944Sobriencompare_new gdbarch.h 127098944Sobrien 127198944Sobrien 127298944Sobrien# 127398944Sobrien# C file 127498944Sobrien# 127598944Sobrien 127698944Sobrienexec > new-gdbarch.c 127798944Sobriencopyright 127898944Sobriencat <<EOF 127998944Sobrien 128098944Sobrien#include "defs.h" 128198944Sobrien#include "arch-utils.h" 128298944Sobrien 128398944Sobrien#include "gdbcmd.h" 128498944Sobrien#include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */ 128598944Sobrien#include "symcat.h" 128698944Sobrien 128798944Sobrien#include "floatformat.h" 128898944Sobrien 128998944Sobrien#include "gdb_assert.h" 1290130803Smarcel#include "gdb_string.h" 129198944Sobrien#include "gdb-events.h" 1292130803Smarcel#include "reggroups.h" 1293130803Smarcel#include "osabi.h" 1294130803Smarcel#include "gdb_obstack.h" 129598944Sobrien 129698944Sobrien/* Static function declarations */ 129798944Sobrien 129898944Sobrienstatic void alloc_gdbarch_data (struct gdbarch *); 129998944Sobrien 130098944Sobrien/* Non-zero if we want to trace architecture code. */ 130198944Sobrien 130298944Sobrien#ifndef GDBARCH_DEBUG 130398944Sobrien#define GDBARCH_DEBUG 0 130498944Sobrien#endif 130598944Sobrienint gdbarch_debug = GDBARCH_DEBUG; 130698944Sobrien 130798944SobrienEOF 130898944Sobrien 130998944Sobrien# gdbarch open the gdbarch object 131098944Sobrienprintf "\n" 131198944Sobrienprintf "/* Maintain the struct gdbarch object */\n" 131298944Sobrienprintf "\n" 131398944Sobrienprintf "struct gdbarch\n" 131498944Sobrienprintf "{\n" 1315130803Smarcelprintf " /* Has this architecture been fully initialized? */\n" 1316130803Smarcelprintf " int initialized_p;\n" 1317130803Smarcelprintf "\n" 1318130803Smarcelprintf " /* An obstack bound to the lifetime of the architecture. */\n" 1319130803Smarcelprintf " struct obstack *obstack;\n" 1320130803Smarcelprintf "\n" 132198944Sobrienprintf " /* basic architectural information */\n" 132298944Sobrienfunction_list | while do_read 132398944Sobriendo 132498944Sobrien if class_is_info_p 132598944Sobrien then 132698944Sobrien printf " ${returntype} ${function};\n" 132798944Sobrien fi 132898944Sobriendone 132998944Sobrienprintf "\n" 133098944Sobrienprintf " /* target specific vector. */\n" 133198944Sobrienprintf " struct gdbarch_tdep *tdep;\n" 133298944Sobrienprintf " gdbarch_dump_tdep_ftype *dump_tdep;\n" 133398944Sobrienprintf "\n" 133498944Sobrienprintf " /* per-architecture data-pointers */\n" 133598944Sobrienprintf " unsigned nr_data;\n" 133698944Sobrienprintf " void **data;\n" 133798944Sobrienprintf "\n" 133898944Sobrienprintf " /* per-architecture swap-regions */\n" 133998944Sobrienprintf " struct gdbarch_swap *swap;\n" 134098944Sobrienprintf "\n" 134198944Sobriencat <<EOF 134298944Sobrien /* Multi-arch values. 134398944Sobrien 134498944Sobrien When extending this structure you must: 134598944Sobrien 134698944Sobrien Add the field below. 134798944Sobrien 134898944Sobrien Declare set/get functions and define the corresponding 134998944Sobrien macro in gdbarch.h. 135098944Sobrien 135198944Sobrien gdbarch_alloc(): If zero/NULL is not a suitable default, 135298944Sobrien initialize the new field. 135398944Sobrien 135498944Sobrien verify_gdbarch(): Confirm that the target updated the field 135598944Sobrien correctly. 135698944Sobrien 135798944Sobrien gdbarch_dump(): Add a fprintf_unfiltered call so that the new 135898944Sobrien field is dumped out 135998944Sobrien 136098944Sobrien \`\`startup_gdbarch()'': Append an initial value to the static 136198944Sobrien variable (base values on the host's c-type system). 136298944Sobrien 136398944Sobrien get_gdbarch(): Implement the set/get functions (probably using 136498944Sobrien the macro's as shortcuts). 136598944Sobrien 136698944Sobrien */ 136798944Sobrien 136898944SobrienEOF 136998944Sobrienfunction_list | while do_read 137098944Sobriendo 137198944Sobrien if class_is_variable_p 137298944Sobrien then 137398944Sobrien printf " ${returntype} ${function};\n" 137498944Sobrien elif class_is_function_p 137598944Sobrien then 137698944Sobrien printf " gdbarch_${function}_ftype *${function}${attrib};\n" 137798944Sobrien fi 137898944Sobriendone 137998944Sobrienprintf "};\n" 138098944Sobrien 138198944Sobrien# A pre-initialized vector 138298944Sobrienprintf "\n" 138398944Sobrienprintf "\n" 138498944Sobriencat <<EOF 138598944Sobrien/* The default architecture uses host values (for want of a better 138698944Sobrien choice). */ 138798944SobrienEOF 138898944Sobrienprintf "\n" 138998944Sobrienprintf "extern const struct bfd_arch_info bfd_default_arch_struct;\n" 139098944Sobrienprintf "\n" 139198944Sobrienprintf "struct gdbarch startup_gdbarch =\n" 139298944Sobrienprintf "{\n" 1393130803Smarcelprintf " 1, /* Always initialized. */\n" 1394130803Smarcelprintf " NULL, /* The obstack. */\n" 139598944Sobrienprintf " /* basic architecture information */\n" 139698944Sobrienfunction_list | while do_read 139798944Sobriendo 139898944Sobrien if class_is_info_p 139998944Sobrien then 1400130803Smarcel printf " ${staticdefault}, /* ${function} */\n" 140198944Sobrien fi 140298944Sobriendone 140398944Sobriencat <<EOF 140498944Sobrien /* target specific vector and its dump routine */ 140598944Sobrien NULL, NULL, 140698944Sobrien /*per-architecture data-pointers and swap regions */ 140798944Sobrien 0, NULL, NULL, 140898944Sobrien /* Multi-arch values */ 140998944SobrienEOF 141098944Sobrienfunction_list | while do_read 141198944Sobriendo 141298944Sobrien if class_is_function_p || class_is_variable_p 141398944Sobrien then 1414130803Smarcel printf " ${staticdefault}, /* ${function} */\n" 141598944Sobrien fi 141698944Sobriendone 141798944Sobriencat <<EOF 141898944Sobrien /* startup_gdbarch() */ 141998944Sobrien}; 142098944Sobrien 142198944Sobrienstruct gdbarch *current_gdbarch = &startup_gdbarch; 142298944SobrienEOF 142398944Sobrien 142498944Sobrien# Create a new gdbarch struct 142598944Sobriencat <<EOF 1426130803Smarcel 142798944Sobrien/* Create a new \`\`struct gdbarch'' based on information provided by 142898944Sobrien \`\`struct gdbarch_info''. */ 142998944SobrienEOF 143098944Sobrienprintf "\n" 143198944Sobriencat <<EOF 143298944Sobrienstruct gdbarch * 143398944Sobriengdbarch_alloc (const struct gdbarch_info *info, 143498944Sobrien struct gdbarch_tdep *tdep) 143598944Sobrien{ 143698944Sobrien /* NOTE: The new architecture variable is named \`\`current_gdbarch'' 143798944Sobrien so that macros such as TARGET_DOUBLE_BIT, when expanded, refer to 143898944Sobrien the current local architecture and not the previous global 143998944Sobrien architecture. This ensures that the new architectures initial 144098944Sobrien values are not influenced by the previous architecture. Once 144198944Sobrien everything is parameterised with gdbarch, this will go away. */ 1442130803Smarcel struct gdbarch *current_gdbarch; 1443130803Smarcel 1444130803Smarcel /* Create an obstack for allocating all the per-architecture memory, 1445130803Smarcel then use that to allocate the architecture vector. */ 1446130803Smarcel struct obstack *obstack = XMALLOC (struct obstack); 1447130803Smarcel obstack_init (obstack); 1448130803Smarcel current_gdbarch = obstack_alloc (obstack, sizeof (*current_gdbarch)); 144998944Sobrien memset (current_gdbarch, 0, sizeof (*current_gdbarch)); 1450130803Smarcel current_gdbarch->obstack = obstack; 145198944Sobrien 145298944Sobrien alloc_gdbarch_data (current_gdbarch); 145398944Sobrien 145498944Sobrien current_gdbarch->tdep = tdep; 145598944SobrienEOF 145698944Sobrienprintf "\n" 145798944Sobrienfunction_list | while do_read 145898944Sobriendo 145998944Sobrien if class_is_info_p 146098944Sobrien then 146198944Sobrien printf " current_gdbarch->${function} = info->${function};\n" 146298944Sobrien fi 146398944Sobriendone 146498944Sobrienprintf "\n" 146598944Sobrienprintf " /* Force the explicit initialization of these. */\n" 146698944Sobrienfunction_list | while do_read 146798944Sobriendo 146898944Sobrien if class_is_function_p || class_is_variable_p 146998944Sobrien then 147098944Sobrien if [ -n "${predefault}" -a "x${predefault}" != "x0" ] 147198944Sobrien then 147298944Sobrien printf " current_gdbarch->${function} = ${predefault};\n" 147398944Sobrien fi 147498944Sobrien fi 147598944Sobriendone 147698944Sobriencat <<EOF 147798944Sobrien /* gdbarch_alloc() */ 147898944Sobrien 147998944Sobrien return current_gdbarch; 148098944Sobrien} 148198944SobrienEOF 148298944Sobrien 148398944Sobrien# Free a gdbarch struct. 148498944Sobrienprintf "\n" 148598944Sobrienprintf "\n" 148698944Sobriencat <<EOF 1487130803Smarcel/* Allocate extra space using the per-architecture obstack. */ 1488130803Smarcel 1489130803Smarcelvoid * 1490130803Smarcelgdbarch_obstack_zalloc (struct gdbarch *arch, long size) 1491130803Smarcel{ 1492130803Smarcel void *data = obstack_alloc (arch->obstack, size); 1493130803Smarcel memset (data, 0, size); 1494130803Smarcel return data; 1495130803Smarcel} 1496130803Smarcel 1497130803Smarcel 149898944Sobrien/* Free a gdbarch struct. This should never happen in normal 149998944Sobrien operation --- once you've created a gdbarch, you keep it around. 150098944Sobrien However, if an architecture's init function encounters an error 150198944Sobrien building the structure, it may need to clean up a partially 150298944Sobrien constructed gdbarch. */ 150398944Sobrien 150498944Sobrienvoid 150598944Sobriengdbarch_free (struct gdbarch *arch) 150698944Sobrien{ 1507130803Smarcel struct obstack *obstack; 150898944Sobrien gdb_assert (arch != NULL); 1509130803Smarcel gdb_assert (!arch->initialized_p); 1510130803Smarcel obstack = arch->obstack; 1511130803Smarcel obstack_free (obstack, 0); /* Includes the ARCH. */ 1512130803Smarcel xfree (obstack); 151398944Sobrien} 151498944SobrienEOF 151598944Sobrien 151698944Sobrien# verify a new architecture 151798944Sobriencat <<EOF 1518130803Smarcel 1519130803Smarcel 1520130803Smarcel/* Ensure that all values in a GDBARCH are reasonable. */ 1521130803Smarcel 1522130803Smarcel/* NOTE/WARNING: The parameter is called \`\`current_gdbarch'' so that it 1523130803Smarcel just happens to match the global variable \`\`current_gdbarch''. That 1524130803Smarcel way macros refering to that variable get the local and not the global 1525130803Smarcel version - ulgh. Once everything is parameterised with gdbarch, this 1526130803Smarcel will go away. */ 1527130803Smarcel 152898944Sobrienstatic void 1529130803Smarcelverify_gdbarch (struct gdbarch *current_gdbarch) 153098944Sobrien{ 153198944Sobrien struct ui_file *log; 153298944Sobrien struct cleanup *cleanups; 153398944Sobrien long dummy; 153498944Sobrien char *buf; 153598944Sobrien log = mem_fileopen (); 153698944Sobrien cleanups = make_cleanup_ui_file_delete (log); 153798944Sobrien /* fundamental */ 1538130803Smarcel if (current_gdbarch->byte_order == BFD_ENDIAN_UNKNOWN) 153998944Sobrien fprintf_unfiltered (log, "\n\tbyte-order"); 1540130803Smarcel if (current_gdbarch->bfd_arch_info == NULL) 154198944Sobrien fprintf_unfiltered (log, "\n\tbfd_arch_info"); 154298944Sobrien /* Check those that need to be defined for the given multi-arch level. */ 154398944SobrienEOF 154498944Sobrienfunction_list | while do_read 154598944Sobriendo 154698944Sobrien if class_is_function_p || class_is_variable_p 154798944Sobrien then 154898944Sobrien if [ "x${invalid_p}" = "x0" ] 154998944Sobrien then 155098944Sobrien printf " /* Skip verify of ${function}, invalid_p == 0 */\n" 155198944Sobrien elif class_is_predicate_p 155298944Sobrien then 155398944Sobrien printf " /* Skip verify of ${function}, has predicate */\n" 155498944Sobrien # FIXME: See do_read for potential simplification 155598944Sobrien elif [ -n "${invalid_p}" -a -n "${postdefault}" ] 155698944Sobrien then 155798944Sobrien printf " if (${invalid_p})\n" 1558130803Smarcel printf " current_gdbarch->${function} = ${postdefault};\n" 155998944Sobrien elif [ -n "${predefault}" -a -n "${postdefault}" ] 156098944Sobrien then 1561130803Smarcel printf " if (current_gdbarch->${function} == ${predefault})\n" 1562130803Smarcel printf " current_gdbarch->${function} = ${postdefault};\n" 156398944Sobrien elif [ -n "${postdefault}" ] 156498944Sobrien then 1565130803Smarcel printf " if (current_gdbarch->${function} == 0)\n" 1566130803Smarcel printf " current_gdbarch->${function} = ${postdefault};\n" 156798944Sobrien elif [ -n "${invalid_p}" ] 156898944Sobrien then 156998944Sobrien printf " if ((GDB_MULTI_ARCH ${gt_level})\n" 157098944Sobrien printf " && (${invalid_p}))\n" 157198944Sobrien printf " fprintf_unfiltered (log, \"\\\\n\\\\t${function}\");\n" 157298944Sobrien elif [ -n "${predefault}" ] 157398944Sobrien then 157498944Sobrien printf " if ((GDB_MULTI_ARCH ${gt_level})\n" 1575130803Smarcel printf " && (current_gdbarch->${function} == ${predefault}))\n" 157698944Sobrien printf " fprintf_unfiltered (log, \"\\\\n\\\\t${function}\");\n" 157798944Sobrien fi 157898944Sobrien fi 157998944Sobriendone 158098944Sobriencat <<EOF 158198944Sobrien buf = ui_file_xstrdup (log, &dummy); 158298944Sobrien make_cleanup (xfree, buf); 158398944Sobrien if (strlen (buf) > 0) 158498944Sobrien internal_error (__FILE__, __LINE__, 158598944Sobrien "verify_gdbarch: the following are invalid ...%s", 158698944Sobrien buf); 158798944Sobrien do_cleanups (cleanups); 158898944Sobrien} 158998944SobrienEOF 159098944Sobrien 159198944Sobrien# dump the structure 159298944Sobrienprintf "\n" 159398944Sobrienprintf "\n" 159498944Sobriencat <<EOF 159598944Sobrien/* Print out the details of the current architecture. */ 159698944Sobrien 159798944Sobrien/* NOTE/WARNING: The parameter is called \`\`current_gdbarch'' so that it 159898944Sobrien just happens to match the global variable \`\`current_gdbarch''. That 159998944Sobrien way macros refering to that variable get the local and not the global 160098944Sobrien version - ulgh. Once everything is parameterised with gdbarch, this 160198944Sobrien will go away. */ 160298944Sobrien 160398944Sobrienvoid 1604130803Smarcelgdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) 160598944Sobrien{ 160698944Sobrien fprintf_unfiltered (file, 160798944Sobrien "gdbarch_dump: GDB_MULTI_ARCH = %d\\n", 160898944Sobrien GDB_MULTI_ARCH); 160998944SobrienEOF 1610130803Smarcelfunction_list | sort -t: -k 3 | while do_read 161198944Sobriendo 1612130803Smarcel # First the predicate 1613130803Smarcel if class_is_predicate_p 1614130803Smarcel then 1615130803Smarcel if class_is_multiarch_p 1616130803Smarcel then 1617130803Smarcel printf " fprintf_unfiltered (file,\n" 1618130803Smarcel printf " \"gdbarch_dump: gdbarch_${function}_p() = %%d\\\\n\",\n" 1619130803Smarcel printf " gdbarch_${function}_p (current_gdbarch));\n" 1620130803Smarcel else 1621130803Smarcel printf "#ifdef ${macro}_P\n" 1622130803Smarcel printf " fprintf_unfiltered (file,\n" 1623130803Smarcel printf " \"gdbarch_dump: %%s # %%s\\\\n\",\n" 1624130803Smarcel printf " \"${macro}_P()\",\n" 1625130803Smarcel printf " XSTRING (${macro}_P ()));\n" 1626130803Smarcel printf " fprintf_unfiltered (file,\n" 1627130803Smarcel printf " \"gdbarch_dump: ${macro}_P() = %%d\\\\n\",\n" 1628130803Smarcel printf " ${macro}_P ());\n" 1629130803Smarcel printf "#endif\n" 1630130803Smarcel fi 1631130803Smarcel fi 163298944Sobrien # multiarch functions don't have macros. 163398944Sobrien if class_is_multiarch_p 163498944Sobrien then 1635130803Smarcel printf " fprintf_unfiltered (file,\n" 1636130803Smarcel printf " \"gdbarch_dump: ${function} = 0x%%08lx\\\\n\",\n" 1637130803Smarcel printf " (long) current_gdbarch->${function});\n" 163898944Sobrien continue 163998944Sobrien fi 164098944Sobrien # Print the macro definition. 164198944Sobrien printf "#ifdef ${macro}\n" 164298944Sobrien if class_is_function_p 164398944Sobrien then 164498944Sobrien printf " fprintf_unfiltered (file,\n" 164598944Sobrien printf " \"gdbarch_dump: %%s # %%s\\\\n\",\n" 164698944Sobrien printf " \"${macro}(${actual})\",\n" 164798944Sobrien printf " XSTRING (${macro} (${actual})));\n" 164898944Sobrien else 164998944Sobrien printf " fprintf_unfiltered (file,\n" 165098944Sobrien printf " \"gdbarch_dump: ${macro} # %%s\\\\n\",\n" 165198944Sobrien printf " XSTRING (${macro}));\n" 165298944Sobrien fi 165398944Sobrien if [ "x${print_p}" = "x()" ] 165498944Sobrien then 165598944Sobrien printf " gdbarch_dump_${function} (current_gdbarch);\n" 165698944Sobrien elif [ "x${print_p}" = "x0" ] 165798944Sobrien then 165898944Sobrien printf " /* skip print of ${macro}, print_p == 0. */\n" 165998944Sobrien elif [ -n "${print_p}" ] 166098944Sobrien then 166198944Sobrien printf " if (${print_p})\n" 166298944Sobrien printf " fprintf_unfiltered (file,\n" 166398944Sobrien printf " \"gdbarch_dump: ${macro} = %s\\\\n\",\n" "${fmt}" 166498944Sobrien printf " ${print});\n" 166598944Sobrien elif class_is_function_p 166698944Sobrien then 1667130803Smarcel printf " fprintf_unfiltered (file,\n" 1668130803Smarcel printf " \"gdbarch_dump: ${macro} = <0x%%08lx>\\\\n\",\n" 1669130803Smarcel printf " (long) current_gdbarch->${function}\n" 1670130803Smarcel printf " /*${macro} ()*/);\n" 167198944Sobrien else 167298944Sobrien printf " fprintf_unfiltered (file,\n" 167398944Sobrien printf " \"gdbarch_dump: ${macro} = %s\\\\n\",\n" "${fmt}" 167498944Sobrien printf " ${print});\n" 167598944Sobrien fi 167698944Sobrien printf "#endif\n" 167798944Sobriendone 167898944Sobriencat <<EOF 167998944Sobrien if (current_gdbarch->dump_tdep != NULL) 168098944Sobrien current_gdbarch->dump_tdep (current_gdbarch, file); 168198944Sobrien} 168298944SobrienEOF 168398944Sobrien 168498944Sobrien 168598944Sobrien# GET/SET 168698944Sobrienprintf "\n" 168798944Sobriencat <<EOF 168898944Sobrienstruct gdbarch_tdep * 168998944Sobriengdbarch_tdep (struct gdbarch *gdbarch) 169098944Sobrien{ 169198944Sobrien if (gdbarch_debug >= 2) 169298944Sobrien fprintf_unfiltered (gdb_stdlog, "gdbarch_tdep called\\n"); 169398944Sobrien return gdbarch->tdep; 169498944Sobrien} 169598944SobrienEOF 169698944Sobrienprintf "\n" 169798944Sobrienfunction_list | while do_read 169898944Sobriendo 169998944Sobrien if class_is_predicate_p 170098944Sobrien then 170198944Sobrien printf "\n" 170298944Sobrien printf "int\n" 170398944Sobrien printf "gdbarch_${function}_p (struct gdbarch *gdbarch)\n" 170498944Sobrien printf "{\n" 1705130803Smarcel printf " gdb_assert (gdbarch != NULL);\n" 1706130803Smarcel printf " return ${predicate};\n" 170798944Sobrien printf "}\n" 170898944Sobrien fi 170998944Sobrien if class_is_function_p 171098944Sobrien then 171198944Sobrien printf "\n" 171298944Sobrien printf "${returntype}\n" 171398944Sobrien if [ "x${formal}" = "xvoid" ] 171498944Sobrien then 171598944Sobrien printf "gdbarch_${function} (struct gdbarch *gdbarch)\n" 171698944Sobrien else 171798944Sobrien printf "gdbarch_${function} (struct gdbarch *gdbarch, ${formal})\n" 171898944Sobrien fi 171998944Sobrien printf "{\n" 1720130803Smarcel printf " gdb_assert (gdbarch != NULL);\n" 1721130803Smarcel printf " gdb_assert (gdbarch->${function} != NULL);\n" 1722130803Smarcel if class_is_predicate_p && test -n "${predefault}" 1723130803Smarcel then 1724130803Smarcel # Allow a call to a function with a predicate. 1725130803Smarcel printf " /* Do not check predicate: ${predicate}, allow call. */\n" 1726130803Smarcel fi 172798944Sobrien printf " if (gdbarch_debug >= 2)\n" 172898944Sobrien printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\\\\n\");\n" 172998944Sobrien if [ "x${actual}" = "x-" -o "x${actual}" = "x" ] 173098944Sobrien then 173198944Sobrien if class_is_multiarch_p 173298944Sobrien then 173398944Sobrien params="gdbarch" 173498944Sobrien else 173598944Sobrien params="" 173698944Sobrien fi 173798944Sobrien else 173898944Sobrien if class_is_multiarch_p 173998944Sobrien then 174098944Sobrien params="gdbarch, ${actual}" 174198944Sobrien else 174298944Sobrien params="${actual}" 174398944Sobrien fi 174498944Sobrien fi 174598944Sobrien if [ "x${returntype}" = "xvoid" ] 174698944Sobrien then 174798944Sobrien printf " gdbarch->${function} (${params});\n" 174898944Sobrien else 174998944Sobrien printf " return gdbarch->${function} (${params});\n" 175098944Sobrien fi 175198944Sobrien printf "}\n" 175298944Sobrien printf "\n" 175398944Sobrien printf "void\n" 175498944Sobrien printf "set_gdbarch_${function} (struct gdbarch *gdbarch,\n" 175598944Sobrien printf " `echo ${function} | sed -e 's/./ /g'` gdbarch_${function}_ftype ${function})\n" 175698944Sobrien printf "{\n" 175798944Sobrien printf " gdbarch->${function} = ${function};\n" 175898944Sobrien printf "}\n" 175998944Sobrien elif class_is_variable_p 176098944Sobrien then 176198944Sobrien printf "\n" 176298944Sobrien printf "${returntype}\n" 176398944Sobrien printf "gdbarch_${function} (struct gdbarch *gdbarch)\n" 176498944Sobrien printf "{\n" 1765130803Smarcel printf " gdb_assert (gdbarch != NULL);\n" 176698944Sobrien if [ "x${invalid_p}" = "x0" ] 176798944Sobrien then 176898944Sobrien printf " /* Skip verify of ${function}, invalid_p == 0 */\n" 176998944Sobrien elif [ -n "${invalid_p}" ] 177098944Sobrien then 1771130803Smarcel printf " /* Check variable is valid. */\n" 1772130803Smarcel printf " gdb_assert (!(${invalid_p}));\n" 177398944Sobrien elif [ -n "${predefault}" ] 177498944Sobrien then 1775130803Smarcel printf " /* Check variable changed from pre-default. */\n" 1776130803Smarcel printf " gdb_assert (gdbarch->${function} != ${predefault});\n" 177798944Sobrien fi 177898944Sobrien printf " if (gdbarch_debug >= 2)\n" 177998944Sobrien printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\\\\n\");\n" 178098944Sobrien printf " return gdbarch->${function};\n" 178198944Sobrien printf "}\n" 178298944Sobrien printf "\n" 178398944Sobrien printf "void\n" 178498944Sobrien printf "set_gdbarch_${function} (struct gdbarch *gdbarch,\n" 178598944Sobrien printf " `echo ${function} | sed -e 's/./ /g'` ${returntype} ${function})\n" 178698944Sobrien printf "{\n" 178798944Sobrien printf " gdbarch->${function} = ${function};\n" 178898944Sobrien printf "}\n" 178998944Sobrien elif class_is_info_p 179098944Sobrien then 179198944Sobrien printf "\n" 179298944Sobrien printf "${returntype}\n" 179398944Sobrien printf "gdbarch_${function} (struct gdbarch *gdbarch)\n" 179498944Sobrien printf "{\n" 1795130803Smarcel printf " gdb_assert (gdbarch != NULL);\n" 179698944Sobrien printf " if (gdbarch_debug >= 2)\n" 179798944Sobrien printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\\\\n\");\n" 179898944Sobrien printf " return gdbarch->${function};\n" 179998944Sobrien printf "}\n" 180098944Sobrien fi 180198944Sobriendone 180298944Sobrien 180398944Sobrien# All the trailing guff 180498944Sobriencat <<EOF 180598944Sobrien 180698944Sobrien 180798944Sobrien/* Keep a registry of per-architecture data-pointers required by GDB 180898944Sobrien modules. */ 180998944Sobrien 181098944Sobrienstruct gdbarch_data 181198944Sobrien{ 181298944Sobrien unsigned index; 1813130803Smarcel int init_p; 181498944Sobrien gdbarch_data_init_ftype *init; 181598944Sobrien}; 181698944Sobrien 181798944Sobrienstruct gdbarch_data_registration 181898944Sobrien{ 181998944Sobrien struct gdbarch_data *data; 182098944Sobrien struct gdbarch_data_registration *next; 182198944Sobrien}; 182298944Sobrien 182398944Sobrienstruct gdbarch_data_registry 182498944Sobrien{ 182598944Sobrien unsigned nr; 182698944Sobrien struct gdbarch_data_registration *registrations; 182798944Sobrien}; 182898944Sobrien 182998944Sobrienstruct gdbarch_data_registry gdbarch_data_registry = 183098944Sobrien{ 183198944Sobrien 0, NULL, 183298944Sobrien}; 183398944Sobrien 183498944Sobrienstruct gdbarch_data * 1835130803Smarcelregister_gdbarch_data (gdbarch_data_init_ftype *init) 183698944Sobrien{ 183798944Sobrien struct gdbarch_data_registration **curr; 1838130803Smarcel /* Append the new registraration. */ 183998944Sobrien for (curr = &gdbarch_data_registry.registrations; 184098944Sobrien (*curr) != NULL; 184198944Sobrien curr = &(*curr)->next); 184298944Sobrien (*curr) = XMALLOC (struct gdbarch_data_registration); 184398944Sobrien (*curr)->next = NULL; 184498944Sobrien (*curr)->data = XMALLOC (struct gdbarch_data); 184598944Sobrien (*curr)->data->index = gdbarch_data_registry.nr++; 184698944Sobrien (*curr)->data->init = init; 1847130803Smarcel (*curr)->data->init_p = 1; 184898944Sobrien return (*curr)->data; 184998944Sobrien} 185098944Sobrien 185198944Sobrien 185298944Sobrien/* Create/delete the gdbarch data vector. */ 185398944Sobrien 185498944Sobrienstatic void 185598944Sobrienalloc_gdbarch_data (struct gdbarch *gdbarch) 185698944Sobrien{ 185798944Sobrien gdb_assert (gdbarch->data == NULL); 185898944Sobrien gdbarch->nr_data = gdbarch_data_registry.nr; 1859130803Smarcel gdbarch->data = GDBARCH_OBSTACK_CALLOC (gdbarch, gdbarch->nr_data, void *); 186098944Sobrien} 186198944Sobrien 1862130803Smarcel/* Initialize the current value of the specified per-architecture 186398944Sobrien data-pointer. */ 186498944Sobrien 186598944Sobrienvoid 186698944Sobrienset_gdbarch_data (struct gdbarch *gdbarch, 186798944Sobrien struct gdbarch_data *data, 186898944Sobrien void *pointer) 186998944Sobrien{ 187098944Sobrien gdb_assert (data->index < gdbarch->nr_data); 1871130803Smarcel gdb_assert (gdbarch->data[data->index] == NULL); 187298944Sobrien gdbarch->data[data->index] = pointer; 187398944Sobrien} 187498944Sobrien 187598944Sobrien/* Return the current value of the specified per-architecture 187698944Sobrien data-pointer. */ 187798944Sobrien 187898944Sobrienvoid * 1879130803Smarcelgdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data) 188098944Sobrien{ 1881130803Smarcel gdb_assert (data->index < gdbarch->nr_data); 1882130803Smarcel /* The data-pointer isn't initialized, call init() to get a value but 1883130803Smarcel only if the architecture initializaiton has completed. Otherwise 1884130803Smarcel punt - hope that the caller knows what they are doing. */ 1885130803Smarcel if (gdbarch->data[data->index] == NULL 1886130803Smarcel && gdbarch->initialized_p) 1887130803Smarcel { 1888130803Smarcel /* Be careful to detect an initialization cycle. */ 1889130803Smarcel gdb_assert (data->init_p); 1890130803Smarcel data->init_p = 0; 1891130803Smarcel gdb_assert (data->init != NULL); 1892130803Smarcel gdbarch->data[data->index] = data->init (gdbarch); 1893130803Smarcel data->init_p = 1; 1894130803Smarcel gdb_assert (gdbarch->data[data->index] != NULL); 1895130803Smarcel } 1896130803Smarcel return gdbarch->data[data->index]; 189798944Sobrien} 189898944Sobrien 189998944Sobrien 190098944Sobrien 190198944Sobrien/* Keep a registry of swapped data required by GDB modules. */ 190298944Sobrien 190398944Sobrienstruct gdbarch_swap 190498944Sobrien{ 190598944Sobrien void *swap; 190698944Sobrien struct gdbarch_swap_registration *source; 190798944Sobrien struct gdbarch_swap *next; 190898944Sobrien}; 190998944Sobrien 191098944Sobrienstruct gdbarch_swap_registration 191198944Sobrien{ 191298944Sobrien void *data; 191398944Sobrien unsigned long sizeof_data; 191498944Sobrien gdbarch_swap_ftype *init; 191598944Sobrien struct gdbarch_swap_registration *next; 191698944Sobrien}; 191798944Sobrien 191898944Sobrienstruct gdbarch_swap_registry 191998944Sobrien{ 192098944Sobrien int nr; 192198944Sobrien struct gdbarch_swap_registration *registrations; 192298944Sobrien}; 192398944Sobrien 192498944Sobrienstruct gdbarch_swap_registry gdbarch_swap_registry = 192598944Sobrien{ 192698944Sobrien 0, NULL, 192798944Sobrien}; 192898944Sobrien 192998944Sobrienvoid 1930130803Smarceldeprecated_register_gdbarch_swap (void *data, 1931130803Smarcel unsigned long sizeof_data, 1932130803Smarcel gdbarch_swap_ftype *init) 193398944Sobrien{ 193498944Sobrien struct gdbarch_swap_registration **rego; 193598944Sobrien for (rego = &gdbarch_swap_registry.registrations; 193698944Sobrien (*rego) != NULL; 193798944Sobrien rego = &(*rego)->next); 193898944Sobrien (*rego) = XMALLOC (struct gdbarch_swap_registration); 193998944Sobrien (*rego)->next = NULL; 194098944Sobrien (*rego)->init = init; 194198944Sobrien (*rego)->data = data; 194298944Sobrien (*rego)->sizeof_data = sizeof_data; 194398944Sobrien} 194498944Sobrien 194598944Sobrienstatic void 1946130803Smarcelcurrent_gdbarch_swap_init_hack (void) 194798944Sobrien{ 194898944Sobrien struct gdbarch_swap_registration *rego; 1949130803Smarcel struct gdbarch_swap **curr = ¤t_gdbarch->swap; 195098944Sobrien for (rego = gdbarch_swap_registry.registrations; 195198944Sobrien rego != NULL; 195298944Sobrien rego = rego->next) 195398944Sobrien { 195498944Sobrien if (rego->data != NULL) 195598944Sobrien { 1956130803Smarcel (*curr) = GDBARCH_OBSTACK_ZALLOC (current_gdbarch, 1957130803Smarcel struct gdbarch_swap); 195898944Sobrien (*curr)->source = rego; 1959130803Smarcel (*curr)->swap = gdbarch_obstack_zalloc (current_gdbarch, 1960130803Smarcel rego->sizeof_data); 196198944Sobrien (*curr)->next = NULL; 196298944Sobrien curr = &(*curr)->next; 196398944Sobrien } 196498944Sobrien if (rego->init != NULL) 196598944Sobrien rego->init (); 196698944Sobrien } 196798944Sobrien} 196898944Sobrien 1969130803Smarcelstatic struct gdbarch * 1970130803Smarcelcurrent_gdbarch_swap_out_hack (void) 197198944Sobrien{ 1972130803Smarcel struct gdbarch *old_gdbarch = current_gdbarch; 197398944Sobrien struct gdbarch_swap *curr; 1974130803Smarcel 1975130803Smarcel gdb_assert (old_gdbarch != NULL); 1976130803Smarcel for (curr = old_gdbarch->swap; 197798944Sobrien curr != NULL; 197898944Sobrien curr = curr->next) 1979130803Smarcel { 1980130803Smarcel memcpy (curr->swap, curr->source->data, curr->source->sizeof_data); 1981130803Smarcel memset (curr->source->data, 0, curr->source->sizeof_data); 1982130803Smarcel } 1983130803Smarcel current_gdbarch = NULL; 1984130803Smarcel return old_gdbarch; 198598944Sobrien} 198698944Sobrien 198798944Sobrienstatic void 1988130803Smarcelcurrent_gdbarch_swap_in_hack (struct gdbarch *new_gdbarch) 198998944Sobrien{ 199098944Sobrien struct gdbarch_swap *curr; 1991130803Smarcel 1992130803Smarcel gdb_assert (current_gdbarch == NULL); 1993130803Smarcel for (curr = new_gdbarch->swap; 199498944Sobrien curr != NULL; 199598944Sobrien curr = curr->next) 199698944Sobrien memcpy (curr->source->data, curr->swap, curr->source->sizeof_data); 1997130803Smarcel current_gdbarch = new_gdbarch; 199898944Sobrien} 199998944Sobrien 200098944Sobrien 200198944Sobrien/* Keep a registry of the architectures known by GDB. */ 200298944Sobrien 200398944Sobrienstruct gdbarch_registration 200498944Sobrien{ 200598944Sobrien enum bfd_architecture bfd_architecture; 200698944Sobrien gdbarch_init_ftype *init; 200798944Sobrien gdbarch_dump_tdep_ftype *dump_tdep; 200898944Sobrien struct gdbarch_list *arches; 200998944Sobrien struct gdbarch_registration *next; 201098944Sobrien}; 201198944Sobrien 201298944Sobrienstatic struct gdbarch_registration *gdbarch_registry = NULL; 201398944Sobrien 201498944Sobrienstatic void 201598944Sobrienappend_name (const char ***buf, int *nr, const char *name) 201698944Sobrien{ 201798944Sobrien *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1)); 201898944Sobrien (*buf)[*nr] = name; 201998944Sobrien *nr += 1; 202098944Sobrien} 202198944Sobrien 202298944Sobrienconst char ** 202398944Sobriengdbarch_printable_names (void) 202498944Sobrien{ 2025130803Smarcel /* Accumulate a list of names based on the registed list of 2026130803Smarcel architectures. */ 2027130803Smarcel enum bfd_architecture a; 2028130803Smarcel int nr_arches = 0; 2029130803Smarcel const char **arches = NULL; 2030130803Smarcel struct gdbarch_registration *rego; 2031130803Smarcel for (rego = gdbarch_registry; 2032130803Smarcel rego != NULL; 2033130803Smarcel rego = rego->next) 203498944Sobrien { 2035130803Smarcel const struct bfd_arch_info *ap; 2036130803Smarcel ap = bfd_lookup_arch (rego->bfd_architecture, 0); 2037130803Smarcel if (ap == NULL) 2038130803Smarcel internal_error (__FILE__, __LINE__, 2039130803Smarcel "gdbarch_architecture_names: multi-arch unknown"); 2040130803Smarcel do 2041130803Smarcel { 2042130803Smarcel append_name (&arches, &nr_arches, ap->printable_name); 2043130803Smarcel ap = ap->next; 2044130803Smarcel } 2045130803Smarcel while (ap != NULL); 204698944Sobrien } 2047130803Smarcel append_name (&arches, &nr_arches, NULL); 2048130803Smarcel return arches; 204998944Sobrien} 205098944Sobrien 205198944Sobrien 205298944Sobrienvoid 205398944Sobriengdbarch_register (enum bfd_architecture bfd_architecture, 205498944Sobrien gdbarch_init_ftype *init, 205598944Sobrien gdbarch_dump_tdep_ftype *dump_tdep) 205698944Sobrien{ 205798944Sobrien struct gdbarch_registration **curr; 205898944Sobrien const struct bfd_arch_info *bfd_arch_info; 205998944Sobrien /* Check that BFD recognizes this architecture */ 206098944Sobrien bfd_arch_info = bfd_lookup_arch (bfd_architecture, 0); 206198944Sobrien if (bfd_arch_info == NULL) 206298944Sobrien { 206398944Sobrien internal_error (__FILE__, __LINE__, 206498944Sobrien "gdbarch: Attempt to register unknown architecture (%d)", 206598944Sobrien bfd_architecture); 206698944Sobrien } 206798944Sobrien /* Check that we haven't seen this architecture before */ 206898944Sobrien for (curr = &gdbarch_registry; 206998944Sobrien (*curr) != NULL; 207098944Sobrien curr = &(*curr)->next) 207198944Sobrien { 207298944Sobrien if (bfd_architecture == (*curr)->bfd_architecture) 207398944Sobrien internal_error (__FILE__, __LINE__, 207498944Sobrien "gdbarch: Duplicate registraration of architecture (%s)", 207598944Sobrien bfd_arch_info->printable_name); 207698944Sobrien } 207798944Sobrien /* log it */ 207898944Sobrien if (gdbarch_debug) 207998944Sobrien fprintf_unfiltered (gdb_stdlog, "register_gdbarch_init (%s, 0x%08lx)\n", 208098944Sobrien bfd_arch_info->printable_name, 208198944Sobrien (long) init); 208298944Sobrien /* Append it */ 208398944Sobrien (*curr) = XMALLOC (struct gdbarch_registration); 208498944Sobrien (*curr)->bfd_architecture = bfd_architecture; 208598944Sobrien (*curr)->init = init; 208698944Sobrien (*curr)->dump_tdep = dump_tdep; 208798944Sobrien (*curr)->arches = NULL; 208898944Sobrien (*curr)->next = NULL; 208998944Sobrien} 209098944Sobrien 209198944Sobrienvoid 209298944Sobrienregister_gdbarch_init (enum bfd_architecture bfd_architecture, 209398944Sobrien gdbarch_init_ftype *init) 209498944Sobrien{ 209598944Sobrien gdbarch_register (bfd_architecture, init, NULL); 209698944Sobrien} 209798944Sobrien 209898944Sobrien 209998944Sobrien/* Look for an architecture using gdbarch_info. Base search on only 210098944Sobrien BFD_ARCH_INFO and BYTE_ORDER. */ 210198944Sobrien 210298944Sobrienstruct gdbarch_list * 210398944Sobriengdbarch_list_lookup_by_info (struct gdbarch_list *arches, 210498944Sobrien const struct gdbarch_info *info) 210598944Sobrien{ 210698944Sobrien for (; arches != NULL; arches = arches->next) 210798944Sobrien { 210898944Sobrien if (info->bfd_arch_info != arches->gdbarch->bfd_arch_info) 210998944Sobrien continue; 211098944Sobrien if (info->byte_order != arches->gdbarch->byte_order) 211198944Sobrien continue; 2112130803Smarcel if (info->osabi != arches->gdbarch->osabi) 2113130803Smarcel continue; 211498944Sobrien return arches; 211598944Sobrien } 211698944Sobrien return NULL; 211798944Sobrien} 211898944Sobrien 211998944Sobrien 2120130803Smarcel/* Find an architecture that matches the specified INFO. Create a new 2121130803Smarcel architecture if needed. Return that new architecture. Assumes 2122130803Smarcel that there is no current architecture. */ 212398944Sobrien 2124130803Smarcelstatic struct gdbarch * 2125130803Smarcelfind_arch_by_info (struct gdbarch *old_gdbarch, struct gdbarch_info info) 212698944Sobrien{ 212798944Sobrien struct gdbarch *new_gdbarch; 212898944Sobrien struct gdbarch_registration *rego; 212998944Sobrien 2130130803Smarcel /* The existing architecture has been swapped out - all this code 2131130803Smarcel works from a clean slate. */ 2132130803Smarcel gdb_assert (current_gdbarch == NULL); 2133130803Smarcel 213498944Sobrien /* Fill in missing parts of the INFO struct using a number of 2135130803Smarcel sources: "set ..."; INFOabfd supplied; and the existing 2136130803Smarcel architecture. */ 2137130803Smarcel gdbarch_info_fill (old_gdbarch, &info); 213898944Sobrien 213998944Sobrien /* Must have found some sort of architecture. */ 214098944Sobrien gdb_assert (info.bfd_arch_info != NULL); 214198944Sobrien 214298944Sobrien if (gdbarch_debug) 214398944Sobrien { 214498944Sobrien fprintf_unfiltered (gdb_stdlog, 2145130803Smarcel "find_arch_by_info: info.bfd_arch_info %s\n", 214698944Sobrien (info.bfd_arch_info != NULL 214798944Sobrien ? info.bfd_arch_info->printable_name 214898944Sobrien : "(null)")); 214998944Sobrien fprintf_unfiltered (gdb_stdlog, 2150130803Smarcel "find_arch_by_info: info.byte_order %d (%s)\n", 215198944Sobrien info.byte_order, 215298944Sobrien (info.byte_order == BFD_ENDIAN_BIG ? "big" 215398944Sobrien : info.byte_order == BFD_ENDIAN_LITTLE ? "little" 215498944Sobrien : "default")); 215598944Sobrien fprintf_unfiltered (gdb_stdlog, 2156130803Smarcel "find_arch_by_info: info.osabi %d (%s)\n", 2157130803Smarcel info.osabi, gdbarch_osabi_name (info.osabi)); 2158130803Smarcel fprintf_unfiltered (gdb_stdlog, 2159130803Smarcel "find_arch_by_info: info.abfd 0x%lx\n", 216098944Sobrien (long) info.abfd); 216198944Sobrien fprintf_unfiltered (gdb_stdlog, 2162130803Smarcel "find_arch_by_info: info.tdep_info 0x%lx\n", 216398944Sobrien (long) info.tdep_info); 216498944Sobrien } 216598944Sobrien 2166130803Smarcel /* Find the tdep code that knows about this architecture. */ 216798944Sobrien for (rego = gdbarch_registry; 216898944Sobrien rego != NULL; 216998944Sobrien rego = rego->next) 217098944Sobrien if (rego->bfd_architecture == info.bfd_arch_info->arch) 217198944Sobrien break; 217298944Sobrien if (rego == NULL) 217398944Sobrien { 217498944Sobrien if (gdbarch_debug) 2175130803Smarcel fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: " 2176130803Smarcel "No matching architecture\n"); 217798944Sobrien return 0; 217898944Sobrien } 217998944Sobrien 2180130803Smarcel /* Ask the tdep code for an architecture that matches "info". */ 218198944Sobrien new_gdbarch = rego->init (info, rego->arches); 218298944Sobrien 2183130803Smarcel /* Did the tdep code like it? No. Reject the change and revert to 2184130803Smarcel the old architecture. */ 218598944Sobrien if (new_gdbarch == NULL) 218698944Sobrien { 218798944Sobrien if (gdbarch_debug) 2188130803Smarcel fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: " 2189130803Smarcel "Target rejected architecture\n"); 2190130803Smarcel return NULL; 219198944Sobrien } 219298944Sobrien 2193130803Smarcel /* Is this a pre-existing architecture (as determined by already 2194130803Smarcel being initialized)? Move it to the front of the architecture 2195130803Smarcel list (keeping the list sorted Most Recently Used). */ 2196130803Smarcel if (new_gdbarch->initialized_p) 219798944Sobrien { 2198130803Smarcel struct gdbarch_list **list; 2199130803Smarcel struct gdbarch_list *this; 220098944Sobrien if (gdbarch_debug) 2201130803Smarcel fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: " 2202130803Smarcel "Previous architecture 0x%08lx (%s) selected\n", 220398944Sobrien (long) new_gdbarch, 220498944Sobrien new_gdbarch->bfd_arch_info->printable_name); 2205130803Smarcel /* Find the existing arch in the list. */ 2206130803Smarcel for (list = ®o->arches; 2207130803Smarcel (*list) != NULL && (*list)->gdbarch != new_gdbarch; 2208130803Smarcel list = &(*list)->next); 2209130803Smarcel /* It had better be in the list of architectures. */ 2210130803Smarcel gdb_assert ((*list) != NULL && (*list)->gdbarch == new_gdbarch); 2211130803Smarcel /* Unlink THIS. */ 2212130803Smarcel this = (*list); 2213130803Smarcel (*list) = this->next; 2214130803Smarcel /* Insert THIS at the front. */ 2215130803Smarcel this->next = rego->arches; 2216130803Smarcel rego->arches = this; 2217130803Smarcel /* Return it. */ 2218130803Smarcel return new_gdbarch; 221998944Sobrien } 222098944Sobrien 2221130803Smarcel /* It's a new architecture. */ 222298944Sobrien if (gdbarch_debug) 2223130803Smarcel fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: " 2224130803Smarcel "New architecture 0x%08lx (%s) selected\n", 2225130803Smarcel (long) new_gdbarch, 2226130803Smarcel new_gdbarch->bfd_arch_info->printable_name); 222798944Sobrien 2228130803Smarcel /* Insert the new architecture into the front of the architecture 2229130803Smarcel list (keep the list sorted Most Recently Used). */ 2230130803Smarcel { 2231130803Smarcel struct gdbarch_list *this = XMALLOC (struct gdbarch_list); 2232130803Smarcel this->next = rego->arches; 2233130803Smarcel this->gdbarch = new_gdbarch; 2234130803Smarcel rego->arches = this; 2235130803Smarcel } 2236130803Smarcel 223798944Sobrien /* Check that the newly installed architecture is valid. Plug in 223898944Sobrien any post init values. */ 223998944Sobrien new_gdbarch->dump_tdep = rego->dump_tdep; 224098944Sobrien verify_gdbarch (new_gdbarch); 2241130803Smarcel new_gdbarch->initialized_p = 1; 224298944Sobrien 2243130803Smarcel /* Initialize any per-architecture swap areas. This phase requires 2244130803Smarcel a valid global CURRENT_GDBARCH. Set it momentarially, and then 2245130803Smarcel swap the entire architecture out. */ 2246130803Smarcel current_gdbarch = new_gdbarch; 2247130803Smarcel current_gdbarch_swap_init_hack (); 2248130803Smarcel current_gdbarch_swap_out_hack (); 224998944Sobrien 225098944Sobrien if (gdbarch_debug) 2251130803Smarcel gdbarch_dump (new_gdbarch, gdb_stdlog); 225298944Sobrien 2253130803Smarcel return new_gdbarch; 225498944Sobrien} 225598944Sobrien 2256130803Smarcelstruct gdbarch * 2257130803Smarcelgdbarch_find_by_info (struct gdbarch_info info) 2258130803Smarcel{ 2259130803Smarcel /* Save the previously selected architecture, setting the global to 2260130803Smarcel NULL. This stops things like gdbarch->init() trying to use the 2261130803Smarcel previous architecture's configuration. The previous architecture 2262130803Smarcel may not even be of the same architecture family. The most recent 2263130803Smarcel architecture of the same family is found at the head of the 2264130803Smarcel rego->arches list. */ 2265130803Smarcel struct gdbarch *old_gdbarch = current_gdbarch_swap_out_hack (); 226698944Sobrien 2267130803Smarcel /* Find the specified architecture. */ 2268130803Smarcel struct gdbarch *new_gdbarch = find_arch_by_info (old_gdbarch, info); 226998944Sobrien 2270130803Smarcel /* Restore the existing architecture. */ 2271130803Smarcel gdb_assert (current_gdbarch == NULL); 2272130803Smarcel current_gdbarch_swap_in_hack (old_gdbarch); 227398944Sobrien 2274130803Smarcel return new_gdbarch; 2275130803Smarcel} 227698944Sobrien 2277130803Smarcel/* Make the specified architecture current, swapping the existing one 2278130803Smarcel out. */ 2279130803Smarcel 2280130803Smarcelvoid 2281130803Smarceldeprecated_current_gdbarch_select_hack (struct gdbarch *new_gdbarch) 2282130803Smarcel{ 2283130803Smarcel gdb_assert (new_gdbarch != NULL); 2284130803Smarcel gdb_assert (current_gdbarch != NULL); 2285130803Smarcel gdb_assert (new_gdbarch->initialized_p); 2286130803Smarcel current_gdbarch_swap_out_hack (); 2287130803Smarcel current_gdbarch_swap_in_hack (new_gdbarch); 2288130803Smarcel architecture_changed_event (); 2289130803Smarcel} 2290130803Smarcel 229198944Sobrienextern void _initialize_gdbarch (void); 229298944Sobrien 229398944Sobrienvoid 229498944Sobrien_initialize_gdbarch (void) 229598944Sobrien{ 229698944Sobrien struct cmd_list_element *c; 229798944Sobrien 229898944Sobrien add_show_from_set (add_set_cmd ("arch", 229998944Sobrien class_maintenance, 230098944Sobrien var_zinteger, 230198944Sobrien (char *)&gdbarch_debug, 230298944Sobrien "Set architecture debugging.\\n\\ 230398944SobrienWhen non-zero, architecture debugging is enabled.", &setdebuglist), 230498944Sobrien &showdebuglist); 230598944Sobrien c = add_set_cmd ("archdebug", 230698944Sobrien class_maintenance, 230798944Sobrien var_zinteger, 230898944Sobrien (char *)&gdbarch_debug, 230998944Sobrien "Set architecture debugging.\\n\\ 231098944SobrienWhen non-zero, architecture debugging is enabled.", &setlist); 231198944Sobrien 231298944Sobrien deprecate_cmd (c, "set debug arch"); 231398944Sobrien deprecate_cmd (add_show_from_set (c, &showlist), "show debug arch"); 231498944Sobrien} 231598944SobrienEOF 231698944Sobrien 231798944Sobrien# close things off 231898944Sobrienexec 1>&2 231998944Sobrien#../move-if-change new-gdbarch.c gdbarch.c 232098944Sobriencompare_new gdbarch.c 2321