2000-08-11 04:55:38 +02:00
#!/bin/sh -u
1999-08-31 03:14:27 +02:00
# Architecture commands for GDB, the GNU debugger.
2004-01-18 00:21:21 +01:00
#
2020-01-01 07:20:01 +01:00
# Copyright (C) 1998-2020 Free Software Foundation, Inc.
1999-08-31 03:14:27 +02:00
#
# This file is part of GDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
2007-08-23 20:19:51 +02:00
# the Free Software Foundation; either version 3 of the License, or
1999-08-31 03:14:27 +02:00
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
2007-08-23 20:19:51 +02:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1999-08-31 03:14:27 +02:00
2006-07-12 20:04:30 +02:00
# Make certain that the script is not running in an internationalized
2002-04-17 20:47:54 +02:00
# environment.
2010-02-01 17:57:01 +01:00
LANG = C ; export LANG
LC_ALL = C ; export LC_ALL
2002-04-17 20:47:54 +02:00
2000-03-30 07:32:23 +02:00
compare_new ( )
{
file = $1
2000-08-11 04:55:38 +02:00
if test ! -r ${ file }
2000-03-30 07:32:23 +02:00
then
echo " ${ file } missing? cp new- ${ file } ${ file } " 1>& 2
2002-02-10 08:37:22 +01:00
elif diff -u ${ file } new-${ file }
2000-03-30 07:32:23 +02:00
then
echo " ${ file } unchanged " 1>& 2
else
echo " ${ file } has changed? cp new- ${ file } ${ file } " 1>& 2
fi
}
# Format of the input table
2007-10-19 14:34:38 +02:00
read = "class returntype function formal actual staticdefault predefault postdefault invalid_p print garbage_at_eol"
2000-04-03 02:00:32 +02:00
do_read ( )
{
2000-08-01 12:31:19 +02:00
comment = ""
class = ""
2012-12-13 11:00:51 +01:00
# On some SH's, 'read' trims leading and trailing whitespace by
# default (e.g., bash), while on others (e.g., dash), it doesn't.
# Set IFS to empty to disable the trimming everywhere.
while IFS = '' read line
2000-08-01 12:31:19 +02:00
do
if test " ${ line } " = ""
then
continue
elif test " ${ line } " = "#" -a " ${ comment } " = ""
2000-06-02 03:59:13 +02:00
then
2000-08-01 12:31:19 +02:00
continue
elif expr " ${ line } " : "#" > /dev/null
2000-06-02 03:59:13 +02:00
then
2000-08-01 12:31:19 +02:00
comment = " ${ comment }
${ line } "
2000-06-02 03:59:13 +02:00
else
2000-09-04 13:40:20 +02:00
# The semantics of IFS varies between different SH's. Some
2017-05-02 19:30:07 +02:00
# treat ``;;' as three fields while some treat it as just two.
# Work around this by eliminating ``;;'' ....
line = "`echo " ${ line } " | sed -e 's/;;/; ;/g' -e 's/;;/; ;/g'`"
2000-09-04 13:40:20 +02:00
2017-05-02 19:30:07 +02:00
OFS = " ${ IFS } " ; IFS = "[;]"
2000-08-01 12:31:19 +02:00
eval read ${ read } <<EOF
${ line }
EOF
IFS = " ${ OFS } "
2004-06-21 17:01:04 +02:00
if test -n " ${ garbage_at_eol } "
then
echo " Garbage at end-of-line in ${ line } " 1>& 2
kill $$
exit 1
fi
2000-09-04 13:40:20 +02:00
# .... and then going back through each field and strip out those
# that ended up with just that space character.
for r in ${ read }
do
if eval test \" \$ { ${ r } } \" = \" \ \"
then
eval ${ r } = ""
fi
done
2001-11-08 02:33:04 +01:00
case " ${ class } " in
m ) staticdefault = " ${ predefault } " ; ;
M ) staticdefault = "0" ; ;
* ) test " ${ staticdefault } " || staticdefault = 0 ; ;
esac
2001-12-25 23:19:40 +01:00
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
case " ${ class } " in
F | V | M )
case " ${ invalid_p } " in
2000-08-01 12:31:19 +02:00
"" )
2003-07-11 05:01:38 +02:00
if test -n " ${ predefault } "
2000-08-01 12:31:19 +02:00
then
#invalid_p="gdbarch->${function} == ${predefault}"
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
predicate = " gdbarch-> ${ function } != ${ predefault } "
2003-07-11 05:01:38 +02:00
elif class_is_variable_p
then
predicate = " gdbarch-> ${ function } != 0 "
elif class_is_function_p
then
predicate = " gdbarch-> ${ function } != NULL "
2000-08-01 12:31:19 +02:00
fi
; ;
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
* )
2002-12-05 16:19:45 +01:00
echo " Predicate function ${ function } with invalid_p. " 1>& 2
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
kill $$
exit 1
; ;
esac
2000-08-01 12:31:19 +02:00
esac
# PREDEFAULT is a valid fallback definition of MEMBER when
# multi-arch is not enabled. This ensures that the
# default value, when multi-arch is the same as the
# default value when not multi-arch. POSTDEFAULT is
# always a valid definition of MEMBER as this again
# ensures consistency.
2001-06-07 22:52:47 +02:00
if [ -n " ${ postdefault } " ]
2000-08-01 12:31:19 +02:00
then
fallbackdefault = " ${ postdefault } "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ predefault } " ]
2000-08-01 12:31:19 +02:00
then
fallbackdefault = " ${ predefault } "
else
2001-10-15 23:38:44 +02:00
fallbackdefault = "0"
2000-08-01 12:31:19 +02:00
fi
#NOT YET: See gdbarch.log for basic verification of
# database
break
2000-06-02 03:59:13 +02:00
fi
2000-08-01 12:31:19 +02:00
done
2001-06-07 22:52:47 +02:00
if [ -n " ${ class } " ]
2000-08-01 12:31:19 +02:00
then
true
2000-04-03 02:00:32 +02:00
else
false
fi
}
1999-08-31 03:14:27 +02:00
2000-06-02 03:59:13 +02:00
fallback_default_p ( )
{
2001-06-07 22:52:47 +02:00
[ -n " ${ postdefault } " -a " x ${ invalid_p } " != "x0" ] \
|| [ -n " ${ predefault } " -a " x ${ invalid_p } " = "x0" ]
2000-06-02 03:59:13 +02:00
}
class_is_variable_p ( )
{
2001-03-17 01:31:22 +01:00
case " ${ class } " in
*v* | *V* ) true ; ;
* ) false ; ;
esac
2000-06-02 03:59:13 +02:00
}
class_is_function_p ( )
{
2001-03-17 01:31:22 +01:00
case " ${ class } " in
*f* | *F* | *m* | *M* ) true ; ;
* ) false ; ;
esac
}
class_is_multiarch_p ( )
{
case " ${ class } " in
*m* | *M* ) true ; ;
* ) false ; ;
esac
2000-06-02 03:59:13 +02:00
}
class_is_predicate_p ( )
{
2001-03-17 01:31:22 +01:00
case " ${ class } " in
*F* | *V* | *M* ) true ; ;
* ) false ; ;
esac
2000-06-02 03:59:13 +02:00
}
class_is_info_p ( )
{
2001-03-17 01:31:22 +01:00
case " ${ class } " in
*i* ) true ; ;
* ) false ; ;
esac
2000-06-02 03:59:13 +02:00
}
1999-09-13 23:40:00 +02:00
# dump out/verify the doco
for field in ${ read }
do
case ${ field } in
class ) : ; ;
1999-12-14 02:06:04 +01:00
2000-04-03 02:00:32 +02:00
# # -> line disable
# f -> function
# hiding a function
2000-04-21 06:17:18 +02:00
# F -> function + predicate
# hiding a function + predicate to test function validity
2000-04-03 02:00:32 +02:00
# v -> variable
# hiding a variable
2000-04-21 06:17:18 +02:00
# V -> variable + predicate
# hiding a variable + predicate to test variables validity
2000-04-03 02:00:32 +02:00
# i -> set from info
# hiding something from the ``struct info'' object
2001-03-17 01:31:22 +01:00
# m -> multi-arch function
# hiding a multi-arch function (parameterised with the architecture)
# M -> multi-arch function + predicate
# hiding a multi-arch function + predicate to test function validity
1999-09-13 23:40:00 +02:00
returntype ) : ; ;
2000-04-03 02:00:32 +02:00
# For functions, the return type; for variables, the data type
1999-09-13 23:40:00 +02:00
function ) : ; ;
2000-04-03 02:00:32 +02:00
# For functions, the member function name; for variables, the
# variable name. Member function names are always prefixed with
# ``gdbarch_'' for name-space purity.
1999-09-13 23:40:00 +02:00
formal ) : ; ;
2000-04-03 02:00:32 +02:00
# The formal argument list. It is assumed that the formal
# argument list includes the actual name of each list element.
# A function with no arguments shall have ``void'' as the
# formal argument list.
1999-09-13 23:40:00 +02:00
actual ) : ; ;
2000-04-03 02:00:32 +02:00
# The list of actual arguments. The arguments specified shall
# match the FORMAL list given above. Functions with out
# arguments leave this blank.
1999-09-13 23:40:00 +02:00
2000-05-30 03:29:26 +02:00
staticdefault ) : ; ;
2000-04-03 02:00:32 +02:00
# To help with the GDB startup a static gdbarch object is
2000-05-30 03:29:26 +02:00
# created. STATICDEFAULT is the value to insert into that
# static gdbarch object. Since this a static object only
# simple expressions can be used.
1999-09-13 23:40:00 +02:00
2000-05-30 03:29:26 +02:00
# If STATICDEFAULT is empty, zero is used.
2000-04-03 02:00:32 +02:00
2000-05-30 03:29:26 +02:00
predefault ) : ; ;
1999-09-13 23:40:00 +02:00
2001-06-16 01:10:55 +02:00
# An initial value to assign to MEMBER of the freshly
# malloc()ed gdbarch object. After initialization, the
# freshly malloc()ed object is passed to the target
# architecture code for further updates.
1999-09-13 23:40:00 +02:00
2000-05-30 03:29:26 +02:00
# If PREDEFAULT is empty, zero is used.
2001-06-16 01:10:55 +02:00
# A non-empty PREDEFAULT, an empty POSTDEFAULT and a zero
# INVALID_P are specified, PREDEFAULT will be used as the
# default for the non- multi-arch target.
# A zero PREDEFAULT function will force the fallback to call
# internal_error().
2000-06-02 03:59:13 +02:00
# Variable declarations can refer to ``gdbarch'' which will
# contain the current architecture. Care should be taken.
2000-05-30 03:29:26 +02:00
postdefault ) : ; ;
# A value to assign to MEMBER of the new gdbarch object should
2001-06-16 01:10:55 +02:00
# the target architecture code fail to change the PREDEFAULT
# value.
2000-05-30 03:29:26 +02:00
# If POSTDEFAULT is empty, no post update is performed.
# If both INVALID_P and POSTDEFAULT are non-empty then
# INVALID_P will be used to determine if MEMBER should be
# changed to POSTDEFAULT.
2001-06-16 01:10:55 +02:00
# If a non-empty POSTDEFAULT and a zero INVALID_P are
# specified, POSTDEFAULT will be used as the default for the
# non- multi-arch target (regardless of the value of
# PREDEFAULT).
2000-06-02 03:59:13 +02:00
# You cannot specify both a zero INVALID_P and a POSTDEFAULT.
2007-11-12 07:47:56 +01:00
# Variable declarations can refer to ``gdbarch'' which
2003-11-10 02:10:55 +01:00
# will contain the current architecture. Care should be
# taken.
1999-09-13 23:40:00 +02:00
1999-12-14 02:06:04 +01:00
invalid_p ) : ; ;
1999-09-13 23:40:00 +02:00
2000-05-30 03:29:26 +02:00
# A predicate equation that validates MEMBER. Non-zero is
2000-04-03 02:00:32 +02:00
# returned if the code creating the new architecture failed to
2000-05-30 03:29:26 +02:00
# initialize MEMBER or the initialized the member is invalid.
# If POSTDEFAULT is non-empty then MEMBER will be updated to
# that value. If POSTDEFAULT is empty then internal_error()
# is called.
# If INVALID_P is empty, a check that MEMBER is no longer
# equal to PREDEFAULT is used.
2000-06-02 03:59:13 +02:00
# The expression ``0'' disables the INVALID_P check making
# PREDEFAULT a legitimate value.
2000-05-30 03:29:26 +02:00
# See also PREDEFAULT and POSTDEFAULT.
1999-09-13 23:40:00 +02:00
print ) : ; ;
2004-08-08 22:50:57 +02:00
# An optional expression that convers MEMBER to a value
# suitable for formatting using %s.
2000-04-03 02:00:32 +02:00
2008-09-05 14:57:16 +02:00
# If PRINT is empty, core_addr_to_string_nz (for CORE_ADDR)
# or plongest (anything else) is used.
1999-09-13 23:40:00 +02:00
2004-06-21 17:01:04 +02:00
garbage_at_eol ) : ; ;
2000-05-30 03:29:26 +02:00
2004-06-21 17:01:04 +02:00
# Catches stray fields.
1999-09-13 23:40:00 +02:00
2002-02-10 08:37:22 +01:00
*)
echo " Bad field ${ field } "
exit 1; ;
1999-09-13 23:40:00 +02:00
esac
done
1999-08-31 03:14:27 +02:00
function_list ( )
{
1999-09-13 23:40:00 +02:00
# See below (DOCO) for description of each field
2000-08-01 12:31:19 +02:00
cat <<EOF
2017-05-02 19:30:07 +02:00
i; const struct bfd_arch_info *; bfd_arch_info; ; ; & bfd_default_arch_struct; ; ; ; gdbarch_bfd_arch_info ( gdbarch) ->printable_name
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
i; enum bfd_endian; byte_order; ; ; BFD_ENDIAN_BIG
i; enum bfd_endian; byte_order_for_code; ; ; BFD_ENDIAN_BIG
2003-01-05 00:38:46 +01:00
#
2017-05-02 19:30:07 +02:00
i; enum gdb_osabi; osabi; ; ; GDB_OSABI_UNKNOWN
2006-11-28 23:10:26 +01:00
#
2017-05-02 19:30:07 +02:00
i; const struct target_desc *; target_desc; ; ; ; ; ; ; host_address_to_string ( gdbarch->target_desc)
2008-01-18 18:07:40 +01:00
2000-08-11 04:55:38 +02:00
# Number of bits in a short or unsigned short for the target machine.
2017-05-02 19:30:07 +02:00
v; int; short_bit; ; ; 8 * sizeof ( short) ; 2*TARGET_CHAR_BIT; ; 0
2000-08-11 04:55:38 +02:00
# Number of bits in an int or unsigned int for the target machine.
2017-05-02 19:30:07 +02:00
v; int; int_bit; ; ; 8 * sizeof ( int) ; 4*TARGET_CHAR_BIT; ; 0
2000-08-11 04:55:38 +02:00
# Number of bits in a long or unsigned long for the target machine.
2017-05-02 19:30:07 +02:00
v; int; long_bit; ; ; 8 * sizeof ( long) ; 4*TARGET_CHAR_BIT; ; 0
2000-08-11 04:55:38 +02:00
# Number of bits in a long long or unsigned long long for the target
# machine.
2017-05-02 19:30:07 +02:00
v; int; long_long_bit; ; ; 8 * sizeof ( LONGEST) ; 2*gdbarch->long_bit; ; 0
2004-08-08 21:49:43 +02:00
2010-07-06 14:56:24 +02:00
# The ABI default bit-size and format for "half", "float", "double", and
# "long double". These bit/format pairs should eventually be combined
# into a single object. For the moment, just initialize them as a pair.
* doublest.c (floatformat_from_length): Use the right element from
gdbarch floatformats.
(floatformat_from_type, extract_typed_floating)
(store_typed_floating): Likewise.
* doublest.h: Remove declarations for undefined floatformat arrays.
* gdbarch.sh (float_format, double_format, long_double_format): Change
to pairs.
(pformat): Update for pairs.
* gdbarch.c, gdbarch.h: Regenerated.
* gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
(floatformats_ieee_double_littlebyte_bigword)
(floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
(floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
(floatformats_vax_d): New variables.
(builtin_type_ieee_single, builtin_type_ieee_double)
(builtin_type_arm_ext, builtin_type_ia64_spill)
(builtin_type_ia64_quad): Replace arrays with individual types.
(builtin_type_ieee_single_big, builtin_type_ieee_single_little)
(builtin_type_ieee_double_big, builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
(builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
(builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
unused and endian-specific types.
(recursive_dump_type): Update for floatformat pairs.
(build_flt): Move higher. Handle bit == -1. Take a floatformat pair.
(build_gdbtypes): Use build_flt.
(_initialize_gdbtypes): Update set of initialized types.
* gdbtypes.h: Update declarations to match gdbtypes.c.
(struct main_type): Store a pointer to two floatformats.
* arch-utils.c (default_float_format, default_double_format): Delete.
* arch-utils.h (default_float_format, default_double_format): Delete.
* arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
# Each format describes both the big and little endian layouts (if
# useful).
2004-08-08 21:49:43 +02:00
2017-05-02 19:30:07 +02:00
v; int; half_bit; ; ; 16; 2*TARGET_CHAR_BIT; ; 0
v; const struct floatformat **; half_format; ; ; ; ; floatformats_ieee_half; ; pformat ( gdbarch->half_format)
v; int; float_bit; ; ; 8 * sizeof ( float) ; 4*TARGET_CHAR_BIT; ; 0
v; const struct floatformat **; float_format; ; ; ; ; floatformats_ieee_single; ; pformat ( gdbarch->float_format)
v; int; double_bit; ; ; 8 * sizeof ( double) ; 8*TARGET_CHAR_BIT; ; 0
v; const struct floatformat **; double_format; ; ; ; ; floatformats_ieee_double; ; pformat ( gdbarch->double_format)
v; int; long_double_bit; ; ; 8 * sizeof ( long double) ; 8*TARGET_CHAR_BIT; ; 0
v; const struct floatformat **; long_double_format; ; ; ; ; floatformats_ieee_double; ; pformat ( gdbarch->long_double_format)
2004-08-08 21:49:43 +02:00
Teach GDB that wchar_t is a built-in type in C++ mode
GDB is currently not aware that wchar_t is a built-in type in C++
mode. This is usually not a problem because the debug info describes
the type, so when you have a program loaded, you don't notice this.
However, if you try expressions involving wchar_t before a program is
loaded, gdb errors out:
(gdb) p (wchar_t)-1
No symbol table is loaded. Use the "file" command.
(gdb) p L"hello"
No type named wchar_t.
(gdb) ptype L"hello"
No type named wchar_t.
This commit teaches gdb about the type. After:
(gdb) p (wchar_t)-1
$1 = -1 L'\xffffffff'
(gdb) p L"hello"
$2 = L"hello"
(gdb) ptype L"hello"
type = wchar_t [6]
Unlike char16_t/char32_t, unfortunately, the underlying type of
wchar_t is implementation dependent, both size and signness. So this
requires adding a couple new gdbarch hooks.
I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it
seems to me that the majority of the ABIs have a 4-byte signed
wchar_t, so that's what I made the default for GDB too. And then I
looked for which ports have a 16-bit and/or unsigned wchar_t, and made
GDB follow suit.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>:
New enum value.
(cplus_language_arch_info): Register cplus_primitive_type_wchar_t.
* gdbtypes.h (struct builtin_type) <builtin_wchar>: New field.
* gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type.
* gdbarch.sh (wchar_bit, wchar_signed): New per-arch values.
* gdbarch.h, gdbarch.c: Regenerate.
* aarch64-tdep.c (aarch64_gdbarch_init): Override
gdbarch_wchar_bit and gdbarch_wchar_signed.
* alpha-tdep.c (alpha_gdbarch_init): Likewise.
* arm-tdep.c (arm_gdbarch_init): Likewise.
* avr-tdep.c (avr_gdbarch_init): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* i386-nto-tdep.c (i386nto_init_abi): Likewise.
* i386-tdep.c (i386_go32_init_abi): Likewise.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* moxie-tdep.c (moxie_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* sparc64-tdep.c (sparc64_init_abi): Likewise.
* windows-tdep.c (windows_init_abi): Likewise.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* gdb.cp/wide_char_types.c: Include <wchar.h>.
(wchar): New global.
* gdb.cp/wide_char_types.exp (wide_char_types_program)
(do_test_wide_char, wide_char_types_no_program, top level): Add
wchar_t testing.
2017-04-12 15:00:49 +02:00
# The ABI default bit-size for "wchar_t". wchar_t is a built-in type
# starting with C++11.
2017-05-02 19:30:07 +02:00
v; int; wchar_bit; ; ; 8 * sizeof ( wchar_t) ; 4*TARGET_CHAR_BIT; ; 0
Teach GDB that wchar_t is a built-in type in C++ mode
GDB is currently not aware that wchar_t is a built-in type in C++
mode. This is usually not a problem because the debug info describes
the type, so when you have a program loaded, you don't notice this.
However, if you try expressions involving wchar_t before a program is
loaded, gdb errors out:
(gdb) p (wchar_t)-1
No symbol table is loaded. Use the "file" command.
(gdb) p L"hello"
No type named wchar_t.
(gdb) ptype L"hello"
No type named wchar_t.
This commit teaches gdb about the type. After:
(gdb) p (wchar_t)-1
$1 = -1 L'\xffffffff'
(gdb) p L"hello"
$2 = L"hello"
(gdb) ptype L"hello"
type = wchar_t [6]
Unlike char16_t/char32_t, unfortunately, the underlying type of
wchar_t is implementation dependent, both size and signness. So this
requires adding a couple new gdbarch hooks.
I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it
seems to me that the majority of the ABIs have a 4-byte signed
wchar_t, so that's what I made the default for GDB too. And then I
looked for which ports have a 16-bit and/or unsigned wchar_t, and made
GDB follow suit.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>:
New enum value.
(cplus_language_arch_info): Register cplus_primitive_type_wchar_t.
* gdbtypes.h (struct builtin_type) <builtin_wchar>: New field.
* gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type.
* gdbarch.sh (wchar_bit, wchar_signed): New per-arch values.
* gdbarch.h, gdbarch.c: Regenerate.
* aarch64-tdep.c (aarch64_gdbarch_init): Override
gdbarch_wchar_bit and gdbarch_wchar_signed.
* alpha-tdep.c (alpha_gdbarch_init): Likewise.
* arm-tdep.c (arm_gdbarch_init): Likewise.
* avr-tdep.c (avr_gdbarch_init): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* i386-nto-tdep.c (i386nto_init_abi): Likewise.
* i386-tdep.c (i386_go32_init_abi): Likewise.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* moxie-tdep.c (moxie_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* sparc64-tdep.c (sparc64_init_abi): Likewise.
* windows-tdep.c (windows_init_abi): Likewise.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* gdb.cp/wide_char_types.c: Include <wchar.h>.
(wchar): New global.
* gdb.cp/wide_char_types.exp (wide_char_types_program)
(do_test_wide_char, wide_char_types_no_program, top level): Add
wchar_t testing.
2017-04-12 15:00:49 +02:00
# One if \`wchar_t' is signed, zero if unsigned.
2017-05-02 19:30:07 +02:00
v; int; wchar_signed; ; ; 1; -1; 1
Teach GDB that wchar_t is a built-in type in C++ mode
GDB is currently not aware that wchar_t is a built-in type in C++
mode. This is usually not a problem because the debug info describes
the type, so when you have a program loaded, you don't notice this.
However, if you try expressions involving wchar_t before a program is
loaded, gdb errors out:
(gdb) p (wchar_t)-1
No symbol table is loaded. Use the "file" command.
(gdb) p L"hello"
No type named wchar_t.
(gdb) ptype L"hello"
No type named wchar_t.
This commit teaches gdb about the type. After:
(gdb) p (wchar_t)-1
$1 = -1 L'\xffffffff'
(gdb) p L"hello"
$2 = L"hello"
(gdb) ptype L"hello"
type = wchar_t [6]
Unlike char16_t/char32_t, unfortunately, the underlying type of
wchar_t is implementation dependent, both size and signness. So this
requires adding a couple new gdbarch hooks.
I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it
seems to me that the majority of the ABIs have a 4-byte signed
wchar_t, so that's what I made the default for GDB too. And then I
looked for which ports have a 16-bit and/or unsigned wchar_t, and made
GDB follow suit.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>:
New enum value.
(cplus_language_arch_info): Register cplus_primitive_type_wchar_t.
* gdbtypes.h (struct builtin_type) <builtin_wchar>: New field.
* gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type.
* gdbarch.sh (wchar_bit, wchar_signed): New per-arch values.
* gdbarch.h, gdbarch.c: Regenerate.
* aarch64-tdep.c (aarch64_gdbarch_init): Override
gdbarch_wchar_bit and gdbarch_wchar_signed.
* alpha-tdep.c (alpha_gdbarch_init): Likewise.
* arm-tdep.c (arm_gdbarch_init): Likewise.
* avr-tdep.c (avr_gdbarch_init): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* i386-nto-tdep.c (i386nto_init_abi): Likewise.
* i386-tdep.c (i386_go32_init_abi): Likewise.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* moxie-tdep.c (moxie_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* sparc64-tdep.c (sparc64_init_abi): Likewise.
* windows-tdep.c (windows_init_abi): Likewise.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* gdb.cp/wide_char_types.c: Include <wchar.h>.
(wchar): New global.
* gdb.cp/wide_char_types.exp (wide_char_types_program)
(do_test_wide_char, wide_char_types_no_program, top level): Add
wchar_t testing.
2017-04-12 15:00:49 +02:00
Add gdbarch callback to provide formats for debug info float types
At this point, all TYPE_CODE_FLT types carry their floating-point format,
except for those creating from reading DWARF or stabs debug info. Those
will be addressed by this commit.
The main issue here is that we actually have to determine which floating-
point format to use. Currently, we only have the type length as input
to this decision. In the future, we may hopefully get --at least in
DWARF-- additional information to help disambiguate multiple different
formats of the same length. For now, we can still look at the type name
as a hint.
This decision logic is encapsulated in a gdbarch callback to allow
platform-specific overrides. The default implementation use the same
logic (compare type length against the various gdbarch_..._bit sizes)
that is currently implemented in floatformat_from_length.
With this commit, all platforms still use the default logic, so there
should be no actual change in behavior. A follow-on commit will add
support for __float128 on Intel and Power.
Once dwarf2read.c and stabsread.c make use of the new callback to
determine floating-point formats, we're now sure every TYPE_CODE_FLT
type will always carry its format. The commit therefore adds asserts
to verify_floatformat to ensure new code will continue to always
provide formats, and removes the code in floatformat_from_type that
used to handle types with a NULL TYPE_FLOATFORMAT.
gdb/ChangeLog:
* gdbarch.sh (floatformat_for_type): New gdbarch callback.
* gdbarch.h, gdbarch.c: Re-generate.
* arch-utils.h (default_floatformat_for_type): New prototype.
* arch-utils.c (default_floatformat_for_type): New function.
* doublest.c (floatformat_from_length): Remove.
(floatformat_from_type): Assume TYPE_FLOATFORMAT is non-NULL.
* gdbtypes.c (verify_floatformat): Require non-NULL format.
* dwarf2read.c (dwarf2_init_float_type): New function.
(read_base_type): Use it.
* stabsread.c (dbx_init_float_type): New function.
(read_sun_floating_type): Use it.
(read_range_type): Likewise.
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-06 17:31:53 +02:00
# Returns the floating-point format to be used for values of length LENGTH.
# NAME, if non-NULL, is the type name, which may be used to distinguish
# different target formats of the same length.
2017-05-02 19:30:07 +02:00
m; const struct floatformat **; floatformat_for_type; const char *name, int length; name, length; 0; default_floatformat_for_type; ; 0
Add gdbarch callback to provide formats for debug info float types
At this point, all TYPE_CODE_FLT types carry their floating-point format,
except for those creating from reading DWARF or stabs debug info. Those
will be addressed by this commit.
The main issue here is that we actually have to determine which floating-
point format to use. Currently, we only have the type length as input
to this decision. In the future, we may hopefully get --at least in
DWARF-- additional information to help disambiguate multiple different
formats of the same length. For now, we can still look at the type name
as a hint.
This decision logic is encapsulated in a gdbarch callback to allow
platform-specific overrides. The default implementation use the same
logic (compare type length against the various gdbarch_..._bit sizes)
that is currently implemented in floatformat_from_length.
With this commit, all platforms still use the default logic, so there
should be no actual change in behavior. A follow-on commit will add
support for __float128 on Intel and Power.
Once dwarf2read.c and stabsread.c make use of the new callback to
determine floating-point formats, we're now sure every TYPE_CODE_FLT
type will always carry its format. The commit therefore adds asserts
to verify_floatformat to ensure new code will continue to always
provide formats, and removes the code in floatformat_from_type that
used to handle types with a NULL TYPE_FLOATFORMAT.
gdb/ChangeLog:
* gdbarch.sh (floatformat_for_type): New gdbarch callback.
* gdbarch.h, gdbarch.c: Re-generate.
* arch-utils.h (default_floatformat_for_type): New prototype.
* arch-utils.c (default_floatformat_for_type): New function.
* doublest.c (floatformat_from_length): Remove.
(floatformat_from_type): Assume TYPE_FLOATFORMAT is non-NULL.
* gdbtypes.c (verify_floatformat): Require non-NULL format.
* dwarf2read.c (dwarf2_init_float_type): New function.
(read_base_type): Use it.
* stabsread.c (dbx_init_float_type): New function.
(read_sun_floating_type): Use it.
(read_range_type): Likewise.
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-06 17:31:53 +02:00
2000-08-25 22:51:19 +02:00
# For most targets, a pointer on the target and its representation as an
# address in GDB have the same size and "look the same". For such a
2007-06-13 19:59:51 +02:00
# target, you need only set gdbarch_ptr_bit and gdbarch_addr_bit
2000-08-25 22:51:19 +02:00
# / addr_bit will be set from it.
#
2007-06-13 19:59:51 +02:00
# If gdbarch_ptr_bit and gdbarch_addr_bit are different, you'll probably
2010-08-06 21:02:15 +02:00
# also need to set gdbarch_dwarf2_addr_size, gdbarch_pointer_to_address and
# gdbarch_address_to_pointer as well.
2000-08-25 22:51:19 +02:00
#
# ptr_bit is the size of a pointer on the target
2017-05-02 19:30:07 +02:00
v; int; ptr_bit; ; ; 8 * sizeof ( void*) ; gdbarch->int_bit; ; 0
2000-08-25 22:51:19 +02:00
# addr_bit is the size of a target address as represented in gdb
2017-05-02 19:30:07 +02:00
v; int; addr_bit; ; ; 8 * sizeof ( void*) ; 0; gdbarch_ptr_bit ( gdbarch) ;
1999-08-31 03:14:27 +02:00
#
2010-08-06 21:02:15 +02:00
# dwarf2_addr_size is the target address size as used in the Dwarf debug
# info. For .debug_frame FDEs, this is supposed to be the target address
# size from the associated CU header, and which is equivalent to the
# DWARF2_ADDR_SIZE as defined by the target specific GCC back-end.
# Unfortunately there is no good way to determine this value. Therefore
# dwarf2_addr_size simply defaults to the target pointer size.
#
# dwarf2_addr_size is not used for .eh_frame FDEs, which are generally
# defined using the target's pointer size so far.
#
# Note that dwarf2_addr_size only needs to be redefined by a target if the
# GCC back-end defines a DWARF2_ADDR_SIZE other than the target pointer size,
# and if Dwarf versions < 4 need to be supported.
2017-05-02 19:30:07 +02:00
v; int; dwarf2_addr_size; ; ; sizeof ( void*) ; 0; gdbarch_ptr_bit ( gdbarch) / TARGET_CHAR_BIT;
2010-08-06 21:02:15 +02:00
#
2001-12-20 04:26:08 +01:00
# One if \`char' acts like \`signed char', zero if \`unsigned char'.
2017-05-02 19:30:07 +02:00
v; int; char_signed; ; ; 1; -1; 1
2001-12-20 04:26:08 +01:00
#
2018-02-21 12:20:03 +01:00
F; CORE_ADDR; read_pc; readable_regcache *regcache; regcache
2017-05-02 19:30:07 +02:00
F; void; write_pc; struct regcache *regcache, CORE_ADDR val; regcache, val
2001-08-11 02:59:29 +02:00
# Function for getting target's idea of a frame pointer. FIXME: GDB's
# whole scheme for dealing with "frames" and "frame pointers" needs a
# serious shakedown.
2017-05-02 19:30:07 +02:00
m; void; virtual_frame_pointer; CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset; pc, frame_regnum, frame_offset; 0; legacy_virtual_frame_pointer; ; 0
2000-08-11 04:55:38 +02:00
#
2018-02-21 12:20:03 +01:00
M; enum register_status; pseudo_register_read; readable_regcache *regcache, int cookednum, gdb_byte *buf; regcache, cookednum, buf
2011-07-22 17:31:52 +02:00
# Read a register into a new struct value. If the register is wholly
# or partly unavailable, this should call mark_value_bytes_unavailable
# as appropriate. If this is defined, then pseudo_register_read will
# never be called.
2018-02-21 12:20:03 +01:00
M; struct value *; pseudo_register_read_value; readable_regcache *regcache, int cookednum; regcache, cookednum
2017-05-02 19:30:07 +02:00
M; void; pseudo_register_write; struct regcache *regcache, int cookednum, const gdb_byte *buf; regcache, cookednum, buf
2001-03-24 02:26:09 +01:00
#
2017-05-02 19:30:07 +02:00
v; int; num_regs; ; ; 0; -1
2000-07-24 16:25:22 +02:00
# This macro gives the number of pseudo-registers that live in the
# register namespace but do not get fetched or stored on the target.
2000-09-04 13:40:20 +02:00
# These pseudo-registers may be aliases for other registers,
# combinations of other registers, or they may be computed by GDB.
2017-05-02 19:30:07 +02:00
v; int; num_pseudo_regs; ; ; 0; 0; ; 0
2002-04-06 22:50:10 +02:00
2010-12-28 17:00:13 +01:00
# Assemble agent expression bytecode to collect pseudo-register REG.
# Return -1 if something goes wrong, 0 otherwise.
2017-05-02 19:30:07 +02:00
M; int; ax_pseudo_register_collect; struct agent_expr *ax, int reg; ax, reg
2010-12-28 17:00:13 +01:00
# Assemble agent expression bytecode to push the value of pseudo-register
# REG on the interpreter stack.
# Return -1 if something goes wrong, 0 otherwise.
2017-05-02 19:30:07 +02:00
M; int; ax_pseudo_register_push_stack; struct agent_expr *ax, int reg; ax, reg
2010-12-28 17:00:13 +01:00
Intel MPX bound violation handling
With Intel Memory Protection Extensions it was introduced the concept of
boundary violation. A boundary violations is presented to the inferior as
a segmentation fault having SIGCODE 3. This patch adds a
handler for a boundary violation extending the information displayed
when a bound violation is presented to the inferior. In the stop mode
case the debugger will also display the kind of violation: "upper" or
"lower", bounds and the address accessed.
On no stop mode the information will still remain unchanged. Additional
information about bound violations are not meaningful in that case user
does not know the line in which violation occurred as well.
When the segmentation fault handler is stop mode the out puts will be
changed as exemplified below.
The usual output of a segfault is:
Program received signal SIGSEGV, Segmentation fault
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In case it is a bound violation it will be presented as:
Program received signal SIGSEGV, Segmentation fault
Upper bound violation while accessing address 0x7fffffffc3b3
Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In mi mode the output of a segfault is:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c",
func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"}
,{name="b",value="0x603050"}, {name="c",value="0x603070"},
{name="d",value="0x603090"},{name="len",value="7"}],
file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"},
thread-id="1",stopped-threads="all",core="6"
in the case of a bound violation:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault",
sigcode-meaning="Upper bound violation",
lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f",
frame={addr="0x0000000000400d7c",func="upper",args=[{name="p",
value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"},
{name="c",value="0x603070"},{name="d",value="0x603090"},
{name="len",value="7"}],file="i386-mpx-sigsegv.c",
fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1",
stopped-threads="all",core="6"
2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* NEWS: Add entry for bound violation.
* amd64-linux-tdep.c (amd64_linux_init_abi_common):
Add handler for segmentation fault.
* gdbarch.sh (handle_segmentation_fault): New.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New.
(SIG_CODE_BONDARY_FAULT): New define.
(i386_linux_init_abi): Use i386_mpx_bound_violation_handler.
* i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* infrun.c (handle_segmentation_fault): New function.
(print_signal_received_reason): Use handle_segmentation_fault.
gdb/testsuite/ChangeLog:
* gdb.arch/i386-mpx-sigsegv.c: New file.
* gdb.arch/i386-mpx-sigsegv.exp: New file.
* gdb.arch/i386-mpx-simple_segv.c: New file.
* gdb.arch/i386-mpx-simple_segv.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Signals): Add bound violation display hints for
a SIGSEGV.
2016-02-18 17:24:59 +01:00
# Some targets/architectures can do extra processing/display of
# segmentation faults. E.g., Intel MPX boundary faults.
# Call the architecture dependent function to handle the fault.
# UIOUT is the output stream where the handler will place information.
2017-05-02 19:30:07 +02:00
M; void; handle_segmentation_fault; struct ui_out *uiout; uiout
Intel MPX bound violation handling
With Intel Memory Protection Extensions it was introduced the concept of
boundary violation. A boundary violations is presented to the inferior as
a segmentation fault having SIGCODE 3. This patch adds a
handler for a boundary violation extending the information displayed
when a bound violation is presented to the inferior. In the stop mode
case the debugger will also display the kind of violation: "upper" or
"lower", bounds and the address accessed.
On no stop mode the information will still remain unchanged. Additional
information about bound violations are not meaningful in that case user
does not know the line in which violation occurred as well.
When the segmentation fault handler is stop mode the out puts will be
changed as exemplified below.
The usual output of a segfault is:
Program received signal SIGSEGV, Segmentation fault
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In case it is a bound violation it will be presented as:
Program received signal SIGSEGV, Segmentation fault
Upper bound violation while accessing address 0x7fffffffc3b3
Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In mi mode the output of a segfault is:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c",
func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"}
,{name="b",value="0x603050"}, {name="c",value="0x603070"},
{name="d",value="0x603090"},{name="len",value="7"}],
file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"},
thread-id="1",stopped-threads="all",core="6"
in the case of a bound violation:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault",
sigcode-meaning="Upper bound violation",
lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f",
frame={addr="0x0000000000400d7c",func="upper",args=[{name="p",
value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"},
{name="c",value="0x603070"},{name="d",value="0x603090"},
{name="len",value="7"}],file="i386-mpx-sigsegv.c",
fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1",
stopped-threads="all",core="6"
2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* NEWS: Add entry for bound violation.
* amd64-linux-tdep.c (amd64_linux_init_abi_common):
Add handler for segmentation fault.
* gdbarch.sh (handle_segmentation_fault): New.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New.
(SIG_CODE_BONDARY_FAULT): New define.
(i386_linux_init_abi): Use i386_mpx_bound_violation_handler.
* i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* infrun.c (handle_segmentation_fault): New function.
(print_signal_received_reason): Use handle_segmentation_fault.
gdb/testsuite/ChangeLog:
* gdb.arch/i386-mpx-sigsegv.c: New file.
* gdb.arch/i386-mpx-sigsegv.exp: New file.
* gdb.arch/i386-mpx-simple_segv.c: New file.
* gdb.arch/i386-mpx-simple_segv.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Signals): Add bound violation display hints for
a SIGSEGV.
2016-02-18 17:24:59 +01:00
2002-04-06 22:50:10 +02:00
# GDB's standard (or well known) register numbers. These can map onto
# a real register or a pseudo (computed) register or not be defined at
2002-04-07 04:16:46 +02:00
# all (-1).
2007-06-18 Markus Deuling <deuling@de.ibm.com>
* gdbarch.sh (SP_REGNUM): Replace by gdbarch_sp_regnum.
* v850-tdep.c (v850_unwind_sp): Likewise.
* std-regs.c (value_of_builtin_frame_sp_reg): Likewise.
* stack.c (frame_info): Likewise.
* stabsread.c (define_symbol): Likewise.
* sh-tdep.c (sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu)
(sh_dwarf2_frame_init_reg, sh_frame_cache, sh_frame_prev_register)
(sh_unwind_sp): Likewise.
* sh64-tdep.c (sh64_push_dummy_call, sh64_frame_cache)
(sh64_frame_prev_register, sh64_unwind_sp): Likewise.
* rs6000-tdep.c (rs6000_push_dummy_call, rs6000_unwind_dummy_id)
(rs6000_frame_cache): Likewise.
* rs6000-nat.c (store_register): Likewise.
* remote-mips.c (mips_wait): Likewise.
* procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call)
(ppc64_sysv_abi_push_dummy_call): Likewise.
* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise.
* ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise.
* ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise.
* ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise.
* m32r-rom.c (m32r_supply_register): Likewise.
* frame.c (frame_sp_unwind): Likewise.
* mips-tdep.c (mips_insn16_frame_cache)
(mips_insn32_frame_cache): Likewise (comment).
* m68klinux-nat.c (supply_gregset): Likewise.
* m68k-tdep.c (m68k_get_longjmp_target): Likewise.
* ia64-tdep.c (ia64_frame_prev_register): Likewise.
* i386-tdep.c (i386_get_longjmp_target): Likewise.
* dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise.
* cris-tdep.c (cris_regnums, cris_sigcontext_addr)
(cris_sigtramp_frame_unwind_cache, cris_push_dummy_call)
(cris_scan_prologue, crisv32_scan_prologue, cris_unwind_sp)
(cris_register_type, crisv32_register_type)
(cris_dwarf2_frame_init_reg): Likewise.
* arch-utils.c (legacy_virtual_frame_pointer): Likewise.
* amd64-tdep.c (amd64_frame_prev_register): Likewise.
* amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Likewise.
* libunwind-frame.c (libunwind_frame_cache): Likewise.
* gdbarch.sh (PC_REGNUM): Replace by gdbarch_pc_regnum.
* regcache.c (read_pc_pid, generic_target_write_pc): Likewise.
* xtensa-tdep.c (xtensa_register_type, xtensa_supply_gregset)
(xtensa_unwind_pc, xtensa_frame_cache, xtensa_frame_prev_register)
(xtensa_extract_return_value, xtensa_store_return_value): Likewise.
* v850-tdep.c (v850_unwind_pc): Likewise.
* stack.c (frame_info): Likewise.
* sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs)
(sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs)
(sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs)
(sh_dwarf2_frame_init_reg, sh_frame_prev_register, sh_unwind_pc)
(sh_dsp_show_regs): Likewise.
* shnbsd-tdep.c (shnbsd_supply_gregset)
(shnbsd_collect_gregset): Likewise.
* shnbsd-nat.c (GETREGS_SUPPLIES): Likewise.
* sh64-tdep.c (sh64_compact_reg_base_num, sh64_show_media_regs)
(sh64_frame_prev_register, sh64_unwind_pc): Likewise.
* rs6000-tdep.c (ppc_supply_gregset, ppc_collect_gregset)
(6000_register_reggroup_p, rs6000_unwind_pc)
(rs6000_frame_cache): Likewise.
* rs6000-nat.c (regmap, rs6000_fetch_inferior_registers)
(rs6000_store_inferior_registers): Likewise.
* remote-mips.c (mips_wait, mips_load): Likewise.
* procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise.
* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise.
* ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise.
* ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise.
* ppcnbsd-nat.c (getregs_supplies, ppcnbsd_supply_pcb): Likewise.
* ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise.
* ppc-linux-nat.c (ppc_register_u_addr, fetch_ppc_registers)
(store_ppc_registers, fill_gregset): Likewise.
* mips-tdep.c (mips_stub_frame_cache, mips_gdbarch_init): Likewise.
* mipsnbsd-tdep.c (mipsnbsd_supply_reg, mipsnbsd_fill_reg): Likewise.
* mipsnbsd-nat.c (getregs_supplies): Likewise.
* m68k-tdep.c (m68k_register_type, m68k_unwind_pc): Likewise.
* m68klinux-nat.c (supply_gregset): Likewise.
* irix5-nat.c (fill_gregset): Likewise.
* i386-tdep.c (i386_unwind_pc): Likewise.
* i386-linux-nat.c (i386_linux_resume): Likewise.
* frame.c (get_prev_frame_1): Likewise.
* dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise.
* dbug-rom.c (dbug_supply_register): Likewise.
* cris-tdep.c (cris_sigtramp_frame_unwind_cache, cris_scan_prologue)
(crisv32_scan_prologue, cris_unwind_pc, cris_register_size)
(cris_register_type, crisv32_register_type, crisv32_register_name)
(cris_dwarf2_frame_init_reg, find_step_target)
(cris_software_single_step, cris_supply_gregset)
(cris_regnums): Likewise.
* alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise.
* aix-thread.c (special_register_p, supply_sprs64, supply_sprs32)
(fill_sprs64, fill_sprs32, store_regs_user_thread): Likewise.
* mips-linux-tdep.c (mips_linux_write_pc): Likewise.
* gdbarch.sh (PS_REGNUM): Replace by gdbarch_ps_regnum.
* dbug-rom.c (dbug_supply_register): Likewise.
* xtensa-tdep.c (xtensa_supply_gregset, xtensa_frame_cache)
(xtensa_frame_prev_register, xtensa_push_dummy_call): Likewise.
* win32-nat.c (win32_resume): Likewise.
* std-regs.c (value_of_builtin_frame_ps_reg)
(value_of_builtin_frame_pc_reg): Likewise.
* m68k-tdep.c (m68k_register_type): Likewise.
* m68klinux-nat.c (supply_gregset): Likewise.
* gdbarch.sh (FP0_REGNUM): Replace by gdbarch_fp0_regnum.
* sh-tdep.c (sh_extract_return_value_fpu, sh_store_return_value_fpu)
(sh2e_show_regs, sh2a_show_regs, sh3e_show_regs, sh4_show_regs)
(sh_sh2a_register_type, sh_sh3e_register_type, sh_sh4_register_type)
(fv_reg_base_num, dr_reg_base_num): Likewise.
* sh64-tdep.c (sh64_fv_reg_base_num, sh64_dr_reg_base_num)
(sh64_fpp_reg_base_num, sh64_compact_reg_base_num, sh64_push_dummy_call)
(sh64_extract_return_value, sh64_store_return_value)
(sh64_show_media_regs, sh64_show_compact_regs, sh64_register_type)
(sh64_do_fp_register, sh64_media_print_registers_info): Likewise.
* procfs.c (procfs_fetch_registers, procfs_store_registers)
(invalidate_cache): Likewise.
* ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise.
* mipsnbsd-tdep.c (mipsnbsd_supply_fpreg)
(mipsnbsd_fill_fpreg): Likewise.
* mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers)
(mipsnbsd_store_inferior_registers): Likewise.
* mips-linux-tdep.c (mips_supply_fpregset, mips_fill_fpregset)
(mips64_supply_fpregset, mips64_fill_fpregset): Likewise.
* mips-linux-nat.c (mips64_linux_register_addr): Likewise.
* m68k-tdep.c (m68k_register_type, m68k_convert_register_p): Likewise.
* m68klinux-nat.c (getfpregs_supplies, supply_fpregset)
(fill_fpregset): Likewise.
* irix5-nat.c (supply_fpregset, fill_fpregset): Likewise.
* i386-tdep.h (struct_return): Likewise (comment).
* i386-nto-tdep.c (i386nto_register_area): Likewise.
* go32-nat.c (fetch_register, go32_fetch_registers, store_register)
(go32_store_registers): Likewise.
* alpha-tdep.c (alpha_next_pc): Likewise.
* alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise.
* alphabsd-nat.c (alphabsd_fetch_inferior_registers)
(alphabsd_store_inferior_registers): Likewise.
* core-regset.c (fetch_core_registers): Likewise.
* i386v4-nat.c (supply_fpregset, fill_fpregset): Likewise.
* gdbarch.c, gdbarch.h: Regenerate.
2007-06-18 19:45:26 +02:00
# gdbarch_sp_regnum will hopefully be replaced by UNWIND_SP.
2017-05-02 19:30:07 +02:00
v; int; sp_regnum; ; ; -1; -1; ; 0
v; int; pc_regnum; ; ; -1; -1; ; 0
v; int; ps_regnum; ; ; -1; -1; ; 0
v; int; fp0_regnum; ; ; 0; -1; ; 0
2000-12-04 05:01:16 +01:00
# Convert stab register number (from \`r\' declaration) to a gdb REGNUM.
2017-05-02 19:30:07 +02:00
m; int; stab_reg_to_regnum; int stab_regnr; stab_regnr; ; no_op_reg_to_regnum; ; 0
2000-12-04 05:01:16 +01:00
# Provide a default mapping from a ecoff register number to a gdb REGNUM.
2017-05-02 19:30:07 +02:00
m; int; ecoff_reg_to_regnum; int ecoff_regnr; ecoff_regnr; ; no_op_reg_to_regnum; ; 0
2000-12-04 05:01:16 +01:00
# Convert from an sdb register number to an internal gdb register number.
2017-05-02 19:30:07 +02:00
m; int; sdb_reg_to_regnum; int sdb_regnr; sdb_regnr; ; no_op_reg_to_regnum; ; 0
* gdbarch.sh: Delete dwarf_reg_to_regnum.
* gdbarch.c, gdbarch.h: Regenerated.
* amd64-tdep.c, arm-tdep.c, h8300-tdep.c, hppa-linux-tdep.c,
hppa-tdep.c, i386-tdep.c, m32c-tdep.c, m68k-tdep.c, mips-tdep.c,
s390-tdep.c, xtensa-tdep.c: Do not set dwarf_reg_to_regnum.
* gdbint.texinfo (Target Conditionals): Delete entry for
gdbarch_dwarf_reg_to_regnum.
2008-05-16 02:27:24 +02:00
# Provide a default mapping from a DWARF2 register number to a gdb REGNUM.
2015-10-27 00:05:21 +01:00
# Return -1 for bad REGNUM. Note: Several targets get this wrong.
2017-05-02 19:30:07 +02:00
m; int; dwarf2_reg_to_regnum; int dwarf2_regnr; dwarf2_regnr; ; no_op_reg_to_regnum; ; 0
m; const char *; register_name; int regnr; regnr; ; 0
2003-06-13 06:40:34 +02:00
2007-01-21 18:37:51 +01:00
# Return the type of a register specified by the architecture. Only
# the register cache should call this function directly; others should
# use "register_type".
2017-05-02 19:30:07 +02:00
M; struct type *; register_type; int reg_nr; reg_nr
2003-06-13 06:40:34 +02:00
gdb: Add default frame methods to gdbarch
Supply default gdbarch methods for gdbarch_dummy_id,
gdbarch_unwind_pc, and gdbarch_unwind_sp. This patch doesn't actually
convert any targets to use these methods, and so, there will be no
user visible changes after this commit.
The implementations for default_dummy_id and default_unwind_sp are
fairly straight forward, these just take on the pattern used by most
targets. Once these default methods are in place then most targets
will be able to switch over.
The implementation for default_unwind_pc is also fairly straight
forward, but maybe needs some explanation.
This patch has gone through a number of iterations:
https://sourceware.org/ml/gdb-patches/2018-03/msg00165.html
https://sourceware.org/ml/gdb-patches/2018-03/msg00306.html
https://sourceware.org/ml/gdb-patches/2018-06/msg00090.html
https://sourceware.org/ml/gdb-patches/2018-09/msg00127.html
and the implementation of default_unwind_pc has changed over this
time. Originally, I took an implementation like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
return frame_unwind_register_unsigned (next_frame, pc_regnum);
}
This is basically a clone of default_unwind_sp, but using $pc. It was
pointed out that we could potentially do better, and in version 2 the
implementation became:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
struct type *type;
int pc_regnum;
CORE_ADDR addr;
struct value *value;
pc_regnum = gdbarch_pc_regnum (gdbarch);
value = frame_unwind_register_value (next_frame, pc_regnum);
type = builtin_type (gdbarch)->builtin_func_ptr;
addr = extract_typed_address (value_contents_all (value), type);
addr = gdbarch_addr_bits_remove (gdbarch, addr);
release_value (value);
value_free (value);
return addr;
}
The idea was to try split out some of the steps of unwinding the $pc,
steps that are on some (or many) targets no-ops, and so allow targets
that do override these methods, to make use of default_unwind_pc.
This implementation remained in place for version 2, 3, and 4.
However, I realised that I'd made a mistake, most targets simply use
frame_unwind_register_unsigned to unwind the $pc, and this throws an
error if the register value is optimized out or unavailable. My new
proposed implementation doesn't do this, I was going to end up
breaking many targets.
I considered duplicating the code from frame_unwind_register_unsigned
that throws the errors into my new default_unwind_pc, however, this
felt really overly complex. So, what I instead went with was to
simply revert back to using frame_unwind_register_unsigned. Almost
all existing targets already use this. Some of the ones that don't can
be converted to, which means almost all targets could end up using the
default.
One addition I have made over the version 1 implementation is to add a
call to gdbarch_addr_bits_remove. For most targets this is a no-op,
but for a handful, having this call in place will mean that they can
use the default method. After all this, the new default_unwind_pc now
looks like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum);
pc = gdbarch_addr_bits_remove (gdbarch, pc);
return pc;
}
gdb/ChangeLog:
* gdb/dummy-frame.c (default_dummy_id): Defined new function.
* gdb/dummy-frame.h (default_dummy_id): Declare new function.
* gdb/frame-unwind.c (default_unwind_pc): Define new function.
(default_unwind_sp): Define new function.
* gdb/frame-unwind.h (default_unwind_pc): Declare new function.
(default_unwind_sp): Declare new function.
* gdb/frame.c (frame_unwind_pc): Assume gdbarch_unwind_pc is
available.
(get_frame_sp): Assume that gdbarch_unwind_sp is available.
* gdb/gdbarch.c: Regenerate.
* gdb/gdbarch.h: Regenerate.
* gdb/gdbarch.sh: Update definition of dummy_id, unwind_pc, and
unwind_sp. Add additional header files to be included in
generated file.
2018-09-07 21:04:44 +02:00
# Generate a dummy frame_id for THIS_FRAME assuming that the frame is
# a dummy frame. A dummy frame is created before an inferior call,
# the frame_id returned here must match the frame_id that was built
# for the inferior call. Usually this means the returned frame_id's
# stack address should match the address returned by
# gdbarch_push_dummy_call, and the returned frame_id's code address
# should match the address at which the breakpoint was set in the dummy
# frame.
m; struct frame_id; dummy_id; struct frame_info *this_frame; this_frame; ; default_dummy_id; ; 0
Convert frame unwinders to use the current frame and
"struct value".
* frame.c (frame_debug): Make global.
(get_frame_id): Pass this frame to unwinder routines.
(frame_pc_unwind): Remove unused unwind->prev_pc support.
(do_frame_register_read): Do not discard the return value of
frame_register_read.
(frame_register_unwind): Remove debug messages. Use
frame_unwind_register_value.
(frame_unwind_register_value, get_frame_register_value): New
functions.
(create_new_frame, get_frame_base_address, get_frame_locals_address)
(get_frame_args_address, get_frame_type): Pass this frame to
unwinder routines.
(frame_cleanup_after_sniffer, frame_prepare_for_sniffer): New
functions.
* frame.h: Update comments.
(frame_debug, frame_unwind_register_value, get_frame_register_value)
(frame_prepare_for_sniffer): Declare.
* frame-unwind.h: Update comments and parameter names.
(default_frame_sniffer): Declare.
(frame_prev_register_ftype): Return a struct value *.
(struct frame_unwind): Remove prev_pc member.
(frame_unwind_sniffer_ftype, frame_unwind_append_sniffer): Delete.
(frame_unwind_append_unwinder, frame_unwind_got_optimized)
(frame_unwind_got_register, frame_unwind_got_memory)
(frame_unwind_got_constant, frame_unwind_got_address): Declare.
* frame-base.h: Update comments and parameter names.
* valops.c (value_fetch_lazy): Use get_frame_register_value. Iterate
if necessary. Add debugging output.
* sentinel-frame.c (sentinel_frame_prev_register)
(sentinel_frame_this_id): Update for new signature.
(sentinel_frame_prev_pc): Delete.
(sentinel_frame_unwinder): Remove prev_pc.
* ia64-tdep.c (ia64_libunwind_frame_unwind): Do not initialize
prev_pc.
* libunwind-frame.c (libunwind_frame_unwind): Likewise.
* frame-unwind.c (struct frame_unwind_table_entry): Remove sniffer.
(frame_unwind_append_sniffer): Delete.
(frame_unwind_append_unwinder): New function.
(frame_unwind_find_by_frame): Take this frame. Only use sniffers
from unwinders. Use frame_prepare_for_sniffer.
(default_frame_sniffer, frame_unwind_got_optimized)
(frame_unwind_got_register, frame_unwind_got_memory)
(frame_unwind_got_constant, frame_unwind_got_address): New functions.
* dummy-frame.c (dummy_frame_sniffer): Use gdbarch_dummy_id.
(dummy_frame_prev_register, dummy_frame_this_id): Update for new
signature.
* gdbarch.sh: Replace unwind_dummy_id with dummy_id.
* gdbarch.c, gdbarch.c: Regenerated.
* frame-base.c (default_frame_base_address)
(default_frame_locals_address, default_frame_args_address): Update
for new signature.
(frame_base_find_by_frame): Pass this frame to unwinder routines.
* infcall.c (call_function_by_hand): Update comments.
* Makefile.in (frame-unwind.o): Update dependencies.
* gdbint.texinfo (Stack Frames): New chapter.
(Algorithms): Move Frames text to the new chapter.
(Target Conditionals): Delete SAVE_DUMMY_FRAME_TOS. Document
gdbarch_dummy_id instead of gdbarch_unwind_dummy_id.
2008-04-30 23:16:46 +02:00
# Implement DUMMY_ID and PUSH_DUMMY_CALL, then delete
2007-06-18 20:37:12 +02:00
# deprecated_fp_regnum.
2017-05-02 19:30:07 +02:00
v; int; deprecated_fp_regnum; ; ; -1; -1; ; 0
2003-06-14 00:18:49 +02:00
2018-11-16 12:21:04 +01:00
M; CORE_ADDR; push_dummy_call; struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr; function , regcache, bp_addr, nargs, args, sp, return_method, struct_addr
2017-05-02 19:30:07 +02:00
v; int; call_dummy_location; ; ; ; AT_ENTRY_POINT; ; 0
M; CORE_ADDR; push_dummy_code; CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache; sp, funaddr, args, nargs, value_type, real_pc, bp_addr, regcache
2004-06-13 18:43:58 +02:00
Skip unwritable frames in command "finish"
Nowadays, GDB can't insert breakpoint on the return address of the
exception handler on ARM M-profile, because the address is a magic
one 0xfffffff9,
(gdb) bt
#0 CT32B1_IRQHandler () at ../src/timer.c:67
#1 <signal handler called>
#2 main () at ../src/timer.c:127
(gdb) info frame
Stack level 0, frame at 0x200ffa8:
pc = 0x4ec in CT32B1_IRQHandler (../src/timer.c:67); saved pc = 0xfffffff9
called by frame at 0x200ffc8
source language c.
Arglist at 0x200ffa0, args:
Locals at 0x200ffa0, Previous frame's sp is 0x200ffa8
Saved registers:
r7 at 0x200ffa0, lr at 0x200ffa4
(gdb) x/x 0xfffffff9
0xfffffff9: Cannot access memory at address 0xfffffff9
(gdb) finish
Run till exit from #0 CT32B1_IRQHandler () at ../src/timer.c:67
Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?)
Warning:
Cannot insert hardware breakpoint 0.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
even some debug probe can't set hardware breakpoint on the magic
address too,
(gdb) hbreak *0xfffffff9
Hardware assisted breakpoint 2 at 0xfffffff9
(gdb) c
Continuing.
Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?)
Warning:
Cannot insert hardware breakpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
The problem described above is quite similar to PR 8841, in which GDB
can't set breakpoint on signal trampoline, which is mapped to a read-only
page by kernel. The rationale of this patch is to skip "unwritable"
frames when looking for caller frames in command "finish", and a new
gdbarch method code_of_frame_writable is added. This patch fixes
the problem on ARM cortex-m target, but it can be used to fix
PR 8841 too.
gdb:
2016-05-10 Yao Qi <yao.qi@arm.com>
* arch-utils.c (default_code_of_frame_writable): New function.
* arch-utils.h (default_code_of_frame_writable): Declare.
* arm-tdep.c (arm_code_of_frame_writable): New function.
(arm_gdbarch_init): Install gdbarch method
code_of_frame_writable if the target is M-profile.
* frame.c (skip_unwritable_frames): New function.
* frame.h (skip_unwritable_frames): Declare.
* gdbarch.sh (code_of_frame_writable): New.
* gdbarch.c, gdbarch.h: Re-generated.
* infcmd.c (finish_command): Call skip_unwritable_frames.
2016-05-23 18:32:56 +02:00
# Return true if the code of FRAME is writable.
2017-05-02 19:30:07 +02:00
m; int; code_of_frame_writable; struct frame_info *frame; frame; ; default_code_of_frame_writable; ; 0
Skip unwritable frames in command "finish"
Nowadays, GDB can't insert breakpoint on the return address of the
exception handler on ARM M-profile, because the address is a magic
one 0xfffffff9,
(gdb) bt
#0 CT32B1_IRQHandler () at ../src/timer.c:67
#1 <signal handler called>
#2 main () at ../src/timer.c:127
(gdb) info frame
Stack level 0, frame at 0x200ffa8:
pc = 0x4ec in CT32B1_IRQHandler (../src/timer.c:67); saved pc = 0xfffffff9
called by frame at 0x200ffc8
source language c.
Arglist at 0x200ffa0, args:
Locals at 0x200ffa0, Previous frame's sp is 0x200ffa8
Saved registers:
r7 at 0x200ffa0, lr at 0x200ffa4
(gdb) x/x 0xfffffff9
0xfffffff9: Cannot access memory at address 0xfffffff9
(gdb) finish
Run till exit from #0 CT32B1_IRQHandler () at ../src/timer.c:67
Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?)
Warning:
Cannot insert hardware breakpoint 0.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
even some debug probe can't set hardware breakpoint on the magic
address too,
(gdb) hbreak *0xfffffff9
Hardware assisted breakpoint 2 at 0xfffffff9
(gdb) c
Continuing.
Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?)
Warning:
Cannot insert hardware breakpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
Command aborted.
The problem described above is quite similar to PR 8841, in which GDB
can't set breakpoint on signal trampoline, which is mapped to a read-only
page by kernel. The rationale of this patch is to skip "unwritable"
frames when looking for caller frames in command "finish", and a new
gdbarch method code_of_frame_writable is added. This patch fixes
the problem on ARM cortex-m target, but it can be used to fix
PR 8841 too.
gdb:
2016-05-10 Yao Qi <yao.qi@arm.com>
* arch-utils.c (default_code_of_frame_writable): New function.
* arch-utils.h (default_code_of_frame_writable): Declare.
* arm-tdep.c (arm_code_of_frame_writable): New function.
(arm_gdbarch_init): Install gdbarch method
code_of_frame_writable if the target is M-profile.
* frame.c (skip_unwritable_frames): New function.
* frame.h (skip_unwritable_frames): Declare.
* gdbarch.sh (code_of_frame_writable): New.
* gdbarch.c, gdbarch.h: Re-generated.
* infcmd.c (finish_command): Call skip_unwritable_frames.
2016-05-23 18:32:56 +02:00
2017-05-02 19:30:07 +02:00
m; 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
m; void; print_float_info; struct ui_file *file, struct frame_info *frame, const char *args; file, frame, args; ; default_print_float_info; ; 0
M; void; print_vector_info; struct ui_file *file, struct frame_info *frame, const char *args; file, frame, args
2000-08-02 13:05:50 +02:00
# MAP a GDB RAW register number onto a simulator register number. See
# also include/...-sim.h.
2017-05-02 19:30:07 +02:00
m; int; register_sim_regno; int reg_nr; reg_nr; ; legacy_register_sim_regno; ; 0
m; int; cannot_fetch_register; int regnum; regnum; ; cannot_register_not; ; 0
m; int; cannot_store_register; int regnum; regnum; ; cannot_register_not; ; 0
2013-10-17 08:11:22 +02:00
# Determine the address where a longjmp will land and save this address
# in PC. Return nonzero on success.
#
# FRAME corresponds to the longjmp frame.
2017-05-02 19:30:07 +02:00
F; int; get_longjmp_target; struct frame_info *frame, CORE_ADDR *pc; frame, pc
2013-10-17 08:11:22 +02:00
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
v; int; believe_pcc_promotion; ; ; ; ; ; ;
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
m; int; convert_register_p; int regnum, struct type *type; regnum, type; 0; generic_convert_register_p; ; 0
f; int; register_to_value; struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep; frame, regnum, type, buf, optimizedp, unavailablep; 0
f; void; value_to_register; struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf; frame, regnum, type, buf; 0
2007-01-08 21:03:49 +01:00
# Construct a value representing the contents of register REGNUM in
Use address_from_register in dwarf2-frame.c:read_addr_from_reg
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
2014-04-17 14:01:39 +02:00
# frame FRAME_ID, interpreted as type TYPE. The routine needs to
2007-01-08 21:03:49 +01:00
# allocate and return a struct value with all value attributes
# (but not the value contents) filled in.
2017-05-02 19:30:07 +02:00
m; struct value *; value_from_register; struct type *type, int regnum, struct frame_id frame_id; type, regnum, frame_id; ; default_value_from_register; ; 0
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; pointer_to_address; struct type *type, const gdb_byte *buf; type, buf; ; unsigned_pointer_to_address; ; 0
m; void; address_to_pointer; struct type *type, gdb_byte *buf, CORE_ADDR addr; type, buf, addr; ; unsigned_address_to_pointer; ; 0
M; CORE_ADDR; integer_to_address; struct type *type, const gdb_byte *buf; type, buf
2003-10-20 17:38:02 +02:00
2012-05-16 16:35:09 +02:00
# Return the return-value convention that will be used by FUNCTION
# to return a value of type VALTYPE. FUNCTION may be NULL in which
2008-04-29 18:06:07 +02:00
# case the return convention is computed based only on VALTYPE.
#
# If READBUF is not NULL, extract the return value and save it in this buffer.
#
# If WRITEBUF is not NULL, it contains a return value which will be
# stored into the appropriate register. This can be used when we want
# to force the value returned by a function (see the "return" command
# for instance).
2017-05-02 19:30:07 +02:00
M; enum return_value_convention; return_value; struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf; function , valtype, regcache, readbuf, writebuf
2003-10-20 17:38:02 +02:00
2012-06-08 16:24:57 +02:00
# Return true if the return value of function is stored in the first hidden
# parameter. In theory, this feature should be language-dependent, specified
# by language and its ABI, such as C++. Unfortunately, compiler may
# implement it to a target-dependent feature. So that we need such hook here
# to be aware of this in GDB.
2017-05-02 19:30:07 +02:00
m; int; return_in_first_hidden_param_p; struct type *type; type; ; default_return_in_first_hidden_param_p; ; 0
2012-06-08 16:24:57 +02:00
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; skip_prologue; CORE_ADDR ip; ip; 0; 0
M; CORE_ADDR; skip_main_prologue; CORE_ADDR ip; ip
PowerPC64 ELFv2 ABI: skip global entry point code
This patch handles another aspect of the ELFv2 ABI, which unfortunately
requires common code changes.
In ELFv2, functions may provide both a global and a local entry point.
The global entry point (where the function symbol points to) is intended
to be used for function-pointer or cross-module (PLT) calls, and requires
r12 to be set up to the entry point address itself. The local entry
point (which is found at a fixed offset after the global entry point,
as defined by bits in the symbol table entries' st_other field), instead
expects r2 to be set up to the current TOC.
Now, when setting a breakpoint on a function by name, you really want
that breakpoint to trigger either way, no matter whether the function
is called via its local or global entry point. Since the global entry
point will always fall through into the local entry point, the way to
achieve that is to simply set the breakpoint at the local entry point.
One way to do that would be to have prologue parsing skip the code
sequence that makes up the global entry point. Unfortunately, this
does not work reliably, since -for optimized code- GDB these days
will not actuall invoke the prologue parsing code but instead just
set the breakpoint at the symbol address and rely on DWARF being
correct at any point throughout the function ...
Unfortunately, I don't really see any way to express the notion of
local entry points with the current set of gdbarch callbacks.
Thus this patch adds a new callback, skip_entrypoint, that is
somewhat analogous to skip_prologue, but is called every time
GDB needs to determine a function start address, even in those
cases where GDB decides to not call skip_prologue.
As a side effect, the skip_entrypoint implementation on ppc64
does not need to perform any instruction parsing; it can simply
rely on the local entry point flags in the symbol table entry.
With this implemented, two test cases would still fail to set
the breakpoint correctly, but that's because they use the construct:
gdb_test "break *hello"
Now, using "*hello" explicitly instructs GDB to set the breakpoint
at the numerical value of "hello" treated as function pointer, so
it will by definition only hit the global entry point.
I think this behaviour is unavoidable, but acceptable -- most people
do not use this construct, and if they do, they get what they
asked for ...
In one of those two test cases, use of this construct is really
not appropriate. I think this was added way back when as a means
to work around prologue skipping problems on some platforms. These
days that shouldn't really be necessary any more ...
For the other (step-bt), we really want to make sure backtracing
works on the very first instruction of the routine. To enable that
test also on powerpc64le-linux, we can modify the code to call the
test function via function pointer (which makes it use the global
entry point in the ELFv2 ABI).
gdb/ChangeLog:
* gdbarch.sh (skip_entrypoint): New callback.
* gdbarch.c, gdbarch.h: Regenerate.
* symtab.c (skip_prologue_sal): Call gdbarch_skip_entrypoint.
* infrun.c (fill_in_stop_func): Likewise.
* ppc-linux-tdep.c: Include "elf/ppc64.h".
(ppc_elfv2_elf_make_msymbol_special): New function.
(ppc_elfv2_skip_entrypoint): Likewise.
(ppc_linux_init_abi): Install them for ELFv2.
gdb/testsuite/ChangeLog:
* gdb.base/sigbpt.exp: Do not use "*" when setting breakpoint
on a function.
* gdb.base/step-bt.c: Call hello via function pointer to make
sure its first instruction is executed on powerpc64le-linux.
2014-02-04 18:44:14 +01:00
# On some platforms, a single function may provide multiple entry points,
# e.g. one that is used for function-pointer calls and a different one
# that is used for direct function calls.
# In order to ensure that breakpoints set on the function will trigger
# no matter via which entry point the function is entered, a platform
# may provide the skip_entrypoint callback. It is called with IP set
# to the main entry point of a function (as determined by the symbol table),
# and should return the address of the innermost entry point, where the
# actual breakpoint needs to be set. Note that skip_entrypoint is used
# by GDB common code even when debugging optimized code, where skip_prologue
# is not used.
2017-05-02 19:30:07 +02:00
M; CORE_ADDR; skip_entrypoint; CORE_ADDR ip; ip
PowerPC64 ELFv2 ABI: skip global entry point code
This patch handles another aspect of the ELFv2 ABI, which unfortunately
requires common code changes.
In ELFv2, functions may provide both a global and a local entry point.
The global entry point (where the function symbol points to) is intended
to be used for function-pointer or cross-module (PLT) calls, and requires
r12 to be set up to the entry point address itself. The local entry
point (which is found at a fixed offset after the global entry point,
as defined by bits in the symbol table entries' st_other field), instead
expects r2 to be set up to the current TOC.
Now, when setting a breakpoint on a function by name, you really want
that breakpoint to trigger either way, no matter whether the function
is called via its local or global entry point. Since the global entry
point will always fall through into the local entry point, the way to
achieve that is to simply set the breakpoint at the local entry point.
One way to do that would be to have prologue parsing skip the code
sequence that makes up the global entry point. Unfortunately, this
does not work reliably, since -for optimized code- GDB these days
will not actuall invoke the prologue parsing code but instead just
set the breakpoint at the symbol address and rely on DWARF being
correct at any point throughout the function ...
Unfortunately, I don't really see any way to express the notion of
local entry points with the current set of gdbarch callbacks.
Thus this patch adds a new callback, skip_entrypoint, that is
somewhat analogous to skip_prologue, but is called every time
GDB needs to determine a function start address, even in those
cases where GDB decides to not call skip_prologue.
As a side effect, the skip_entrypoint implementation on ppc64
does not need to perform any instruction parsing; it can simply
rely on the local entry point flags in the symbol table entry.
With this implemented, two test cases would still fail to set
the breakpoint correctly, but that's because they use the construct:
gdb_test "break *hello"
Now, using "*hello" explicitly instructs GDB to set the breakpoint
at the numerical value of "hello" treated as function pointer, so
it will by definition only hit the global entry point.
I think this behaviour is unavoidable, but acceptable -- most people
do not use this construct, and if they do, they get what they
asked for ...
In one of those two test cases, use of this construct is really
not appropriate. I think this was added way back when as a means
to work around prologue skipping problems on some platforms. These
days that shouldn't really be necessary any more ...
For the other (step-bt), we really want to make sure backtracing
works on the very first instruction of the routine. To enable that
test also on powerpc64le-linux, we can modify the code to call the
test function via function pointer (which makes it use the global
entry point in the ELFv2 ABI).
gdb/ChangeLog:
* gdbarch.sh (skip_entrypoint): New callback.
* gdbarch.c, gdbarch.h: Regenerate.
* symtab.c (skip_prologue_sal): Call gdbarch_skip_entrypoint.
* infrun.c (fill_in_stop_func): Likewise.
* ppc-linux-tdep.c: Include "elf/ppc64.h".
(ppc_elfv2_elf_make_msymbol_special): New function.
(ppc_elfv2_skip_entrypoint): Likewise.
(ppc_linux_init_abi): Install them for ELFv2.
gdb/testsuite/ChangeLog:
* gdb.base/sigbpt.exp: Do not use "*" when setting breakpoint
on a function.
* gdb.base/step-bt.c: Call hello via function pointer to make
sure its first instruction is executed on powerpc64le-linux.
2014-02-04 18:44:14 +01:00
2017-05-02 19:30:07 +02:00
f; int; inner_than; CORE_ADDR lhs, CORE_ADDR rhs; lhs, rhs; 0; 0
m; const gdb_byte *; breakpoint_from_pc; CORE_ADDR *pcptr, int *lenptr; pcptr, lenptr; 0; default_breakpoint_from_pc; ; 0
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
2016-11-03 15:35:13 +01:00
# Return the breakpoint kind for this target based on *PCPTR.
2017-05-02 19:30:07 +02:00
m; int; breakpoint_kind_from_pc; CORE_ADDR *pcptr; pcptr; ; 0;
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
2016-11-03 15:35:13 +01:00
# Return the software breakpoint from KIND. KIND can have target
# specific meaning like the Z0 kind parameter.
# SIZE is set to the software breakpoint's length in memory.
2017-05-02 19:30:07 +02:00
m; const gdb_byte *; sw_breakpoint_from_kind; int kind, int *size; kind, size; ; NULL; ; 0
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
2016-11-03 15:35:13 +01:00
2016-11-03 15:35:14 +01:00
# Return the breakpoint kind for this target based on the current
# processor state (e.g. the current instruction mode on ARM) and the
# *PCPTR. In default, it is gdbarch->breakpoint_kind_from_pc.
2017-05-02 19:30:07 +02:00
m; int; breakpoint_kind_from_current_state; struct regcache *regcache, CORE_ADDR *pcptr; regcache, pcptr; 0; default_breakpoint_kind_from_current_state; ; 0
2016-11-03 15:35:14 +01:00
2017-05-02 19:30:07 +02:00
M; CORE_ADDR; adjust_breakpoint_address; CORE_ADDR bpaddr; bpaddr
m; int; memory_insert_breakpoint; struct bp_target_info *bp_tgt; bp_tgt; 0; default_memory_insert_breakpoint; ; 0
m; int; memory_remove_breakpoint; struct bp_target_info *bp_tgt; bp_tgt; 0; default_memory_remove_breakpoint; ; 0
v; CORE_ADDR; decr_pc_after_break; ; ; 0; ; ; 0
2004-06-18 23:36:16 +02:00
# A function can be addressed by either it's "pointer" (possibly a
# descriptor address) or "entry point" (first executable instruction).
# The method "convert_from_func_ptr_addr" converting the former to the
2007-06-18 20:23:08 +02:00
# latter. gdbarch_deprecated_function_start_offset is being used to implement
2004-06-18 23:36:16 +02:00
# a simplified subset of that functionality - the function's address
# corresponds to the "function pointer" and the function's start
# corresponds to the "function entry point" - and hence is redundant.
2017-05-02 19:30:07 +02:00
v; CORE_ADDR; deprecated_function_start_offset; ; ; 0; ; ; 0
2004-06-18 23:36:16 +02:00
* Makefile.in (arm-tdep.o, eval.o, target-descriptions.o)
(xml-tdesc.o): Update.
* xml-support.c: Add a comment.
(gdb_xml_enums_boolean): New variable.
(gdb_xml_parse_attr_enum): Use strcasecmp.
* xml-support.h (gdb_xml_enums_boolean): Declare.
* xml-tdesc.c (struct tdesc_parsing_data): Record current_feature,
next_regnum, and current_union.
(tdesc_start_feature, tdesc_start_reg, tdesc_start_union)
(tdesc_end_union, tdesc_start_field, tdesc_start_vector)
(field_attributes, union_children, reg_attributes, union_attributes)
(vector_attributes, feature_attributes, feature_children): New.
(target_children): Make static. Add <feature>.
(tdesc_elements): Make static.
* target-descriptions.c (struct tdesc_reg, tdesc_reg_p, type_p)
(struct tdesc_feature, tdesc_feature_p): New types.
(struct target_desc): Add features member.
(struct tdesc_arch_data, tdesc_data): New.
(target_find_description): Clarify error message. Warn about
ignored register descriptions.
(tdesc_has_registers, tdesc_find_feature, tdesc_feature_name)
(tdesc_named_type, tdesc_data_init, tdesc_data_alloc)
(tdesc_data_cleanup, tdesc_numbered_register)
(tdesc_numbered_register_choices, tdesc_find_register)
(tdesc_register_name, tdesc_register_type)
(tdesc_remote_register_number, tdesc_register_reggroup_p)
(set_tdesc_pseudo_register_name, set_tdesc_pseudo_register_type)
(set_tdesc_pseudo_register_reggroup_p, tdesc_use_registers)
(tdesc_free_reg, tdesc_create_reg, tdesc_free_feature)
(tdesc_create_feature, tdesc_record_type): New.
(free_target_description): Free features.
(_initialize_target_descriptions): Initialize tdesc_data.
* arch-utils.c (default_remote_register_number): New.
* arch-utils.h (default_remote_register_number): New prototype.
* target-descriptions.h (set_tdesc_pseudo_register_name)
(set_tdesc_pseudo_register_type, set_tdesc_pseudo_register_reggroup_p)
(tdesc_use_registers, tdesc_data_alloc, tdesc_data_cleanup)
(tdesc_numbered_register, tdesc_numbered_register_choices)
(tdesc_has_registers, tdesc_find_feature, tdesc_feature_name)
(tdesc_named_type, tdesc_create_feature, tdesc_record_type)
(tdesc_create_reg): Declare.
* gdbarch.sh (remote_register_number): New entry.
* gdbarch.c, gdbarch.h: Regenerate.
* remote.c (init_remote_state): Use gdbarch_remote_register_number.
* features/gdb-target.dtd: Add feature, reg, vector, union, and field.
* arm-tdep.c (arm_register_aliases): New.
(arm_register_name_strings): Rename to...
(arm_register_names): ...this. Make const. Delete the old version.
(current_option, arm_register_byte): Delete.
(set_disassembly_style): Simplify. Do not adjust arm_register_names.
(value_of_arm_user_reg): New.
(arm_gdbarch_init): Verify any described registers. Call
tdesc_use_registers. Don't use arm_register_byte. Create aliases
for standard register names.
(_initialize_arm_tdep): Do not adjust arm_register_names.
* user-regs.c (struct user_reg): Add baton member.
(append_user_reg, user_reg_add_builtin, user_regs_init)
(user_reg_add, value_of_user_reg): Use a baton for user
register functions.
* std-regs.c: Update.
* user-regs.h (user_reg_read_ftype, user_reg_add_builtin)
(user_reg_add): Add baton argument.
* NEWS: Mention target description register support.
* features/arm-core.xml, features/arm-fpa.xml: New.
* eval.c (evaluate_subexp_standard): Allow ptype $register
when the program is not running.
* gdb.texinfo (-target-disconnect): Use @smallexample.
(Requirements): Add anchor for Expat. Update description.
(Target Descriptions): Mention Expat.
(Target Description Format): Document new elements. Use
@smallexample.
(Predefined Target Types, Standard Target Features): New sections.
* doc/gdbint.texinfo (Target Descriptions): New section.
* gdb.xml/single-reg.xml, gdb.xml/tdesc-regs.exp,
gdb.xml/core-only.xml, gdb.xml/extra-regs.xml: New files.
2007-02-08 22:00:36 +01:00
# Return the remote protocol register number associated with this
# register. Normally the identity mapping.
2017-05-02 19:30:07 +02:00
m; int; remote_register_number; int regno; regno; ; default_remote_register_number; ; 0
* Makefile.in (arm-tdep.o, eval.o, target-descriptions.o)
(xml-tdesc.o): Update.
* xml-support.c: Add a comment.
(gdb_xml_enums_boolean): New variable.
(gdb_xml_parse_attr_enum): Use strcasecmp.
* xml-support.h (gdb_xml_enums_boolean): Declare.
* xml-tdesc.c (struct tdesc_parsing_data): Record current_feature,
next_regnum, and current_union.
(tdesc_start_feature, tdesc_start_reg, tdesc_start_union)
(tdesc_end_union, tdesc_start_field, tdesc_start_vector)
(field_attributes, union_children, reg_attributes, union_attributes)
(vector_attributes, feature_attributes, feature_children): New.
(target_children): Make static. Add <feature>.
(tdesc_elements): Make static.
* target-descriptions.c (struct tdesc_reg, tdesc_reg_p, type_p)
(struct tdesc_feature, tdesc_feature_p): New types.
(struct target_desc): Add features member.
(struct tdesc_arch_data, tdesc_data): New.
(target_find_description): Clarify error message. Warn about
ignored register descriptions.
(tdesc_has_registers, tdesc_find_feature, tdesc_feature_name)
(tdesc_named_type, tdesc_data_init, tdesc_data_alloc)
(tdesc_data_cleanup, tdesc_numbered_register)
(tdesc_numbered_register_choices, tdesc_find_register)
(tdesc_register_name, tdesc_register_type)
(tdesc_remote_register_number, tdesc_register_reggroup_p)
(set_tdesc_pseudo_register_name, set_tdesc_pseudo_register_type)
(set_tdesc_pseudo_register_reggroup_p, tdesc_use_registers)
(tdesc_free_reg, tdesc_create_reg, tdesc_free_feature)
(tdesc_create_feature, tdesc_record_type): New.
(free_target_description): Free features.
(_initialize_target_descriptions): Initialize tdesc_data.
* arch-utils.c (default_remote_register_number): New.
* arch-utils.h (default_remote_register_number): New prototype.
* target-descriptions.h (set_tdesc_pseudo_register_name)
(set_tdesc_pseudo_register_type, set_tdesc_pseudo_register_reggroup_p)
(tdesc_use_registers, tdesc_data_alloc, tdesc_data_cleanup)
(tdesc_numbered_register, tdesc_numbered_register_choices)
(tdesc_has_registers, tdesc_find_feature, tdesc_feature_name)
(tdesc_named_type, tdesc_create_feature, tdesc_record_type)
(tdesc_create_reg): Declare.
* gdbarch.sh (remote_register_number): New entry.
* gdbarch.c, gdbarch.h: Regenerate.
* remote.c (init_remote_state): Use gdbarch_remote_register_number.
* features/gdb-target.dtd: Add feature, reg, vector, union, and field.
* arm-tdep.c (arm_register_aliases): New.
(arm_register_name_strings): Rename to...
(arm_register_names): ...this. Make const. Delete the old version.
(current_option, arm_register_byte): Delete.
(set_disassembly_style): Simplify. Do not adjust arm_register_names.
(value_of_arm_user_reg): New.
(arm_gdbarch_init): Verify any described registers. Call
tdesc_use_registers. Don't use arm_register_byte. Create aliases
for standard register names.
(_initialize_arm_tdep): Do not adjust arm_register_names.
* user-regs.c (struct user_reg): Add baton member.
(append_user_reg, user_reg_add_builtin, user_regs_init)
(user_reg_add, value_of_user_reg): Use a baton for user
register functions.
* std-regs.c: Update.
* user-regs.h (user_reg_read_ftype, user_reg_add_builtin)
(user_reg_add): Add baton argument.
* NEWS: Mention target description register support.
* features/arm-core.xml, features/arm-fpa.xml: New.
* eval.c (evaluate_subexp_standard): Allow ptype $register
when the program is not running.
* gdb.texinfo (-target-disconnect): Use @smallexample.
(Requirements): Add anchor for Expat. Update description.
(Target Descriptions): Mention Expat.
(Target Description Format): Document new elements. Use
@smallexample.
(Predefined Target Types, Standard Target Features): New sections.
* doc/gdbint.texinfo (Target Descriptions): New section.
* gdb.xml/single-reg.xml, gdb.xml/tdesc-regs.exp,
gdb.xml/core-only.xml, gdb.xml/extra-regs.xml: New files.
2007-02-08 22:00:36 +01:00
2005-03-31 21:58:26 +02:00
# Fetch the target specific address used to represent a load module.
2017-05-02 19:30:07 +02:00
F; CORE_ADDR; fetch_tls_load_module_address; struct objfile *objfile; objfile
2019-03-12 21:39:02 +01:00
# Return the thread-local address at OFFSET in the thread-local
# storage for the thread PTID and the shared library or executable
# file given by LM_ADDR. If that block of thread-local storage hasn't
# been allocated yet, this function may throw an error. LM_ADDR may
# be zero for statically linked multithreaded inferiors.
M; CORE_ADDR; get_thread_local_address; ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset; ptid, lm_addr, offset
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
v; CORE_ADDR; frame_args_skip; ; ; 0; ; ; 0
gdb: Add default frame methods to gdbarch
Supply default gdbarch methods for gdbarch_dummy_id,
gdbarch_unwind_pc, and gdbarch_unwind_sp. This patch doesn't actually
convert any targets to use these methods, and so, there will be no
user visible changes after this commit.
The implementations for default_dummy_id and default_unwind_sp are
fairly straight forward, these just take on the pattern used by most
targets. Once these default methods are in place then most targets
will be able to switch over.
The implementation for default_unwind_pc is also fairly straight
forward, but maybe needs some explanation.
This patch has gone through a number of iterations:
https://sourceware.org/ml/gdb-patches/2018-03/msg00165.html
https://sourceware.org/ml/gdb-patches/2018-03/msg00306.html
https://sourceware.org/ml/gdb-patches/2018-06/msg00090.html
https://sourceware.org/ml/gdb-patches/2018-09/msg00127.html
and the implementation of default_unwind_pc has changed over this
time. Originally, I took an implementation like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
return frame_unwind_register_unsigned (next_frame, pc_regnum);
}
This is basically a clone of default_unwind_sp, but using $pc. It was
pointed out that we could potentially do better, and in version 2 the
implementation became:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
struct type *type;
int pc_regnum;
CORE_ADDR addr;
struct value *value;
pc_regnum = gdbarch_pc_regnum (gdbarch);
value = frame_unwind_register_value (next_frame, pc_regnum);
type = builtin_type (gdbarch)->builtin_func_ptr;
addr = extract_typed_address (value_contents_all (value), type);
addr = gdbarch_addr_bits_remove (gdbarch, addr);
release_value (value);
value_free (value);
return addr;
}
The idea was to try split out some of the steps of unwinding the $pc,
steps that are on some (or many) targets no-ops, and so allow targets
that do override these methods, to make use of default_unwind_pc.
This implementation remained in place for version 2, 3, and 4.
However, I realised that I'd made a mistake, most targets simply use
frame_unwind_register_unsigned to unwind the $pc, and this throws an
error if the register value is optimized out or unavailable. My new
proposed implementation doesn't do this, I was going to end up
breaking many targets.
I considered duplicating the code from frame_unwind_register_unsigned
that throws the errors into my new default_unwind_pc, however, this
felt really overly complex. So, what I instead went with was to
simply revert back to using frame_unwind_register_unsigned. Almost
all existing targets already use this. Some of the ones that don't can
be converted to, which means almost all targets could end up using the
default.
One addition I have made over the version 1 implementation is to add a
call to gdbarch_addr_bits_remove. For most targets this is a no-op,
but for a handful, having this call in place will mean that they can
use the default method. After all this, the new default_unwind_pc now
looks like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum);
pc = gdbarch_addr_bits_remove (gdbarch, pc);
return pc;
}
gdb/ChangeLog:
* gdb/dummy-frame.c (default_dummy_id): Defined new function.
* gdb/dummy-frame.h (default_dummy_id): Declare new function.
* gdb/frame-unwind.c (default_unwind_pc): Define new function.
(default_unwind_sp): Define new function.
* gdb/frame-unwind.h (default_unwind_pc): Declare new function.
(default_unwind_sp): Declare new function.
* gdb/frame.c (frame_unwind_pc): Assume gdbarch_unwind_pc is
available.
(get_frame_sp): Assume that gdbarch_unwind_sp is available.
* gdb/gdbarch.c: Regenerate.
* gdb/gdbarch.h: Regenerate.
* gdb/gdbarch.sh: Update definition of dummy_id, unwind_pc, and
unwind_sp. Add additional header files to be included in
generated file.
2018-09-07 21:04:44 +02:00
m; CORE_ADDR; unwind_pc; struct frame_info *next_frame; next_frame; ; default_unwind_pc; ; 0
m; CORE_ADDR; unwind_sp; struct frame_info *next_frame; next_frame; ; default_unwind_sp; ; 0
2003-06-26 19:18:43 +02:00
# DEPRECATED_FRAME_LOCALS_ADDRESS as been replaced by the per-frame
# frame-base. Enable frame-base before frame-unwind.
2017-05-02 19:30:07 +02:00
F; int; frame_num_args; struct frame_info *frame; frame
1999-08-31 03:14:27 +02:00
#
2017-05-02 19:30:07 +02:00
M; CORE_ADDR; frame_align; CORE_ADDR address; address
m; int; stabs_argument_has_addr; struct type *type; type; ; default_stabs_argument_has_addr; ; 0
v; int; frame_red_zone_size
2000-06-02 03:59:13 +02:00
#
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; convert_from_func_ptr_addr; CORE_ADDR addr, struct target_ops *targ; addr, targ; ; convert_from_func_ptr_addr_identity; ; 0
2001-06-16 00:10:21 +02:00
# On some machines there are bits in addresses which are not really
# part of the address, but are used by the kernel, the hardware, etc.
2007-06-09 15:49:20 +02:00
# for special purposes. gdbarch_addr_bits_remove takes out any such bits so
2001-06-16 00:10:21 +02:00
# we get a "real" address such as one would find in a symbol table.
# This is used only for addresses of instructions, and even then I'm
# not sure it's used in all contexts. It exists to deal with there
# being a few stray bits in the PC which would mislead us, not as some
# sort of generic thing to handle alignment or segmentation (it's
# possible it should be in TARGET_READ_PC instead).
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; addr_bits_remove; CORE_ADDR addr; addr; ; core_addr_identity; ; 0
2007-04-12 16:52:20 +02:00
Clear non-significant bits of address on memory access
ARMv8 supports tagged address, that is, the top one byte in address
is ignored. It is always enabled on aarch64-linux. See
https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt
The tag in the tagged address is modeled as non-significant bits in
address, so this patch adds a new gdbarch method significant_addr_bit and
clear the non-significant bits (the top byte in ARMv8) of the virtual
address at the point before passing address to target cache layer. IOW,
the address used in the target cache layer is already cleared.
Before this patch,
(gdb) x/x 0x0000000000411030
0x411030 <global>: 0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030: Cannot access memory at address 0xf000000000411030
After this patch,
(gdb) x/x 0x0000000000411030
0x411030 <global>: 0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030: 0x00000000
Note that I used address_significant in paddress, but it causes a
regression gdb.base/long_long.exp, because gdb clears the non-significant
bits in address, but test still expects them.
p/a val.oct^M
$24 = 0x2ee53977053977^M
(gdb) FAIL: gdb.base/long_long.exp: p/a val.oct
so I defer the change there.
gdb:
2017-12-08 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_gdbarch_init): Install gdbarch
significant_addr_bit.
* gdbarch.sh (significant_addr_bit): New.
* gdbarch.c, gdbarch.h: Re-generated.
* target.c (memory_xfer_partial): Call address_significant.
* utils.c (address_significant): New function.
* utils.h (address_significant): Declare.
2017-12-08 Yao Qi <yao.qi@linaro.org>
gdb/testsuite:
* gdb.arch/aarch64-tagged-pointer.c: New file.
* gdb.arch/aarch64-tagged-pointer.exp: New file.
2017-12-08 18:27:03 +01:00
# On some machines, not all bits of an address word are significant.
# For example, on AArch64, the top bits of an address known as the "tag"
# are ignored by the kernel, the hardware, etc. and can be regarded as
# additional data associated with the address.
2018-05-26 02:58:51 +02:00
v; int; significant_addr_bit; ; ; ; ; ; 0
Clear non-significant bits of address on memory access
ARMv8 supports tagged address, that is, the top one byte in address
is ignored. It is always enabled on aarch64-linux. See
https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt
The tag in the tagged address is modeled as non-significant bits in
address, so this patch adds a new gdbarch method significant_addr_bit and
clear the non-significant bits (the top byte in ARMv8) of the virtual
address at the point before passing address to target cache layer. IOW,
the address used in the target cache layer is already cleared.
Before this patch,
(gdb) x/x 0x0000000000411030
0x411030 <global>: 0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030: Cannot access memory at address 0xf000000000411030
After this patch,
(gdb) x/x 0x0000000000411030
0x411030 <global>: 0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030: 0x00000000
Note that I used address_significant in paddress, but it causes a
regression gdb.base/long_long.exp, because gdb clears the non-significant
bits in address, but test still expects them.
p/a val.oct^M
$24 = 0x2ee53977053977^M
(gdb) FAIL: gdb.base/long_long.exp: p/a val.oct
so I defer the change there.
gdb:
2017-12-08 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_gdbarch_init): Install gdbarch
significant_addr_bit.
* gdbarch.sh (significant_addr_bit): New.
* gdbarch.c, gdbarch.h: Re-generated.
* target.c (memory_xfer_partial): Call address_significant.
* utils.c (address_significant): New function.
* utils.h (address_significant): Declare.
2017-12-08 Yao Qi <yao.qi@linaro.org>
gdb/testsuite:
* gdb.arch/aarch64-tagged-pointer.c: New file.
* gdb.arch/aarch64-tagged-pointer.exp: New file.
2017-12-08 18:27:03 +01:00
2007-04-12 16:52:20 +02:00
# FIXME/cagney/2001-01-18: This should be split in two. A target method that
# indicates if the target needs software single step. An ISA method to
# implement it.
#
# FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the
# target can single step. If not, then implement single step using breakpoints.
2001-03-24 03:07:49 +01:00
#
2016-11-08 15:28:32 +01:00
# Return a vector of addresses on which the software single step
# breakpoints should be inserted. NULL means software single step is
# not used.
# Multiple breakpoints may be inserted for some instructions such as
# conditional branch. However, each implementation must always evaluate
# the condition and only put the breakpoint at the branch destination if
# the condition is true, so that we ensure forward progress when stepping
# past a conditional branch to self.
2017-05-02 19:30:07 +02:00
F; std::vector<CORE_ADDR>; software_single_step; struct regcache *regcache; regcache
2007-04-12 16:52:20 +02:00
2004-10-31 18:38:16 +01:00
# Return non-zero if the processor is executing a delay slot and a
# further single-step is needed before the instruction finishes.
2017-05-02 19:30:07 +02:00
M; int; single_step_through_delay; struct frame_info *frame; frame
2003-09-04 02:05:52 +02:00
# FIXME: cagney/2003-08-28: Need to find a better way of selecting the
2004-07-10 03:17:53 +02:00
# disassembler. Perhaps objdump can handle it?
2017-05-24 18:23:52 +02:00
f; int; print_insn; bfd_vma vma, struct disassemble_info *info; vma, info; ; default_print_insn; ; 0
2017-05-02 19:30:07 +02:00
f; CORE_ADDR; skip_trampoline_code; struct frame_info *frame, CORE_ADDR pc; frame, pc; ; generic_skip_trampoline_code; ; 0
2002-08-21 01:01:29 +02:00
2008-07-22 04:10:14 +02:00
# If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER
2003-11-09 13:07:16 +01:00
# evaluates non-zero, this is the address where the debugger will place
# a step-resume breakpoint to get us past the dynamic linker.
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; skip_solib_resolver; CORE_ADDR pc; pc; ; generic_skip_solib_resolver; ; 0
2002-08-21 01:01:29 +02:00
# Some systems also have trampoline code for returning from shared libs.
2017-05-02 19:30:07 +02:00
m; int; in_solib_return_trampoline; CORE_ADDR pc, const char *name; pc, name; ; generic_in_solib_return_trampoline; ; 0
2002-08-21 01:01:29 +02:00
infrun: step through indirect branch thunks
With version 7.3 GCC supports new options
-mindirect-branch=<choice>
-mfunction-return=<choice>
The choices are:
keep behaves as before
thunk jumps through a thunk
thunk-external jumps through an external thunk
thunk-inline jumps through an inlined thunk
For thunk and thunk-external, GDB would, on a call to the thunk, step into
the thunk and then resume to its caller assuming that this is an
undebuggable function. On a return thunk, GDB would stop inside the
thunk.
Make GDB step through such thunks instead.
Before:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
30 }
After:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
inc (x=41) at gdb.base/step-indirect-call-thunk.c:23
23 return x + 1;
This is independent of the step-mode. In order to step into the thunk,
you would need to use stepi.
When stepping over an indirect call thunk, GDB would first step through
the thunk, then recognize that it stepped into a sub-routine and resume to
the caller (of the thunk). Not sure whether this is worth optimizing.
Thunk detection is implemented via gdbarch. I implemented the methods for
IA. Other architectures may run into unexpected fails.
The tests assume a fixed number of instruction steps to reach a thunk.
This depends on the compiler as well as the architecture. They may need
adjustments when we add support for more architectures. Or we can simply
drop those tests that cover being able to step into thunks using
instruction stepping.
When using an older GCC, the tests will fail to build and will be reported
as untested:
Running .../gdb.base/step-indirect-call-thunk.exp ...
gdb compile failed, \
gcc: error: unrecognized command line option '-mindirect-branch=thunk'
gcc: error: unrecognized command line option '-mfunction-return=thunk'
=== gdb Summary ===
# of untested testcases 1
gdb/
* infrun.c (process_event_stop_test): Call
gdbarch_in_indirect_branch_thunk.
* gdbarch.sh (in_indirect_branch_thunk): New.
* gdbarch.c: Regenerated.
* gdbarch.h: Regenerated.
* x86-tdep.h: New.
* x86-tdep.c: New.
* Makefile.in (ALL_TARGET_OBS): Add x86-tdep.o.
(HFILES_NO_SRCDIR): Add x86-tdep.h.
(ALLDEPFILES): Add x86-tdep.c.
* arch-utils.h (default_in_indirect_branch_thunk): New.
* arch-utils.c (default_in_indirect_branch_thunk): New.
* i386-tdep: Include x86-tdep.h.
(i386_in_indirect_branch_thunk): New.
(i386_elf_init_abi): Set in_indirect_branch_thunk gdbarch
function.
* amd64-tdep: Include x86-tdep.h.
(amd64_in_indirect_branch_thunk): New.
(amd64_init_abi): Set in_indirect_branch_thunk gdbarch function.
testsuite/
* gdb.base/step-indirect-call-thunk.exp: New.
* gdb.base/step-indirect-call-thunk.c: New.
* gdb.reverse/step-indirect-call-thunk.exp: New.
* gdb.reverse/step-indirect-call-thunk.c: New.
2018-02-14 14:30:57 +01:00
# Return true if PC lies inside an indirect branch thunk.
m; bool; in_indirect_branch_thunk; CORE_ADDR pc; pc; ; default_in_indirect_branch_thunk; ; 0
2001-11-06 12:02:12 +01:00
# A target might have problems with watchpoints as soon as the stack
# frame of the current function has been destroyed. This mostly happens
2015-05-26 12:59:17 +02:00
# as the first action in a function's epilogue. stack_frame_destroyed_p()
2001-11-06 12:02:12 +01:00
# is defined to return a non-zero value if either the given addr is one
# instruction after the stack destroying instruction up to the trailing
# return instruction or if we can figure out that the stack frame has
# already been invalidated regardless of the value of addr. Targets
# which don't suffer from that problem could just let this functionality
# untouched.
2017-05-02 19:30:07 +02:00
m; int; stack_frame_destroyed_p; CORE_ADDR addr; addr; 0; generic_stack_frame_destroyed_p; ; 0
MIPS: Keep the ISA bit in compressed code addresses
1. Background information
The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned. As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception. This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.
Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI). The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.
As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2. That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.
So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit. Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.
To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution. They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.
This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.
A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture. Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes. The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.
2. Statement of the problem
To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time. This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged. Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.
A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected. This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.
While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle. This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).
This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.
This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:
(short *) main
will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.
This is probably best illustrated with a simple real program example.
Let's consider the following simple program:
$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
return 1;
}
int __attribute__ ((mips16)) bar (void)
{
return 2;
}
int __attribute__ ((nomips16)) foo32 (void)
{
return 3;
}
int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;
int
main (void)
{
return foop ();
}
$
This is plain C with no odd tricks, except from the instruction mode
attributes. They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.
Let's try it with Linux, so that everyone can repeat this experiment:
$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$
Let's have a look at some interesting symbols:
$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar
68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p
70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop
78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32
80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo
88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi
$
Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).
So let's try to run and poke at this program with GDB. I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):
$ ./foobar
$ echo $?
1
$
So far, so good.
$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Yay, it worked! OK, so let's poke at it:
(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)
A-ha! Here's the difference and finally the ISA bit!
(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)
And here as well...
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
main () at foobar.c:24
24 }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)
So let's be a bit inquisitive...
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Actually we do not like to run foo here at all. Let's run bar instead!
(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)
Hmm, no ISA bit. Is it going to work?
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>: jr ra
0x0040068e <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9 }
(gdb)
Oops!
(gdb) p/x $pc
$12 = 0x40068c
(gdb)
We're still there!
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
So let's try something else:
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4 }
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
The same problem!
(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14 }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>: jr ra
0x00400688 <+4>: li v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0 foo32 () at foobar.c:14
main () at foobar.c:24
24 }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)
That did work though, so it's the ISA bit only!
(gdb) quit
Enough!
That's the tip of the iceberg only though. So let's rebuild the
executable with some dynamic symbols:
$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
$
OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm... What does `objdump' do then:
$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn: file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l df *ABS* 00000000 foobar.c
004009cc g F .text 00000004 0xf0 bar
00410b88 g O .data 00000004 foo32p
00410b84 g O .data 00000004 foop
004009c4 g F .text 00000008 foo32
004009c0 g F .text 00000004 0xf0 foo
00410b80 g O .data 00000004 fooi
DYNAMIC SYMBOL TABLE:
004009cc g DF .text 00000004 Base 0xf0 bar
00410b88 g DO .data 00000004 Base foo32p
00410b84 g DO .data 00000004 Base foop
004009c4 g DF .text 00000008 Base foo32
004009c0 g DF .text 00000004 Base 0xf0 foo
00410b80 g DO .data 00000004 Base fooi
$
Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.
Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:
$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
Compilation Unit @ offset 0x88:
Length: 0xbb (32-bit)
Version: 4
Abbrev Offset: 62
Pointer Size: 4
<0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
<94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
<98> DW_AT_language : 1 (ANSI C)
<99> DW_AT_name : (indirect string, offset: 0x190): foobar.c
<9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...]
<a1> DW_AT_ranges : 0x0
<a5> DW_AT_low_pc : 0x0
<a9> DW_AT_stmt_list : 0x27
<1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
<ae> DW_AT_external : 1
<ae> DW_AT_name : foo
<b2> DW_AT_decl_file : 1
<b3> DW_AT_decl_line : 1
<b4> DW_AT_prototyped : 1
<b4> DW_AT_type : <0xc2>
<b8> DW_AT_low_pc : 0x400680
<bc> DW_AT_high_pc : 0x400684
<c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<c2> DW_AT_GNU_all_call_sites: 1
<1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
<c3> DW_AT_byte_size : 4
<c4> DW_AT_encoding : 5 (signed)
<c5> DW_AT_name : int
<1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
<ca> DW_AT_external : 1
<ca> DW_AT_name : (indirect string, offset: 0x18a): foo32
<ce> DW_AT_decl_file : 1
<cf> DW_AT_decl_line : 11
<d0> DW_AT_prototyped : 1
<d0> DW_AT_type : <0xc2>
<d4> DW_AT_low_pc : 0x400684
<d8> DW_AT_high_pc : 0x40068c
<dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<de> DW_AT_GNU_all_call_sites: 1
<1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
<df> DW_AT_external : 1
<df> DW_AT_name : bar
<e3> DW_AT_decl_file : 1
<e4> DW_AT_decl_line : 6
<e5> DW_AT_prototyped : 1
<e5> DW_AT_type : <0xc2>
<e9> DW_AT_low_pc : 0x40068c
<ed> DW_AT_high_pc : 0x400690
<f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f3> DW_AT_GNU_all_call_sites: 1
<1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
<f4> DW_AT_external : 1
<f4> DW_AT_name : (indirect string, offset: 0x199): main
<f8> DW_AT_decl_file : 1
<f9> DW_AT_decl_line : 21
<fa> DW_AT_prototyped : 1
<fa> DW_AT_type : <0xc2>
<fe> DW_AT_low_pc : 0x400490
<102> DW_AT_high_pc : 0x4004a4
<106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<108> DW_AT_GNU_all_tail_call_sites: 1
[...]
$
-- no sign of the ISA bit anywhere -- frame info:
$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:
00000000 0000000c ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
DW_CFA_def_cfa_register: r29
DW_CFA_nop
00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684
00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c
00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690
00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
DW_CFA_advance_loc: 6 to 00400496
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r31 at cfa-4
DW_CFA_advance_loc: 6 to 0040049c
DW_CFA_restore: r31
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
[...]
$
-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):
$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:
Offset Begin End
00000000 00400680 00400690
00000000 00400490 004004a4
00000000 <End of list>
$
-- no sign of the ISA bit anywhere -- line info:
$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
Offset: 0x27
Length: 78
DWARF Version: 2
Prologue Length: 31
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table:
Entry Dir Time Size Name
1 0 0 0 foobar.c
Line Number Statements:
Extended opcode 2: set Address to 0x400681
Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
Advance Line by -7 to 7
Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
Advance PC by 3 to 0x400690
Extended opcode 1: End of Sequence
Extended opcode 2: set Address to 0x400491
Advance Line by 21 to 22
Copy
Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
Advance PC by 7 to 0x4004a4
Extended opcode 1: End of Sequence
[...]
-- a-ha, the ISA bit is there! However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:
00019630 <__libc_init_first>:
19630: e8a0 jrc ra
19632: 6500 nop
00019634 <_init>:
19634: f000 6a11 li v0,17
19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54>
1963c: f400 3240 sll v0,16
19640: e269 addu v0,v1
19642: 659a move gp,v0
19644: 64f6 save 48,ra,s0-s1
19646: 671c move s0,gp
19648: d204 sw v0,16(sp)
1964a: f352 984c lw v0,-27828(s0)
1964e: 6724 move s1,a0
and the corresponding DWARF-2 line info:
Line Number Statements:
Extended opcode 2: set Address to 0x19631
Advance Line by 44 to 45
Copy
Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
Advance PC by constant 17 to 0x19646
Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53
-- see that "Advance PC by constant 17" there? It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all. For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?
3. Solution:
I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.
In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.
All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down. This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.
Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places. Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.
I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB. I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.
Here's the resulting change. It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed. The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.
With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).
4. Results obtained
The change fixes the example above -- to repeat only the crucial steps:
(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>: jr ra
0x0040068f <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
main () at foobar.c:24
24 }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)
-- excellent!
The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:
=== gdb Summary ===
# of expected passes 14299
# of unexpected failures 187
# of expected failures 56
# of known failures 58
# of unresolved testcases 11
# of untested testcases 52
# of unsupported tests 174
MIPS16:
=== gdb Summary ===
# of expected passes 14298
# of unexpected failures 187
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 12
# of untested testcases 52
# of unsupported tests 174
microMIPS:
=== gdb Summary ===
# of expected passes 14149
# of unexpected failures 201
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 7
# of untested testcases 53
# of unsupported tests 175
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
Maciej W. Rozycki <macro@mips.com>
Pedro Alves <pedro@codesourcery.com>
gdb/
* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
remove `predefault' and `invalid_p' initializers.
(make_symbol_special): New architecture method.
(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
(objfile, symbol): New declarations.
* arch-utils.h (default_elf_make_msymbol_special): Remove
prototype.
(default_make_symbol_special): New prototype.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* mips-tdep.h (mips_unmake_compact_addr): New prototype.
* arch-utils.c (default_elf_make_msymbol_special): Remove
function.
(default_make_symbol_special): New function.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* dwarf2-frame.c (decode_frame_entry_1): Call
`gdbarch_adjust_dwarf2_addr'.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise. Call `gdbarch_make_symbol_special'.
(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
(read_call_site_scope): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(read_attribute_value): Likewise.
(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
* elfread.c (elf_symtab_read): Don't call
`gdbarch_elf_make_msymbol_special' if unset.
* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
the ISA bit from the PC.
* mips-tdep.c (mips_unmake_compact_addr): New function.
(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
address appropriately.
(mips_make_symbol_special): New function.
(mips_pc_is_mips): Set the ISA bit before symbol lookup.
(mips_pc_is_mips16): Likewise.
(mips_pc_is_micromips): Likewise.
(mips_pc_isa): Likewise.
(mips_adjust_dwarf2_addr): New function.
(mips_adjust_dwarf2_line): Likewise.
(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
(mips_addr_bits_remove): Likewise.
(mips_skip_trampoline_code): Likewise.
(mips_write_pc): Don't set the ISA bit.
(mips_eabi_push_dummy_call): Likewise.
(mips_o64_push_dummy_call): Likewise.
(mips_gdbarch_init): Install `mips_make_symbol_special',
`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
handlers.
* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
target-specific symbol address adjustments.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
gdb/testsuite/
* gdb.base/func-ptrs.c: New file.
* gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
# Process an ELF symbol in the minimal symbol table in a backend-specific
# way. Normally this hook is supposed to do nothing, however if required,
# then this hook can be used to apply tranformations to symbols that are
# considered special in some way. For example the MIPS backend uses it
# to interpret \`st_other' information to mark compressed code symbols so
# that they can be treated in the appropriate manner in the processing of
# the main symbol table and DWARF-2 records.
2017-05-02 19:30:07 +02:00
F; void; elf_make_msymbol_special; asymbol *sym, struct minimal_symbol *msym; sym, msym
f; void; coff_make_msymbol_special; int val, struct minimal_symbol *msym; val, msym; ; default_coff_make_msymbol_special; ; 0
MIPS: Keep the ISA bit in compressed code addresses
1. Background information
The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned. As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception. This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.
Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI). The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.
As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2. That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.
So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit. Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.
To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution. They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.
This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.
A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture. Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes. The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.
2. Statement of the problem
To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time. This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged. Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.
A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected. This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.
While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle. This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).
This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.
This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:
(short *) main
will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.
This is probably best illustrated with a simple real program example.
Let's consider the following simple program:
$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
return 1;
}
int __attribute__ ((mips16)) bar (void)
{
return 2;
}
int __attribute__ ((nomips16)) foo32 (void)
{
return 3;
}
int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;
int
main (void)
{
return foop ();
}
$
This is plain C with no odd tricks, except from the instruction mode
attributes. They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.
Let's try it with Linux, so that everyone can repeat this experiment:
$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$
Let's have a look at some interesting symbols:
$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar
68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p
70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop
78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32
80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo
88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi
$
Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).
So let's try to run and poke at this program with GDB. I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):
$ ./foobar
$ echo $?
1
$
So far, so good.
$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Yay, it worked! OK, so let's poke at it:
(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)
A-ha! Here's the difference and finally the ISA bit!
(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)
And here as well...
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
main () at foobar.c:24
24 }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)
So let's be a bit inquisitive...
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Actually we do not like to run foo here at all. Let's run bar instead!
(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)
Hmm, no ISA bit. Is it going to work?
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>: jr ra
0x0040068e <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9 }
(gdb)
Oops!
(gdb) p/x $pc
$12 = 0x40068c
(gdb)
We're still there!
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
So let's try something else:
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4 }
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
The same problem!
(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14 }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>: jr ra
0x00400688 <+4>: li v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0 foo32 () at foobar.c:14
main () at foobar.c:24
24 }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)
That did work though, so it's the ISA bit only!
(gdb) quit
Enough!
That's the tip of the iceberg only though. So let's rebuild the
executable with some dynamic symbols:
$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
$
OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm... What does `objdump' do then:
$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn: file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l df *ABS* 00000000 foobar.c
004009cc g F .text 00000004 0xf0 bar
00410b88 g O .data 00000004 foo32p
00410b84 g O .data 00000004 foop
004009c4 g F .text 00000008 foo32
004009c0 g F .text 00000004 0xf0 foo
00410b80 g O .data 00000004 fooi
DYNAMIC SYMBOL TABLE:
004009cc g DF .text 00000004 Base 0xf0 bar
00410b88 g DO .data 00000004 Base foo32p
00410b84 g DO .data 00000004 Base foop
004009c4 g DF .text 00000008 Base foo32
004009c0 g DF .text 00000004 Base 0xf0 foo
00410b80 g DO .data 00000004 Base fooi
$
Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.
Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:
$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
Compilation Unit @ offset 0x88:
Length: 0xbb (32-bit)
Version: 4
Abbrev Offset: 62
Pointer Size: 4
<0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
<94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
<98> DW_AT_language : 1 (ANSI C)
<99> DW_AT_name : (indirect string, offset: 0x190): foobar.c
<9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...]
<a1> DW_AT_ranges : 0x0
<a5> DW_AT_low_pc : 0x0
<a9> DW_AT_stmt_list : 0x27
<1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
<ae> DW_AT_external : 1
<ae> DW_AT_name : foo
<b2> DW_AT_decl_file : 1
<b3> DW_AT_decl_line : 1
<b4> DW_AT_prototyped : 1
<b4> DW_AT_type : <0xc2>
<b8> DW_AT_low_pc : 0x400680
<bc> DW_AT_high_pc : 0x400684
<c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<c2> DW_AT_GNU_all_call_sites: 1
<1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
<c3> DW_AT_byte_size : 4
<c4> DW_AT_encoding : 5 (signed)
<c5> DW_AT_name : int
<1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
<ca> DW_AT_external : 1
<ca> DW_AT_name : (indirect string, offset: 0x18a): foo32
<ce> DW_AT_decl_file : 1
<cf> DW_AT_decl_line : 11
<d0> DW_AT_prototyped : 1
<d0> DW_AT_type : <0xc2>
<d4> DW_AT_low_pc : 0x400684
<d8> DW_AT_high_pc : 0x40068c
<dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<de> DW_AT_GNU_all_call_sites: 1
<1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
<df> DW_AT_external : 1
<df> DW_AT_name : bar
<e3> DW_AT_decl_file : 1
<e4> DW_AT_decl_line : 6
<e5> DW_AT_prototyped : 1
<e5> DW_AT_type : <0xc2>
<e9> DW_AT_low_pc : 0x40068c
<ed> DW_AT_high_pc : 0x400690
<f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f3> DW_AT_GNU_all_call_sites: 1
<1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
<f4> DW_AT_external : 1
<f4> DW_AT_name : (indirect string, offset: 0x199): main
<f8> DW_AT_decl_file : 1
<f9> DW_AT_decl_line : 21
<fa> DW_AT_prototyped : 1
<fa> DW_AT_type : <0xc2>
<fe> DW_AT_low_pc : 0x400490
<102> DW_AT_high_pc : 0x4004a4
<106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<108> DW_AT_GNU_all_tail_call_sites: 1
[...]
$
-- no sign of the ISA bit anywhere -- frame info:
$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:
00000000 0000000c ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
DW_CFA_def_cfa_register: r29
DW_CFA_nop
00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684
00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c
00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690
00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
DW_CFA_advance_loc: 6 to 00400496
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r31 at cfa-4
DW_CFA_advance_loc: 6 to 0040049c
DW_CFA_restore: r31
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
[...]
$
-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):
$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:
Offset Begin End
00000000 00400680 00400690
00000000 00400490 004004a4
00000000 <End of list>
$
-- no sign of the ISA bit anywhere -- line info:
$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
Offset: 0x27
Length: 78
DWARF Version: 2
Prologue Length: 31
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table:
Entry Dir Time Size Name
1 0 0 0 foobar.c
Line Number Statements:
Extended opcode 2: set Address to 0x400681
Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
Advance Line by -7 to 7
Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
Advance PC by 3 to 0x400690
Extended opcode 1: End of Sequence
Extended opcode 2: set Address to 0x400491
Advance Line by 21 to 22
Copy
Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
Advance PC by 7 to 0x4004a4
Extended opcode 1: End of Sequence
[...]
-- a-ha, the ISA bit is there! However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:
00019630 <__libc_init_first>:
19630: e8a0 jrc ra
19632: 6500 nop
00019634 <_init>:
19634: f000 6a11 li v0,17
19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54>
1963c: f400 3240 sll v0,16
19640: e269 addu v0,v1
19642: 659a move gp,v0
19644: 64f6 save 48,ra,s0-s1
19646: 671c move s0,gp
19648: d204 sw v0,16(sp)
1964a: f352 984c lw v0,-27828(s0)
1964e: 6724 move s1,a0
and the corresponding DWARF-2 line info:
Line Number Statements:
Extended opcode 2: set Address to 0x19631
Advance Line by 44 to 45
Copy
Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
Advance PC by constant 17 to 0x19646
Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53
-- see that "Advance PC by constant 17" there? It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all. For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?
3. Solution:
I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.
In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.
All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down. This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.
Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places. Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.
I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB. I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.
Here's the resulting change. It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed. The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.
With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).
4. Results obtained
The change fixes the example above -- to repeat only the crucial steps:
(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>: jr ra
0x0040068f <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
main () at foobar.c:24
24 }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)
-- excellent!
The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:
=== gdb Summary ===
# of expected passes 14299
# of unexpected failures 187
# of expected failures 56
# of known failures 58
# of unresolved testcases 11
# of untested testcases 52
# of unsupported tests 174
MIPS16:
=== gdb Summary ===
# of expected passes 14298
# of unexpected failures 187
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 12
# of untested testcases 52
# of unsupported tests 174
microMIPS:
=== gdb Summary ===
# of expected passes 14149
# of unexpected failures 201
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 7
# of untested testcases 53
# of unsupported tests 175
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
Maciej W. Rozycki <macro@mips.com>
Pedro Alves <pedro@codesourcery.com>
gdb/
* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
remove `predefault' and `invalid_p' initializers.
(make_symbol_special): New architecture method.
(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
(objfile, symbol): New declarations.
* arch-utils.h (default_elf_make_msymbol_special): Remove
prototype.
(default_make_symbol_special): New prototype.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* mips-tdep.h (mips_unmake_compact_addr): New prototype.
* arch-utils.c (default_elf_make_msymbol_special): Remove
function.
(default_make_symbol_special): New function.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* dwarf2-frame.c (decode_frame_entry_1): Call
`gdbarch_adjust_dwarf2_addr'.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise. Call `gdbarch_make_symbol_special'.
(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
(read_call_site_scope): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(read_attribute_value): Likewise.
(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
* elfread.c (elf_symtab_read): Don't call
`gdbarch_elf_make_msymbol_special' if unset.
* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
the ISA bit from the PC.
* mips-tdep.c (mips_unmake_compact_addr): New function.
(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
address appropriately.
(mips_make_symbol_special): New function.
(mips_pc_is_mips): Set the ISA bit before symbol lookup.
(mips_pc_is_mips16): Likewise.
(mips_pc_is_micromips): Likewise.
(mips_pc_isa): Likewise.
(mips_adjust_dwarf2_addr): New function.
(mips_adjust_dwarf2_line): Likewise.
(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
(mips_addr_bits_remove): Likewise.
(mips_skip_trampoline_code): Likewise.
(mips_write_pc): Don't set the ISA bit.
(mips_eabi_push_dummy_call): Likewise.
(mips_o64_push_dummy_call): Likewise.
(mips_gdbarch_init): Install `mips_make_symbol_special',
`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
handlers.
* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
target-specific symbol address adjustments.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
gdb/testsuite/
* gdb.base/func-ptrs.c: New file.
* gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
# Process a symbol in the main symbol table in a backend-specific way.
# Normally this hook is supposed to do nothing, however if required,
# then this hook can be used to apply tranformations to symbols that
# are considered special in some way. This is currently used by the
# MIPS backend to make sure compressed code symbols have the ISA bit
# set. This in turn is needed for symbol values seen in GDB to match
# the values used at the runtime by the program itself, for function
# and label references.
2017-05-02 19:30:07 +02:00
f; void; make_symbol_special; struct symbol *sym, struct objfile *objfile; sym, objfile; ; default_make_symbol_special; ; 0
MIPS: Keep the ISA bit in compressed code addresses
1. Background information
The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned. As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception. This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.
Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI). The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.
As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2. That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.
So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit. Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.
To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution. They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.
This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.
A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture. Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes. The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.
2. Statement of the problem
To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time. This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged. Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.
A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected. This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.
While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle. This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).
This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.
This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:
(short *) main
will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.
This is probably best illustrated with a simple real program example.
Let's consider the following simple program:
$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
return 1;
}
int __attribute__ ((mips16)) bar (void)
{
return 2;
}
int __attribute__ ((nomips16)) foo32 (void)
{
return 3;
}
int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;
int
main (void)
{
return foop ();
}
$
This is plain C with no odd tricks, except from the instruction mode
attributes. They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.
Let's try it with Linux, so that everyone can repeat this experiment:
$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$
Let's have a look at some interesting symbols:
$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar
68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p
70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop
78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32
80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo
88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi
$
Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).
So let's try to run and poke at this program with GDB. I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):
$ ./foobar
$ echo $?
1
$
So far, so good.
$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Yay, it worked! OK, so let's poke at it:
(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)
A-ha! Here's the difference and finally the ISA bit!
(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)
And here as well...
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
main () at foobar.c:24
24 }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)
So let's be a bit inquisitive...
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Actually we do not like to run foo here at all. Let's run bar instead!
(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)
Hmm, no ISA bit. Is it going to work?
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>: jr ra
0x0040068e <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9 }
(gdb)
Oops!
(gdb) p/x $pc
$12 = 0x40068c
(gdb)
We're still there!
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
So let's try something else:
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4 }
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
The same problem!
(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14 }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>: jr ra
0x00400688 <+4>: li v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0 foo32 () at foobar.c:14
main () at foobar.c:24
24 }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)
That did work though, so it's the ISA bit only!
(gdb) quit
Enough!
That's the tip of the iceberg only though. So let's rebuild the
executable with some dynamic symbols:
$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
$
OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm... What does `objdump' do then:
$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn: file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l df *ABS* 00000000 foobar.c
004009cc g F .text 00000004 0xf0 bar
00410b88 g O .data 00000004 foo32p
00410b84 g O .data 00000004 foop
004009c4 g F .text 00000008 foo32
004009c0 g F .text 00000004 0xf0 foo
00410b80 g O .data 00000004 fooi
DYNAMIC SYMBOL TABLE:
004009cc g DF .text 00000004 Base 0xf0 bar
00410b88 g DO .data 00000004 Base foo32p
00410b84 g DO .data 00000004 Base foop
004009c4 g DF .text 00000008 Base foo32
004009c0 g DF .text 00000004 Base 0xf0 foo
00410b80 g DO .data 00000004 Base fooi
$
Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.
Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:
$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
Compilation Unit @ offset 0x88:
Length: 0xbb (32-bit)
Version: 4
Abbrev Offset: 62
Pointer Size: 4
<0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
<94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
<98> DW_AT_language : 1 (ANSI C)
<99> DW_AT_name : (indirect string, offset: 0x190): foobar.c
<9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...]
<a1> DW_AT_ranges : 0x0
<a5> DW_AT_low_pc : 0x0
<a9> DW_AT_stmt_list : 0x27
<1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
<ae> DW_AT_external : 1
<ae> DW_AT_name : foo
<b2> DW_AT_decl_file : 1
<b3> DW_AT_decl_line : 1
<b4> DW_AT_prototyped : 1
<b4> DW_AT_type : <0xc2>
<b8> DW_AT_low_pc : 0x400680
<bc> DW_AT_high_pc : 0x400684
<c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<c2> DW_AT_GNU_all_call_sites: 1
<1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
<c3> DW_AT_byte_size : 4
<c4> DW_AT_encoding : 5 (signed)
<c5> DW_AT_name : int
<1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
<ca> DW_AT_external : 1
<ca> DW_AT_name : (indirect string, offset: 0x18a): foo32
<ce> DW_AT_decl_file : 1
<cf> DW_AT_decl_line : 11
<d0> DW_AT_prototyped : 1
<d0> DW_AT_type : <0xc2>
<d4> DW_AT_low_pc : 0x400684
<d8> DW_AT_high_pc : 0x40068c
<dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<de> DW_AT_GNU_all_call_sites: 1
<1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
<df> DW_AT_external : 1
<df> DW_AT_name : bar
<e3> DW_AT_decl_file : 1
<e4> DW_AT_decl_line : 6
<e5> DW_AT_prototyped : 1
<e5> DW_AT_type : <0xc2>
<e9> DW_AT_low_pc : 0x40068c
<ed> DW_AT_high_pc : 0x400690
<f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f3> DW_AT_GNU_all_call_sites: 1
<1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
<f4> DW_AT_external : 1
<f4> DW_AT_name : (indirect string, offset: 0x199): main
<f8> DW_AT_decl_file : 1
<f9> DW_AT_decl_line : 21
<fa> DW_AT_prototyped : 1
<fa> DW_AT_type : <0xc2>
<fe> DW_AT_low_pc : 0x400490
<102> DW_AT_high_pc : 0x4004a4
<106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<108> DW_AT_GNU_all_tail_call_sites: 1
[...]
$
-- no sign of the ISA bit anywhere -- frame info:
$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:
00000000 0000000c ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
DW_CFA_def_cfa_register: r29
DW_CFA_nop
00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684
00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c
00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690
00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
DW_CFA_advance_loc: 6 to 00400496
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r31 at cfa-4
DW_CFA_advance_loc: 6 to 0040049c
DW_CFA_restore: r31
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
[...]
$
-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):
$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:
Offset Begin End
00000000 00400680 00400690
00000000 00400490 004004a4
00000000 <End of list>
$
-- no sign of the ISA bit anywhere -- line info:
$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
Offset: 0x27
Length: 78
DWARF Version: 2
Prologue Length: 31
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table:
Entry Dir Time Size Name
1 0 0 0 foobar.c
Line Number Statements:
Extended opcode 2: set Address to 0x400681
Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
Advance Line by -7 to 7
Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
Advance PC by 3 to 0x400690
Extended opcode 1: End of Sequence
Extended opcode 2: set Address to 0x400491
Advance Line by 21 to 22
Copy
Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
Advance PC by 7 to 0x4004a4
Extended opcode 1: End of Sequence
[...]
-- a-ha, the ISA bit is there! However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:
00019630 <__libc_init_first>:
19630: e8a0 jrc ra
19632: 6500 nop
00019634 <_init>:
19634: f000 6a11 li v0,17
19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54>
1963c: f400 3240 sll v0,16
19640: e269 addu v0,v1
19642: 659a move gp,v0
19644: 64f6 save 48,ra,s0-s1
19646: 671c move s0,gp
19648: d204 sw v0,16(sp)
1964a: f352 984c lw v0,-27828(s0)
1964e: 6724 move s1,a0
and the corresponding DWARF-2 line info:
Line Number Statements:
Extended opcode 2: set Address to 0x19631
Advance Line by 44 to 45
Copy
Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
Advance PC by constant 17 to 0x19646
Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53
-- see that "Advance PC by constant 17" there? It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all. For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?
3. Solution:
I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.
In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.
All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down. This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.
Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places. Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.
I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB. I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.
Here's the resulting change. It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed. The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.
With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).
4. Results obtained
The change fixes the example above -- to repeat only the crucial steps:
(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>: jr ra
0x0040068f <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
main () at foobar.c:24
24 }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)
-- excellent!
The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:
=== gdb Summary ===
# of expected passes 14299
# of unexpected failures 187
# of expected failures 56
# of known failures 58
# of unresolved testcases 11
# of untested testcases 52
# of unsupported tests 174
MIPS16:
=== gdb Summary ===
# of expected passes 14298
# of unexpected failures 187
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 12
# of untested testcases 52
# of unsupported tests 174
microMIPS:
=== gdb Summary ===
# of expected passes 14149
# of unexpected failures 201
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 7
# of untested testcases 53
# of unsupported tests 175
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
Maciej W. Rozycki <macro@mips.com>
Pedro Alves <pedro@codesourcery.com>
gdb/
* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
remove `predefault' and `invalid_p' initializers.
(make_symbol_special): New architecture method.
(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
(objfile, symbol): New declarations.
* arch-utils.h (default_elf_make_msymbol_special): Remove
prototype.
(default_make_symbol_special): New prototype.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* mips-tdep.h (mips_unmake_compact_addr): New prototype.
* arch-utils.c (default_elf_make_msymbol_special): Remove
function.
(default_make_symbol_special): New function.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* dwarf2-frame.c (decode_frame_entry_1): Call
`gdbarch_adjust_dwarf2_addr'.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise. Call `gdbarch_make_symbol_special'.
(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
(read_call_site_scope): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(read_attribute_value): Likewise.
(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
* elfread.c (elf_symtab_read): Don't call
`gdbarch_elf_make_msymbol_special' if unset.
* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
the ISA bit from the PC.
* mips-tdep.c (mips_unmake_compact_addr): New function.
(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
address appropriately.
(mips_make_symbol_special): New function.
(mips_pc_is_mips): Set the ISA bit before symbol lookup.
(mips_pc_is_mips16): Likewise.
(mips_pc_is_micromips): Likewise.
(mips_pc_isa): Likewise.
(mips_adjust_dwarf2_addr): New function.
(mips_adjust_dwarf2_line): Likewise.
(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
(mips_addr_bits_remove): Likewise.
(mips_skip_trampoline_code): Likewise.
(mips_write_pc): Don't set the ISA bit.
(mips_eabi_push_dummy_call): Likewise.
(mips_o64_push_dummy_call): Likewise.
(mips_gdbarch_init): Install `mips_make_symbol_special',
`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
handlers.
* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
target-specific symbol address adjustments.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
gdb/testsuite/
* gdb.base/func-ptrs.c: New file.
* gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
# Adjust the address retrieved from a DWARF-2 record other than a line
# entry in a backend-specific way. Normally this hook is supposed to
# return the address passed unchanged, however if that is incorrect for
# any reason, then this hook can be used to fix the address up in the
# required manner. This is currently used by the MIPS backend to make
# sure addresses in FDE, range records, etc. referring to compressed
# code have the ISA bit set, matching line information and the symbol
# table.
2017-05-02 19:30:07 +02:00
f; CORE_ADDR; adjust_dwarf2_addr; CORE_ADDR pc; pc; ; default_adjust_dwarf2_addr; ; 0
MIPS: Keep the ISA bit in compressed code addresses
1. Background information
The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned. As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception. This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.
Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI). The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.
As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2. That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.
So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit. Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.
To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution. They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.
This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.
A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture. Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes. The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.
2. Statement of the problem
To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time. This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged. Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.
A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected. This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.
While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle. This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).
This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.
This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:
(short *) main
will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.
This is probably best illustrated with a simple real program example.
Let's consider the following simple program:
$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
return 1;
}
int __attribute__ ((mips16)) bar (void)
{
return 2;
}
int __attribute__ ((nomips16)) foo32 (void)
{
return 3;
}
int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;
int
main (void)
{
return foop ();
}
$
This is plain C with no odd tricks, except from the instruction mode
attributes. They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.
Let's try it with Linux, so that everyone can repeat this experiment:
$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$
Let's have a look at some interesting symbols:
$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar
68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p
70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop
78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32
80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo
88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi
$
Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).
So let's try to run and poke at this program with GDB. I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):
$ ./foobar
$ echo $?
1
$
So far, so good.
$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Yay, it worked! OK, so let's poke at it:
(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)
A-ha! Here's the difference and finally the ISA bit!
(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)
And here as well...
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
main () at foobar.c:24
24 }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)
So let's be a bit inquisitive...
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Actually we do not like to run foo here at all. Let's run bar instead!
(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)
Hmm, no ISA bit. Is it going to work?
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>: jr ra
0x0040068e <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9 }
(gdb)
Oops!
(gdb) p/x $pc
$12 = 0x40068c
(gdb)
We're still there!
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
So let's try something else:
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4 }
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
The same problem!
(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14 }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>: jr ra
0x00400688 <+4>: li v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0 foo32 () at foobar.c:14
main () at foobar.c:24
24 }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)
That did work though, so it's the ISA bit only!
(gdb) quit
Enough!
That's the tip of the iceberg only though. So let's rebuild the
executable with some dynamic symbols:
$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
$
OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm... What does `objdump' do then:
$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn: file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l df *ABS* 00000000 foobar.c
004009cc g F .text 00000004 0xf0 bar
00410b88 g O .data 00000004 foo32p
00410b84 g O .data 00000004 foop
004009c4 g F .text 00000008 foo32
004009c0 g F .text 00000004 0xf0 foo
00410b80 g O .data 00000004 fooi
DYNAMIC SYMBOL TABLE:
004009cc g DF .text 00000004 Base 0xf0 bar
00410b88 g DO .data 00000004 Base foo32p
00410b84 g DO .data 00000004 Base foop
004009c4 g DF .text 00000008 Base foo32
004009c0 g DF .text 00000004 Base 0xf0 foo
00410b80 g DO .data 00000004 Base fooi
$
Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.
Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:
$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
Compilation Unit @ offset 0x88:
Length: 0xbb (32-bit)
Version: 4
Abbrev Offset: 62
Pointer Size: 4
<0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
<94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
<98> DW_AT_language : 1 (ANSI C)
<99> DW_AT_name : (indirect string, offset: 0x190): foobar.c
<9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...]
<a1> DW_AT_ranges : 0x0
<a5> DW_AT_low_pc : 0x0
<a9> DW_AT_stmt_list : 0x27
<1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
<ae> DW_AT_external : 1
<ae> DW_AT_name : foo
<b2> DW_AT_decl_file : 1
<b3> DW_AT_decl_line : 1
<b4> DW_AT_prototyped : 1
<b4> DW_AT_type : <0xc2>
<b8> DW_AT_low_pc : 0x400680
<bc> DW_AT_high_pc : 0x400684
<c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<c2> DW_AT_GNU_all_call_sites: 1
<1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
<c3> DW_AT_byte_size : 4
<c4> DW_AT_encoding : 5 (signed)
<c5> DW_AT_name : int
<1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
<ca> DW_AT_external : 1
<ca> DW_AT_name : (indirect string, offset: 0x18a): foo32
<ce> DW_AT_decl_file : 1
<cf> DW_AT_decl_line : 11
<d0> DW_AT_prototyped : 1
<d0> DW_AT_type : <0xc2>
<d4> DW_AT_low_pc : 0x400684
<d8> DW_AT_high_pc : 0x40068c
<dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<de> DW_AT_GNU_all_call_sites: 1
<1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
<df> DW_AT_external : 1
<df> DW_AT_name : bar
<e3> DW_AT_decl_file : 1
<e4> DW_AT_decl_line : 6
<e5> DW_AT_prototyped : 1
<e5> DW_AT_type : <0xc2>
<e9> DW_AT_low_pc : 0x40068c
<ed> DW_AT_high_pc : 0x400690
<f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f3> DW_AT_GNU_all_call_sites: 1
<1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
<f4> DW_AT_external : 1
<f4> DW_AT_name : (indirect string, offset: 0x199): main
<f8> DW_AT_decl_file : 1
<f9> DW_AT_decl_line : 21
<fa> DW_AT_prototyped : 1
<fa> DW_AT_type : <0xc2>
<fe> DW_AT_low_pc : 0x400490
<102> DW_AT_high_pc : 0x4004a4
<106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<108> DW_AT_GNU_all_tail_call_sites: 1
[...]
$
-- no sign of the ISA bit anywhere -- frame info:
$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:
00000000 0000000c ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
DW_CFA_def_cfa_register: r29
DW_CFA_nop
00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684
00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c
00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690
00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
DW_CFA_advance_loc: 6 to 00400496
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r31 at cfa-4
DW_CFA_advance_loc: 6 to 0040049c
DW_CFA_restore: r31
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
[...]
$
-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):
$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:
Offset Begin End
00000000 00400680 00400690
00000000 00400490 004004a4
00000000 <End of list>
$
-- no sign of the ISA bit anywhere -- line info:
$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
Offset: 0x27
Length: 78
DWARF Version: 2
Prologue Length: 31
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table:
Entry Dir Time Size Name
1 0 0 0 foobar.c
Line Number Statements:
Extended opcode 2: set Address to 0x400681
Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
Advance Line by -7 to 7
Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
Advance PC by 3 to 0x400690
Extended opcode 1: End of Sequence
Extended opcode 2: set Address to 0x400491
Advance Line by 21 to 22
Copy
Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
Advance PC by 7 to 0x4004a4
Extended opcode 1: End of Sequence
[...]
-- a-ha, the ISA bit is there! However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:
00019630 <__libc_init_first>:
19630: e8a0 jrc ra
19632: 6500 nop
00019634 <_init>:
19634: f000 6a11 li v0,17
19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54>
1963c: f400 3240 sll v0,16
19640: e269 addu v0,v1
19642: 659a move gp,v0
19644: 64f6 save 48,ra,s0-s1
19646: 671c move s0,gp
19648: d204 sw v0,16(sp)
1964a: f352 984c lw v0,-27828(s0)
1964e: 6724 move s1,a0
and the corresponding DWARF-2 line info:
Line Number Statements:
Extended opcode 2: set Address to 0x19631
Advance Line by 44 to 45
Copy
Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
Advance PC by constant 17 to 0x19646
Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53
-- see that "Advance PC by constant 17" there? It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all. For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?
3. Solution:
I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.
In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.
All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down. This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.
Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places. Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.
I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB. I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.
Here's the resulting change. It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed. The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.
With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).
4. Results obtained
The change fixes the example above -- to repeat only the crucial steps:
(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>: jr ra
0x0040068f <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
main () at foobar.c:24
24 }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)
-- excellent!
The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:
=== gdb Summary ===
# of expected passes 14299
# of unexpected failures 187
# of expected failures 56
# of known failures 58
# of unresolved testcases 11
# of untested testcases 52
# of unsupported tests 174
MIPS16:
=== gdb Summary ===
# of expected passes 14298
# of unexpected failures 187
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 12
# of untested testcases 52
# of unsupported tests 174
microMIPS:
=== gdb Summary ===
# of expected passes 14149
# of unexpected failures 201
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 7
# of untested testcases 53
# of unsupported tests 175
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
Maciej W. Rozycki <macro@mips.com>
Pedro Alves <pedro@codesourcery.com>
gdb/
* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
remove `predefault' and `invalid_p' initializers.
(make_symbol_special): New architecture method.
(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
(objfile, symbol): New declarations.
* arch-utils.h (default_elf_make_msymbol_special): Remove
prototype.
(default_make_symbol_special): New prototype.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* mips-tdep.h (mips_unmake_compact_addr): New prototype.
* arch-utils.c (default_elf_make_msymbol_special): Remove
function.
(default_make_symbol_special): New function.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* dwarf2-frame.c (decode_frame_entry_1): Call
`gdbarch_adjust_dwarf2_addr'.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise. Call `gdbarch_make_symbol_special'.
(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
(read_call_site_scope): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(read_attribute_value): Likewise.
(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
* elfread.c (elf_symtab_read): Don't call
`gdbarch_elf_make_msymbol_special' if unset.
* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
the ISA bit from the PC.
* mips-tdep.c (mips_unmake_compact_addr): New function.
(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
address appropriately.
(mips_make_symbol_special): New function.
(mips_pc_is_mips): Set the ISA bit before symbol lookup.
(mips_pc_is_mips16): Likewise.
(mips_pc_is_micromips): Likewise.
(mips_pc_isa): Likewise.
(mips_adjust_dwarf2_addr): New function.
(mips_adjust_dwarf2_line): Likewise.
(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
(mips_addr_bits_remove): Likewise.
(mips_skip_trampoline_code): Likewise.
(mips_write_pc): Don't set the ISA bit.
(mips_eabi_push_dummy_call): Likewise.
(mips_o64_push_dummy_call): Likewise.
(mips_gdbarch_init): Install `mips_make_symbol_special',
`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
handlers.
* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
target-specific symbol address adjustments.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
gdb/testsuite/
* gdb.base/func-ptrs.c: New file.
* gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
# Adjust the address updated by a line entry in a backend-specific way.
# Normally this hook is supposed to return the address passed unchanged,
# however in the case of inconsistencies in these records, this hook can
# be used to fix them up in the required manner. This is currently used
# by the MIPS backend to make sure all line addresses in compressed code
# are presented with the ISA bit set, which is not always the case. This
# in turn ensures breakpoint addresses are correctly matched against the
# stop PC.
2017-05-02 19:30:07 +02:00
f; CORE_ADDR; adjust_dwarf2_line; CORE_ADDR addr, int rel; addr, rel; ; default_adjust_dwarf2_line; ; 0
v; int; cannot_step_breakpoint; ; ; 0; 0; ; 0
2018-08-31 15:24:13 +02:00
# See comment in target.h about continuable, steppable and
# non-steppable watchpoints.
2017-05-02 19:30:07 +02:00
v; int; have_nonsteppable_watchpoint; ; ; 0; 0; ; 0
F; int; address_class_type_flags; int byte_size, int dwarf2_addr_class; byte_size, dwarf2_addr_class
M; const char *; address_class_type_flags_to_name; int type_flags; type_flags
2017-04-26 15:05:03 +02:00
# Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction.
# FS are passed from the generic execute_cfa_program function.
2017-05-02 19:30:07 +02:00
m; bool; execute_dwarf_cfa_vendor_op; gdb_byte op, struct dwarf2_frame_state *fs; op, fs; ; default_execute_dwarf_cfa_vendor_op; ; 0
2014-01-17 10:54:56 +01:00
# Return the appropriate type_flags for the supplied address class.
# This function should return 1 if the address class was recognized and
# type_flags was set, zero otherwise.
2017-05-02 19:30:07 +02:00
M; int; address_class_name_to_type_flags; const char *name, int *type_flags_ptr; name, type_flags_ptr
2002-11-02 16:13:34 +01:00
# Is a register in a group
2017-05-02 19:30:07 +02:00
m; int; register_reggroup_p; int regnum, struct reggroup *reggroup; regnum, reggroup; ; default_register_reggroup_p; ; 0
2003-10-11 14:05:44 +02:00
# Fetch the pointer to the ith function argument.
2017-05-02 19:30:07 +02:00
F; CORE_ADDR; fetch_pointer_argument; struct frame_info *frame, int argi, struct type *type; frame, argi, type
2003-10-11 14:52:30 +02:00
Replace 'core_regset_sections' by iterator method
The core_regset_sections list in gdbarch (needed for multi-arch
capable core file generation support) is replaced by an iterator
method. Overall, this reduces the code a bit, and it allows for more
flexibility.
gdb/ChangeLog:
* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
(amd64_linux_iterate_over_regset_sections): New.
(amd64_linux_init_abi_common): Don't install the regset section
list, but the new iterator in gdbarch.
* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
(arm_linux_vfp_regset_sections): Remove. Move combined logic...
(arm_linux_iterate_over_regset_sections): ...here. New function.
(arm_linux_init_abi): Set iterator instead of section list.
* corelow.c (get_core_registers_cb): New function, logic moved
from...
(get_core_registers): ...loop body here. Use new iterator method
instead of walking through the regset section list.
* gdbarch.sh: Remove 'core_regset_sections'. New method
'iterate_over_regset_sections'. New typedef
'iterate_over_regset_sections_cb'.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* i386-linux-tdep.c (i386_linux_regset_sections)
(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
Remove.
(i386_linux_iterate_over_regset_sections): New.
(i386_linux_init_abi): Don't choose a regset section list, but
install new iterator in gdbarch.
* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
(linux_collect_regset_section_cb): New function, logic moved
from...
(linux_collect_thread_registers): ...loop body here. Use iterator
method instead of walking through list.
(linux_make_corefile_notes_1): Check for presence of iterator
method instead of regset section list.
* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
(ppc64_linux_fp_regset_sections): Remove. Move combined logic...
(ppc_linux_iterate_over_regset_sections): ...here. New function.
(ppc_linux_init_abi): Don't choose from above regset section
lists, but install new iterator in gdbarch.
* regset.h (struct core_regset_section): Remove.
* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
have_linux_v1, have_linux_v2, and have_tdb.
(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
(s390x_linux64v2_regset_sections): Remove. Move combined logic...
(s390_iterate_over_regset_sections): ...here. New function. Use
new tdep fields.
(s390_gdbarch_init): Set new tdep fields. Don't choose from above
regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
# Iterate over all supported register notes in a core file. For each
# supported register note section, the iterator must call CB and pass
# CB_DATA unchanged. If REGCACHE is not NULL, the iterator can limit
# the supported register note sections based on the current register
# values. Otherwise it should enumerate all supported register note
# sections.
2017-05-02 19:30:07 +02:00
M; void; iterate_over_regset_sections; iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache; cb, cb_data, regcache
2008-05-24 18:32:01 +02:00
2012-01-20 10:56:56 +01:00
# Create core file notes
2017-05-02 19:30:07 +02:00
M; char *; make_corefile_notes; bfd *obfd, int *note_size; obfd, note_size
2012-01-20 10:56:56 +01:00
2012-01-20 10:59:15 +01:00
# Find core file memory regions
2017-05-02 19:30:07 +02:00
M; int; find_memory_regions; find_memory_region_ftype func, void *data; func, data
2012-01-20 10:59:15 +01:00
2007-09-04 01:06:35 +02:00
# Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from
2014-01-27 05:56:56 +01:00
# core file into buffer READBUF with length LEN. Return the number of bytes read
# (zero indicates failure).
# failed, otherwise, return the red length of READBUF.
2017-05-02 19:30:07 +02:00
M; ULONGEST; core_xfer_shared_libraries; gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len
2007-09-04 01:06:35 +02:00
ppc-aix core file relocation.
The current code attempts to provide relocation support when debugging
core files via the rs6000_xfer_partial method of the rs6000-nat
target_ops vector. However, this target_ops vector does not get pushed
on the target stack at all when debugging core files, thus bypassing
completely that part of the code.
This patch fixes the problem by extending corelow's core_xfer_partial
into handling the TARGET_OBJECT_LIBRARIES_AIX object.
gdb/ChangeLog:
* gdbarch.sh (core_xfer_shared_libraries_aix): New method.
* gdbarch.h, gdbarch.c: Regenerate.
* corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX
handling.
* rs6000-aix-tdep.h: New file.
* Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h.
* rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and
"xml-utils.h".
(struct field_info, struct ld_info_desc): New types.
(ld_info32_desc, ld_info64_desc): New static constants.
(struct ld_info): New type.
(rs6000_aix_extract_ld_info): New function.
(rs6000_aix_shared_library_to_xml): Likewise.
(rs6000_aix_ld_info_to_xml): Likewise.
(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
(rs6000_aix_init_osabi): Add call to
set_gdbarch_core_xfer_shared_libraries_aix.
* rs6000-nat.c: Add "rs6000-aix-tdep.h" include.
Remove "xml-utils.h" include.
(LdInfo): Delete typedef.
(ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME):
Delete macros.
(rs6000_ptrace_ldinfo): Change return type to gdb_byte *.
Adjust code accordingly.
(rs6000_core_ldinfo): Delete, folded into
rs6000_aix_core_xfer_shared_libraries_aix.
(rs6000_xfer_shared_library): Delete.
(rs6000_xfer_shared_libraries): Reimplement.
2013-05-15 14:26:14 +02:00
# Read offset OFFSET of TARGET_OBJECT_LIBRARIES_AIX formatted shared
# libraries list from core file into buffer READBUF with length LEN.
2014-01-27 05:56:56 +01:00
# Return the number of bytes read (zero indicates failure).
2017-05-02 19:30:07 +02:00
M; ULONGEST; core_xfer_shared_libraries_aix; gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len
ppc-aix core file relocation.
The current code attempts to provide relocation support when debugging
core files via the rs6000_xfer_partial method of the rs6000-nat
target_ops vector. However, this target_ops vector does not get pushed
on the target stack at all when debugging core files, thus bypassing
completely that part of the code.
This patch fixes the problem by extending corelow's core_xfer_partial
into handling the TARGET_OBJECT_LIBRARIES_AIX object.
gdb/ChangeLog:
* gdbarch.sh (core_xfer_shared_libraries_aix): New method.
* gdbarch.h, gdbarch.c: Regenerate.
* corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX
handling.
* rs6000-aix-tdep.h: New file.
* Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h.
* rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and
"xml-utils.h".
(struct field_info, struct ld_info_desc): New types.
(ld_info32_desc, ld_info64_desc): New static constants.
(struct ld_info): New type.
(rs6000_aix_extract_ld_info): New function.
(rs6000_aix_shared_library_to_xml): Likewise.
(rs6000_aix_ld_info_to_xml): Likewise.
(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
(rs6000_aix_init_osabi): Add call to
set_gdbarch_core_xfer_shared_libraries_aix.
* rs6000-nat.c: Add "rs6000-aix-tdep.h" include.
Remove "xml-utils.h" include.
(LdInfo): Delete typedef.
(ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME):
Delete macros.
(rs6000_ptrace_ldinfo): Change return type to gdb_byte *.
Adjust code accordingly.
(rs6000_core_ldinfo): Delete, folded into
rs6000_aix_core_xfer_shared_libraries_aix.
(rs6000_xfer_shared_library): Delete.
(rs6000_xfer_shared_libraries): Reimplement.
2013-05-15 14:26:14 +02:00
2010-07-19 19:51:25 +02:00
# How the core target converts a PTID from a core file to a string.
Change pid_to_str to return std::string
Currently the target pid_to_str method returns a const char *, so many
implementations have a static buffer that they update. This patch
changes these methods to return a std::string instead. I think this
is cleaner and avoids possible gotchas when calling pid_to_str on
different ptids in a single statement. (Though no such calls exist
currently.)
This also updates various helper functions, and the gdbarch pid_to_str
methods.
I also made a best effort to fix all the callers, but I can't build
some of the *-nat.c files.
Tested by the buildbot.
gdb/ChangeLog
2019-03-13 Tom Tromey <tromey@adacore.com>
* i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers)
(i386_gnu_nat_target::store_registers): Update.
* target-debug.h (target_debug_print_std_string): New macro.
* x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
* windows-tdep.c (display_one_tib): Update.
* tui/tui-stack.c (tui_make_status_line): Update.
* top.c (print_inferior_quit_action): Update.
* thread.c (thr_try_catch_cmd): Update.
(add_thread_with_info): Update.
(thread_target_id_str): Update.
(thr_try_catch_cmd): Update.
(thread_command): Update.
(thread_find_command): Update.
* record-btrace.c (record_btrace_target::info_record)
(record_btrace_resume_thread, record_btrace_target::resume)
(record_btrace_cancel_resume, record_btrace_step_thread)
(record_btrace_target::wait, record_btrace_target::wait)
(record_btrace_target::wait, record_btrace_target::stop): Update.
* progspace.c (print_program_space): Update.
* process-stratum-target.c
(process_stratum_target::thread_address_space): Update.
* linux-fork.c (linux_fork_mourn_inferior)
(detach_checkpoint_command, info_checkpoints_command)
(linux_fork_context): Update.
(linux_fork_detach): Update.
(class scoped_switch_fork_info): Update.
(delete_checkpoint_command): Update.
* infrun.c (follow_fork_inferior): Update.
(follow_fork_inferior): Update.
(proceed_after_vfork_done): Update.
(handle_vfork_child_exec_or_exit): Update.
(follow_exec): Update.
(displaced_step_prepare_throw): Update.
(displaced_step_restore): Update.
(start_step_over): Update.
(resume_1): Update.
(clear_proceed_status_thread): Update.
(proceed): Update.
(print_target_wait_results): Update.
(do_target_wait): Update.
(context_switch): Update.
(stop_all_threads): Update.
(restart_threads): Update.
(finish_step_over): Update.
(handle_signal_stop): Update.
(switch_back_to_stepped_thread): Update.
(keep_going_pass_signal): Update.
(print_exited_reason): Update.
(normal_stop): Update.
* inferior.c (inferior_pid_to_str): Change return type.
(print_selected_inferior): Update.
(add_inferior): Update.
(detach_inferior): Update.
* dummy-frame.c (fprint_dummy_frames): Update.
* dcache.c (dcache_info_1): Update.
* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
(btrace_fetch, btrace_clear): Update.
* linux-tdep.c (linux_core_pid_to_str): Change return type.
* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return
type.
* fbsd-tdep.c (fbsd_core_pid_to_str): Change return type.
* sol2-tdep.h (sol2_core_pid_to_str): Change return type.
* sol2-tdep.c (sol2_core_pid_to_str): Change return type.
* gdbarch.c, gdbarch.h: Rebuild.
* gdbarch.sh (core_pid_to_str): Change return type.
* windows-nat.c (struct windows_nat_target) <pid_to_str>: Change
return type.
(windows_nat_target::pid_to_str): Change return type.
(windows_delete_thread): Update.
(windows_nat_target::attach): Update.
(windows_nat_target::files_info): Update.
* target-delegates.c: Rebuild.
* sol-thread.c (class sol_thread_target) <pid_to_str>: Change
return type.
(sol_thread_target::pid_to_str): Change return type.
* remote.c (class remote_target) <pid_to_str>: Change return
type.
(remote_target::pid_to_str): Change return type.
(extended_remote_target::attach, remote_target::remote_stop_ns)
(remote_target::remote_notif_remove_queued_reply)
(remote_target::push_stop_reply, remote_target::disable_btrace):
Update.
(extended_remote_target::attach): Update.
* remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return
type.
(gdbsim_target::pid_to_str): Change return type.
* ravenscar-thread.c (struct ravenscar_thread_target)
<pid_to_str>: Change return type.
(ravenscar_thread_target::pid_to_str): Change return type.
* procfs.c (class procfs_target) <pid_to_str>: Change return
type.
(procfs_target::pid_to_str): Change return type.
(procfs_target::attach): Update.
(procfs_target::detach): Update.
(procfs_target::fetch_registers): Update.
(procfs_target::store_registers): Update.
(procfs_target::wait): Update.
(procfs_target::files_info): Update.
* obsd-nat.c (obsd_nat_target::pid_to_str): Change return type.
* nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change
return type.
(nto_procfs_target::pid_to_str): Change return type.
(nto_procfs_target::files_info, nto_procfs_target::attach): Update.
* linux-thread-db.c (class thread_db_target) <pid_to_str>: Change
return type.
* linux-nat.c (linux_nat_target::pid_to_str): Change return type.
(exit_lwp): Update.
(attach_proc_task_lwp_callback, get_detach_signal)
(detach_one_lwp, resume_lwp, linux_nat_target::resume)
(linux_nat_target::resume, wait_lwp, stop_callback)
(maybe_clear_ignore_sigint, stop_wait_callback, status_callback)
(save_stop_reason, select_event_lwp, linux_nat_filter_event)
(linux_nat_wait_1, resume_stopped_resumed_lwps)
(linux_nat_target::wait, linux_nat_stop_lwp): Update.
* inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return
type.
(inf_ptrace_target::attach): Update.
(inf_ptrace_target::files_info): Update.
* go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return
type.
(go32_nat_target::pid_to_str): Change return type.
* gnu-nat.c (gnu_nat_target::pid_to_str): Change return type.
(gnu_nat_target::wait): Update.
(gnu_nat_target::wait): Update.
(gnu_nat_target::resume): Update.
* fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type.
(fbsd_nat_target::wait): Update.
* darwin-nat.c (darwin_nat_target::pid_to_str): Change return
type.
(darwin_nat_target::attach): Update.
* corelow.c (class core_target) <pid_to_str>: Change return type.
(core_target::pid_to_str): Change return type.
* target.c (normal_pid_to_str): Change return type.
(default_pid_to_str): Likewise.
(target_pid_to_str): Change return type.
(target_translate_tls_address): Update.
(target_announce_detach): Update.
* bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change
return type.
(bsd_uthread_target::pid_to_str): Change return type.
* bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return
type.
(bsd_kvm_target::pid_to_str): Change return type.
* aix-thread.c (class aix_thread_target) <pid_to_str>: Change
return type.
(aix_thread_target::pid_to_str): Change return type.
* target.h (struct target_ops) <pid_to_str>: Change return type.
(target_pid_to_str, normal_pid_to_str): Likewise.
* obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return
type.
* linux-nat.h (class linux_nat_target) <pid_to_str>: Change return
type.
* inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change
return type.
* gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return
type.
* fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return
type.
* darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change
return type.
2019-02-28 17:09:55 +01:00
M; std::string; core_pid_to_str; ptid_t ptid; ptid
* corelow.c (get_core_registers): Adjust.
(core_file_thread_alive): Rename to...
(core_thread_alive): ... this.
(core_pid_to_str): Try gdbarch_core_pid_to_str first.
(init_core_ops): Adjust.
(coreops_suppress_target): Delete.
(_initialize_corelow): Unconditionally add core_ops.
* procfs.c: Include "inf-child.h".
(procfs_ops): Delete.
(init_procfs_ops): Delete. Reimplement as...
(procfs_target): ... this, inheriting from inf-child.
(procfs_attach, procfs_detach, procfs_fetch_registers): Adjust.
(procfs_prepare_to_store): Delete.
(procfs_store_registers, procfs_resume): Adjust.
(procfs_open): Delete.
(procfs_suppress_run): Delete.
(procfs_can_run): Delete.
(procfs_mourn_inferior): Adjust.
(procfs_init_inferior): Add target_ops parameter. Adjust.
(procfs_create_inferior): Don't pass procfs_init_inferior to
fork_inferior. Instead call it after fork_inferior returns.
(procfs_find_new_threads): Adjust.
(_initialize_procfs): Adjust to use procfs_target instead of
init_procfs_ops.
* sol-thread.c (orig_core_ops, sol_core_ops): Delete.
(lwp_to_thread): Use target_thread_alive.
(sol_thread_open): Delete.
(sol_thread_attach): Delete.
(sol_thread_detach, sol_thread_resume, sol_thread_wait)
(sol_thread_fetch_registers, sol_thread_store_registers): Adjust
to use find_target_beneath.
(sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete.
(sol_thread_xfer_partial): Adjust to use find_target_beneath.
(sol_thread_files_info, sol_thread_kill_inferior): Delete.
(check_for_thread_db): New.
(sol_thread_notice_signals, sol_thread_create_inferior): Delete.
(sol_thread_new_objfile): Call check_for_thread_db.
(sol_thread_mourn_inferior): Adjust to use find_target_beneath.
(sol_thread_can_run): Delete.
(sol_thread_alive): Adjust to use find_target_beneath.
(sol_thread_stop): Delete.
(rw_common): Use target_write_memory or target_read_memory.
(ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers.
(ps_lsetregs, ps_lsetfpregs): Use target_store_registers.
(solaris_pid_to_str): Remove check for libthread_db initialization
failing.
(sol_find_new_threads): Remove check for libthread_db
initialization failing, or for an invalid inferior_ptid. Adjust
to use find_target_beneath.
(sol_core_open, sol_core_close, sol_core_detach,
sol_core_files_info, sol_find_memory_regions,
sol_make_note_section, ignore): Delete.
(init_sol_thread_ops): Make it a thread_stratum target. Remove
unneeded callback settings.
(init_sol_core_ops): Delete.
(_initialize_sol_thread): No longer call init_sol_core_ops, set
procfs_suppress_run, or hack with core_ops.
* target.h (struct target_ops): Add a target_ops * parameter to
to_resume, to_fetch_registers, to_store_registers, to_thread_alive
and to_find_new_threads.
(target_fetch_registers, target_store_registers)
(target_thread_alive, target_find_new_threads): Redeclare as
function.
* target.c (update_current_target): Do not inherit or de_fault
to_resume, to_fetch_registers, to_store_registers,
to_thread_alive, to_find_new_threads.
(target_resume): Adjust.
(target_thread_alive, target_find_new_threads): New.
(debug_to_resume, debug_to_fetch_registers): Delete.
(target_fetch_registers): New.
(debug_to_store_registers): Delete.
(target_store_registers): New.
(debug_to_thread_alive, debug_to_find_new_threads): Delete.
(setup_target_debug): Adjust.
* gdbcore.h (core_ops): Delete declaration.
* inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c,
inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c,
i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c,
hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c,
nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c,
alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c,
bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c,
hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c,
ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c,
m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c,
mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c,
ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c,
shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c,
vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes.
* gdbarch.sh (core_pid_to_str): New gdbarch callback.
* gdbarch.h, gdbarch.c: Regenerate.
* sol2-tdep.c: Include "inferior.h".
(sol2_core_pid_to_str): New.
* sol2-tdep.h (sol2_core_pid_to_str): Declare.
* amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it.
* i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
2016-01-18 18:49:23 +01:00
# How the core target extracts the name of a thread from a core file.
2017-05-02 19:30:07 +02:00
M; const char *; core_thread_name; struct thread_info *thr; thr
2016-01-18 18:49:23 +01:00
2017-06-28 20:11:20 +02:00
# Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
# from core file into buffer READBUF with length LEN. Return the number
# of bytes read (zero indicates EOF, a negative value indicates failure).
M; LONGEST; core_xfer_siginfo; gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len
2009-06-17 20:48:26 +02:00
# BFD target to use when generating a core file.
2017-05-02 19:30:07 +02:00
V; const char *; gcore_bfd_target; ; ; 0; 0; ; ; pstring ( gdbarch->gcore_bfd_target)
2009-06-17 20:48:26 +02:00
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
# If the elements of C++ vtables are in-place function descriptors rather
# than normal function pointers (which may point to code or a descriptor),
# set this to one.
2017-05-02 19:30:07 +02:00
v; int; vtable_function_descriptors; ; ; 0; 0; ; 0
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
# Set if the least significant bit of the delta is used instead of the least
# significant bit of the pfn for pointers to virtual member functions.
2017-05-02 19:30:07 +02:00
v; int; vbit_in_delta; ; ; 0; 0; ; 0
2007-05-07 20:20:21 +02:00
# Advance PC to next instruction in order to skip a permanent breakpoint.
2017-05-02 19:30:07 +02:00
f; void; skip_permanent_breakpoint; struct regcache *regcache; regcache; default_skip_permanent_breakpoint; default_skip_permanent_breakpoint; ; 0
2007-05-11 21:57:17 +02:00
2011-12-28 19:45:46 +01:00
# The maximum length of an instruction on this architecture in bytes.
2017-05-02 19:30:07 +02:00
V; ULONGEST; max_insn_length; ; ; 0; 0
Implement displaced stepping.
gdb/
* gdbarch.sh (max_insn_length): New 'variable'.
(displaced_step_copy, displaced_step_fixup)
(displaced_step_free_closure, displaced_step_location): New
functions.
(struct displaced_step_closure): Add forward declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* arch-utils.c: #include "objfiles.h".
(simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New functions.
* arch-utils.h (simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New prototypes.
* i386-tdep.c (I386_MAX_INSN_LEN): Rename to...
(I386_MAX_MATCHED_INSN_LEN): ... this.
(i386_absolute_jmp_p, i386_absolute_call_p)
(i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p)
(i386_displaced_step_fixup): New functions.
(struct i386_insn, i386_match_insn): Update.
(i386_gdbarch_init): Set gdbarch_max_insn_length.
* i386-tdep.h (I386_MAX_INSN_LEN): New.
(i386_displaced_step_fixup): New prototype.
* i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h".
Register gdbarch_displaced_step_copy,
gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure,
and gdbarch_displaced_step_location functions.
* infrun.c (debug_displaced): New variable.
(show_debug_displaced): New function.
(struct displaced_step_request): New struct.
(displaced_step_request_queue, displaced_step_ptid)
(displaced_step_gdbarch, displaced_step_closure)
(displaced_step_original, displaced_step_copy)
(displaced_step_saved_copy, can_use_displaced_stepping): New
variables.
(show_can_use_displaced_stepping, use_displaced_stepping)
(displaced_step_clear, cleanup_displaced_step_closure)
(displaced_step_dump_bytes, displaced_step_prepare)
(displaced_step_clear_cleanup, write_memory_ptid)
(displaced_step_fixup): New functions.
(resume): Call displaced_step_prepare.
(proceed): Call read_pc once, and remember the value. If using
displaced stepping, don't remove breakpoints.
(handle_inferior_event): Call displaced_step_fixup. Add some
debugging output. When we try to step over a breakpoint, but get
a signal to deliver to the thread instead, ensure the step-resume
breakpoint is actually inserted. If a thread hop is needed, and
displaced stepping is enabled, don't remove breakpoints.
(init_wait_for_inferior): Call displaced_step_clear.
(_initialize_infrun): Add "set debug displaced" command. Add
"maint set can-use-displaced-stepping" command. Clear
displaced_step_ptid.
* inferior.h (debug_displaced): Declare variable.
(displaced_step_dump_bytes): Declare function.
* Makefile.in (arch-utils.o, i386-linux-tdep.o): Update
dependencies.
gdb/testsuite/
* gdb.asm/asmsrc1.s: Add scratch space.
gdb/doc/
* gdb.texinfo (Debugging Output): Document "set/show debug
displaced".
(Maintenance Commands): Document "maint set/show
can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
# Copy the instruction at FROM to TO, and make any adjustments
# necessary to single-step it at that address.
#
# REGS holds the state the thread's registers will have before
# executing the copied instruction; the PC in REGS will refer to FROM,
# not the copy at TO. The caller should update it to point at TO later.
#
# Return a pointer to data of the architecture's choice to be passed
# to gdbarch_displaced_step_fixup. Or, return NULL to indicate that
# the instruction's effects have been completely simulated, with the
# resulting state written back to REGS.
#
# For a general explanation of displaced stepping and how GDB uses it,
# see the comments in infrun.c.
#
# The TO area is only guaranteed to have space for
# gdbarch_max_insn_length (arch) bytes, so this function must not
# write more bytes than that to that area.
#
# If you do not provide this function, GDB assumes that the
# architecture does not support displaced stepping.
#
2015-08-06 19:23:00 +02:00
# If the instruction cannot execute out of line, return NULL. The
# core falls back to stepping past the instruction in-line instead in
# that case.
2020-02-14 22:45:40 +01:00
M; displaced_step_closure_up; displaced_step_copy_insn; CORE_ADDR from, CORE_ADDR to, struct regcache *regs; from, to, regs
Implement displaced stepping.
gdb/
* gdbarch.sh (max_insn_length): New 'variable'.
(displaced_step_copy, displaced_step_fixup)
(displaced_step_free_closure, displaced_step_location): New
functions.
(struct displaced_step_closure): Add forward declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* arch-utils.c: #include "objfiles.h".
(simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New functions.
* arch-utils.h (simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New prototypes.
* i386-tdep.c (I386_MAX_INSN_LEN): Rename to...
(I386_MAX_MATCHED_INSN_LEN): ... this.
(i386_absolute_jmp_p, i386_absolute_call_p)
(i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p)
(i386_displaced_step_fixup): New functions.
(struct i386_insn, i386_match_insn): Update.
(i386_gdbarch_init): Set gdbarch_max_insn_length.
* i386-tdep.h (I386_MAX_INSN_LEN): New.
(i386_displaced_step_fixup): New prototype.
* i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h".
Register gdbarch_displaced_step_copy,
gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure,
and gdbarch_displaced_step_location functions.
* infrun.c (debug_displaced): New variable.
(show_debug_displaced): New function.
(struct displaced_step_request): New struct.
(displaced_step_request_queue, displaced_step_ptid)
(displaced_step_gdbarch, displaced_step_closure)
(displaced_step_original, displaced_step_copy)
(displaced_step_saved_copy, can_use_displaced_stepping): New
variables.
(show_can_use_displaced_stepping, use_displaced_stepping)
(displaced_step_clear, cleanup_displaced_step_closure)
(displaced_step_dump_bytes, displaced_step_prepare)
(displaced_step_clear_cleanup, write_memory_ptid)
(displaced_step_fixup): New functions.
(resume): Call displaced_step_prepare.
(proceed): Call read_pc once, and remember the value. If using
displaced stepping, don't remove breakpoints.
(handle_inferior_event): Call displaced_step_fixup. Add some
debugging output. When we try to step over a breakpoint, but get
a signal to deliver to the thread instead, ensure the step-resume
breakpoint is actually inserted. If a thread hop is needed, and
displaced stepping is enabled, don't remove breakpoints.
(init_wait_for_inferior): Call displaced_step_clear.
(_initialize_infrun): Add "set debug displaced" command. Add
"maint set can-use-displaced-stepping" command. Clear
displaced_step_ptid.
* inferior.h (debug_displaced): Declare variable.
(displaced_step_dump_bytes): Declare function.
* Makefile.in (arch-utils.o, i386-linux-tdep.o): Update
dependencies.
gdb/testsuite/
* gdb.asm/asmsrc1.s: Add scratch space.
gdb/doc/
* gdb.texinfo (Debugging Output): Document "set/show debug
displaced".
(Maintenance Commands): Document "maint set/show
can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
2009-09-29 02:53:04 +02:00
# Return true if GDB should use hardware single-stepping to execute
# the displaced instruction identified by CLOSURE. If false,
# GDB will simply restart execution at the displaced instruction
# location, and it is up to the target to ensure GDB will receive
# control again (e.g. by placing a software breakpoint instruction
# into the displaced instruction buffer).
#
# The default implementation returns false on all targets that
# provide a gdbarch_software_single_step routine, and true otherwise.
2017-05-02 19:30:07 +02:00
m; int; displaced_step_hw_singlestep; struct displaced_step_closure *closure; closure; ; default_displaced_step_hw_singlestep; ; 0
2009-09-29 02:53:04 +02:00
Implement displaced stepping.
gdb/
* gdbarch.sh (max_insn_length): New 'variable'.
(displaced_step_copy, displaced_step_fixup)
(displaced_step_free_closure, displaced_step_location): New
functions.
(struct displaced_step_closure): Add forward declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* arch-utils.c: #include "objfiles.h".
(simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New functions.
* arch-utils.h (simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New prototypes.
* i386-tdep.c (I386_MAX_INSN_LEN): Rename to...
(I386_MAX_MATCHED_INSN_LEN): ... this.
(i386_absolute_jmp_p, i386_absolute_call_p)
(i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p)
(i386_displaced_step_fixup): New functions.
(struct i386_insn, i386_match_insn): Update.
(i386_gdbarch_init): Set gdbarch_max_insn_length.
* i386-tdep.h (I386_MAX_INSN_LEN): New.
(i386_displaced_step_fixup): New prototype.
* i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h".
Register gdbarch_displaced_step_copy,
gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure,
and gdbarch_displaced_step_location functions.
* infrun.c (debug_displaced): New variable.
(show_debug_displaced): New function.
(struct displaced_step_request): New struct.
(displaced_step_request_queue, displaced_step_ptid)
(displaced_step_gdbarch, displaced_step_closure)
(displaced_step_original, displaced_step_copy)
(displaced_step_saved_copy, can_use_displaced_stepping): New
variables.
(show_can_use_displaced_stepping, use_displaced_stepping)
(displaced_step_clear, cleanup_displaced_step_closure)
(displaced_step_dump_bytes, displaced_step_prepare)
(displaced_step_clear_cleanup, write_memory_ptid)
(displaced_step_fixup): New functions.
(resume): Call displaced_step_prepare.
(proceed): Call read_pc once, and remember the value. If using
displaced stepping, don't remove breakpoints.
(handle_inferior_event): Call displaced_step_fixup. Add some
debugging output. When we try to step over a breakpoint, but get
a signal to deliver to the thread instead, ensure the step-resume
breakpoint is actually inserted. If a thread hop is needed, and
displaced stepping is enabled, don't remove breakpoints.
(init_wait_for_inferior): Call displaced_step_clear.
(_initialize_infrun): Add "set debug displaced" command. Add
"maint set can-use-displaced-stepping" command. Clear
displaced_step_ptid.
* inferior.h (debug_displaced): Declare variable.
(displaced_step_dump_bytes): Declare function.
* Makefile.in (arch-utils.o, i386-linux-tdep.o): Update
dependencies.
gdb/testsuite/
* gdb.asm/asmsrc1.s: Add scratch space.
gdb/doc/
* gdb.texinfo (Debugging Output): Document "set/show debug
displaced".
(Maintenance Commands): Document "maint set/show
can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
# Fix up the state resulting from successfully single-stepping a
# displaced instruction, to give the result we would have gotten from
# stepping the instruction in its original location.
#
# REGS is the register state resulting from single-stepping the
# displaced instruction.
#
# CLOSURE is the result from the matching call to
# gdbarch_displaced_step_copy_insn.
#
# If you provide gdbarch_displaced_step_copy_insn.but not this
# function, then GDB assumes that no fixup is needed after
# single-stepping the instruction.
#
# For a general explanation of displaced stepping and how GDB uses it,
# see the comments in infrun.c.
2017-05-02 19:30:07 +02:00
M; void; displaced_step_fixup; struct displaced_step_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs; closure, from, to, regs; ; NULL
Implement displaced stepping.
gdb/
* gdbarch.sh (max_insn_length): New 'variable'.
(displaced_step_copy, displaced_step_fixup)
(displaced_step_free_closure, displaced_step_location): New
functions.
(struct displaced_step_closure): Add forward declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* arch-utils.c: #include "objfiles.h".
(simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New functions.
* arch-utils.h (simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New prototypes.
* i386-tdep.c (I386_MAX_INSN_LEN): Rename to...
(I386_MAX_MATCHED_INSN_LEN): ... this.
(i386_absolute_jmp_p, i386_absolute_call_p)
(i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p)
(i386_displaced_step_fixup): New functions.
(struct i386_insn, i386_match_insn): Update.
(i386_gdbarch_init): Set gdbarch_max_insn_length.
* i386-tdep.h (I386_MAX_INSN_LEN): New.
(i386_displaced_step_fixup): New prototype.
* i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h".
Register gdbarch_displaced_step_copy,
gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure,
and gdbarch_displaced_step_location functions.
* infrun.c (debug_displaced): New variable.
(show_debug_displaced): New function.
(struct displaced_step_request): New struct.
(displaced_step_request_queue, displaced_step_ptid)
(displaced_step_gdbarch, displaced_step_closure)
(displaced_step_original, displaced_step_copy)
(displaced_step_saved_copy, can_use_displaced_stepping): New
variables.
(show_can_use_displaced_stepping, use_displaced_stepping)
(displaced_step_clear, cleanup_displaced_step_closure)
(displaced_step_dump_bytes, displaced_step_prepare)
(displaced_step_clear_cleanup, write_memory_ptid)
(displaced_step_fixup): New functions.
(resume): Call displaced_step_prepare.
(proceed): Call read_pc once, and remember the value. If using
displaced stepping, don't remove breakpoints.
(handle_inferior_event): Call displaced_step_fixup. Add some
debugging output. When we try to step over a breakpoint, but get
a signal to deliver to the thread instead, ensure the step-resume
breakpoint is actually inserted. If a thread hop is needed, and
displaced stepping is enabled, don't remove breakpoints.
(init_wait_for_inferior): Call displaced_step_clear.
(_initialize_infrun): Add "set debug displaced" command. Add
"maint set can-use-displaced-stepping" command. Clear
displaced_step_ptid.
* inferior.h (debug_displaced): Declare variable.
(displaced_step_dump_bytes): Declare function.
* Makefile.in (arch-utils.o, i386-linux-tdep.o): Update
dependencies.
gdb/testsuite/
* gdb.asm/asmsrc1.s: Add scratch space.
gdb/doc/
* gdb.texinfo (Debugging Output): Document "set/show debug
displaced".
(Maintenance Commands): Document "maint set/show
can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
# Return the address of an appropriate place to put displaced
# instructions while we step over them. There need only be one such
# place, since we're only stepping one thread over a breakpoint at a
# time.
#
# For a general explanation of displaced stepping and how GDB uses it,
# see the comments in infrun.c.
2017-05-02 19:30:07 +02:00
m; CORE_ADDR; displaced_step_location; void; ; ; NULL; ; ( ! gdbarch->displaced_step_location) != ( ! gdbarch->displaced_step_copy_insn)
Implement displaced stepping.
gdb/
* gdbarch.sh (max_insn_length): New 'variable'.
(displaced_step_copy, displaced_step_fixup)
(displaced_step_free_closure, displaced_step_location): New
functions.
(struct displaced_step_closure): Add forward declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* arch-utils.c: #include "objfiles.h".
(simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New functions.
* arch-utils.h (simple_displaced_step_copy_insn)
(simple_displaced_step_free_closure)
(displaced_step_at_entry_point): New prototypes.
* i386-tdep.c (I386_MAX_INSN_LEN): Rename to...
(I386_MAX_MATCHED_INSN_LEN): ... this.
(i386_absolute_jmp_p, i386_absolute_call_p)
(i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p)
(i386_displaced_step_fixup): New functions.
(struct i386_insn, i386_match_insn): Update.
(i386_gdbarch_init): Set gdbarch_max_insn_length.
* i386-tdep.h (I386_MAX_INSN_LEN): New.
(i386_displaced_step_fixup): New prototype.
* i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h".
Register gdbarch_displaced_step_copy,
gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure,
and gdbarch_displaced_step_location functions.
* infrun.c (debug_displaced): New variable.
(show_debug_displaced): New function.
(struct displaced_step_request): New struct.
(displaced_step_request_queue, displaced_step_ptid)
(displaced_step_gdbarch, displaced_step_closure)
(displaced_step_original, displaced_step_copy)
(displaced_step_saved_copy, can_use_displaced_stepping): New
variables.
(show_can_use_displaced_stepping, use_displaced_stepping)
(displaced_step_clear, cleanup_displaced_step_closure)
(displaced_step_dump_bytes, displaced_step_prepare)
(displaced_step_clear_cleanup, write_memory_ptid)
(displaced_step_fixup): New functions.
(resume): Call displaced_step_prepare.
(proceed): Call read_pc once, and remember the value. If using
displaced stepping, don't remove breakpoints.
(handle_inferior_event): Call displaced_step_fixup. Add some
debugging output. When we try to step over a breakpoint, but get
a signal to deliver to the thread instead, ensure the step-resume
breakpoint is actually inserted. If a thread hop is needed, and
displaced stepping is enabled, don't remove breakpoints.
(init_wait_for_inferior): Call displaced_step_clear.
(_initialize_infrun): Add "set debug displaced" command. Add
"maint set can-use-displaced-stepping" command. Clear
displaced_step_ptid.
* inferior.h (debug_displaced): Declare variable.
(displaced_step_dump_bytes): Declare function.
* Makefile.in (arch-utils.o, i386-linux-tdep.o): Update
dependencies.
gdb/testsuite/
* gdb.asm/asmsrc1.s: Add scratch space.
gdb/doc/
* gdb.texinfo (Debugging Output): Document "set/show debug
displaced".
(Maintenance Commands): Document "maint set/show
can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
2010-05-26 20:19:28 +02:00
# Relocate an instruction to execute at a different address. OLDLOC
# is the address in the inferior memory where the instruction to
# relocate is currently at. On input, TO points to the destination
# where we want the instruction to be copied (and possibly adjusted)
# to. On output, it points to one past the end of the resulting
# instruction(s). The effect of executing the instruction at TO shall
# be the same as if executing it at FROM. For example, call
# instructions that implicitly push the return address on the stack
# should be adjusted to return to the instruction after OLDLOC;
# relative branches, and other PC-relative instructions need the
# offset adjusted; etc.
2017-05-02 19:30:07 +02:00
M; void; relocate_instruction; CORE_ADDR *to, CORE_ADDR from; to, from; ; NULL
2010-05-26 20:19:28 +02:00
2007-05-11 21:57:17 +02:00
# Refresh overlay mapped state for section OSECT.
2017-05-02 19:30:07 +02:00
F; void; overlay_update; struct obj_section *osect; osect
2007-09-10 23:14:11 +02:00
2017-05-02 19:30:07 +02:00
M; const struct target_desc *; core_read_description; struct target_ops *target, bfd *abfd; target, abfd
2007-10-19 14:23:21 +02:00
# Handle special encoding of static variables in stabs debug info.
2017-05-02 19:30:07 +02:00
F; const char *; static_transform_name; const char *name; name
2007-10-19 14:26:35 +02:00
# Set if the address in N_SO or N_FUN stabs may be zero.
2017-05-02 19:30:07 +02:00
v; int; sofun_address_maybe_missing; ; ; 0; 0; ; 0
2008-05-01 21:31:52 +02:00
2009-04-30 04:52:16 +02:00
# Parse the instruction at ADDR storing in the record execution log
# the registers REGCACHE and memory ranges that will be affected when
# the instruction executes, along with their current values.
# Return -1 if something goes wrong, 0 otherwise.
2017-05-02 19:30:07 +02:00
M; int; process_record; struct regcache *regcache, CORE_ADDR addr; regcache, addr
2009-04-30 04:52:16 +02:00
2009-09-21 07:52:06 +02:00
# Save process state after a signal.
# Return -1 if something goes wrong, 0 otherwise.
2017-05-02 19:30:07 +02:00
M; int; process_record_signal; struct regcache *regcache, enum gdb_signal signal; regcache, signal
2009-09-21 07:52:06 +02:00
2012-05-24 19:03:28 +02:00
# Signal translation: translate inferior's signal (target's) number
2012-06-04 18:23:16 +02:00
# into GDB's representation. The implementation of this method must
# be host independent. IOW, don't rely on symbols of the NAT_FILE
# header (the nm-*.h files), the host <signal.h> header, or similar
# headers. This is mainly used when cross-debugging core files ---
# "Live" targets hide the translation behind the target interface
2012-06-04 18:23:57 +02:00
# (target_wait, target_resume, etc.).
2017-05-02 19:30:07 +02:00
M; enum gdb_signal; gdb_signal_from_target; int signo; signo
2008-05-02 22:38:16 +02:00
This patch implements the new gdbarch method gdbarch_gdb_signal_to_target.
It will be used when one wants to convert between the internal GDB signal
representation (enum gdb_signal) and the target's representation.
The idea of this patch came from a chat between Pedro and I on IRC, plus
the discussion of my patches to add the new $_exitsignal convenience
variable:
<http://sourceware.org/ml/gdb-patches/2013-06/msg00452.html>
<http://sourceware.org/ml/gdb-patches/2013-06/msg00352.html>
What I did was to investigate, on the Linux kernel, which targets shared
the signal numbers definition with the generic definition, present at
<include/uapi/asm-generic/signal.h>. For the record, I used linux-3.10-rc7
as the main source of information, always looking at
<arch/<ARCH_NAME>/include/uapi/asm/signal.h>. For SIGRTMAX (which defaults
to _NSIG in most cases), I had to look at different signal-related
files, but most of them (except MIPS) were defined to 64 anyway.
Then, with all the differences in hand, I implemented the bits on each
target.
2013-08-09 Sergio Durigan Junior <sergiodj@redhat.com>
* linux-tdep.c: Define enum with generic signal numbers.
(linux_gdb_signal_from_target): New function.
(linux_gdb_signal_to_target): Likewise.
(linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
methods to the functions above.
* linux-tdep.h (linux_gdb_signal_from_target): New prototype.
(linux_gdb_signal_to_target): Likewise.
* alpha-linux-tdep.c: Define new enum with signals different
from generic Linux kernel.
(alpha_linux_gdb_signal_from_target): New function.
(alpha_linux_gdb_signal_to_target): Likewise.
(alpha_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
with the functions mentioned above.
* avr-tdep.c: Define enum with differences between Linux kernel
and AVR signals.
(avr_linux_gdb_signal_from_target): New function.
(avr_linux_gdb_signal_to_target): Likewise.
(avr_gdbarch_init): Set gdbarch_gdb_signal_{to,from}_target to
the functions mentioned above.
* sparc-linux-tdep.c: Define enum with differences between SPARC
and generic Linux kernel signal numbers.
(sparc32_linux_gdb_signal_from_target): New function.
(sparc32_linux_gdb_signal_to_target): Likewise.
(sparc32_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
to the functions defined above.
* xtensa-linux-tdep.c: Define enum with differences between
Xtensa and Linux kernel generic signals.
(xtensa_linux_gdb_signal_from_target): New function.
(xtensa_linux_gdb_signal_to_target): Likewise.
(xtensa_linux_init_abi): Set gdbarch_gdb_signal_to_target
to the functions defined above.
* mips-linux-tdep.c: Define enum with differences between
signals in MIPS and Linux kernel generic ones.
(mips_gdb_signal_to_target): New function.
(mips_gdb_signal_from_target): Redefine to use new enum, handle
only different signals from the Linux kernel generic.
(mips_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
the functions defined above.
* mips-linux-tdep.h (enum mips_signals): Remove.
2013-08-09 18:54:43 +02:00
# Signal translation: translate the GDB's internal signal number into
# the inferior's signal (target's) representation. The implementation
# of this method must be host independent. IOW, don't rely on symbols
# of the NAT_FILE header (the nm-*.h files), the host <signal.h>
# header, or similar headers.
# Return the target signal number if found, or -1 if the GDB internal
# signal number is invalid.
2017-05-02 19:30:07 +02:00
M; int; gdb_signal_to_target; enum gdb_signal signal; signal
This patch implements the new gdbarch method gdbarch_gdb_signal_to_target.
It will be used when one wants to convert between the internal GDB signal
representation (enum gdb_signal) and the target's representation.
The idea of this patch came from a chat between Pedro and I on IRC, plus
the discussion of my patches to add the new $_exitsignal convenience
variable:
<http://sourceware.org/ml/gdb-patches/2013-06/msg00452.html>
<http://sourceware.org/ml/gdb-patches/2013-06/msg00352.html>
What I did was to investigate, on the Linux kernel, which targets shared
the signal numbers definition with the generic definition, present at
<include/uapi/asm-generic/signal.h>. For the record, I used linux-3.10-rc7
as the main source of information, always looking at
<arch/<ARCH_NAME>/include/uapi/asm/signal.h>. For SIGRTMAX (which defaults
to _NSIG in most cases), I had to look at different signal-related
files, but most of them (except MIPS) were defined to 64 anyway.
Then, with all the differences in hand, I implemented the bits on each
target.
2013-08-09 Sergio Durigan Junior <sergiodj@redhat.com>
* linux-tdep.c: Define enum with generic signal numbers.
(linux_gdb_signal_from_target): New function.
(linux_gdb_signal_to_target): Likewise.
(linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
methods to the functions above.
* linux-tdep.h (linux_gdb_signal_from_target): New prototype.
(linux_gdb_signal_to_target): Likewise.
* alpha-linux-tdep.c: Define new enum with signals different
from generic Linux kernel.
(alpha_linux_gdb_signal_from_target): New function.
(alpha_linux_gdb_signal_to_target): Likewise.
(alpha_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
with the functions mentioned above.
* avr-tdep.c: Define enum with differences between Linux kernel
and AVR signals.
(avr_linux_gdb_signal_from_target): New function.
(avr_linux_gdb_signal_to_target): Likewise.
(avr_gdbarch_init): Set gdbarch_gdb_signal_{to,from}_target to
the functions mentioned above.
* sparc-linux-tdep.c: Define enum with differences between SPARC
and generic Linux kernel signal numbers.
(sparc32_linux_gdb_signal_from_target): New function.
(sparc32_linux_gdb_signal_to_target): Likewise.
(sparc32_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
to the functions defined above.
* xtensa-linux-tdep.c: Define enum with differences between
Xtensa and Linux kernel generic signals.
(xtensa_linux_gdb_signal_from_target): New function.
(xtensa_linux_gdb_signal_to_target): Likewise.
(xtensa_linux_init_abi): Set gdbarch_gdb_signal_to_target
to the functions defined above.
* mips-linux-tdep.c: Define enum with differences between
signals in MIPS and Linux kernel generic ones.
(mips_gdb_signal_to_target): New function.
(mips_gdb_signal_from_target): Redefine to use new enum, handle
only different signals from the Linux kernel generic.
(mips_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
the functions defined above.
* mips-linux-tdep.h (enum mips_signals): Remove.
2013-08-09 18:54:43 +02:00
2009-02-06 23:59:01 +01:00
# Extra signal info inspection.
#
# Return a type suitable to inspect extra signal information.
2017-05-02 19:30:07 +02:00
M; struct type *; get_siginfo_type; void;
2009-02-06 23:59:01 +01:00
2008-05-02 22:38:16 +02:00
# Record architecture-specific information from the symbol table.
2017-05-02 19:30:07 +02:00
M; void; record_special_symbol; struct objfile *objfile, asymbol *sym; objfile, sym
* remote.c (remote_start_remote): If the solib list is global,
fetch libraries and insert breakpoints after connecting.
* infcmd.c (post_create_inferior): If the solist is shared between
inferiors, no need to refetch it on every new inferior.
(detach_command): If the shared library list is shared between
inferiors, then don't clear it on every inferior detach.
* gdbarch.sh (has_global_solist): New.
* i386-dicos-tdep.c (i386_dicos_init_abi): Set
gdbarch_has_global_solist.
* target.c (target_pre_inferior): If the shared library list is
shared between inferiors, then don't clear it here, neither
invalidate the memory regions or clear the target description.
(target_detach): If the shared library list is shared between
inferiors, then don't remove breakpoints from the target here.
(target_disconnect): Comment.
* solib.c (update_solib_list): Check for null_ptid.
* breakpoint.c (insert_breakpoints, update_global_location_list):
If the shared library list is shared between inferiors, insert
breakpoints even if there's no execution.
(breakpoint_init_inferior): If the shared library list is shared
between inferiors, don't delete breakpoints or mark them
uninserted here.
* gdbarch.c, gdbarch.h: Regenerate.
2008-11-03 15:01:27 +01:00
2009-09-15 05:30:08 +02:00
# Function for the 'catch syscall' feature.
# Get architecture-specific system calls information from registers.
Use thread_info and inferior pointers more throughout
This is more preparation bits for multi-target support.
In a multi-target scenario, we need to address the case of different
processes/threads running on different targets that happen to have the
same PID/PTID. E.g., we can have both process 123 in target 1, and
process 123 in target 2, while they're in reality different processes
running on different machines. Or maybe we've loaded multiple
instances of the same core file. Etc.
To address this, in my WIP multi-target branch, threads and processes
are uniquely identified by the (process_stratum target_ops *, ptid_t)
and (process_stratum target_ops *, pid) tuples respectively. I.e.,
each process_stratum instance has its own thread/process number space.
As you can imagine, that requires passing around target_ops * pointers
in a number of functions where we're currently passing only a ptid_t
or an int. E.g., when we look up a thread_info object by ptid_t in
find_thread_ptid, the ptid_t alone isn't sufficient.
In many cases though, we already have the thread_info or inferior
pointer handy, but we "lose" it somewhere along the call stack, only
to look it up again by ptid_t/pid. Since thread_info or inferior
objects know their parent target, if we pass around thread_info or
inferior pointers when possible, we avoid having to add extra
target_ops parameters to many functions, and also, we eliminate a
number of by ptid_t/int lookups.
So that's what this patch does. In a bit more detail:
- Changes a number of functions and methods to take a thread_info or
inferior pointer instead of a ptid_t or int parameter.
- Changes a number of structure fields from ptid_t/int to inferior or
thread_info pointers.
- Uses the inferior_thread() function whenever possible instead of
inferior_ptid.
- Uses thread_info pointers directly when possible instead of the
is_running/is_stopped etc. routines that require a lookup.
- A number of functions are eliminated along the way, such as:
int valid_gdb_inferior_id (int num);
int pid_to_gdb_inferior_id (int pid);
int gdb_inferior_id_to_pid (int num);
int in_inferior_list (int pid);
- A few structures and places hold a thread_info pointer across
inferior execution, so now they take a strong reference to the
(refcounted) thread_info object to avoid the thread_info pointer
getting stale. This is done in enable_thread_stack_temporaries and
in the infcall.c code.
- Related, there's a spot in infcall.c where using a RAII object to
handle the refcount would be handy, so a gdb::ref_ptr specialization
for thread_info is added (thread_info_ref, in gdbthread.h), along
with a gdb_ref_ptr policy that works for all refcounted_object types
(in common/refcounted-object.h).
gdb/ChangeLog:
2018-06-21 Pedro Alves <palves@redhat.com>
* ada-lang.h (ada_get_task_number): Take a thread_info pointer
instead of a ptid_t. All callers adjusted.
* ada-tasks.c (ada_get_task_number): Likewise. All callers
adjusted.
(print_ada_task_info, display_current_task_id, task_command_1):
Adjust.
* breakpoint.c (watchpoint_in_thread_scope): Adjust to use
inferior_thread.
(breakpoint_kind): Adjust.
(remove_breakpoints_pid): Rename to ...
(remove_breakpoints_inf): ... this. Adjust to take an inferior
pointer. All callers adjusted.
(bpstat_clear_actions): Use inferior_thread.
(get_bpstat_thread): New.
(bpstat_do_actions): Use it.
(bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust
to take a thread_info pointer. All callers adjusted.
(set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint)
(breakpoint_re_set_thread): Use inferior_thread.
* breakpoint.h (struct inferior): Forward declare.
(bpstat_stop_status): Update.
(remove_breakpoints_pid): Delete.
(remove_breakpoints_inf): New.
* bsd-uthread.c (bsd_uthread_target::wait)
(bsd_uthread_target::update_thread_list): Use find_thread_ptid.
* btrace.c (btrace_add_pc, btrace_enable, btrace_fetch)
(maint_btrace_packet_history_cmd)
(maint_btrace_clear_packet_history_cmd): Adjust.
(maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use
inferior_thread.
* cli/cli-interp.c: Include "inferior.h".
* common/refcounted-object.h (struct
refcounted_object_ref_policy): New.
* compile/compile-object-load.c: Include gdbthread.h.
(store_regs): Use inferior_thread.
* corelow.c (core_target::close): Use current_inferior.
(core_target_open): Adjust to use first_thread_of_inferior and use
the current inferior.
* ctf.c (ctf_target::close): Adjust to use current_inferior.
* dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ...
<thread>: ... this new field. All references adjusted.
(dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor):
Take a thread_info pointer instead of a ptid_t.
* dummy-frame.h (dummy_frame_push, dummy_frame_pop)
(dummy_frame_discard, register_dummy_frame_dtor): Take a
thread_info pointer instead of a ptid_t.
* elfread.c: Include "inferior.h".
(elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop):
Use inferior_thread.
* eval.c (evaluate_subexp): Likewise.
* frame.c (frame_pop, has_stack_frames, find_frame_sal): Use
inferior_thread.
* gdb_proc_service.h (struct thread_info): Forward declare.
(struct ps_prochandle) <ptid>: Delete, replaced by ...
<thread>: ... this new field. All references adjusted.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a
'thread' parameter. All implementations and callers adjusted.
* gdbthread.h (thread_info) <set_running>: New method.
(delete_thread, delete_thread_silent): Take a thread_info pointer
instead of a ptid.
(global_thread_id_to_ptid, ptid_to_global_thread_id): Delete.
(first_thread_of_process): Delete, replaced by ...
(first_thread_of_inferior): ... this new function. All callers
adjusted.
(any_live_thread_of_process): Delete, replaced by ...
(any_live_thread_of_inferior): ... this new function. All callers
adjusted.
(switch_to_thread, switch_to_no_thread): Declare.
(is_executing): Delete.
(enable_thread_stack_temporaries): Update comment.
<enable_thread_stack_temporaries>: Take a thread_info pointer
instead of a ptid_t. Incref the thread.
<~enable_thread_stack_temporaries>: Decref the thread.
<m_ptid>: Delete
<m_thr>: New.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary)
(value_in_thread_stack_temporaries, can_access_registers_thread):
Take a thread_info pointer instead of a ptid_t. All callers
adjusted.
* infcall.c (get_call_return_value): Use inferior_thread.
(run_inferior_call): Work with thread pointers instead of ptid_t.
(call_function_by_hand_dummy): Work with thread pointers instead
of ptid_t. Use thread_info_ref.
* infcmd.c (proceed_thread_callback): Access thread's state
directly.
(ensure_valid_thread, ensure_not_running): Use inferior_thread,
access thread's state directly.
(continue_command): Use inferior_thread.
(info_program_command): Use find_thread_ptid and access thread
state directly.
(proceed_after_attach_callback): Use thread state directly.
(notice_new_inferior): Take a thread_info pointer instead of a
ptid_t. All callers adjusted.
(exit_inferior): Take an inferior pointer instead of a pid. All
callers adjusted.
(exit_inferior_silent): New.
(detach_inferior): Delete.
(valid_gdb_inferior_id, pid_to_gdb_inferior_id)
(gdb_inferior_id_to_pid, in_inferior_list): Delete.
(detach_inferior_command, kill_inferior_command): Use
find_inferior_id instead of valid_gdb_inferior_id and
gdb_inferior_id_to_pid.
(inferior_command): Use inferior and thread pointers.
* inferior.h (struct thread_info): Forward declare.
(notice_new_inferior): Take a thread_info pointer instead of a
ptid_t. All callers adjusted.
(detach_inferior): Delete declaration.
(exit_inferior, exit_inferior_silent): Take an inferior pointer
instead of a pid. All callers adjusted.
(gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list)
(valid_gdb_inferior_id): Delete.
* infrun.c (follow_fork_inferior, proceed_after_vfork_done)
(handle_vfork_child_exec_or_exit, follow_exec): Adjust.
(struct displaced_step_inferior_state) <pid>: Delete, replaced by
...
<inf>: ... this new field.
<step_ptid>: Delete, replaced by ...
<step_thread>: ... this new field.
(get_displaced_stepping_state): Take an inferior pointer instead
of a pid. All callers adjusted.
(displaced_step_in_progress_any_inferior): Adjust.
(displaced_step_in_progress_thread): Take a thread pointer instead
of a ptid_t. All callers adjusted.
(displaced_step_in_progress, add_displaced_stepping_state): Take
an inferior pointer instead of a pid. All callers adjusted.
(get_displaced_step_closure_by_addr): Adjust.
(remove_displaced_stepping_state): Take an inferior pointer
instead of a pid. All callers adjusted.
(displaced_step_prepare_throw, displaced_step_prepare)
(displaced_step_fixup): Take a thread pointer instead of a ptid_t.
All callers adjusted.
(start_step_over): Adjust.
(infrun_thread_ptid_changed): Remove bit updating ptids in the
displaced step queue.
(do_target_resume): Adjust.
(fetch_inferior_event): Use inferior_thread.
(context_switch, get_inferior_stop_soon): Take an
execution_control_state pointer instead of a ptid_t. All callers
adjusted.
(switch_to_thread_cleanup): Delete.
(stop_all_threads): Use scoped_restore_current_thread.
* inline-frame.c: Include "gdbthread.h".
(inline_state) <inline_state>: Take a thread pointer instead of a
ptid_t. All callers adjusted.
<ptid>: Delete, replaced by ...
<thread>: ... this new field.
(find_inline_frame_state): Take a thread pointer instead of a
ptid_t. All callers adjusted.
(skip_inline_frames, step_into_inline_frame)
(inline_skipped_frames, inline_skipped_symbol): Take a thread
pointer instead of a ptid_t. All callers adjusted.
* inline-frame.h (skip_inline_frames, step_into_inline_frame)
(inline_skipped_frames, inline_skipped_symbol): Likewise.
* linux-fork.c (delete_checkpoint_command): Adjust to use thread
pointers directly.
* linux-nat.c (get_detach_signal): Likewise.
* linux-thread-db.c (thread_from_lwp): New 'stopped' parameter.
(thread_db_notice_clone): Adjust.
(thread_db_find_new_threads_silently)
(thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take
a thread pointer instead of a ptid_t. All callers adjusted.
* mi/mi-cmd-var.c: Include "inferior.h".
(mi_cmd_var_update_iter): Update to use thread pointers.
* mi/mi-interp.c (mi_new_thread): Update to use the thread's
inferior directly.
(mi_output_running_pid, mi_inferior_count): Delete, bits factored
out to ...
(mi_output_running): ... this new function.
(mi_on_resume_1): Adjust to use it.
(mi_user_selected_context_changed): Adjust to use inferior_thread.
* mi/mi-main.c (proceed_thread): Adjust to use thread pointers
directly.
(interrupt_thread_callback): : Adjust to use thread and inferior
pointers.
* proc-service.c: Include "gdbthread.h".
(ps_pglobal_lookup): Adjust to use the thread's inferior directly.
* progspace-and-thread.c: Include "inferior.h".
* progspace.c: Include "inferior.h".
* python/py-exitedevent.c (create_exited_event_object): Adjust to
hold a reference to an inferior_object.
* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use
inferior_thread.
* python/py-inferior.c (struct inferior_object): Give the type a
tag name instead of a typedef.
(python_on_normal_stop): No need to check if the current thread is
listed.
(inferior_to_inferior_object): Change return type to
inferior_object. All callers adjusted.
(find_thread_object): Delete, bits factored out to ...
(thread_to_thread_object): ... this new function.
* python/py-infthread.c (create_thread_object): Use
inferior_to_inferior_object.
(thpy_is_stopped): Use thread pointer directly.
(gdbpy_selected_thread): Use inferior_thread.
* python/py-record-btrace.c (btpy_list_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(btpy_insn_or_gap_new): Drop const.
(btpy_list_new): Take a thread pointer instead of a ptid_t. All
callers adjusted.
* python/py-record.c: Include "gdbthread.h".
(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
a ptid_t. All callers adjusted.
(gdbpy_current_recording): Use inferior_thread.
* python/py-record.h (recpy_record_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(recpy_element_object) <ptid>: Delete
field, replaced with ...
<thread>: ... this new field. All users adjusted.
(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
a ptid_t. All callers adjusted.
* python/py-threadevent.c: Include "gdbthread.h".
(get_event_thread): Use thread_to_thread_object.
* python/python-internal.h (struct inferior_object): Forward
declare.
(find_thread_object, find_inferior_object): Delete declarations.
(thread_to_thread_object, inferior_to_inferior_object): New
declarations.
* record-btrace.c: Include "inferior.h".
(require_btrace_thread): Use inferior_thread.
(record_btrace_frame_sniffer)
(record_btrace_tailcall_frame_sniffer): Use inferior_thread.
(get_thread_current_frame): Use scoped_restore_current_thread and
switch_to_thread.
(get_thread_current_frame): Use thread pointer directly.
(record_btrace_replay_at_breakpoint): Use thread's inferior
pointer directly.
* record-full.c: Include "inferior.h".
* regcache.c: Include "gdbthread.h".
(get_thread_arch_regcache): Use the inferior's address space
directly.
(get_thread_regcache, registers_changed_thread): New.
* regcache.h (get_thread_regcache(thread_info *thread)): New
overload.
(registers_changed_thread): New.
(remote_target) <remote_detach_1>: Swap order of parameters.
(remote_add_thread): <remote_add_thread>: Return the new thread.
(get_remote_thread_info(ptid_t)): New overload.
(remote_target::remote_notice_new_inferior): Use thread pointers
directly.
(remote_target::process_initial_stop_replies): Use
thread_info::set_running.
(remote_target::remote_detach_1, remote_target::detach)
(extended_remote_target::detach): Adjust.
* stack.c (frame_show_address): Use inferior_thread.
* target-debug.h (target_debug_print_thread_info_pp): New.
* target-delegates.c: Regenerate.
* target.c (default_thread_address_space): Delete.
(memory_xfer_partial_1): Use current_inferior.
(target_detach): Use current_inferior.
(target_thread_address_space): Delete.
(generic_mourn_inferior): Use current_inferior.
* target.h (struct target_ops) <thread_address_space>: Delete.
(target_thread_address_space): Delete.
* thread.c (init_thread_list): Use ALL_THREADS_SAFE. Use thread
pointers directly.
(delete_thread_1, delete_thread, delete_thread_silent): Take a
thread pointer instead of a ptid_t. Adjust all callers.
(ptid_to_global_thread_id, global_thread_id_to_ptid): Delete.
(first_thread_of_process): Delete, replaced by ...
(first_thread_of_inferior): ... this new function. All callers
adjusted.
(any_thread_of_process): Rename to ...
(any_thread_of_inferior): ... this, and take an inferior pointer.
(any_live_thread_of_process): Rename to ...
(any_live_thread_of_inferior): ... this, and take an inferior
pointer.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(value_in_thread_stack_temporaries)
(get_last_thread_stack_temporary): Take a thread pointer instead
of a ptid_t. Adjust all callers.
(thread_info::set_running): New.
(validate_registers_access): Use inferior_thread.
(can_access_registers_ptid): Rename to ...
(can_access_registers_thread): ... this, and take a thread
pointer.
(print_thread_info_1): Adjust to compare thread pointers instead
of ptids.
(switch_to_no_thread, switch_to_thread): Make extern.
(scoped_restore_current_thread::~scoped_restore_current_thread):
Use m_thread pointer directly.
(scoped_restore_current_thread::scoped_restore_current_thread):
Use inferior_thread.
(thread_command): Use thread pointer directly.
(thread_num_make_value_helper): Use inferior_thread.
* top.c (execute_command): Use inferior_thread.
* tui/tui-interp.c: Include "inferior.h".
* varobj.c (varobj_create): Use inferior_thread.
(value_of_root_1): Use find_thread_global_id instead of
global_thread_id_to_ptid.
2018-06-21 18:09:31 +02:00
M; LONGEST; get_syscall_number; thread_info *thread; thread
2009-09-15 05:30:08 +02:00
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
This patch intends to partially fix PR breakpoints/10737, which is
about making the syscall information (for the "catch syscall" command)
be per-arch, instead of global. This is not a full fix because of the
other issues pointed by Pedro here:
<https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5>
However, I consider it a good step towards the real fix. It will also
help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>.
What this patch does, basically, is move the "syscalls_info"
struct to gdbarch. Currently, the syscall information is stored in a
global variable inside gdb/xml-syscall.c, which means that there is no
easy way to correlate this info with the current target or
architecture being used, for example. This causes strange behaviors,
because the syscall info is not re-read when the arch changes. For
example, if you put a syscall catchpoint in syscall 5 on i386 (syscall
open), and then load a x86_64 program on GDB and put the same syscall
5 there (fstat on x86_64), you will still see that GDB tells you that
it is catching "open", even though it is not. With this patch, GDB
correctly says that it will be catching fstat syscalls.
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'open' [5])
But with the patch:
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'fstat' [5])
As I said, there are still some problems on the "catch syscall"
mechanism, because (for example) the user should be able to "catch
syscall open" on i386, and then expect "open" to be caught also on
x86_64. Currently, it doesn't work. I intend to work on this later.
gdb/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* bfin-linux-tdep.c (bfin_linux_init_abi): Likewise.
* breakpoint.c (print_it_catch_syscall): Adjust call to
get_syscall_by_number to provide gdbarch.
(print_one_catch_syscall): Likewise.
(print_mention_catch_syscall): Likewise.
(print_recreate_catch_syscall): Likewise.
(catch_syscall_split_args): Adjust calls to get_syscall_by_number
and get_syscall_by_name to provide gdbarch.
(catch_syscall_completer): Adjust call to get_syscall_names to
provide gdbarch.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* gdbarch.sh: Forward declare "struct syscalls_info".
(xml_syscall_file): New variable.
(syscalls_info): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise.
* xml-syscall.c: Include gdbarch.h.
(set_xml_syscall_file_name): Accept gdbarch parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
(my_gdb_datadir): Delete global variable.
(struct syscalls_info) <my_gdb_datadir>: New variable.
(struct syscalls_info) <sysinfo>: Rename variable to
"syscalls_info".
(sysinfo): Delete global variable.
(have_initialized_sysinfo): Likewise.
(xml_syscall_file): Likewise.
(sysinfo_free_syscalls_desc): Rename to...
(syscalls_info_free_syscalls_desc): ... this.
(free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust
code to the new layout of "struct syscalls_info".
(make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to
"syscalls_info".
(syscall_create_syscall_desc): Likewise.
(syscall_start_syscall): Likewise.
(syscall_parse_xml): Likewise.
(xml_init_syscalls_info): Likewise. Drop "const" from return value.
(init_sysinfo): Rename to...
(init_syscalls_info): ...this. Add gdbarch as a parameter.
Adjust function to deal with gdbarch.
(xml_get_syscall_number): Delete parameter sysinfo. Accept
gdbarch as a parameter. Adjust code.
(xml_get_syscall_name): Likewise.
(xml_list_of_syscalls): Likewise.
(set_xml_syscall_file_name): Accept gdbarch as parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
* xml-syscall.h (set_xml_syscall_file_name): Likewise.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
gdb/testsuite/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
# The filename of the XML syscall for this architecture.
2017-05-02 19:30:07 +02:00
v; const char *; xml_syscall_file; ; ; 0; 0; ; 0; pstring ( gdbarch->xml_syscall_file)
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
This patch intends to partially fix PR breakpoints/10737, which is
about making the syscall information (for the "catch syscall" command)
be per-arch, instead of global. This is not a full fix because of the
other issues pointed by Pedro here:
<https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5>
However, I consider it a good step towards the real fix. It will also
help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>.
What this patch does, basically, is move the "syscalls_info"
struct to gdbarch. Currently, the syscall information is stored in a
global variable inside gdb/xml-syscall.c, which means that there is no
easy way to correlate this info with the current target or
architecture being used, for example. This causes strange behaviors,
because the syscall info is not re-read when the arch changes. For
example, if you put a syscall catchpoint in syscall 5 on i386 (syscall
open), and then load a x86_64 program on GDB and put the same syscall
5 there (fstat on x86_64), you will still see that GDB tells you that
it is catching "open", even though it is not. With this patch, GDB
correctly says that it will be catching fstat syscalls.
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'open' [5])
But with the patch:
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'fstat' [5])
As I said, there are still some problems on the "catch syscall"
mechanism, because (for example) the user should be able to "catch
syscall open" on i386, and then expect "open" to be caught also on
x86_64. Currently, it doesn't work. I intend to work on this later.
gdb/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* bfin-linux-tdep.c (bfin_linux_init_abi): Likewise.
* breakpoint.c (print_it_catch_syscall): Adjust call to
get_syscall_by_number to provide gdbarch.
(print_one_catch_syscall): Likewise.
(print_mention_catch_syscall): Likewise.
(print_recreate_catch_syscall): Likewise.
(catch_syscall_split_args): Adjust calls to get_syscall_by_number
and get_syscall_by_name to provide gdbarch.
(catch_syscall_completer): Adjust call to get_syscall_names to
provide gdbarch.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* gdbarch.sh: Forward declare "struct syscalls_info".
(xml_syscall_file): New variable.
(syscalls_info): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise.
* xml-syscall.c: Include gdbarch.h.
(set_xml_syscall_file_name): Accept gdbarch parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
(my_gdb_datadir): Delete global variable.
(struct syscalls_info) <my_gdb_datadir>: New variable.
(struct syscalls_info) <sysinfo>: Rename variable to
"syscalls_info".
(sysinfo): Delete global variable.
(have_initialized_sysinfo): Likewise.
(xml_syscall_file): Likewise.
(sysinfo_free_syscalls_desc): Rename to...
(syscalls_info_free_syscalls_desc): ... this.
(free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust
code to the new layout of "struct syscalls_info".
(make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to
"syscalls_info".
(syscall_create_syscall_desc): Likewise.
(syscall_start_syscall): Likewise.
(syscall_parse_xml): Likewise.
(xml_init_syscalls_info): Likewise. Drop "const" from return value.
(init_sysinfo): Rename to...
(init_syscalls_info): ...this. Add gdbarch as a parameter.
Adjust function to deal with gdbarch.
(xml_get_syscall_number): Delete parameter sysinfo. Accept
gdbarch as a parameter. Adjust code.
(xml_get_syscall_name): Likewise.
(xml_list_of_syscalls): Likewise.
(set_xml_syscall_file_name): Accept gdbarch as parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
* xml-syscall.h (set_xml_syscall_file_name): Likewise.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
gdb/testsuite/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
# Information about system calls from this architecture
2017-05-02 19:30:07 +02:00
v; struct syscalls_info *; syscalls_info; ; ; 0; 0; ; 0; host_address_to_string ( gdbarch->syscalls_info)
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
This patch intends to partially fix PR breakpoints/10737, which is
about making the syscall information (for the "catch syscall" command)
be per-arch, instead of global. This is not a full fix because of the
other issues pointed by Pedro here:
<https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5>
However, I consider it a good step towards the real fix. It will also
help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>.
What this patch does, basically, is move the "syscalls_info"
struct to gdbarch. Currently, the syscall information is stored in a
global variable inside gdb/xml-syscall.c, which means that there is no
easy way to correlate this info with the current target or
architecture being used, for example. This causes strange behaviors,
because the syscall info is not re-read when the arch changes. For
example, if you put a syscall catchpoint in syscall 5 on i386 (syscall
open), and then load a x86_64 program on GDB and put the same syscall
5 there (fstat on x86_64), you will still see that GDB tells you that
it is catching "open", even though it is not. With this patch, GDB
correctly says that it will be catching fstat syscalls.
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'open' [5])
But with the patch:
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'fstat' [5])
As I said, there are still some problems on the "catch syscall"
mechanism, because (for example) the user should be able to "catch
syscall open" on i386, and then expect "open" to be caught also on
x86_64. Currently, it doesn't work. I intend to work on this later.
gdb/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* bfin-linux-tdep.c (bfin_linux_init_abi): Likewise.
* breakpoint.c (print_it_catch_syscall): Adjust call to
get_syscall_by_number to provide gdbarch.
(print_one_catch_syscall): Likewise.
(print_mention_catch_syscall): Likewise.
(print_recreate_catch_syscall): Likewise.
(catch_syscall_split_args): Adjust calls to get_syscall_by_number
and get_syscall_by_name to provide gdbarch.
(catch_syscall_completer): Adjust call to get_syscall_names to
provide gdbarch.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* gdbarch.sh: Forward declare "struct syscalls_info".
(xml_syscall_file): New variable.
(syscalls_info): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise.
* xml-syscall.c: Include gdbarch.h.
(set_xml_syscall_file_name): Accept gdbarch parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
(my_gdb_datadir): Delete global variable.
(struct syscalls_info) <my_gdb_datadir>: New variable.
(struct syscalls_info) <sysinfo>: Rename variable to
"syscalls_info".
(sysinfo): Delete global variable.
(have_initialized_sysinfo): Likewise.
(xml_syscall_file): Likewise.
(sysinfo_free_syscalls_desc): Rename to...
(syscalls_info_free_syscalls_desc): ... this.
(free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust
code to the new layout of "struct syscalls_info".
(make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to
"syscalls_info".
(syscall_create_syscall_desc): Likewise.
(syscall_start_syscall): Likewise.
(syscall_parse_xml): Likewise.
(xml_init_syscalls_info): Likewise. Drop "const" from return value.
(init_sysinfo): Rename to...
(init_syscalls_info): ...this. Add gdbarch as a parameter.
Adjust function to deal with gdbarch.
(xml_get_syscall_number): Delete parameter sysinfo. Accept
gdbarch as a parameter. Adjust code.
(xml_get_syscall_name): Likewise.
(xml_list_of_syscalls): Likewise.
(set_xml_syscall_file_name): Accept gdbarch as parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
* xml-syscall.h (set_xml_syscall_file_name): Likewise.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
gdb/testsuite/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
2012-04-27 22:47:57 +02:00
# SystemTap related fields and functions.
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of prefixes used to mark an integer constant
# on the architecture's assembly.
2012-04-27 22:47:57 +02:00
# For example, on x86 integer constants are written as:
#
# \$10 ;; integer constant 10
#
# in this case, this prefix would be the character \`\$\'.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_integer_prefixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_integer_prefixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of suffixes used to mark an integer constant
# on the architecture's assembly.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_integer_suffixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_integer_suffixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of prefixes used to mark a register name on
# the architecture's assembly.
2012-04-27 22:47:57 +02:00
# For example, on x86 the register name is written as:
#
# \%eax ;; register eax
#
# in this case, this prefix would be the character \`\%\'.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_register_prefixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_register_prefixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of suffixes used to mark a register name on
# the architecture's assembly.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_register_suffixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_register_suffixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of prefixes used to mark a register
# indirection on the architecture's assembly.
2012-04-27 22:47:57 +02:00
# For example, on x86 the register indirection is written as:
#
# \(\%eax\) ;; indirecting eax
#
# in this case, this prefix would be the charater \`\(\'.
#
# Please note that we use the indirection prefix also for register
# displacement, e.g., \`4\(\%eax\)\' on x86.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_register_indirection_prefixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_register_indirection_prefixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# A NULL-terminated array of suffixes used to mark a register
# indirection on the architecture's assembly.
2012-04-27 22:47:57 +02:00
# For example, on x86 the register indirection is written as:
#
# \(\%eax\) ;; indirecting eax
#
# in this case, this prefix would be the charater \`\)\'.
#
# Please note that we use the indirection suffix also for register
# displacement, e.g., \`4\(\%eax\)\' on x86.
2017-05-02 19:30:07 +02:00
v; const char *const *; stap_register_indirection_suffixes; ; ; 0; 0; ; 0; pstring_list ( gdbarch->stap_register_indirection_suffixes)
2012-04-27 22:47:57 +02:00
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
# Prefix(es) used to name a register using GDB's nomenclature.
2012-04-27 22:47:57 +02:00
#
# For example, on PPC a register is represented by a number in the assembly
# language (e.g., \`10\' is the 10th general-purpose register). However,
# inside GDB this same register has an \`r\' appended to its name, so the 10th
# register would be represented as \`r10\' internally.
2017-05-02 19:30:07 +02:00
v; const char *; stap_gdb_register_prefix; ; ; 0; 0; ; 0; pstring ( gdbarch->stap_gdb_register_prefix)
2012-04-27 22:47:57 +02:00
# Suffix used to name a register using GDB's nomenclature.
2017-05-02 19:30:07 +02:00
v; const char *; stap_gdb_register_suffix; ; ; 0; 0; ; 0; pstring ( gdbarch->stap_gdb_register_suffix)
2012-04-27 22:47:57 +02:00
# Check if S is a single operand.
#
# Single operands can be:
# \- Literal integers, e.g. \`\$10\' on x86
# \- Register access, e.g. \`\%eax\' on x86
# \- Register indirection, e.g. \`\(\%eax\)\' on x86
# \- Register displacement, e.g. \`4\(\%eax\)\' on x86
#
# This function should check for these patterns on the string
# and return 1 if some were found, or zero otherwise. Please try to match
# as much info as you can from the string, i.e., if you have to match
# something like \`\(\%\', do not match just the \`\(\'.
2017-05-02 19:30:07 +02:00
M; int; stap_is_single_operand; const char *s; s
2012-04-27 22:47:57 +02:00
# Function used to handle a "special case" in the parser.
#
# A "special case" is considered to be an unknown token, i.e., a token
# that the parser does not know how to parse. A good example of special
# case would be ARM's register displacement syntax:
#
# [R0, #4] ;; displacing R0 by 4
#
# Since the parser assumes that a register displacement is of the form:
#
# <number> <indirection_prefix> <register_name> <indirection_suffix>
#
# it means that it will not be able to recognize and parse this odd syntax.
# Therefore, we should add a special case function that will handle this token.
#
# This function should generate the proper expression form of the expression
# using GDB\'s internal expression mechanism (e.g., \`write_exp_elt_opcode\'
# and so on). It should also return 1 if the parsing was successful, or zero
# if the token was not recognized as a special token (in this case, returning
# zero means that the special parser is deferring the parsing to the generic
# parser), and should advance the buffer pointer (p->arg).
2017-05-02 19:30:07 +02:00
M; int; stap_parse_special_token; struct stap_parse_info *p; p
2012-04-27 22:47:57 +02:00
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-26 23:34:50 +02:00
# Perform arch-dependent adjustments to a register name.
#
# In very specific situations, it may be necessary for the register
# name present in a SystemTap probe's argument to be handled in a
# special way. For example, on i386, GCC may over-optimize the
# register allocation and use smaller registers than necessary. In
# such cases, the client that is reading and evaluating the SystemTap
# probe (ourselves) will need to actually fetch values from the wider
# version of the register in question.
#
# To illustrate the example, consider the following probe argument
# (i386):
#
# 4@%ax
#
# This argument says that its value can be found at the %ax register,
# which is a 16-bit register. However, the argument's prefix says
# that its type is "uint32_t", which is 32-bit in size. Therefore, in
# this case, GDB should actually fetch the probe's value from register
# %eax, not %ax. In this scenario, this function would actually
# replace the register name from %ax to %eax.
#
# The rationale for this can be found at PR breakpoints/24541.
2019-07-02 13:06:06 +02:00
M; std::string; stap_adjust_register; struct stap_parse_info *p, const std::string \& regname, int regnum; p, regname, regnum
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-26 23:34:50 +02:00
2015-02-17 15:54:44 +01:00
# DTrace related functions.
# The expression to compute the NARTGth+1 argument to a DTrace USDT probe.
# NARG must be >= 0.
Make base class for parser_state
This makes a new base class, expr_builder, for parser_state. This
separates the state needed to construct an expression from the state
needed by the parsers.
gdb/ChangeLog
2019-04-04 Tom Tromey <tom@tromey.com>
* gdbarch.h, gdbarch.c: Rebuild.
* gdbarch.sh (dtrace_parse_probe_argument): Change type.
* stap-probe.h:
(struct stap_parse_info): Replace "parser_state" with
"expr_builder".
* parser-defs.h (struct expr_builder): Rename from "parser_state".
(parser_state): New class.
* parse.c (expr_builder): Rename.
(expr_builder::release): Rename.
(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
(write_exp_elt_longcst, write_exp_elt_floatcst)
(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
(write_exp_string_vector, write_exp_bitstring)
(write_exp_msymbol, mark_struct_expression)
(write_dollar_variable)
(insert_type_address_space, increase_expout_size): Replace
"parser_state" with "expr_builder".
* dtrace-probe.c: Replace "parser_state" with "expr_builder".
* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace
"parser_state" with "expr_builder".
2019-03-24 17:28:42 +01:00
M; void; dtrace_parse_probe_argument; struct expr_builder *builder, int narg; builder, narg
2015-02-17 15:54:44 +01:00
# True if the given ADDR does not contain the instruction sequence
# corresponding to a disabled DTrace is-enabled probe.
2017-05-02 19:30:07 +02:00
M; int; dtrace_probe_is_enabled; CORE_ADDR addr; addr
2015-02-17 15:54:44 +01:00
# Enable a DTrace is-enabled probe at ADDR.
2017-05-02 19:30:07 +02:00
M; void; dtrace_enable_probe; CORE_ADDR addr; addr
2015-02-17 15:54:44 +01:00
# Disable a DTrace is-enabled probe at ADDR.
2017-05-02 19:30:07 +02:00
M; void; dtrace_disable_probe; CORE_ADDR addr; addr
2012-04-27 22:47:57 +02:00
* remote.c (remote_start_remote): If the solib list is global,
fetch libraries and insert breakpoints after connecting.
* infcmd.c (post_create_inferior): If the solist is shared between
inferiors, no need to refetch it on every new inferior.
(detach_command): If the shared library list is shared between
inferiors, then don't clear it on every inferior detach.
* gdbarch.sh (has_global_solist): New.
* i386-dicos-tdep.c (i386_dicos_init_abi): Set
gdbarch_has_global_solist.
* target.c (target_pre_inferior): If the shared library list is
shared between inferiors, then don't clear it here, neither
invalidate the memory regions or clear the target description.
(target_detach): If the shared library list is shared between
inferiors, then don't remove breakpoints from the target here.
(target_disconnect): Comment.
* solib.c (update_solib_list): Check for null_ptid.
* breakpoint.c (insert_breakpoints, update_global_location_list):
If the shared library list is shared between inferiors, insert
breakpoints even if there's no execution.
(breakpoint_init_inferior): If the shared library list is shared
between inferiors, don't delete breakpoints or mark them
uninserted here.
* gdbarch.c, gdbarch.h: Regenerate.
2008-11-03 15:01:27 +01:00
# True if the list of shared libraries is one and only for all
# processes, as opposed to a list of shared libraries per inferior.
2009-05-19 02:23:49 +02:00
# This usually means that all processes, although may or may not share
# an address space, will see the same set of symbols at the same
# addresses.
2017-05-02 19:30:07 +02:00
v; int; has_global_solist; ; ; 0; 0; ; 0
2009-05-19 02:23:49 +02:00
# On some targets, even though each inferior has its own private
# address space, the debug interface takes care of making breakpoints
# visible to all address spaces automatically. For such cases,
# this property should be set to true.
2017-05-02 19:30:07 +02:00
v; int; has_global_breakpoints; ; ; 0; 0; ; 0
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
Add base multi-executable/process support to GDB.
gdb/
* Makefile.in (SFILES): Add progspace.c.
(COMMON_OBS): Add progspace.o.
* progspace.h: New.
* progspace.c: New.
* breakpoint.h (struct bp_target_info) <placed_address_space>: New
field.
(struct bp_location) <pspace>: New field.
(struct breakpoint) <pspace>: New field.
(bpstat_stop_status, breakpoint_here_p)
(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
(regular_breakpoint_inserted_here_p)
(software_breakpoint_inserted_here_p, breakpoint_thread_match)
(set_default_breakpoint): Adjust prototypes.
(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
Adjust prototypes.
* breakpoint.c (executing_startup): Delete.
(default_breakpoint_sspace): New.
(breakpoint_restore_shadows): Skip if the address space doesn't
match.
(update_watchpoint): Record the frame's program space in the
breakpoint location.
(insert_bp_location): Record the address space in target_info.
Adjust to pass the symbol space to solib_name_from_address.
(breakpoint_program_space_exit): New.
(insert_breakpoint_locations): Switch the symbol space and thread
when inserting breakpoints. Don't insert breakpoints in a vfork
parent waiting for vfork done if we're not attached to the vfork
child.
(remove_breakpoints_pid): New.
(reattach_breakpoints): Switch to a thread of PID. Ignore
breakpoints of other symbol spaces.
(create_internal_breakpoint): Store the symbol space in the sal.
(create_longjmp_master_breakpoint): Iterate over all symbol
spaces.
(update_breakpoints_after_exec): Ignore breakpoints for other
symbol spaces.
(remove_breakpoint): Rename to ...
(remove_breakpoint_1): ... this. Pass the breakpoints symbol
space to solib_name_from_address.
(remove_breakpoint): New.
(mark_breakpoints_out): Ignore breakpoints from other symbol
spaces.
(breakpoint_init_inferior): Ditto.
(breakpoint_here_p): Add an address space argument and adjust to
use breakpoint_address_match.
(moribund_breakpoint_here_p): Ditto.
(regular_breakpoint_inserted_here_p): Ditto.
(breakpoint_inserted_here_p): Ditto.
(software_breakpoint_inserted_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_check_location): Ditto.
(bpstat_stop_status): Ditto.
(print_breakpoint_location): If there's a location to print,
switch the current symbol space.
(print_one_breakpoint_location): Add `allflag' argument.
(print_one_breakpoint): Ditto. Adjust.
(do_captured_breakpoint_query): Adjust.
(breakpoint_1): Adjust.
(breakpoint_has_pc): Also match the symbol space.
(describe_other_breakpoints): Add a symbol space argument and
adjust.
(set_default_breakpoint): Add a symbol space argument. Set
default_breakpoint_sspace.
(breakpoint_address_match): New.
(check_duplicates_for): Add an address space argument, and adjust.
(set_raw_breakpoint): Record the symbol space in the location and
in the breakpoint.
(set_longjmp_breakpoint): Skip longjmp master breakpoints from
other symbol spaces.
(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
(disable_breakpoints_in_shlibs): Skip breakpoints from other
symbol spaces.
(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
(create_catchpoint): Set the symbol space in the sal.
(disable_breakpoints_before_startup): Skip breakpoints from other
symbol spaces. Set executing_startup in the current symbol space.
(enable_breakpoints_after_startup): Clear executing_startup in the
current symbol space. Skip breakpoints from other symbol spaces.
(clone_momentary_breakpoint): Also copy the symbol space.
(add_location_to_breakpoint): Set the location's symbol space.
(bp_loc_is_permanent): Switch thread and symbol space.
(create_breakpoint): Adjust.
(expand_line_sal_maybe): Expand comment to mention symbol spaces.
Switch thread and symbol space when reading memory.
(parse_breakpoint_sals): Set the symbol space in the sal.
(break_command_really): Ditto.
(skip_prologue_sal): Switch and space.
(resolve_sal_pc): Ditto.
(watch_command_1): Record the symbol space in the sal.
(create_ada_exception_breakpoint): Adjust.
(clear_command): Adjust. Match symbol spaces.
(update_global_location_list): Use breakpoint_address_match.
(breakpoint_re_set_one): Switch thread and space.
(breakpoint_re_set): Save symbol space.
(breakpoint_re_set_thread): Also reset the symbol space.
(deprecated_insert_raw_breakpoint): Add an address space argument.
Adjust.
(insert_single_step_breakpoint): Ditto.
(single_step_breakpoint_inserted_here_p): Ditto.
(clear_syscall_counts): New.
(_initialize_breakpoint): Install it as inferior_exit observer.
* exec.h: Include "progspace.h".
(exec_bfd, exec_bfd_mtime): New defines.
(exec_close): Declare.
* exec.c: Include "gdbthread.h" and "progspace.h".
(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
(using_exec_ops): New.
(exec_close_1): Rename to exec_close, and make public.
(exec_close): Rename to exec_close_1, and adjust all callers. Add
description. Remove target sections and close executables from
all program spaces.
(exec_file_attach): Add comment.
(add_target_sections): Check on `using_exec_ops' to check if the
target should be pushed.
(remove_target_sections): Only unpush the target if there are no
more target sections in any symbol space.
* gdbcore.h: Include "exec.h".
(exec_bfd, exec_bfd_mtime): Remove declarations.
* frame.h (get_frame_program_space, get_frame_address_space)
(frame_unwind_program_space): Declare.
* frame.c (struct frame_info) <pspace, aspace>: New fields.
(create_sentinel_frame): Add program space argument. Set the
pspace and aspace fields of the frame object.
(get_current_frame, create_new_frame): Adjust.
(get_frame_program_space): New.
(frame_unwind_program_space): New.
(get_frame_address_space): New.
* stack.c (print_frame_info): Adjust.
(print_frame): Use the frame's program space.
* gdbthread.h (any_live_thread_of_process): Declare.
* thread.c (any_live_thread_of_process): New.
(switch_to_thread): Switch the program space as well.
(restore_selected_frame): Don't warn if trying to restore frame
level 0.
* inferior.h: Include "progspace.h".
(detach_fork): Declare.
(struct inferior) <removable, aspace, pspace>
<vfork_parent, vfork_child, pending_detach>
<waiting_for_vfork_done>: New fields.
<terminal_info>: Remove field.
<data, num_data>: New fields.
(register_inferior_data, register_inferior_data_with_cleanup)
(clear_inferior_data, set_inferior_data, inferior_data): Declare.
(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
(inferior_appeared): Declare.
(find_inferior_pid): Typo.
(find_inferior_id, find_inferior_for_program_space): Declare.
(set_current_inferior, save_current_inferior, prune_inferiors)
(number_of_inferiors): Declare.
(inferior_list): Declare.
* inferior.c: Include "gdbcore.h" and "symfile.h".
(inferior_list): Make public.
(delete_inferior_1): Always delete thread silently.
(find_inferior_id): Make public.
(current_inferior_): New.
(current_inferior): Use it.
(set_current_inferior): New.
(restore_inferior): New.
(save_current_inferior): New.
(free_inferior): Free the per-inferior data.
(add_inferior_silent): Allocate per-inferior data.
Call inferior_appeared.
(delete_threads_of_inferior): New.
(delete_inferior_1): Adjust interface to take an inferior pointer.
(delete_inferior): Adjust.
(delete_inferior_silent): Adjust.
(exit_inferior_1): New.
(exit_inferior): New.
(exit_inferior_silent): New.
(exit_inferior_num_silent): New.
(detach_inferior): Adjust.
(inferior_appeared): New.
(discard_all_inferiors): Adjust.
(find_inferior_id): Make public. Assert pid is not zero.
(find_inferior_for_program_space): New.
(have_inferiors): Check if we have any inferior with pid not zero.
(have_live_inferiors): Go over all pushed targets looking for
process_stratum.
(prune_inferiors): New.
(number_of_inferiors): New.
(print_inferior): Add executable column. Print vfork parent/child
relationships.
(inferior_command): Adjust to cope with not running inferiors.
(remove_inferior_command): New.
(add_inferior_command): New.
(clone_inferior_command): New.
(struct inferior_data): New.
(struct inferior_data_registration): New.
(struct inferior_data_registry): New.
(inferior_data_registry): New.
(register_inferior_data_with_cleanup): New.
(register_inferior_data): New.
(inferior_alloc_data): New.
(inferior_free_data): New.
(clear_inferior_data): New.
(set_inferior_data): New.
(inferior_data): New.
(initialize_inferiors): New.
(_initialize_inferiors): Register "add-inferior",
"remove-inferior" and "clone-inferior" commands.
* objfiles.h: Include "progspace.h".
(struct objfile) <pspace>: New field.
(symfile_objfile, object_files): Don't declare.
(ALL_PSPACE_OBJFILES): New.
(ALL_PSPACE_OBJFILES_SAFE): New.
(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
(ALL_PSPACE_SYMTABS): New.
(ALL_PRIMARY_SYMTABS): Adjust.
(ALL_PSPACE_PRIMARY_SYMTABS): New.
(ALL_PSYMTABS): Adjust.
(ALL_PSPACE_PSYMTABS): New.
* objfiles.c (object_files, symfile_objfile): Delete.
(struct objfile_sspace_info): New.
(objfiles_pspace_data): New.
(objfiles_pspace_data_cleanup): New.
(get_objfile_pspace_data): New.
(objfiles_changed_p): Delete.
(allocate_objfile): Set the objfile's program space. Adjust to
reference objfiles_changed_p in pspace data.
(free_objfile): Adjust to reference objfiles_changed_p in pspace
data.
(objfile_relocate): Ditto.
(update_section_map): Add pspace argument. Adjust to iterate over
objfiles in the passed in pspace.
(find_pc_section): Delete sections and num_sections statics.
Adjust to refer to program space's objfiles_changed_p. Adjust to
refer to sections and num_sections store in the objfile's pspace
data.
(objfiles_changed): Adjust to reference objfiles_changed_p in
pspace data.
(_initialize_objfiles): New.
* linespec.c (decode_all_digits, decode_dollar): Set the sal's
program space.
* source.c (current_source_pspace): New.
(get_current_source_symtab_and_line): Set the sal's program space.
(set_current_source_symtab_and_line): Set current_source_pspace.
(select_source_symtab): Ditto. Use ALL_OBJFILES.
(forget_cached_source_info): Iterate over all program spaces.
* symfile.c (clear_symtab_users): Adjust.
* symmisc.c (print_symbol_bcache_statistics): Iterate over all
program spaces.
(print_objfile_statistics): Ditto.
(maintenance_print_msymbols): Ditto.
(maintenance_print_objfiles): Ditto.
(maintenance_info_symtabs): Ditto.
(maintenance_info_psymtabs): Ditto.
* symtab.h (SYMTAB_PSPACE): New.
(struct symtab_and_line) <pspace>: New field.
* symtab.c (init_sal): Clear the sal's program space.
(find_pc_sect_symtab): Set the sal's program space. Switch thread
and space.
(append_expanded_sal): Add program space argument. Iterate over
all program spaces.
(expand_line_sal): Iterate over all program spaces. Switch
program space.
* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
(struct target_ops) <to_thread_address_space>: New field.
(target_thread_address_space): Define.
* target.c (target_detach): Only remove breakpoints from the
inferior we're detaching.
(target_thread_address_space): New.
* defs.h (initialize_progspace): Declare.
* top.c (gdb_init): Call it.
* solist.h (struct so_list) <sspace>: New field.
* solib.h (struct program_space): Forward declare.
(solib_name_from_address): Adjust prototype.
* solib.c (so_list_head): Replace with a macro referencing the
program space.
(update_solib_list): Set the so's program space.
(solib_name_from_address): Add a program space argument and adjust.
* solib-svr4.c (struct svr4_info) <pid>: Delete field.
<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
<interp_plt_sect_high>: New fields.
(svr4_info_p, svr4_info): Delete.
(solib_svr4_sspace_data): New.
(get_svr4_info): Rewrite.
(svr4_sspace_data_cleanup): New.
(open_symbol_file_object): Adjust.
(svr4_default_sos): Adjust.
(svr4_fetch_objfile_link_map): Adjust.
(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
(interp_plt_sect_high): Delete.
(svr4_in_dynsym_resolve_code): Adjust.
(enable_break): Adjust.
(svr4_clear_solib): Revert bit that removed the svr4_info here,
and reinstate clearing debug_base, debug_loader_offset_p,
debug_loader_offset and debug_loader_name.
(_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't
install an inferior_exit observer anymore.
* printcmd.c (struct display) <pspace>: New field.
(display_command): Set the display's sspace.
(do_one_display): Match the display's sspace.
(display_uses_solib_p): Ditto.
* linux-fork.c (detach_fork): Moved to infrun.c.
(_initialize_linux_fork): Moved "detach-on-fork" command to
infrun.c.
* infrun.c (detach_fork): Moved from linux-fork.c.
(proceed_after_vfork_done): New.
(handle_vfork_child_exec_or_exit): New.
(follow_exec_mode_replace, follow_exec_mode_keep)
(follow_exec_mode_names, follow_exec_mode_string)
(show_follow_exec_mode_string): New.
(follow_exec): New. Reinstate the mark_breakpoints_out call.
Remove shared libraries before attaching new executable. If user
wants to keep the inferior, keep it.
(displaced_step_fixup): Adjust to pass an address space to the
breakpoints module.
(resume): Ditto.
(clear_proceed_status): In all-stop mode, always clear the proceed
status of all threads.
(prepare_to_proceed): Adjust to pass an address space to the
breakpoints module.
(proceed): Ditto.
(adjust_pc_after_break): Ditto.
(handle_inferior_event): When handling a process exit, switch the
program space to the inferior's that had exited. Call
handle_vfork_child_exec_or_exit. Adjust to pass an address space
to the breakpoints module. In non-stop mode, when following a
fork and detach-fork is off, also resume the other branch. Handle
TARGET_WAITKIND_VFORK_DONE. Set the program space in sals.
(normal_stop): Prune inferiors.
(_initialize_infrun): Install the new "follow-exec-mode" command.
"detach-on-fork" moved here.
* regcache.h (get_regcache_aspace): Declare.
* regcache.c (struct regcache) <aspace>: New field.
(regcache_xmalloc): Clear the aspace.
(get_regcache_aspace): New.
(regcache_cpy): Copy the aspace field.
(regcache_cpy_no_passthrough): Ditto.
(get_thread_regcache): Fetch the thread's address space from the
target, and store it in the regcache.
* infcall.c (call_function_by_hand): Set the sal's pspace.
* arch-utils.c (default_has_shared_address_space): New.
* arch-utils.h (default_has_shared_address_space): Declare.
* gdbarch.sh (has_shared_address_space): New.
* gdbarch.h, gdbarch.c: Regenerate.
* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
(linux_has_shared_address_space): New.
(_initialize_linux_tdep): Declare.
* arm-tdep.c (arm_software_single_step): Pass the frame's address
space to insert_single_step_breakpoint.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
frame's pspace to breakpoint functions.
* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
(cris_software_single_step): Ditto.
* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
Pass the frame's pspace to breakpoint functions.
(mips_software_single_step): Adjust.
(mips_single_step_through_delay): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* solib-irix.c (enable_break): Adjust to pass the current frame's
address space to breakpoint functions.
* sparc-tdep.c (sparc_software_single_step): Ditto.
* spu-tdep.c (spu_software_single_step): Ditto.
* alpha-tdep.c (alpha_software_single_step): Ditto.
* record.c (record_wait): Adjust to pass an address space to the
breakpoints module.
* fork-child.c (fork_inferior): Set the new inferior's program and
address spaces.
* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
and address spaces.
(inf_ptrace_attach): Set the inferior's program and address spaces.
* linux-nat.c: Include "solib.h".
(linux_child_follow_fork): Manage parent and child's program and
address spaces. Clone the parent's program space if necessary.
Don't wait for the vfork to be done here. Refuse to resume if
following the vfork parent while leaving the child stopped.
(resume_callback): Don't resume a vfork parent.
(linux_nat_resume): Also check for pending events in the
lp->waitstatus field.
(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
events to the core.
(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
(cancel_breakpoint): Adjust.
* linux-thread-db.c (thread_db_wait): Don't remove thread event
breakpoints here.
(thread_db_mourn_inferior): Don't mark breakpoints out here.
Remove thread event breakpoints after mourning.
* corelow.c: Include progspace.h.
(core_open): Set the inferior's program and address spaces.
* remote.c (remote_add_inferior): Set the new inferior's program
and address spaces.
(remote_start_remote): Update address spaces.
(extended_remote_create_inferior_1): Don't init the thread list if
we already debugging other inferiors.
* darwin-nat.c (darwin_attach): Set the new inferior's program and
address spaces.
* gnu-nat.c (gnu_attach): Ditto.
* go32-nat.c (go32_create_inferior): Ditto.
* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
* monitor.c (monitor_open): Ditto.
* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
* procfs.c (do_attach): Ditto.
* windows-nat.c (do_initial_windows_stuff): Ditto.
* inflow.c (inferior_process_group)
(terminal_init_inferior_with_pgrp, terminal_inferior,
(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
to use per-inferior data instead of inferior->terminal_info.
(inflow_inferior_data): New.
(inflow_new_inferior): Delete.
(inflow_inferior_data_cleanup): New.
(get_inflow_inferior_data): New.
* mi/mi-interp.c (mi_new_inferior): Rename to...
(mi_inferior_appeared): ... this.
(mi_interpreter_init): Adjust.
* tui/tui-disasm.c: Include "progspace.h".
(tui_set_disassem_content): Pass an address space to
breakpoint_here_p.
* NEWS: Mention multi-program debugging support. Mention new
commands "add-inferior", "clone-inferior", "remove-inferior",
"maint info program-spaces", and new option "set
follow-exec-mode".
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* observer.texi (new_inferior): Rename to...
(inferior_appeared): ... this.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/testsuite/
* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
* gdb.base/foll-exec.exp: Adjust to expect a process id before
"Executing new program".
* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
* gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being
left listed after having been killed.
* gdb.base/attach.exp: Adjust to spell out "symbol-file".
* gdb.base/maint.exp: Adjust test.
* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
* gdb.multi/Makefile.in: New.
* gdb.multi/base.exp: New.
* gdb.multi/goodbye.c: New.
* gdb.multi/hangout.c: New.
* gdb.multi/hello.c: New.
* gdb.multi/bkpt-multi-exec.c: New.
* gdb.multi/bkpt-multi-exec.exp: New.
* gdb.multi/crashme.c: New.
2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com>
gdb/doc/
* gdb.texinfo (Inferiors): Rename node to ...
(Inferiors and Programs): ... this. Mention running multiple
programs in the same debug session.
<info inferiors>: Mention the new 'Executable' column if "info
inferiors". Update examples. Document the "add-inferior",
"clone-inferior", "remove-inferior" and "maint info
program-spaces" commands.
(Process): Rename node to...
(Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
# True if inferiors share an address space (e.g., uClinux).
2017-05-02 19:30:07 +02:00
m; int; has_shared_address_space; void; ; ; default_has_shared_address_space; ; 0
2010-01-06 05:20:27 +01:00
# True if a fast tracepoint can be set at an address.
2018-02-22 00:53:56 +01:00
m; int; fast_tracepoint_valid_at; CORE_ADDR addr, std::string *msg; addr, msg; ; default_fast_tracepoint_valid_at; ; 0
2010-02-03 17:43:03 +01:00
2016-02-18 09:21:38 +01:00
# Guess register state based on tracepoint location. Used for tracepoints
# where no registers have been collected, but there's only one location,
# allowing us to guess the PC value, and perhaps some other registers.
# On entry, regcache has all registers marked as unavailable.
2017-05-02 19:30:07 +02:00
m; void; guess_tracepoint_registers; struct regcache *regcache, CORE_ADDR addr; regcache, addr; ; default_guess_tracepoint_registers; ; 0
2016-02-18 09:21:38 +01:00
2010-03-05 21:18:19 +01:00
# Return the "auto" target charset.
2017-05-02 19:30:07 +02:00
f; const char *; auto_charset; void; ; default_auto_charset; default_auto_charset; ; 0
2010-03-05 21:18:19 +01:00
# Return the "auto" target wide charset.
2017-05-02 19:30:07 +02:00
f; const char *; auto_wide_charset; void; ; default_auto_wide_charset; default_auto_wide_charset; ; 0
2010-03-08 20:28:27 +01:00
# If non-empty, this is a file extension that will be opened in place
# of the file extension reported by the shared library list.
#
# This is most useful for toolchains that use a post-linker tool,
# where the names of the files run on the target differ in extension
# compared to the names of the files GDB should load for debug info.
2017-05-02 19:30:07 +02:00
v; const char *; solib_symbols_extension; ; ; ; ; ; ; pstring ( gdbarch->solib_symbols_extension)
2010-04-24 15:12:56 +02:00
# If true, the target OS has DOS-based file system semantics. That
# is, absolute paths include a drive name, and the backslash is
# considered a directory separator.
2017-05-02 19:30:07 +02:00
v; int; has_dos_based_file_system; ; ; 0; 0; ; 0
2011-09-27 15:09:37 +02:00
# Generate bytecodes to collect the return address in a frame.
# Since the bytecodes run on the target, possibly with GDB not even
# connected, the full unwinding machinery is not available, and
# typically this function will issue bytecodes for one or more likely
# places that the return address may be found.
2017-05-02 19:30:07 +02:00
m; void; gen_return_address; struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope; ax, value, scope; ; default_gen_return_address; ; 0
2011-09-27 15:09:37 +02:00
2012-01-20 10:49:58 +01:00
# Implement the "info proc" command.
2017-05-02 19:30:07 +02:00
M; void; info_proc; const char *args, enum info_proc_what what; args, what
2012-01-20 10:49:58 +01:00
2012-12-14 16:30:38 +01:00
# Implement the "info proc" command for core files. Noe that there
# are two "info_proc"-like methods on gdbarch -- one for core files,
# one for live targets.
2017-05-02 19:30:07 +02:00
M; void; core_info_proc; const char *args, enum info_proc_what what; args, what
2012-12-14 16:30:38 +01:00
2012-06-05 15:50:50 +02:00
# Iterate over all objfiles in the order that makes the most sense
# for the architecture to make global symbol searches.
#
# CB is a callback function where OBJFILE is the objfile to be searched,
# and CB_DATA a pointer to user-defined data (the same data that is passed
# when calling this gdbarch method). The iteration stops if this function
# returns nonzero.
#
# CB_DATA is a pointer to some user-defined data to be passed to
# the callback.
#
# If not NULL, CURRENT_OBJFILE corresponds to the objfile being
# inspected when the symbol search was requested.
2017-05-02 19:30:07 +02:00
m; void; iterate_over_objfiles_in_search_order; iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile; cb, cb_data, current_objfile; 0; default_iterate_over_objfiles_in_search_order; ; 0
2012-06-05 15:50:50 +02:00
2012-12-15 15:27:56 +01:00
# Ravenscar arch-dependent ops.
2017-05-02 19:30:07 +02:00
v; struct ravenscar_arch_ops *; ravenscar_ops; ; ; NULL; NULL; ; 0; host_address_to_string ( gdbarch->ravenscar_ops)
gdbarch: add instruction predicate methods
Add new methods to gdbarch for analyzing the instruction at a given address.
Implement those methods for i386 and amd64 architectures.
This is needed by "record btrace" to detect function calls in the
execution trace.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call)
(amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
(amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
to gdbarch.
* i386-tdep.c (i386_insn_is_call, i386_insn_is_ret)
(i386_insn_is_jump, i386_jmp_p): New.
(i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
insn_is_jump to gdbarch.
* gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
* gdbarch.h: Regenerated.
* gdbarch.c: Regenerated.
* arch-utils.h (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
* arch-utils.c (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
2013-03-22 15:56:56 +01:00
# Return non-zero if the instruction at ADDR is a call; zero otherwise.
2017-05-02 19:30:07 +02:00
m; int; insn_is_call; CORE_ADDR addr; addr; ; default_insn_is_call; ; 0
gdbarch: add instruction predicate methods
Add new methods to gdbarch for analyzing the instruction at a given address.
Implement those methods for i386 and amd64 architectures.
This is needed by "record btrace" to detect function calls in the
execution trace.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call)
(amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
(amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
to gdbarch.
* i386-tdep.c (i386_insn_is_call, i386_insn_is_ret)
(i386_insn_is_jump, i386_jmp_p): New.
(i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
insn_is_jump to gdbarch.
* gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
* gdbarch.h: Regenerated.
* gdbarch.c: Regenerated.
* arch-utils.h (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
* arch-utils.c (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
2013-03-22 15:56:56 +01:00
# Return non-zero if the instruction at ADDR is a return; zero otherwise.
2017-05-02 19:30:07 +02:00
m; int; insn_is_ret; CORE_ADDR addr; addr; ; default_insn_is_ret; ; 0
gdbarch: add instruction predicate methods
Add new methods to gdbarch for analyzing the instruction at a given address.
Implement those methods for i386 and amd64 architectures.
This is needed by "record btrace" to detect function calls in the
execution trace.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call)
(amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
(amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
to gdbarch.
* i386-tdep.c (i386_insn_is_call, i386_insn_is_ret)
(i386_insn_is_jump, i386_jmp_p): New.
(i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
insn_is_jump to gdbarch.
* gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
* gdbarch.h: Regenerated.
* gdbarch.c: Regenerated.
* arch-utils.h (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
* arch-utils.c (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
2013-03-22 15:56:56 +01:00
# Return non-zero if the instruction at ADDR is a jump; zero otherwise.
2017-05-02 19:30:07 +02:00
m; int; insn_is_jump; CORE_ADDR addr; addr; ; default_insn_is_jump; ; 0
2014-02-27 13:40:15 +01:00
Recognize more program breakpoint patterns
New in v3:
- Code cleanups based on reviews.
New in v2:
- Fixed misc problems based on reviews.
- Switched to using gdbarch_program_breakpoint_here_p as opposed to
gdbarch_insn_is_breakpoint.
- Fixed matching of brk instructions. Previously the mask was incorrect, which
was showing up as a few failures in the testsuite. Now it is clean.
- New testcase (separate patch).
- Moved program_breakpoint_here () to arch-utils.c and made it the default
implementation of gdbarch_program_breakpoint_here_p.
--
It was reported to me that program breakpoints (permanent ones inserted into
the code itself) other than the one GDB uses for AArch64 (0xd4200000) do not
generate visible stops when continuing, and GDB will continue spinning
infinitely.
This happens because GDB, upon hitting one of those program breakpoints, thinks
the SIGTRAP came from a delayed breakpoint hit...
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14198)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14198
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14198.14198.0 [process 14198],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
...
... which is not the case.
If the program breakpoint is one GDB recognizes, then it will stop when it
hits it.
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x0
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14193)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14193
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14193] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 14193.14193.0 [process 14193],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 14193 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun: process 14193 not executing
infrun: stop_all_threads done
Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk_0.c:7
7 asm("brk %0\n\t" ::"n"(0x0));
infrun: infrun_async(0)
Otherwise GDB will keep trying to resume the inferior and will keep
seeing the SIGTRAP's, without stopping.
To the user it appears GDB has gone into an infinite loop, interruptible only
by Ctrl-C.
Also, windbg seems to use a different variation of AArch64 breakpoint compared
to GDB. This causes problems when debugging Windows on ARM binaries, when
program breakpoints are being used.
The proposed patch creates a new gdbarch method (gdbarch_program_breakpoint_here_p)
that tells GDB whether the underlying instruction is a breakpoint instruction
or not.
This is more general than only checking for the instruction GDB uses as
breakpoint.
The existing logic is still preserved for targets that do not implement this
new gdbarch method.
The end result is like so:
(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 16417)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 16417
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 16417] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 16417.16417.0 [process 16417],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: process 16417 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun: process 16417 not executing
infrun: stop_all_threads done
Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk.c:7
7 asm("brk %0\n\t" ::"n"(0x900 + 0xf));
infrun: infrun_async(0)
gdb/ChangeLog:
2020-01-29 Luis Machado <luis.machado@linaro.org>
* aarch64-tdep.c (BRK_INSN_MASK): Define to 0xffe0001f.
(BRK_INSN_MASK): Define to 0xd4200000.
(aarch64_program_breakpoint_here_p): New function.
(aarch64_gdbarch_init): Set gdbarch_program_breakpoint_here_p hook.
* arch-utils.c (default_program_breakpoint_here_p): Moved from
breakpoint.c.
* arch-utils.h (default_program_breakpoint_here_p): Moved from
breakpoint.h
* breakpoint.c (bp_loc_is_permanent): Changed return type to bool and
call gdbarch_program_breakpoint_here_p.
(program_breakpoint_here): Moved to arch-utils.c, renamed to
default_program_breakpoint_here_p, changed return type to bool and
simplified.
* breakpoint.h (program_breakpoint_here): Moved prototype to
arch-utils.h, renamed to default_program_breakpoint_here_p and changed
return type to bool.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (program_breakpoint_here_p): New method.
* infrun.c (handle_signal_stop): Call
gdbarch_program_breakpoint_here_p.
2019-12-23 16:04:26 +01:00
# Return true if there's a program/permanent breakpoint planted in
# memory at ADDRESS, return false otherwise.
m; bool; program_breakpoint_here_p; CORE_ADDR address; address; ; default_program_breakpoint_here_p; ; 0
2014-02-27 13:40:15 +01:00
# Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
# Return 0 if *READPTR is already at the end of the buffer.
# Return -1 if there is insufficient buffer for a whole entry.
# Return 1 if an entry was read into *TYPEP and *VALP.
2017-05-02 19:30:07 +02:00
M; int; auxv_parse; gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp; readptr, endptr, typep, valp
2014-10-10 16:57:13 +02:00
2016-06-12 00:51:38 +02:00
# Print the description of a single auxv entry described by TYPE and VAL
# to FILE.
2017-05-02 19:30:07 +02:00
m; void; print_auxv_entry; struct ui_file *file, CORE_ADDR type, CORE_ADDR val; file, type, val; ; default_print_auxv_entry; ; 0
2016-06-12 00:51:38 +02:00
2014-10-10 16:57:13 +02:00
# Find the address range of the current inferior's vsyscall/vDSO, and
# write it to *RANGE. If the vsyscall's length can't be determined, a
# range with zero length is returned. Returns true if the vsyscall is
# found, false otherwise.
2017-05-02 19:30:07 +02:00
m; int; vsyscall_range; struct mem_range *range; range; ; default_vsyscall_range; ; 0
2014-05-14 22:08:57 +02:00
# Allocate SIZE bytes of PROT protected page aligned memory in inferior.
# PROT has GDB_MMAP_PROT_* bitmask format.
# Throw an error if it is not possible. Returned address is always valid.
2017-05-02 19:30:07 +02:00
f; CORE_ADDR; infcall_mmap; CORE_ADDR size, unsigned prot; size, prot; ; default_infcall_mmap; ; 0
2014-05-14 22:08:57 +02:00
2015-06-03 21:22:56 +02:00
# Deallocate SIZE bytes of memory at ADDR in inferior from gdbarch_infcall_mmap.
# Print a warning if it is not possible.
2017-05-02 19:30:07 +02:00
f; void; infcall_munmap; CORE_ADDR addr, CORE_ADDR size; addr, size; ; default_infcall_munmap; ; 0
2015-06-03 21:22:56 +02:00
2014-05-14 22:08:57 +02:00
# Return string (caller has to use xfree for it) with options for GCC
# to produce code for this target, typically "-m64", "-m32" or "-m31".
# These options are put before CU's DW_AT_producer compilation options so that
2019-10-15 18:57:40 +02:00
# they can override it.
m; std::string; gcc_target_options; void; ; ; default_gcc_target_options; ; 0
add gnu_triplet_regexp gdbarch method
gdb has to inform libcc1.so of the target being used, so that the
correct compiler can be invoked. The compiler is invoked using the
GNU configury triplet prefix, e.g., "x86_64-unknown-linux-gnu-gcc".
In order for this to work we need to map the gdbarch to the GNU
configury triplet arch. In most cases these are identical; however,
the x86 family poses some problems, as the BFD arch names are quite
different from the GNU triplet names. So, we introduce a new gdbarch
method for this. A regular expression is used because there are
various valid values for the arch prefix in the triplet.
This patch also updates the osabi code to associate a regular
expression with the OS ABI. I have only added a concrete value for
Linux. Note that the "-gnu" part is optional, at least on Fedora it
is omitted from the installed GCC executable's name.
gdb/ChangeLog
2014-12-12 Tom Tromey <tromey@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* osabi.h (osabi_triplet_regexp): Declare.
* osabi.c (struct osabi_names): New.
(gdb_osabi_names): Change type to struct osabi_names. Update
values.
(gdbarch_osabi_name): Update.
(osabi_triplet_regexp): New function.
(osabi_from_tdesc_string, _initialize_gdb_osabi): Update.
* i386-tdep.c (i386_gnu_triplet_regexp): New method.
(i386_elf_init_abi, i386_go32_init_abi, i386_gdbarch_init): Call
set_gdbarch_gnu_triplet_regexp.
* gdbarch.sh (gnu_triplet_regexp): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_gnu_triplet_regexp): Declare.
* arch-utils.c (default_gnu_triplet_regexp): New function.
2014-06-13 17:28:24 +02:00
# Return a regular expression that matches names used by this
# architecture in GNU configury triplets. The result is statically
# allocated and must not be freed. The default implementation simply
# returns the BFD architecture name, which is correct in nearly every
# case.
2017-05-02 19:30:07 +02:00
m; const char *; gnu_triplet_regexp; void; ; ; default_gnu_triplet_regexp; ; 0
2015-06-12 22:51:51 +02:00
# Return the size in 8-bit bytes of an addressable memory unit on this
# architecture. This corresponds to the number of 8-bit bytes associated to
# each address in memory.
2017-05-02 19:30:07 +02:00
m; int; addressable_memory_unit_size; void; ; ; default_addressable_memory_unit_size; ; 0
2015-06-12 22:51:51 +02:00
2017-02-28 19:32:07 +01:00
# Functions for allowing a target to modify its disassembler options.
GDB PR tdep/8282: MIPS: Wire in `set disassembler-options'
Implement MIPS target support for passing options to the disassembler,
complementing commit 65b48a81404c ("GDB: Add support for the new
set/show disassembler-options commands.").
This includes options that expect an argument, so adjust the generic
code and data structures used so as to handle such options. So as to
give backends syntax flexibility no specific delimiter has been defined
to separate options from their respective arguments, so it has to be
included as the last character of the option name. Completion code
however has not been adjusted and consequently option arguments cannot
be completed at this time.
Also the MIPS target has non-empty defaults for the options, so that ABI
names for the general-purpose registers respect our `set mips abi ...'
setting rather than always being determined from the ELF headers of the
binary file selected. Handle these defaults as implicit options, never
shown to the user and always prepended to the user-specified options, so
that the latters can override the defaults.
The resulting output for the MIPS target is as follows:
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
no-aliases Use canonical instruction forms.
msa Recognize MSA instructions.
virt Recognize the virtualization ASE instructions.
xpa Recognize the eXtended Physical Address (XPA) ASE
instructions.
ginv Recognize the Global INValidate (GINV) ASE instructions.
gpr-names=ABI Print GPR names according to specified ABI.
Default: based on binary being disassembled.
fpr-names=ABI Print FPR names according to specified ABI.
Default: numeric.
cp0-names=ARCH Print CP0 register names according to specified architecture.
Default: based on binary being disassembled.
hwr-names=ARCH Print HWR names according to specified architecture.
Default: based on binary being disassembled.
reg-names=ABI Print GPR and FPR names according to specified ABI.
reg-names=ARCH Print CP0 register and HWR names according to specified
architecture.
For the options above, the following values are supported for "ABI":
numeric 32 n32 64
For the options above, the following values are supported for "ARCH":
numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600
r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000
r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64
mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e
loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp
(gdb)
which corresponds to what `objdump --help' used to print for the MIPS
target, with minor formatting changes, most notably option argument
lists being wrapped, but also the amount of white space separating
options from the respective descriptions. The relevant part the new
code is now also used by `objdump --help', which means these formatting
changes apply to both outputs, except for argument list wrapping, which
is GDB-specific.
This also adds a separating new line between the heading and option
lists where descriptions are provided, hence:
(gdb) set architecture s390:31-bit
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
esa Disassemble in ESA architecture mode
zarch Disassemble in z/Architecture mode
insnlength Print unknown instructions according to length from first two bits
(gdb)
but:
(gdb) set architecture powerpc:common
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl,
821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300,
e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5,
power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge,
ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe,
spe2, titan, vle, vsx
(gdb)
Existing affected target backends have been adjusted accordingly.
This has been verified manually with:
(gdb) set architecture arm
(gdb) set architecture powerpc:common
(gdb) set architecture s390:31-bit
to cause no issues with the `show disassembler-options' and `set
disassembler-options' commands. A test case for the MIPS target has
also been provided, covering the default settings with ABI overrides as
well as disassembler option overrides.
2018-07-02 Maciej W. Rozycki <macro@mips.com>
Simon Marchi <simon.marchi@polymtl.ca>
include/
PR tdep/8282
* dis-asm.h (disasm_option_arg_t): New typedef.
(disasm_options_and_args_t): Likewise.
(disasm_options_t): Add `arg' member, document members.
(disassembler_options_mips): New prototype.
(disassembler_options_arm, disassembler_options_powerpc)
(disassembler_options_s390): Update prototypes.
opcodes/
PR tdep/8282
* mips-dis.c (mips_option_arg_t): New enumeration.
(mips_options): New variable.
(disassembler_options_mips): New function.
(print_mips_disassembler_options): Reimplement in terms of
`disassembler_options_mips'.
* arm-dis.c (disassembler_options_arm): Adapt to using the
`disasm_options_and_args_t' structure.
* ppc-dis.c (disassembler_options_powerpc): Likewise.
* s390-dis.c (disassembler_options_s390): Likewise.
gdb/
PR tdep/8282
* disasm.h (gdb_disassembler): Add
`m_disassembler_options_holder'. member
* disasm.c (get_all_disassembler_options): New function.
(gdb_disassembler::gdb_disassembler): Use it.
(gdb_buffered_insn_length_init_dis): Likewise.
(gdb_buffered_insn_length): Adjust accordingly.
(set_disassembler_options): Handle options with arguments.
(show_disassembler_options_sfunc): Likewise. Add a leading new
line if showing options with descriptions.
(disassembler_options_completer): Adapt to using the
`disasm_options_and_args_t' structure.
* mips-tdep.c (mips_disassembler_options): New variable.
(mips_disassembler_options_o32): Likewise.
(mips_disassembler_options_n32): Likewise.
(mips_disassembler_options_n64): Likewise.
(gdb_print_insn_mips): Don't set `disassembler_options'.
(gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove
functions.
(mips_gdbarch_init): Always set `gdbarch_print_insn' to
`gdb_print_insn_mips'. Set `gdbarch_disassembler_options',
`gdbarch_disassembler_options_implicit' and
`gdbarch_valid_disassembler_options'.
* arm-tdep.c (_initialize_arm_tdep): Adapt to using the
`disasm_options_and_args_t' structure.
* gdbarch.sh (disassembler_options_implicit): New `gdbarch'
method.
(valid_disassembler_options): Switch from `disasm_options_t' to
the `disasm_options_and_args_t' structure.
* NEWS: Document `set disassembler-options' support for the MIPS
target.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
gdb/doc/
PR tdep/8282
* gdb.texinfo (Source and Machine Code): Document `set
disassembler-options' support for the MIPS target.
gdb/testsuite/
PR tdep/8282
* gdb.arch/mips-disassembler-options.exp: New test.
* gdb.arch/mips-disassembler-options.s: New test source.
2018-07-03 00:57:21 +02:00
v; const char *; disassembler_options_implicit; ; ; 0; 0; ; 0; pstring ( gdbarch->disassembler_options_implicit)
2017-05-02 19:30:07 +02:00
v; char **; disassembler_options; ; ; 0; 0; ; 0; pstring_ptr ( gdbarch->disassembler_options)
GDB PR tdep/8282: MIPS: Wire in `set disassembler-options'
Implement MIPS target support for passing options to the disassembler,
complementing commit 65b48a81404c ("GDB: Add support for the new
set/show disassembler-options commands.").
This includes options that expect an argument, so adjust the generic
code and data structures used so as to handle such options. So as to
give backends syntax flexibility no specific delimiter has been defined
to separate options from their respective arguments, so it has to be
included as the last character of the option name. Completion code
however has not been adjusted and consequently option arguments cannot
be completed at this time.
Also the MIPS target has non-empty defaults for the options, so that ABI
names for the general-purpose registers respect our `set mips abi ...'
setting rather than always being determined from the ELF headers of the
binary file selected. Handle these defaults as implicit options, never
shown to the user and always prepended to the user-specified options, so
that the latters can override the defaults.
The resulting output for the MIPS target is as follows:
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
no-aliases Use canonical instruction forms.
msa Recognize MSA instructions.
virt Recognize the virtualization ASE instructions.
xpa Recognize the eXtended Physical Address (XPA) ASE
instructions.
ginv Recognize the Global INValidate (GINV) ASE instructions.
gpr-names=ABI Print GPR names according to specified ABI.
Default: based on binary being disassembled.
fpr-names=ABI Print FPR names according to specified ABI.
Default: numeric.
cp0-names=ARCH Print CP0 register names according to specified architecture.
Default: based on binary being disassembled.
hwr-names=ARCH Print HWR names according to specified architecture.
Default: based on binary being disassembled.
reg-names=ABI Print GPR and FPR names according to specified ABI.
reg-names=ARCH Print CP0 register and HWR names according to specified
architecture.
For the options above, the following values are supported for "ABI":
numeric 32 n32 64
For the options above, the following values are supported for "ARCH":
numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600
r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000
r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64
mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e
loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp
(gdb)
which corresponds to what `objdump --help' used to print for the MIPS
target, with minor formatting changes, most notably option argument
lists being wrapped, but also the amount of white space separating
options from the respective descriptions. The relevant part the new
code is now also used by `objdump --help', which means these formatting
changes apply to both outputs, except for argument list wrapping, which
is GDB-specific.
This also adds a separating new line between the heading and option
lists where descriptions are provided, hence:
(gdb) set architecture s390:31-bit
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
esa Disassemble in ESA architecture mode
zarch Disassemble in z/Architecture mode
insnlength Print unknown instructions according to length from first two bits
(gdb)
but:
(gdb) set architecture powerpc:common
(gdb) show disassembler-options
The current disassembler options are ''
The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl,
821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300,
e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5,
power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge,
ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe,
spe2, titan, vle, vsx
(gdb)
Existing affected target backends have been adjusted accordingly.
This has been verified manually with:
(gdb) set architecture arm
(gdb) set architecture powerpc:common
(gdb) set architecture s390:31-bit
to cause no issues with the `show disassembler-options' and `set
disassembler-options' commands. A test case for the MIPS target has
also been provided, covering the default settings with ABI overrides as
well as disassembler option overrides.
2018-07-02 Maciej W. Rozycki <macro@mips.com>
Simon Marchi <simon.marchi@polymtl.ca>
include/
PR tdep/8282
* dis-asm.h (disasm_option_arg_t): New typedef.
(disasm_options_and_args_t): Likewise.
(disasm_options_t): Add `arg' member, document members.
(disassembler_options_mips): New prototype.
(disassembler_options_arm, disassembler_options_powerpc)
(disassembler_options_s390): Update prototypes.
opcodes/
PR tdep/8282
* mips-dis.c (mips_option_arg_t): New enumeration.
(mips_options): New variable.
(disassembler_options_mips): New function.
(print_mips_disassembler_options): Reimplement in terms of
`disassembler_options_mips'.
* arm-dis.c (disassembler_options_arm): Adapt to using the
`disasm_options_and_args_t' structure.
* ppc-dis.c (disassembler_options_powerpc): Likewise.
* s390-dis.c (disassembler_options_s390): Likewise.
gdb/
PR tdep/8282
* disasm.h (gdb_disassembler): Add
`m_disassembler_options_holder'. member
* disasm.c (get_all_disassembler_options): New function.
(gdb_disassembler::gdb_disassembler): Use it.
(gdb_buffered_insn_length_init_dis): Likewise.
(gdb_buffered_insn_length): Adjust accordingly.
(set_disassembler_options): Handle options with arguments.
(show_disassembler_options_sfunc): Likewise. Add a leading new
line if showing options with descriptions.
(disassembler_options_completer): Adapt to using the
`disasm_options_and_args_t' structure.
* mips-tdep.c (mips_disassembler_options): New variable.
(mips_disassembler_options_o32): Likewise.
(mips_disassembler_options_n32): Likewise.
(mips_disassembler_options_n64): Likewise.
(gdb_print_insn_mips): Don't set `disassembler_options'.
(gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove
functions.
(mips_gdbarch_init): Always set `gdbarch_print_insn' to
`gdb_print_insn_mips'. Set `gdbarch_disassembler_options',
`gdbarch_disassembler_options_implicit' and
`gdbarch_valid_disassembler_options'.
* arm-tdep.c (_initialize_arm_tdep): Adapt to using the
`disasm_options_and_args_t' structure.
* gdbarch.sh (disassembler_options_implicit): New `gdbarch'
method.
(valid_disassembler_options): Switch from `disasm_options_t' to
the `disasm_options_and_args_t' structure.
* NEWS: Document `set disassembler-options' support for the MIPS
target.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
gdb/doc/
PR tdep/8282
* gdb.texinfo (Source and Machine Code): Document `set
disassembler-options' support for the MIPS target.
gdb/testsuite/
PR tdep/8282
* gdb.arch/mips-disassembler-options.exp: New test.
* gdb.arch/mips-disassembler-options.s: New test source.
2018-07-03 00:57:21 +02:00
v; const disasm_options_and_args_t *; valid_disassembler_options; ; ; 0; 0; ; 0; host_address_to_string ( gdbarch->valid_disassembler_options)
2017-02-28 19:32:07 +01:00
gdb: Restructure type_align and gdbarch_type_align
This commit restructures the relationship between the type_align
function and the gdbarch_type_align method.
The problem being addressed with this commit is this; previously the
type_align function was structured so that for "basic" types (int,
float, etc) the gdbarch_type_align hook was called, which for
"compound" types (arrays, structs, etc) the common type_align code has
a fixed method for how to extract a "basic" type and would then call
itself on that "basic" type.
The problem is that if an architecture wants to modify the alignment
rules for a "compound" type then this is not currently possible.
In the revised structure, all types pass through the
gdbarch_type_align method. If this method returns 0 then this
indicates that the architecture has no special rules for this type,
and GDB should apply the default rules for alignment. However, the
architecture is free to provide an alignment for any type, both
"basic" and "compound".
After this commit the default alignment rules now all live in the
type_align function, the default_type_align only ever returns 0,
meaning apply the default rules.
I've updated the 3 targets (arc, i386, and nios2) that already
override the gdbarch_type_align method to fit the new scheme.
Tested on X86-64/GNU Linux with no regressions.
gdb/ChangeLog:
* arc-tdep.c (arc_type_align): Provide alignment for basic types,
return 0 for other types.
* arch-utils.c (default_type_align): Always return 0.
* gdbarch.h: Regenerate.
* gdbarch.sh (type_align): Extend comment.
* gdbtypes.c (type_align): Add additional comments, always call
gdbarch_type_align before applying the default rules.
* i386-tdep.c (i386_type_align): Return 0 as the default rule,
generic code will then apply a suitable default.
* nios2-tdep.c (nios2_type_align): Provide alignment for basic
types, return 0 for other types.
2019-02-22 21:49:04 +01:00
# Type alignment override method. Return the architecture specific
# alignment required for TYPE. If there is no special handling
# required for TYPE then return the value 0, GDB will then apply the
# default rules as laid out in gdbtypes.c:type_align.
Add initial type alignment support
This adds some basic type alignment support to gdb. It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment. It also adds a new gdbarch method and updates
i386-tdep.c.
None of this new functionality is used anywhere yet, so tests will
wait until the next patch.
2018-04-30 Tom Tromey <tom@tromey.com>
* i386-tdep.c (i386_type_align): New function.
(i386_gdbarch_init): Update.
* gdbarch.sh (type_align): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_type_align): Declare.
* arch-utils.c (default_type_align): New function.
* gdbtypes.h (TYPE_ALIGN_BITS): New define.
(struct type) <align_log2>: New field.
<instance_flags>: Now a bitfield.
(TYPE_RAW_ALIGN): New macro.
(type_align, type_raw_align, set_type_align): Declare.
* gdbtypes.c (type_align, type_raw_align, set_type_align): New
functions.
* dwarf2read.c (quirk_rust_enum): Set type alignment.
(get_alignment, maybe_set_alignment): New functions.
(read_structure_type, read_enumeration_type, read_array_type)
(read_set_type, read_tag_pointer_type, read_tag_reference_type)
(read_subrange_type, read_base_type): Set type alignment.
2018-04-20 19:50:09 +02:00
m; ULONGEST; type_align; struct type *type; type; ; default_type_align; ; 0
2019-08-16 11:19:18 +02:00
# Return a string containing any flags for the given PC in the given FRAME.
f; std::string; get_pc_address_flags; frame_info *frame, CORE_ADDR pc; frame, pc; ; default_get_pc_address_flags; ; 0
1999-08-31 03:14:27 +02:00
EOF
}
2000-05-30 03:29:26 +02:00
#
# The .log file
#
exec > new-gdbarch.log
2000-08-01 12:31:19 +02:00
function_list | while do_read
2000-05-30 03:29:26 +02:00
do
cat <<EOF
2004-08-08 22:50:57 +02:00
${ class } ${ returntype } ${ function } ( $formal )
1999-08-31 03:14:27 +02:00
EOF
2000-09-04 13:40:20 +02:00
for r in ${ read }
do
eval echo \" \ \ \ \ ${ r } = \$ { ${ r } } \"
done
2000-06-02 03:59:13 +02:00
if class_is_predicate_p && fallback_default_p
2000-05-30 03:29:26 +02:00
then
2004-06-20 21:17:17 +02:00
echo " Error: predicate function ${ function } can not have a non- multi-arch default " 1>& 2
2000-05-30 03:29:26 +02:00
kill $$
exit 1
fi
2001-06-07 22:52:47 +02:00
if [ " x ${ invalid_p } " = "x0" -a -n " ${ postdefault } " ]
2000-06-02 03:59:13 +02:00
then
echo "Error: postdefault is useless when invalid_p=0" 1>& 2
kill $$
exit 1
fi
2001-11-08 02:33:04 +01:00
if class_is_multiarch_p
then
if class_is_predicate_p ; then :
elif test " x ${ predefault } " = "x"
then
2004-08-08 22:50:57 +02:00
echo " Error: pure multi-arch function ${ function } must have a predefault " 1>& 2
2001-11-08 02:33:04 +01:00
kill $$
exit 1
fi
fi
2000-09-04 13:40:20 +02:00
echo ""
2000-05-30 03:29:26 +02:00
done
exec 1>& 2
compare_new gdbarch.log
1999-08-31 03:14:27 +02:00
copyright ( )
{
cat <<EOF
2012-07-27 22:23:05 +02:00
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */
/* vi:set ro: */
2000-03-30 07:32:23 +02:00
1999-08-31 03:14:27 +02:00
/* Dynamic architecture support for GDB, the GNU debugger.
2004-01-18 00:21:21 +01:00
2020-01-01 07:37:10 +01:00
Copyright ( C) 1998-2020 Free Software Foundation, Inc.
1999-08-31 03:14:27 +02:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
2007-08-23 20:19:51 +02:00
the Free Software Foundation; either version 3 of the License, or
1999-08-31 03:14:27 +02:00
( at your option) any later version.
2016-01-01 05:33:14 +01:00
1999-08-31 03:14:27 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2016-01-01 05:33:14 +01:00
1999-08-31 03:14:27 +02:00
You should have received a copy of the GNU General Public License
2007-08-23 20:19:51 +02:00
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1999-08-31 03:14:27 +02:00
/* This file was created with the aid of \` \` gdbarch.sh'' .
2000-08-25 22:51:19 +02:00
The Bourne shell script \` \` gdbarch.sh'' creates the files
1999-08-31 03:14:27 +02:00
\` \` new-gdbarch.c'' and \` \` new-gdbarch.h and then compares them
against the existing \` \` gdbarch.[ hc] '' . Any differences found
being reported.
If editing this file, please also run gdbarch.sh and merge any
2000-08-25 22:51:19 +02:00
changes into that script. Conversely, when making sweeping changes
1999-08-31 03:14:27 +02:00
to this file, modifying gdbarch.sh and using its output may prove
2011-01-07 20:36:19 +01:00
easier. */
1999-08-31 03:14:27 +02:00
EOF
}
#
# The .h file
#
exec > new-gdbarch.h
copyright
cat <<EOF
#ifndef GDBARCH_H
#define GDBARCH_H
2017-05-02 19:30:07 +02:00
#include <vector>
2014-08-13 20:15:00 +02:00
#include "frame.h"
2017-02-28 19:32:07 +01:00
#include "dis-asm.h"
Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:
foo *f = obstack_alloc (obstack, sizeof (foo));
f = new (f) foo;
It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap. This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:
foo *f = obstack_new<foo> (obstack);
Right now there's only one usage (in tdesc_data_init).
To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:
- OBSTACK_ZALLOC/OBSTACK_CALLOC
- XOBNEW/XOBNEW
- GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC
Unfortunately, there's no way to catch wrong usages of obstack_alloc.
By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC. The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD. Because it inherits from struct symbol, template_symbol is
not a POD. This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0. We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5. So here I considered
two alternatives:
1. Relax that criterion to use std::is_trivially_constructible and add a
bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
are allocated and initialized
I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused. When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.
gdb/ChangeLog:
* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
#include "gdb_obstack.h"
2020-02-14 22:45:40 +01:00
#include "infrun.h"
2020-03-16 21:56:34 +01:00
#include "osabi.h"
2014-08-13 20:15:00 +02:00
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-12 19:41:26 +02:00
struct floatformat;
struct ui_file;
1999-08-31 03:14:27 +02:00
struct value;
2001-12-07 13:10:15 +01:00
struct objfile;
2007-05-11 21:57:17 +02:00
struct obj_section;
2002-02-06 02:20:23 +01:00
struct minimal_symbol;
2002-07-03 23:27:55 +02:00
struct regcache;
2002-11-02 16:13:34 +01:00
struct reggroup;
2003-10-11 14:52:30 +02:00
struct regset;
2003-09-04 Andrew Cagney <cagney@redhat.com>
* avr-tdep.c: Include "dis-asm.h".
* cris-tdep.c: Include "dis-asm.h".
(cris_delayed_get_disassembler): Use "struct disassemble_info"
instead of corresponding typedef.
* h8300-tdep.c: Include "dis-asm.h".
* ia64-tdep.c: Include "dis-asm.h".
* i386-tdep.c: Include "dis-asm.h".
(i386_print_insn): Use "struct disassemble_info" instead of
corresponding typedef.
* m68k-tdep.c: Include "dis-asm.h".
* mcore-tdep.c: Include "dis-asm.h".
* mips-tdep.c: Include "dis-asm.h".
(gdb_print_insn_mips): Make static, use "struct disassemble_info"
instead of corresponding typedef.
* ns32k-tdep.c: Include "dis-asm.h".
* s390-tdep.c: Include "dis-asm.h".
* sparc-tdep.c: Include "dis-asm.h".
* vax-tdep.c: Include "dis-asm.h".
* v850-tdep.c: Include "dis-asm.h".
* mn10300-tdep.c: Include "dis-asm.h".
* rs6000-tdep.c: Include "dis-asm.h".
* xstormy16-tdep.c: Include "dis-asm.h".
(_initialize_xstormy16_tdep): Delete "extern" declaration of
print_insn_xstormy16.
* Makefile.in (v850-tdep.o): Update dependencies.
(vax-tdep.o, sparc-tdep.o, s390-tdep.o): Ditto.
(ns32k-tdep.o, mips-tdep.o, mcore-tdep.o): Ditto.
(m68k-tdep.o, ia64-tdep.o, i386-tdep.o): Ditto.
(h8300-tdep.o, cris-tdep.o, avr-tdep.o): Ditto.
(mn10300-tdep.o, xstormy16-tdep.o, disasm.o): Ditto.
(gdbarch_h): Remove $(dis_asm_h).
* disasm.c: Include "dis-asm.h".
(dis_asm_read_memory): Use "struct disassemble_info" instead of
corresponding typedef.
(dis_asm_memory_error, dump_insns, do_assembly_only): Ditto.
(gdb_disassemble_info, gdb_disassembly, gdb_print_insn): Ditto.
* gdbarch.sh: Do not include "dis-asm.h".
(struct disassemble_info): Declare opaque.
(TARGET_PRINT_INSN): Update declaration.
* gdbarch.h, gdbarch.c: Re-generate.
2003-09-09 06:41:32 +02:00
struct disassemble_info;
2003-10-23 01:54:11 +02:00
struct target_ops;
2004-03-15 21:38:08 +01:00
struct obstack;
gdb/
* breakpoint.c (deprecated_read_memory_nobpt): Update to use
shadow_len.
(insert_bp_location, reattach_breakpoints, remove_breakpoint)
(delete_breakpoint): Update calls to changed methods.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(single_step_breakpoints, insert_single_step_breakpoint)
(remove_single_step_breakpoints): New.
* breakpoint.h (struct bp_target_info): New.
(struct bp_location): Replace shadow_contents with
target_info and overlay_target_info.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(insert_single_step_breakpoint, remove_single_step_breakpoints): New
prototypes.
* gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h.
(memory_insert_breakpoint, memory_remove_breakpoint): Update second
argument.
* mem-break.c (default_memory_insert_breakpoint): Update. Set
placed_address, placed_size, and shadow_len.
(default_memory_remove_breakpoint): Update. Don't use
BREAKPOINT_FROM_PC.
(memory_insert_breakpoint, memory_remove_breakpoint): Update.
* target.c (update_current_target): Update prototypes for changed
functions.
(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint):
Update.
* target.h: Forward declare struct bp_target_info.
(struct target_ops): Use a bp_target_info argument for
to_insert_breakpoint, to_remove_breakpoint,
to_insert_hw_breakpoint, and to_remove_hw_breakpoint.
(target_insert_breakpoint, target_remove_breakpoint)
(target_insert_hw_breakpoint, target_remove_hw_breakpoint)
(memory_insert_breakpoint, memory_remove_breakpoint)
(default_memory_insert_breakpoint, default_memory_remove_breakpoint):
Update.
* config/i386/nm-i386.h: Forward declare struct bp_target_info.
(i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update.
(target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* alpha-tdep.c (alpha_software_single_step): Use
insert_single_step_breakpoint and remove_single_step_breakpoints.
Remove unused statics.
* arm-tdep.c (arm_software_single_step): Likewise. Add a note.
* cris-tdep.c (cris_software_single_step): Likewise.
* mips-tdep.c (mips_software_single_step): Likewise.
* rs6000-tdep.c (rs6000_software_single_step): Likewise.
* sparc-tdep.c (sparc_software_single_step): Likewise.
* wince.c (struct thread_info_struct): Remove step_prev.
(undoSStep): Use remove_single_step_breakpoints.
(wince_software_single_step): Use insert_single_step_breakpoint.
* corelow.c (ignore): Remove unneeded prototype. Update arguments.
* exec.c (ignore): Likewise.
* sol-thread.c (ignore): Likewise.
* procfs.c (dbx_link_shadow_contents): Delete.
(dbx_link_bpt): New.
(procfs_mourn_inferior): Remove it if necessary.
(remove_dbx_link_breakpoint): Use it.
(insert_dbx_link_bpt_in_file): Set it.
(procfs_init_inferior): Don't update dbx_link_bpt_addr.
* rs6000-nat.c (exec_one_dummy_insn): Use
deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* solib-irix.c (shadow_contents, breakpoint_addr): Delete.
(base_breakpoint): New.
(disable_break): Use it.
(enable_break): Set it.
* i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint):
Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint)
(ia64_memory_remove_breakpoint): Likewise.
* m32r-tdep.c (m32r_memory_insert_breakpoint)
(m32r_memory_remove_breakpoint): Likewise.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Likewise. Remove unnecessary prototypes. Use placed_address
and placed_size. Removed useless read from memory.
* nto-procfs.c (procfs_insert_breakpoint)
(procfs_remove_breakpoint, procfs_insert_hw_breakpoint)
(procfs_remove_hw_breakpoint): Update.
* ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
* remote-e7000.c (e7000_insert_breakpoint)
(e7000_remove_breakpoint): Likewise.
* remote-m32r-sdi.c (m32r_insert_breakpoint)
(m32r_remove_breakpoint): Likewise.
* remote-mips.c (mips_insert_breakpoint)
(mips_remove_breakpoint): Likewise.
* remote-rdp.c (remote_rdp_insert_breakpoint)
(remote_rdp_remove_breakpoint): Likewise.
(rdp_step): Use deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint):
Update.
* remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint):
Delete.
(init_gdbsim_ops): Use memory_insert_breakpoint and
memory_remove_breakpoint.
* remote-st.c (st2000_insert_breakpoint)
(st2000_remove_breakpoint): Update. Remove unused
BREAKPOINT_FROM_PC.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
Update. Use placed_address and placed_size.
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.
gdb/doc/
* gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
(Watchpoints): Move description of target_insert_hw_breakpoint and
target_remove_hw_breakpoint ...
(Breakpoints): ... to here. Document target_insert_breakpoint and
target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
struct bp_target_info;
2006-11-28 23:10:26 +01:00
struct target_desc;
MIPS: Keep the ISA bit in compressed code addresses
1. Background information
The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned. As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception. This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.
Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI). The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.
As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2. That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.
So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit. Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.
To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution. They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.
This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.
A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture. Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes. The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.
2. Statement of the problem
To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time. This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged. Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.
A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected. This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.
While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle. This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).
This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.
This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:
(short *) main
will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.
This is probably best illustrated with a simple real program example.
Let's consider the following simple program:
$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
return 1;
}
int __attribute__ ((mips16)) bar (void)
{
return 2;
}
int __attribute__ ((nomips16)) foo32 (void)
{
return 3;
}
int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;
int
main (void)
{
return foop ();
}
$
This is plain C with no odd tricks, except from the instruction mode
attributes. They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.
Let's try it with Linux, so that everyone can repeat this experiment:
$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$
Let's have a look at some interesting symbols:
$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar
68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p
70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop
78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32
80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo
88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi
$
Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).
So let's try to run and poke at this program with GDB. I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):
$ ./foobar
$ echo $?
1
$
So far, so good.
$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Yay, it worked! OK, so let's poke at it:
(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)
A-ha! Here's the difference and finally the ISA bit!
(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)
And here as well...
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
main () at foobar.c:24
24 }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)
So let's be a bit inquisitive...
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb)
Actually we do not like to run foo here at all. Let's run bar instead!
(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)
Hmm, no ISA bit. Is it going to work?
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>: jr ra
0x0040068e <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9 }
(gdb)
Oops!
(gdb) p/x $pc
$12 = 0x40068c
(gdb)
We're still there!
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
So let's try something else:
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4 }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>: jr ra
0x00400682 <+2>: li v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0 foo () at foobar.c:4
Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4 }
(gdb) continue
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)
The same problem!
(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14 }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>: jr ra
0x00400688 <+4>: li v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0 foo32 () at foobar.c:14
main () at foobar.c:24
24 }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)
That did work though, so it's the ISA bit only!
(gdb) quit
Enough!
That's the tip of the iceberg only though. So let's rebuild the
executable with some dynamic symbols:
$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
Symbol table '.symtab' contains 95 entries:
55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c
69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar
71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p
72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop
79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32
81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo
89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi
$
OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm... What does `objdump' do then:
$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn: file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l df *ABS* 00000000 foobar.c
004009cc g F .text 00000004 0xf0 bar
00410b88 g O .data 00000004 foo32p
00410b84 g O .data 00000004 foop
004009c4 g F .text 00000008 foo32
004009c0 g F .text 00000004 0xf0 foo
00410b80 g O .data 00000004 fooi
DYNAMIC SYMBOL TABLE:
004009cc g DF .text 00000004 Base 0xf0 bar
00410b88 g DO .data 00000004 Base foo32p
00410b84 g DO .data 00000004 Base foop
004009c4 g DF .text 00000008 Base foo32
004009c0 g DF .text 00000004 Base 0xf0 foo
00410b80 g DO .data 00000004 Base fooi
$
Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.
Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:
$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
Compilation Unit @ offset 0x88:
Length: 0xbb (32-bit)
Version: 4
Abbrev Offset: 62
Pointer Size: 4
<0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
<94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
<98> DW_AT_language : 1 (ANSI C)
<99> DW_AT_name : (indirect string, offset: 0x190): foobar.c
<9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...]
<a1> DW_AT_ranges : 0x0
<a5> DW_AT_low_pc : 0x0
<a9> DW_AT_stmt_list : 0x27
<1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
<ae> DW_AT_external : 1
<ae> DW_AT_name : foo
<b2> DW_AT_decl_file : 1
<b3> DW_AT_decl_line : 1
<b4> DW_AT_prototyped : 1
<b4> DW_AT_type : <0xc2>
<b8> DW_AT_low_pc : 0x400680
<bc> DW_AT_high_pc : 0x400684
<c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<c2> DW_AT_GNU_all_call_sites: 1
<1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
<c3> DW_AT_byte_size : 4
<c4> DW_AT_encoding : 5 (signed)
<c5> DW_AT_name : int
<1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
<ca> DW_AT_external : 1
<ca> DW_AT_name : (indirect string, offset: 0x18a): foo32
<ce> DW_AT_decl_file : 1
<cf> DW_AT_decl_line : 11
<d0> DW_AT_prototyped : 1
<d0> DW_AT_type : <0xc2>
<d4> DW_AT_low_pc : 0x400684
<d8> DW_AT_high_pc : 0x40068c
<dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<de> DW_AT_GNU_all_call_sites: 1
<1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
<df> DW_AT_external : 1
<df> DW_AT_name : bar
<e3> DW_AT_decl_file : 1
<e4> DW_AT_decl_line : 6
<e5> DW_AT_prototyped : 1
<e5> DW_AT_type : <0xc2>
<e9> DW_AT_low_pc : 0x40068c
<ed> DW_AT_high_pc : 0x400690
<f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<f3> DW_AT_GNU_all_call_sites: 1
<1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
<f4> DW_AT_external : 1
<f4> DW_AT_name : (indirect string, offset: 0x199): main
<f8> DW_AT_decl_file : 1
<f9> DW_AT_decl_line : 21
<fa> DW_AT_prototyped : 1
<fa> DW_AT_type : <0xc2>
<fe> DW_AT_low_pc : 0x400490
<102> DW_AT_high_pc : 0x4004a4
<106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<108> DW_AT_GNU_all_tail_call_sites: 1
[...]
$
-- no sign of the ISA bit anywhere -- frame info:
$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:
00000000 0000000c ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -4
Return address column: 31
DW_CFA_def_cfa_register: r29
DW_CFA_nop
00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684
00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c
00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690
00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
DW_CFA_advance_loc: 6 to 00400496
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r31 at cfa-4
DW_CFA_advance_loc: 6 to 0040049c
DW_CFA_restore: r31
DW_CFA_def_cfa_offset: 0
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
[...]
$
-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):
$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:
Offset Begin End
00000000 00400680 00400690
00000000 00400490 004004a4
00000000 <End of list>
$
-- no sign of the ISA bit anywhere -- line info:
$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
Offset: 0x27
Length: 78
DWARF Version: 2
Prologue Length: 31
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table is empty.
The File Name Table:
Entry Dir Time Size Name
1 0 0 0 foobar.c
Line Number Statements:
Extended opcode 2: set Address to 0x400681
Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
Advance Line by -7 to 7
Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
Advance PC by 3 to 0x400690
Extended opcode 1: End of Sequence
Extended opcode 2: set Address to 0x400491
Advance Line by 21 to 22
Copy
Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
Advance PC by 7 to 0x4004a4
Extended opcode 1: End of Sequence
[...]
-- a-ha, the ISA bit is there! However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:
00019630 <__libc_init_first>:
19630: e8a0 jrc ra
19632: 6500 nop
00019634 <_init>:
19634: f000 6a11 li v0,17
19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54>
1963c: f400 3240 sll v0,16
19640: e269 addu v0,v1
19642: 659a move gp,v0
19644: 64f6 save 48,ra,s0-s1
19646: 671c move s0,gp
19648: d204 sw v0,16(sp)
1964a: f352 984c lw v0,-27828(s0)
1964e: 6724 move s1,a0
and the corresponding DWARF-2 line info:
Line Number Statements:
Extended opcode 2: set Address to 0x19631
Advance Line by 44 to 45
Copy
Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
Advance PC by constant 17 to 0x19646
Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
Advance Line by -6 to 53
Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53
-- see that "Advance PC by constant 17" there? It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all. For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?
3. Solution:
I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.
In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.
All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down. This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.
Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places. Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.
I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB. I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.
Here's the resulting change. It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed. The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.
With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).
4. Results obtained
The change fixes the example above -- to repeat only the crucial steps:
(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar
Breakpoint 1, main () at foobar.c:23
23 return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9 }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>: jr ra
0x0040068f <+2>: li v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0 bar () at foobar.c:9
main () at foobar.c:24
24 }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)
-- excellent!
The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:
=== gdb Summary ===
# of expected passes 14299
# of unexpected failures 187
# of expected failures 56
# of known failures 58
# of unresolved testcases 11
# of untested testcases 52
# of unsupported tests 174
MIPS16:
=== gdb Summary ===
# of expected passes 14298
# of unexpected failures 187
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 12
# of untested testcases 52
# of unsupported tests 174
microMIPS:
=== gdb Summary ===
# of expected passes 14149
# of unexpected failures 201
# of unexpected successes 2
# of expected failures 54
# of known failures 58
# of unresolved testcases 7
# of untested testcases 53
# of unsupported tests 175
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
Maciej W. Rozycki <macro@mips.com>
Pedro Alves <pedro@codesourcery.com>
gdb/
* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
remove `predefault' and `invalid_p' initializers.
(make_symbol_special): New architecture method.
(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
(objfile, symbol): New declarations.
* arch-utils.h (default_elf_make_msymbol_special): Remove
prototype.
(default_make_symbol_special): New prototype.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* mips-tdep.h (mips_unmake_compact_addr): New prototype.
* arch-utils.c (default_elf_make_msymbol_special): Remove
function.
(default_make_symbol_special): New function.
(default_adjust_dwarf2_addr): Likewise.
(default_adjust_dwarf2_line): Likewise.
* dwarf2-frame.c (decode_frame_entry_1): Call
`gdbarch_adjust_dwarf2_addr'.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
* dwarf2read.c (create_addrmap_from_index): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(process_full_comp_unit): Likewise.
(read_file_scope): Likewise.
(read_func_scope): Likewise. Call `gdbarch_make_symbol_special'.
(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
(read_call_site_scope): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(read_attribute_value): Likewise.
(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
* elfread.c (elf_symtab_read): Don't call
`gdbarch_elf_make_msymbol_special' if unset.
* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
the ISA bit from the PC.
* mips-tdep.c (mips_unmake_compact_addr): New function.
(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
address appropriately.
(mips_make_symbol_special): New function.
(mips_pc_is_mips): Set the ISA bit before symbol lookup.
(mips_pc_is_mips16): Likewise.
(mips_pc_is_micromips): Likewise.
(mips_pc_isa): Likewise.
(mips_adjust_dwarf2_addr): New function.
(mips_adjust_dwarf2_line): Likewise.
(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
(mips_addr_bits_remove): Likewise.
(mips_skip_trampoline_code): Likewise.
(mips_write_pc): Don't set the ISA bit.
(mips_eabi_push_dummy_call): Likewise.
(mips_o64_push_dummy_call): Likewise.
(mips_gdbarch_init): Install `mips_make_symbol_special',
`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
handlers.
* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
target-specific symbol address adjustments.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
2014-12-12 Maciej W. Rozycki <macro@codesourcery.com>
gdb/testsuite/
* gdb.base/func-ptrs.c: New file.
* gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
struct symbol;
2009-09-15 05:30:08 +02:00
struct syscall;
2010-12-28 17:00:13 +01:00
struct agent_expr;
2011-09-27 15:09:37 +02:00
struct axs_value;
2012-04-27 22:47:57 +02:00
struct stap_parse_info;
Make base class for parser_state
This makes a new base class, expr_builder, for parser_state. This
separates the state needed to construct an expression from the state
needed by the parsers.
gdb/ChangeLog
2019-04-04 Tom Tromey <tom@tromey.com>
* gdbarch.h, gdbarch.c: Rebuild.
* gdbarch.sh (dtrace_parse_probe_argument): Change type.
* stap-probe.h:
(struct stap_parse_info): Replace "parser_state" with
"expr_builder".
* parser-defs.h (struct expr_builder): Rename from "parser_state".
(parser_state): New class.
* parse.c (expr_builder): Rename.
(expr_builder::release): Rename.
(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
(write_exp_elt_longcst, write_exp_elt_floatcst)
(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
(write_exp_string_vector, write_exp_bitstring)
(write_exp_msymbol, mark_struct_expression)
(write_dollar_variable)
(insert_type_address_space, increase_expout_size): Replace
"parser_state" with "expr_builder".
* dtrace-probe.c: Replace "parser_state" with "expr_builder".
* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace
"parser_state" with "expr_builder".
2019-03-24 17:28:42 +01:00
struct expr_builder;
2012-12-15 15:27:56 +01:00
struct ravenscar_arch_ops;
2014-10-10 16:57:13 +02:00
struct mem_range;
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
This patch intends to partially fix PR breakpoints/10737, which is
about making the syscall information (for the "catch syscall" command)
be per-arch, instead of global. This is not a full fix because of the
other issues pointed by Pedro here:
<https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5>
However, I consider it a good step towards the real fix. It will also
help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>.
What this patch does, basically, is move the "syscalls_info"
struct to gdbarch. Currently, the syscall information is stored in a
global variable inside gdb/xml-syscall.c, which means that there is no
easy way to correlate this info with the current target or
architecture being used, for example. This causes strange behaviors,
because the syscall info is not re-read when the arch changes. For
example, if you put a syscall catchpoint in syscall 5 on i386 (syscall
open), and then load a x86_64 program on GDB and put the same syscall
5 there (fstat on x86_64), you will still see that GDB tells you that
it is catching "open", even though it is not. With this patch, GDB
correctly says that it will be catching fstat syscalls.
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'open' [5])
But with the patch:
(gdb) set architecture i386
The target architecture is assumed to be i386
(gdb) catch syscall 5
Catchpoint 1 (syscall 'open' [5])
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) catch syscall 5
Catchpoint 2 (syscall 'fstat' [5])
As I said, there are still some problems on the "catch syscall"
mechanism, because (for example) the user should be able to "catch
syscall open" on i386, and then expect "open" to be caught also on
x86_64. Currently, it doesn't work. I intend to work on this later.
gdb/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* bfin-linux-tdep.c (bfin_linux_init_abi): Likewise.
* breakpoint.c (print_it_catch_syscall): Adjust call to
get_syscall_by_number to provide gdbarch.
(print_one_catch_syscall): Likewise.
(print_mention_catch_syscall): Likewise.
(print_recreate_catch_syscall): Likewise.
(catch_syscall_split_args): Adjust calls to get_syscall_by_number
and get_syscall_by_name to provide gdbarch.
(catch_syscall_completer): Adjust call to get_syscall_names to
provide gdbarch.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* gdbarch.sh: Forward declare "struct syscalls_info".
(xml_syscall_file): New variable.
(syscalls_info): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise.
* xml-syscall.c: Include gdbarch.h.
(set_xml_syscall_file_name): Accept gdbarch parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
(my_gdb_datadir): Delete global variable.
(struct syscalls_info) <my_gdb_datadir>: New variable.
(struct syscalls_info) <sysinfo>: Rename variable to
"syscalls_info".
(sysinfo): Delete global variable.
(have_initialized_sysinfo): Likewise.
(xml_syscall_file): Likewise.
(sysinfo_free_syscalls_desc): Rename to...
(syscalls_info_free_syscalls_desc): ... this.
(free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust
code to the new layout of "struct syscalls_info".
(make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to
"syscalls_info".
(syscall_create_syscall_desc): Likewise.
(syscall_start_syscall): Likewise.
(syscall_parse_xml): Likewise.
(xml_init_syscalls_info): Likewise. Drop "const" from return value.
(init_sysinfo): Rename to...
(init_syscalls_info): ...this. Add gdbarch as a parameter.
Adjust function to deal with gdbarch.
(xml_get_syscall_number): Delete parameter sysinfo. Accept
gdbarch as a parameter. Adjust code.
(xml_get_syscall_name): Likewise.
(xml_list_of_syscalls): Likewise.
(set_xml_syscall_file_name): Accept gdbarch as parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
* xml-syscall.h (set_xml_syscall_file_name): Likewise.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
gdb/testsuite/
2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
struct syscalls_info;
2016-01-18 18:49:23 +01:00
struct thread_info;
Intel MPX bound violation handling
With Intel Memory Protection Extensions it was introduced the concept of
boundary violation. A boundary violations is presented to the inferior as
a segmentation fault having SIGCODE 3. This patch adds a
handler for a boundary violation extending the information displayed
when a bound violation is presented to the inferior. In the stop mode
case the debugger will also display the kind of violation: "upper" or
"lower", bounds and the address accessed.
On no stop mode the information will still remain unchanged. Additional
information about bound violations are not meaningful in that case user
does not know the line in which violation occurred as well.
When the segmentation fault handler is stop mode the out puts will be
changed as exemplified below.
The usual output of a segfault is:
Program received signal SIGSEGV, Segmentation fault
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In case it is a bound violation it will be presented as:
Program received signal SIGSEGV, Segmentation fault
Upper bound violation while accessing address 0x7fffffffc3b3
Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In mi mode the output of a segfault is:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c",
func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"}
,{name="b",value="0x603050"}, {name="c",value="0x603070"},
{name="d",value="0x603090"},{name="len",value="7"}],
file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"},
thread-id="1",stopped-threads="all",core="6"
in the case of a bound violation:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault",
sigcode-meaning="Upper bound violation",
lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f",
frame={addr="0x0000000000400d7c",func="upper",args=[{name="p",
value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"},
{name="c",value="0x603070"},{name="d",value="0x603090"},
{name="len",value="7"}],file="i386-mpx-sigsegv.c",
fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1",
stopped-threads="all",core="6"
2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* NEWS: Add entry for bound violation.
* amd64-linux-tdep.c (amd64_linux_init_abi_common):
Add handler for segmentation fault.
* gdbarch.sh (handle_segmentation_fault): New.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New.
(SIG_CODE_BONDARY_FAULT): New define.
(i386_linux_init_abi): Use i386_mpx_bound_violation_handler.
* i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* infrun.c (handle_segmentation_fault): New function.
(print_signal_received_reason): Use handle_segmentation_fault.
gdb/testsuite/ChangeLog:
* gdb.arch/i386-mpx-sigsegv.c: New file.
* gdb.arch/i386-mpx-sigsegv.exp: New file.
* gdb.arch/i386-mpx-simple_segv.c: New file.
* gdb.arch/i386-mpx-simple_segv.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Signals): Add bound violation display hints for
a SIGSEGV.
2016-02-18 17:24:59 +01:00
struct ui_out;
1999-08-31 03:14:27 +02:00
2014-10-22 13:16:56 +02:00
#include "regcache.h"
2012-11-09 02:47:20 +01:00
/* The architecture associated with the inferior through the
connection to the target.
The architecture vector provides some information that is really a
property of the inferior, accessed through a particular target:
ptrace operations; the layout of certain RSP packets; the solib_ops
vector; etc. To differentiate architecture accesses to
per-inferior/target properties from
per-thread/per-frame/per-objfile properties, accesses to
per-inferior/target properties should be made through this
gdbarch. */
/* This is a convenience wrapper for 'current_inferior ()->gdbarch' . */
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 20:58:03 +01:00
extern struct gdbarch *target_gdbarch ( void) ;
2012-11-09 02:47:20 +01:00
2012-06-05 15:50:50 +02:00
/* Callback type for the 'iterate_over_objfiles_in_search_order'
gdbarch method. */
typedef int ( iterate_over_objfiles_in_search_order_cb_ftype)
( struct objfile *objfile, void *cb_data) ;
Replace 'core_regset_sections' by iterator method
The core_regset_sections list in gdbarch (needed for multi-arch
capable core file generation support) is replaced by an iterator
method. Overall, this reduces the code a bit, and it allows for more
flexibility.
gdb/ChangeLog:
* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
(amd64_linux_iterate_over_regset_sections): New.
(amd64_linux_init_abi_common): Don't install the regset section
list, but the new iterator in gdbarch.
* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
(arm_linux_vfp_regset_sections): Remove. Move combined logic...
(arm_linux_iterate_over_regset_sections): ...here. New function.
(arm_linux_init_abi): Set iterator instead of section list.
* corelow.c (get_core_registers_cb): New function, logic moved
from...
(get_core_registers): ...loop body here. Use new iterator method
instead of walking through the regset section list.
* gdbarch.sh: Remove 'core_regset_sections'. New method
'iterate_over_regset_sections'. New typedef
'iterate_over_regset_sections_cb'.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* i386-linux-tdep.c (i386_linux_regset_sections)
(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
Remove.
(i386_linux_iterate_over_regset_sections): New.
(i386_linux_init_abi): Don't choose a regset section list, but
install new iterator in gdbarch.
* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
(linux_collect_regset_section_cb): New function, logic moved
from...
(linux_collect_thread_registers): ...loop body here. Use iterator
method instead of walking through list.
(linux_make_corefile_notes_1): Check for presence of iterator
method instead of regset section list.
* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
(ppc64_linux_fp_regset_sections): Remove. Move combined logic...
(ppc_linux_iterate_over_regset_sections): ...here. New function.
(ppc_linux_init_abi): Don't choose from above regset section
lists, but install new iterator in gdbarch.
* regset.h (struct core_regset_section): Remove.
* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
have_linux_v1, have_linux_v2, and have_tdb.
(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
(s390x_linux64v2_regset_sections): Remove. Move combined logic...
(s390_iterate_over_regset_sections): ...here. New function. Use
new tdep fields.
(s390_gdbarch_init): Set new tdep fields. Don't choose from above
regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
2015-01-14 13:01:38 +01:00
/* Callback type for regset section iterators. The callback usually
invokes the REGSET' s supply or collect method, to which it must
2018-08-13 11:04:11 +02:00
pass a buffer - for collects this buffer will need to be created using
COLLECT_SIZE, for supply the existing buffer being read from should
be at least SUPPLY_SIZE. SECT_NAME is a BFD section name, and HUMAN_NAME
is used for diagnostic messages. CB_DATA should have been passed
unchanged through the iterator. */
2015-01-14 13:01:38 +01:00
Replace 'core_regset_sections' by iterator method
The core_regset_sections list in gdbarch (needed for multi-arch
capable core file generation support) is replaced by an iterator
method. Overall, this reduces the code a bit, and it allows for more
flexibility.
gdb/ChangeLog:
* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
(amd64_linux_iterate_over_regset_sections): New.
(amd64_linux_init_abi_common): Don't install the regset section
list, but the new iterator in gdbarch.
* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
(arm_linux_vfp_regset_sections): Remove. Move combined logic...
(arm_linux_iterate_over_regset_sections): ...here. New function.
(arm_linux_init_abi): Set iterator instead of section list.
* corelow.c (get_core_registers_cb): New function, logic moved
from...
(get_core_registers): ...loop body here. Use new iterator method
instead of walking through the regset section list.
* gdbarch.sh: Remove 'core_regset_sections'. New method
'iterate_over_regset_sections'. New typedef
'iterate_over_regset_sections_cb'.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* i386-linux-tdep.c (i386_linux_regset_sections)
(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
Remove.
(i386_linux_iterate_over_regset_sections): New.
(i386_linux_init_abi): Don't choose a regset section list, but
install new iterator in gdbarch.
* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
(linux_collect_regset_section_cb): New function, logic moved
from...
(linux_collect_thread_registers): ...loop body here. Use iterator
method instead of walking through list.
(linux_make_corefile_notes_1): Check for presence of iterator
method instead of regset section list.
* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
(ppc64_linux_fp_regset_sections): Remove. Move combined logic...
(ppc_linux_iterate_over_regset_sections): ...here. New function.
(ppc_linux_init_abi): Don't choose from above regset section
lists, but install new iterator in gdbarch.
* regset.h (struct core_regset_section): Remove.
* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
have_linux_v1, have_linux_v2, and have_tdb.
(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
(s390x_linux64v2_regset_sections): Remove. Move combined logic...
(s390_iterate_over_regset_sections): ...here. New function. Use
new tdep fields.
(s390_gdbarch_init): Set new tdep fields. Don't choose from above
regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
typedef void ( iterate_over_regset_sections_cb)
2018-08-13 11:04:11 +02:00
( const char *sect_name, int supply_size, int collect_size,
const struct regset *regset, const char *human_name, void *cb_data) ;
2018-11-16 12:21:00 +01:00
/* For a function call, does the function return a value using a
normal value return or a structure return - passing a hidden
argument pointing to storage. For the latter, there are two
cases: language-mandated structure return and target ABI
structure return . */
enum function_call_return_method
{
/* Standard value return . */
return_method_normal = 0,
/* Language ABI structure return . This is handled
by passing the return location as the first parameter to
the function , even preceding "this" . */
return_method_hidden_param,
/* Target ABI struct return . This is target-specific; for instance,
on ia64 the first argument is passed in out0 but the hidden
structure return pointer would normally be passed in r8. */
return_method_struct,
} ;
1999-08-31 03:14:27 +02:00
EOF
# function typedef's
2000-09-04 13:40:20 +02:00
printf "\n"
printf "\n"
2011-01-07 20:36:19 +01:00
printf "/* The following are pre-initialized by GDBARCH. */\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_info_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf " extern ${ returntype } gdbarch_ ${ function } (struct gdbarch *gdbarch);\n "
2011-01-07 20:36:19 +01:00
printf " /* set_gdbarch_ ${ function } () - not applicable - pre-initialized. */\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
# function typedef's
2000-09-04 13:40:20 +02:00
printf "\n"
printf "\n"
2011-01-07 20:36:19 +01:00
printf "/* The following are initialized by the target dependent code. */\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2001-06-07 22:52:47 +02:00
if [ -n " ${ comment } " ]
2000-08-01 12:31:19 +02:00
then
echo " ${ comment } " | sed \
-e '2 s,#,/*,' \
-e '3,$ s,#, ,' \
-e '$ s,$, */,'
fi
2004-06-21 Andrew Cagney <cagney@gnu.org>
* gdbarch.sh: When the macro field is empty, do not generate a
macro definition. When the macro field is "=", generate the macro
name from the upper-case function name.
(NUM_REGS, NUM_PSEUDO_REGS, SP_REGNUM, PC_REGNUM, PS_REGNUM)
(FP0_REGNUM, STAB_REG_TO_REGNUM, ECOFF_REG_TO_REGNUM)
(DWARF_REG_TO_REGNUM, SDB_REG_TO_REGNUM, DWARF2_REG_TO_REGNUM)
(REGISTER_NAME, DEPRECATED_REGISTER_VIRTUAL_TYPE)
(DEPRECATED_REGISTER_BYTES, DEPRECATED_REGISTER_BYTE)
(DEPRECATED_REGISTER_RAW_SIZE, DEPRECATED_REGISTER_VIRTUAL_SIZE)
(DEPRECATED_SAVE_DUMMY_FRAME_TOS, DEPRECATED_FP_REGNUM)
(DEPRECATED_TARGET_READ_FP, DEPRECATED_PUSH_ARGUMENTS)
(DEPRECATED_PUSH_RETURN_ADDRESS, DEPRECATED_DUMMY_WRITE_SP)
(DEPRECATED_REGISTER_SIZE, CALL_DUMMY_LOCATION)
(DEPRECATED_DO_REGISTERS_INFO, REGISTER_SIM_REGNO)
(REGISTER_BYTES_OK, CANNOT_FETCH_REGISTER, CANNOT_STORE_REGISTER)
(GET_LONGJMP_TARGET, DEPRECATED_INIT_FRAME_PC)
(BELIEVE_PCC_PROMOTION, DEPRECATED_GET_SAVED_REGISTER)
(CONVERT_REGISTER_P, REGISTER_TO_VALUE, VALUE_TO_REGISTER)
(POINTER_TO_ADDRESS, ADDRESS_TO_POINTER, INTEGER_TO_ADDRESS)
(DEPRECATED_POP_FRAME, DEPRECATED_STORE_STRUCT_RETURN)
(EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE)
(DEPRECATED_EXTRACT_RETURN_VALUE, DEPRECATED_STORE_RETURN_VALUE)
(DEPRECATED_USE_STRUCT_CONVENTION)
(DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS)
(DEPRECATED_FRAME_INIT_SAVED_REGS)
(DEPRECATED_INIT_EXTRA_FRAME_INFO, SKIP_PROLOGUE, INNER_THAN)
(BREAKPOINT_FROM_PC, MEMORY_INSERT_BREAKPOINT)
(MEMORY_REMOVE_BREAKPOINT, DECR_PC_AFTER_BREAK)
(DEPRECATED_FUNCTION_START_OFFSET, FRAME_ARGS_SKIP)
(DEPRECATED_FRAMELESS_FUNCTION_INVOCATION, DEPRECATED_FRAME_CHAIN)
(DEPRECATED_FRAME_CHAIN_VALID, DEPRECATED_FRAME_SAVED_PC)
(DEPRECATED_FRAME_ARGS_ADDRESS, DEPRECATED_FRAME_LOCALS_ADDRESS)
(DEPRECATED_SAVED_PC_AFTER_CALL, FRAME_NUM_ARGS)
(DEPRECATED_STACK_ALIGN, DEPRECATED_REG_STRUCT_HAS_ADDR)
(FRAME_RED_ZONE_SIZE, ADDR_BITS_REMOVE, SMASH_TEXT_ADDRESS)
(SOFTWARE_SINGLE_STEP, SKIP_TRAMPOLINE_CODE)
(IN_SOLIB_CALL_TRAMPOLINE, IN_SOLIB_RETURN_TRAMPOLINE)
(ELF_MAKE_MSYMBOL_SPECIAL, COFF_MAKE_MSYMBOL_SPECIAL)
(NAME_OF_MALLOC, CANNOT_STEP_BREAKPOINT)
(HAVE_NONSTEPPABLE_WATCHPOINT, ADDRESS_CLASS_TYPE_FLAGS)
(FETCH_POINTER_ARGUMENT): Replace the macro name with "=".
2004-06-21 21:54:50 +02:00
if class_is_predicate_p
2000-04-21 06:17:18 +02:00
then
2004-06-21 Andrew Cagney <cagney@gnu.org>
* gdbarch.sh: When the macro field is empty, do not generate a
macro definition. When the macro field is "=", generate the macro
name from the upper-case function name.
(NUM_REGS, NUM_PSEUDO_REGS, SP_REGNUM, PC_REGNUM, PS_REGNUM)
(FP0_REGNUM, STAB_REG_TO_REGNUM, ECOFF_REG_TO_REGNUM)
(DWARF_REG_TO_REGNUM, SDB_REG_TO_REGNUM, DWARF2_REG_TO_REGNUM)
(REGISTER_NAME, DEPRECATED_REGISTER_VIRTUAL_TYPE)
(DEPRECATED_REGISTER_BYTES, DEPRECATED_REGISTER_BYTE)
(DEPRECATED_REGISTER_RAW_SIZE, DEPRECATED_REGISTER_VIRTUAL_SIZE)
(DEPRECATED_SAVE_DUMMY_FRAME_TOS, DEPRECATED_FP_REGNUM)
(DEPRECATED_TARGET_READ_FP, DEPRECATED_PUSH_ARGUMENTS)
(DEPRECATED_PUSH_RETURN_ADDRESS, DEPRECATED_DUMMY_WRITE_SP)
(DEPRECATED_REGISTER_SIZE, CALL_DUMMY_LOCATION)
(DEPRECATED_DO_REGISTERS_INFO, REGISTER_SIM_REGNO)
(REGISTER_BYTES_OK, CANNOT_FETCH_REGISTER, CANNOT_STORE_REGISTER)
(GET_LONGJMP_TARGET, DEPRECATED_INIT_FRAME_PC)
(BELIEVE_PCC_PROMOTION, DEPRECATED_GET_SAVED_REGISTER)
(CONVERT_REGISTER_P, REGISTER_TO_VALUE, VALUE_TO_REGISTER)
(POINTER_TO_ADDRESS, ADDRESS_TO_POINTER, INTEGER_TO_ADDRESS)
(DEPRECATED_POP_FRAME, DEPRECATED_STORE_STRUCT_RETURN)
(EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE)
(DEPRECATED_EXTRACT_RETURN_VALUE, DEPRECATED_STORE_RETURN_VALUE)
(DEPRECATED_USE_STRUCT_CONVENTION)
(DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS)
(DEPRECATED_FRAME_INIT_SAVED_REGS)
(DEPRECATED_INIT_EXTRA_FRAME_INFO, SKIP_PROLOGUE, INNER_THAN)
(BREAKPOINT_FROM_PC, MEMORY_INSERT_BREAKPOINT)
(MEMORY_REMOVE_BREAKPOINT, DECR_PC_AFTER_BREAK)
(DEPRECATED_FUNCTION_START_OFFSET, FRAME_ARGS_SKIP)
(DEPRECATED_FRAMELESS_FUNCTION_INVOCATION, DEPRECATED_FRAME_CHAIN)
(DEPRECATED_FRAME_CHAIN_VALID, DEPRECATED_FRAME_SAVED_PC)
(DEPRECATED_FRAME_ARGS_ADDRESS, DEPRECATED_FRAME_LOCALS_ADDRESS)
(DEPRECATED_SAVED_PC_AFTER_CALL, FRAME_NUM_ARGS)
(DEPRECATED_STACK_ALIGN, DEPRECATED_REG_STRUCT_HAS_ADDR)
(FRAME_RED_ZONE_SIZE, ADDR_BITS_REMOVE, SMASH_TEXT_ADDRESS)
(SOFTWARE_SINGLE_STEP, SKIP_TRAMPOLINE_CODE)
(IN_SOLIB_CALL_TRAMPOLINE, IN_SOLIB_RETURN_TRAMPOLINE)
(ELF_MAKE_MSYMBOL_SPECIAL, COFF_MAKE_MSYMBOL_SPECIAL)
(NAME_OF_MALLOC, CANNOT_STEP_BREAKPOINT)
(HAVE_NONSTEPPABLE_WATCHPOINT, ADDRESS_CLASS_TYPE_FLAGS)
(FETCH_POINTER_ARGUMENT): Replace the macro name with "=".
2004-06-21 21:54:50 +02:00
printf "\n"
printf " extern int gdbarch_ ${ function } _p (struct gdbarch *gdbarch);\n "
2001-03-17 01:31:22 +01:00
fi
2000-04-21 06:17:18 +02:00
if class_is_variable_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf " extern ${ returntype } gdbarch_ ${ function } (struct gdbarch *gdbarch);\n "
printf " extern void set_gdbarch_ ${ function } (struct gdbarch *gdbarch, ${ returntype } ${ function } );\n "
2000-04-21 06:17:18 +02:00
fi
if class_is_function_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
2001-06-07 22:52:47 +02:00
if [ " x ${ formal } " = "xvoid" ] && class_is_multiarch_p
2001-03-17 01:31:22 +01:00
then
printf " typedef ${ returntype } (gdbarch_ ${ function } _ftype) (struct gdbarch *gdbarch);\n "
elif class_is_multiarch_p
then
printf " typedef ${ returntype } (gdbarch_ ${ function } _ftype) (struct gdbarch *gdbarch, ${ formal } );\n "
else
printf " typedef ${ returntype } (gdbarch_ ${ function } _ftype) ( ${ formal } );\n "
fi
2001-06-07 22:52:47 +02:00
if [ " x ${ formal } " = "xvoid" ]
1999-08-31 03:14:27 +02:00
then
2000-09-04 13:40:20 +02:00
printf " extern ${ returntype } gdbarch_ ${ function } (struct gdbarch *gdbarch);\n "
1999-08-31 03:14:27 +02:00
else
2000-09-04 13:40:20 +02:00
printf " extern ${ returntype } gdbarch_ ${ function } (struct gdbarch *gdbarch, ${ formal } );\n "
1999-08-31 03:14:27 +02:00
fi
2000-09-04 13:40:20 +02:00
printf " extern void set_gdbarch_ ${ function } (struct gdbarch *gdbarch, gdbarch_ ${ function } _ftype * ${ function } );\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
# close it off
cat <<EOF
extern struct gdbarch_tdep *gdbarch_tdep ( struct gdbarch *gdbarch) ;
/* Mechanism for co-ordinating the selection of a specific
architecture.
GDB targets ( *-tdep.c) can register an interest in a specific
architecture. Other GDB components can register a need to maintain
per-architecture data.
The mechanisms below ensures that there is only a loose connection
between the set-architecture command and the various GDB
2000-09-02 02:02:54 +02:00
components. Each component can independently register their need
1999-08-31 03:14:27 +02:00
to maintain architecture specific data with gdbarch.
Pragmatics:
Previously, a single TARGET_ARCHITECTURE_HOOK was provided. It
didn' t scale.
The more traditional mega-struct containing architecture specific
data for all the various GDB components was also considered. Since
2000-09-02 02:02:54 +02:00
GDB is built from a variable number of ( fairly independent)
1999-08-31 03:14:27 +02:00
components it was determined that the global aproach was not
2011-01-07 20:36:19 +01:00
applicable. */
1999-08-31 03:14:27 +02:00
/* Register a new architectural family with GDB.
Register support for the specified ARCHITECTURE with GDB. When
gdbarch determines that the specified architecture has been
selected, the corresponding INIT function is called.
--
The INIT function takes two parameters: INFO which contains the
information available to gdbarch about the ( possibly new)
architecture; ARCHES which is a list of the previously created
\` \` struct gdbarch'' for this architecture.
2002-04-20 19:41:18 +02:00
The INFO parameter is, as far as possible, be pre-initialized with
2006-11-10 20:20:37 +01:00
information obtained from INFO.ABFD or the global defaults.
2002-04-20 19:41:18 +02:00
The ARCHES parameter is a linked list ( sorted most recently used)
of all the previously created architures for this architecture
family. The ( possibly NULL) ARCHES->gdbarch can used to access
values from the previously selected architecture for this
2009-07-02 19:29:17 +02:00
architecture family.
1999-08-31 03:14:27 +02:00
The INIT function shall return any of: NULL - indicating that it
2000-10-27 21:17:57 +02:00
doesn' t recognize the selected architecture; an existing \` \` struct
1999-08-31 03:14:27 +02:00
gdbarch'' from the ARCHES list - indicating that the new
architecture is just a synonym for an earlier architecture ( see
gdbarch_list_lookup_by_info( ) ) ; a newly created \` \` struct gdbarch''
2000-06-10 07:37:47 +02:00
- that describes the selected architecture ( see gdbarch_alloc( ) ) .
The DUMP_TDEP function shall print out all target specific values.
Care should be taken to ensure that the function works in both the
2011-01-07 20:36:19 +01:00
multi-arch and non- multi-arch cases. */
1999-08-31 03:14:27 +02:00
struct gdbarch_list
{
struct gdbarch *gdbarch;
struct gdbarch_list *next;
} ;
struct gdbarch_info
{
2011-01-07 20:36:19 +01:00
/* Use default: NULL ( ZERO) . */
1999-08-31 03:14:27 +02:00
const struct bfd_arch_info *bfd_arch_info;
2001-12-29 20:25:58 +01:00
/* Use default: BFD_ENDIAN_UNKNOWN ( NB: is not ZERO) . */
2014-01-02 04:02:56 +01:00
enum bfd_endian byte_order;
1999-08-31 03:14:27 +02:00
2014-01-02 04:02:56 +01:00
enum bfd_endian byte_order_for_code;
2008-08-11 21:00:25 +02:00
2011-01-07 20:36:19 +01:00
/* Use default: NULL ( ZERO) . */
1999-08-31 03:14:27 +02:00
bfd *abfd;
2011-01-07 20:36:19 +01:00
/* Use default: NULL ( ZERO) . */
2017-08-07 16:53:54 +02:00
union
{
/* Architecture-specific information. The generic form for targets
that have extra requirements. */
struct gdbarch_tdep_info *tdep_info;
/* Architecture-specific target description data. Numerous targets
need only this, so give them an easy way to hold it. */
struct tdesc_arch_data *tdesc_data;
/* SPU file system ID. This is a single integer, so using the
generic form would only complicate code. Other targets may
reuse this member if suitable. */
int *id;
} ;
2003-01-05 00:38:46 +01:00
/* Use default: GDB_OSABI_UNINITIALIZED ( -1) . */
enum gdb_osabi osabi;
2006-11-28 23:10:26 +01:00
/* Use default: NULL ( ZERO) . */
const struct target_desc *target_desc;
1999-08-31 03:14:27 +02:00
} ;
typedef struct gdbarch *( gdbarch_init_ftype) ( struct gdbarch_info info, struct gdbarch_list *arches) ;
2000-06-10 07:37:47 +02:00
typedef void ( gdbarch_dump_tdep_ftype) ( struct gdbarch *gdbarch, struct ui_file *file) ;
1999-08-31 03:14:27 +02:00
2000-06-10 07:37:47 +02:00
/* DEPRECATED - use gdbarch_register( ) */
1999-08-31 03:14:27 +02:00
extern void register_gdbarch_init ( enum bfd_architecture architecture, gdbarch_init_ftype *) ;
2000-06-10 07:37:47 +02:00
extern void gdbarch_register ( enum bfd_architecture architecture,
gdbarch_init_ftype *,
gdbarch_dump_tdep_ftype *) ;
1999-08-31 03:14:27 +02:00
2000-06-07 06:38:02 +02:00
/* Return a freshly allocated, NULL terminated, array of the valid
architecture names. Since architectures are registered during the
_initialize phase this function only returns useful information
2011-01-07 20:36:19 +01:00
once initialization has been completed. */
2000-06-07 06:38:02 +02:00
extern const char **gdbarch_printable_names ( void) ;
1999-08-31 03:14:27 +02:00
/* Helper function . Search the list of ARCHES for a GDBARCH that
2011-01-07 20:36:19 +01:00
matches the information provided by INFO. */
1999-08-31 03:14:27 +02:00
2006-11-28 23:10:26 +01:00
extern struct gdbarch_list *gdbarch_list_lookup_by_info ( struct gdbarch_list *arches, const struct gdbarch_info *info) ;
1999-08-31 03:14:27 +02:00
/* Helper function . Create a preliminary \` \` struct gdbarch'' . Perform
2006-11-28 23:10:26 +01:00
basic initialization using values obtained from the INFO and TDEP
1999-08-31 03:14:27 +02:00
parameters. set_gdbarch_*( ) functions are called to complete the
2011-01-07 20:36:19 +01:00
initialization of the object. */
1999-08-31 03:14:27 +02:00
extern struct gdbarch *gdbarch_alloc ( const struct gdbarch_info *info, struct gdbarch_tdep *tdep) ;
2000-06-10 07:37:47 +02:00
/* Helper function . Free a partially-constructed \` \` struct gdbarch'' .
It is assumed that the caller freeds the \` \` struct
2011-01-07 20:36:19 +01:00
gdbarch_tdep'' . */
2000-06-10 07:37:47 +02:00
2000-03-21 21:40:43 +01:00
extern void gdbarch_free ( struct gdbarch *) ;
Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:
foo *f = obstack_alloc (obstack, sizeof (foo));
f = new (f) foo;
It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap. This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:
foo *f = obstack_new<foo> (obstack);
Right now there's only one usage (in tdesc_data_init).
To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:
- OBSTACK_ZALLOC/OBSTACK_CALLOC
- XOBNEW/XOBNEW
- GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC
Unfortunately, there's no way to catch wrong usages of obstack_alloc.
By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC. The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD. Because it inherits from struct symbol, template_symbol is
not a POD. This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0. We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5. So here I considered
two alternatives:
1. Relax that criterion to use std::is_trivially_constructible and add a
bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
are allocated and initialized
I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused. When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.
gdb/ChangeLog:
* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
/* Get the obstack owned by ARCH. */
extern obstack *gdbarch_obstack ( gdbarch *arch) ;
2000-03-21 21:40:43 +01:00
2003-07-22 21:49:58 +02:00
/* Helper function . Allocate memory from the \` \` struct gdbarch''
obstack. The memory is freed when the corresponding architecture
is also freed. */
Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:
foo *f = obstack_alloc (obstack, sizeof (foo));
f = new (f) foo;
It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap. This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:
foo *f = obstack_new<foo> (obstack);
Right now there's only one usage (in tdesc_data_init).
To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:
- OBSTACK_ZALLOC/OBSTACK_CALLOC
- XOBNEW/XOBNEW
- GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC
Unfortunately, there's no way to catch wrong usages of obstack_alloc.
By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC. The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD. Because it inherits from struct symbol, template_symbol is
not a POD. This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0. We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5. So here I considered
two alternatives:
1. Relax that criterion to use std::is_trivially_constructible and add a
bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
are allocated and initialized
I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused. When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.
gdb/ChangeLog:
* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE) \
obstack_calloc<TYPE> ( gdbarch_obstack ( ( GDBARCH) ) , ( NR) )
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE) \
obstack_zalloc<TYPE> ( gdbarch_obstack ( ( GDBARCH) ) )
2003-07-22 21:49:58 +02:00
2015-08-30 00:07:50 +02:00
/* Duplicate STRING, returning an equivalent string that' s allocated on the
obstack associated with GDBARCH. The string is freed when the corresponding
architecture is also freed. */
extern char *gdbarch_obstack_strdup ( struct gdbarch *arch, const char *string) ;
2003-07-22 21:49:58 +02:00
2011-01-07 20:36:19 +01:00
/* Helper function . Force an update of the current architecture.
1999-08-31 03:14:27 +02:00
2001-05-14 18:43:35 +02:00
The actual architecture selected is determined by INFO, \` \` ( gdb) set
architecture'' et.al., the existing architecture and BFD' s default
architecture. INFO should be initialized to zero and then selected
fields should be updated.
1999-08-31 03:14:27 +02:00
2011-01-07 20:36:19 +01:00
Returns non-zero if the update succeeds. */
2000-08-11 03:30:11 +02:00
extern int gdbarch_update_p ( struct gdbarch_info info) ;
1999-08-31 03:14:27 +02:00
2003-11-10 05:39:17 +01:00
/* Helper function . Find an architecture matching info.
INFO should be initialized using gdbarch_info_init, relevant fields
set, and then finished using gdbarch_info_fill.
Returns the corresponding architecture, or NULL if no matching
2009-07-02 19:29:17 +02:00
architecture was found. */
2003-11-10 05:39:17 +01:00
extern struct gdbarch *gdbarch_find_by_info ( struct gdbarch_info info) ;
2012-11-14 16:40:35 +01:00
/* Helper function . Set the target gdbarch to "gdbarch" . */
2003-11-10 05:39:17 +01:00
2012-11-14 16:40:35 +01:00
extern void set_target_gdbarch ( struct gdbarch *gdbarch) ;
2003-11-10 05:39:17 +01:00
1999-08-31 03:14:27 +02:00
/* Register per-architecture data-pointer.
Reserve space for a per-architecture data-pointer. An identifier
for the reserved data-pointer is returned. That identifer should
2001-02-07 03:17:48 +01:00
be saved in a local static variable.
1999-08-31 03:14:27 +02:00
2003-08-05 00:24:44 +02:00
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
1999-08-31 03:14:27 +02:00
2001-02-07 03:17:48 +01:00
When a previously created architecture is re-selected, the
per-architecture data-pointer for that previous architecture is
2002-06-08 20:09:01 +02:00
restored. INIT( ) is not re-called.
1999-08-31 03:14:27 +02:00
Multiple registrarants for any architecture are allowed ( and
strongly encouraged) . */
2001-02-07 03:17:48 +01:00
struct gdbarch_data;
1999-08-31 03:14:27 +02:00
2004-03-15 21:38:08 +01:00
typedef void *( gdbarch_data_pre_init_ftype) ( struct obstack *obstack) ;
extern struct gdbarch_data *gdbarch_data_register_pre_init ( gdbarch_data_pre_init_ftype *init) ;
typedef void *( gdbarch_data_post_init_ftype) ( struct gdbarch *gdbarch) ;
extern struct gdbarch_data *gdbarch_data_register_post_init ( gdbarch_data_post_init_ftype *init) ;
extern void deprecated_set_gdbarch_data ( struct gdbarch *gdbarch,
struct gdbarch_data *data,
void *pointer) ;
1999-08-31 03:14:27 +02:00
2002-05-12 03:02:58 +02:00
extern void *gdbarch_data ( struct gdbarch *gdbarch, struct gdbarch_data *) ;
1999-08-31 03:14:27 +02:00
2000-09-02 02:02:54 +02:00
/* Set the dynamic target-system-dependent parameters ( architecture,
2011-01-07 20:36:19 +01:00
byte-order, ...) using information found in the BFD. */
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_from_file ( bfd *) ;
1999-10-26 05:43:48 +02:00
/* Initialize the current architecture to the "first" one we find on
our list. */
extern void initialize_current_architecture ( void) ;
1999-08-31 03:14:27 +02:00
/* gdbarch trace variable */
2012-08-02 11:36:40 +02:00
extern unsigned int gdbarch_debug;
1999-08-31 03:14:27 +02:00
2000-06-10 07:37:47 +02:00
extern void gdbarch_dump ( struct gdbarch *gdbarch, struct ui_file *file) ;
1999-08-31 03:14:27 +02:00
2018-10-22 04:29:21 +02:00
/* Return the number of cooked registers ( raw + pseudo) for ARCH. */
static inline int
gdbarch_num_cooked_regs ( gdbarch *arch)
{
return gdbarch_num_regs ( arch) + gdbarch_num_pseudo_regs ( arch) ;
}
1999-08-31 03:14:27 +02:00
#endif
EOF
exec 1>& 2
#../move-if-change new-gdbarch.h gdbarch.h
2000-03-30 07:32:23 +02:00
compare_new gdbarch.h
1999-08-31 03:14:27 +02:00
#
# C file
#
exec > new-gdbarch.c
copyright
cat <<EOF
#include "defs.h"
Bring IEEE_FLOAT under gdbarch's control.
* gdbarch.sh (IEEE_FLOAT): New entry.
* gdbarch.c, gdbarch.h: Regenerated.
* valprint.c (IEEE_FLOAT): Provide a default #definition for this.
(print_floating): Use IEEE_FLOAT as if it were an expression; use
the code specific to IEEE-format numbers whenever the value of
IEEE_FLOAT is non-zero.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arc/tm-arc.h, config/arm/tm-arm.h, config/fr30/tm-fr30.h,
config/h8300/tm-h8300.h, config/i386/tm-i386.h,
config/i960/tm-i960.h, config/m88k/tm-m88k.h,
config/mips/tm-mips.h, config/pa/tm-hppa.h,
config/sparc/tm-sparc.h, config/delta/tm-delta.h,
config/frv/tm-frv.h (IEEE_FLOAT): For all ports that #define
IEEE_FLOAT, make sure they give it the value (1).
2000-04-14 21:14:19 +02:00
#include "arch-utils.h"
1999-08-31 03:14:27 +02:00
#include "gdbcmd.h"
2007-05-31 18:57:30 +02:00
#include "inferior.h"
1999-08-31 03:14:27 +02:00
#include "symcat.h"
2000-06-02 03:59:13 +02:00
#include "floatformat.h"
2002-11-02 16:13:34 +01:00
#include "reggroups.h"
2003-01-05 00:38:46 +01:00
#include "osabi.h"
2003-07-22 21:49:58 +02:00
#include "gdb_obstack.h"
2018-04-09 16:34:48 +02:00
#include "observable.h"
2008-08-22 15:35:00 +02:00
#include "regcache.h"
2012-06-05 15:50:50 +02:00
#include "objfiles.h"
2016-06-12 00:51:38 +02:00
#include "auxv.h"
gdb: Add default frame methods to gdbarch
Supply default gdbarch methods for gdbarch_dummy_id,
gdbarch_unwind_pc, and gdbarch_unwind_sp. This patch doesn't actually
convert any targets to use these methods, and so, there will be no
user visible changes after this commit.
The implementations for default_dummy_id and default_unwind_sp are
fairly straight forward, these just take on the pattern used by most
targets. Once these default methods are in place then most targets
will be able to switch over.
The implementation for default_unwind_pc is also fairly straight
forward, but maybe needs some explanation.
This patch has gone through a number of iterations:
https://sourceware.org/ml/gdb-patches/2018-03/msg00165.html
https://sourceware.org/ml/gdb-patches/2018-03/msg00306.html
https://sourceware.org/ml/gdb-patches/2018-06/msg00090.html
https://sourceware.org/ml/gdb-patches/2018-09/msg00127.html
and the implementation of default_unwind_pc has changed over this
time. Originally, I took an implementation like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
return frame_unwind_register_unsigned (next_frame, pc_regnum);
}
This is basically a clone of default_unwind_sp, but using $pc. It was
pointed out that we could potentially do better, and in version 2 the
implementation became:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
struct type *type;
int pc_regnum;
CORE_ADDR addr;
struct value *value;
pc_regnum = gdbarch_pc_regnum (gdbarch);
value = frame_unwind_register_value (next_frame, pc_regnum);
type = builtin_type (gdbarch)->builtin_func_ptr;
addr = extract_typed_address (value_contents_all (value), type);
addr = gdbarch_addr_bits_remove (gdbarch, addr);
release_value (value);
value_free (value);
return addr;
}
The idea was to try split out some of the steps of unwinding the $pc,
steps that are on some (or many) targets no-ops, and so allow targets
that do override these methods, to make use of default_unwind_pc.
This implementation remained in place for version 2, 3, and 4.
However, I realised that I'd made a mistake, most targets simply use
frame_unwind_register_unsigned to unwind the $pc, and this throws an
error if the register value is optimized out or unavailable. My new
proposed implementation doesn't do this, I was going to end up
breaking many targets.
I considered duplicating the code from frame_unwind_register_unsigned
that throws the errors into my new default_unwind_pc, however, this
felt really overly complex. So, what I instead went with was to
simply revert back to using frame_unwind_register_unsigned. Almost
all existing targets already use this. Some of the ones that don't can
be converted to, which means almost all targets could end up using the
default.
One addition I have made over the version 1 implementation is to add a
call to gdbarch_addr_bits_remove. For most targets this is a no-op,
but for a handful, having this call in place will mean that they can
use the default method. After all this, the new default_unwind_pc now
looks like this:
CORE_ADDR
default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
int pc_regnum = gdbarch_pc_regnum (gdbarch);
CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum);
pc = gdbarch_addr_bits_remove (gdbarch, pc);
return pc;
}
gdb/ChangeLog:
* gdb/dummy-frame.c (default_dummy_id): Defined new function.
* gdb/dummy-frame.h (default_dummy_id): Declare new function.
* gdb/frame-unwind.c (default_unwind_pc): Define new function.
(default_unwind_sp): Define new function.
* gdb/frame-unwind.h (default_unwind_pc): Declare new function.
(default_unwind_sp): Declare new function.
* gdb/frame.c (frame_unwind_pc): Assume gdbarch_unwind_pc is
available.
(get_frame_sp): Assume that gdbarch_unwind_sp is available.
* gdb/gdbarch.c: Regenerate.
* gdb/gdbarch.h: Regenerate.
* gdb/gdbarch.sh: Update definition of dummy_id, unwind_pc, and
unwind_sp. Add additional header files to be included in
generated file.
2018-09-07 21:04:44 +02:00
#include "frame-unwind.h"
#include "dummy-frame.h"
2001-02-07 03:17:48 +01:00
1999-08-31 03:14:27 +02:00
/* Static function declarations */
2001-06-06 16:46:30 +02:00
static void alloc_gdbarch_data ( struct gdbarch *) ;
1999-08-31 03:14:27 +02:00
/* Non-zero if we want to trace architecture code. */
#ifndef GDBARCH_DEBUG
#define GDBARCH_DEBUG 0
#endif
2012-08-02 11:36:40 +02:00
unsigned int gdbarch_debug = GDBARCH_DEBUG;
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
static void
show_gdbarch_debug ( struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered ( file, _( "Architecture debugging is %s.\\n" ) , value) ;
}
1999-08-31 03:14:27 +02:00
2004-08-08 21:49:43 +02:00
static const char *
* doublest.c (floatformat_from_length): Use the right element from
gdbarch floatformats.
(floatformat_from_type, extract_typed_floating)
(store_typed_floating): Likewise.
* doublest.h: Remove declarations for undefined floatformat arrays.
* gdbarch.sh (float_format, double_format, long_double_format): Change
to pairs.
(pformat): Update for pairs.
* gdbarch.c, gdbarch.h: Regenerated.
* gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
(floatformats_ieee_double_littlebyte_bigword)
(floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
(floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
(floatformats_vax_d): New variables.
(builtin_type_ieee_single, builtin_type_ieee_double)
(builtin_type_arm_ext, builtin_type_ia64_spill)
(builtin_type_ia64_quad): Replace arrays with individual types.
(builtin_type_ieee_single_big, builtin_type_ieee_single_little)
(builtin_type_ieee_double_big, builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
(builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
(builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
unused and endian-specific types.
(recursive_dump_type): Update for floatformat pairs.
(build_flt): Move higher. Handle bit == -1. Take a floatformat pair.
(build_gdbtypes): Use build_flt.
(_initialize_gdbtypes): Update set of initialized types.
* gdbtypes.h: Update declarations to match gdbtypes.c.
(struct main_type): Store a pointer to two floatformats.
* arch-utils.c (default_float_format, default_double_format): Delete.
* arch-utils.h (default_float_format, default_double_format): Delete.
* arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
pformat ( const struct floatformat **format)
2004-08-08 21:49:43 +02:00
{
if ( format = = NULL)
return "(null)" ;
else
* doublest.c (floatformat_from_length): Use the right element from
gdbarch floatformats.
(floatformat_from_type, extract_typed_floating)
(store_typed_floating): Likewise.
* doublest.h: Remove declarations for undefined floatformat arrays.
* gdbarch.sh (float_format, double_format, long_double_format): Change
to pairs.
(pformat): Update for pairs.
* gdbarch.c, gdbarch.h: Regenerated.
* gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
(floatformats_ieee_double_littlebyte_bigword)
(floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
(floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
(floatformats_vax_d): New variables.
(builtin_type_ieee_single, builtin_type_ieee_double)
(builtin_type_arm_ext, builtin_type_ia64_spill)
(builtin_type_ia64_quad): Replace arrays with individual types.
(builtin_type_ieee_single_big, builtin_type_ieee_single_little)
(builtin_type_ieee_double_big, builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
(builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
(builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
unused and endian-specific types.
(recursive_dump_type): Update for floatformat pairs.
(build_flt): Move higher. Handle bit == -1. Take a floatformat pair.
(build_gdbtypes): Use build_flt.
(_initialize_gdbtypes): Update set of initialized types.
* gdbtypes.h: Update declarations to match gdbtypes.c.
(struct main_type): Store a pointer to two floatformats.
* arch-utils.c (default_float_format, default_double_format): Delete.
* arch-utils.h (default_float_format, default_double_format): Delete.
* arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
/* Just print out one of them - this is only for diagnostics. */
return format[ 0] ->name;
2004-08-08 21:49:43 +02:00
}
2010-03-08 20:28:27 +01:00
static const char *
pstring ( const char *string)
{
if ( string = = NULL)
return "(null)" ;
return string;
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
}
-Wwrite-strings: The Rest
This is the remainder boring constification that all looks more of less
borderline obvious IMO.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* ada-exp.y (yyerror): Constify.
* ada-lang.c (bound_name, get_selections)
(ada_variant_discrim_type)
(ada_variant_discrim_name, ada_value_struct_elt)
(ada_lookup_struct_elt_type, is_unchecked_variant)
(ada_which_variant_applies, standard_exc, ada_get_next_arg)
(catch_ada_exception_command_split)
(catch_ada_assert_command_split, catch_assert_command)
(ada_op_name): Constify.
* ada-lang.h (ada_yyerror, get_selections)
(ada_variant_discrim_name, ada_value_struct_elt): Constify.
* arc-tdep.c (arc_print_frame_cache): Constify.
* arm-tdep.c (arm_skip_stub): Constify.
* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
(gen_aggregate_elt_ref): Constify.
* bcache.c (print_bcache_statistics): Constify.
* bcache.h (print_bcache_statistics): Constify.
* break-catch-throw.c (catch_exception_command_1):
* breakpoint.c (struct ep_type_description::description):
Constify.
(add_solib_catchpoint): Constify.
(catch_fork_command_1): Add cast.
(add_catch_command): Constify.
* breakpoint.h (add_catch_command, add_solib_catchpoint):
Constify.
* bsd-uthread.c (bsd_uthread_state): Constify.
* buildsym.c (patch_subfile_names): Constify.
* buildsym.h (next_symbol_text_func, patch_subfile_names):
Constify.
* c-exp.y (yyerror): Constify.
(token::oper): Constify.
* c-lang.h (c_yyerror, cp_print_class_member): Constify.
* c-varobj.c (cplus_describe_child): Constify.
* charset.c (find_charset_names): Add cast.
(find_charset_names): Constify array and add const_cast.
* cli/cli-cmds.c (complete_command, cd_command): Constify.
(edit_command): Constify.
* cli/cli-decode.c (lookup_cmd): Constify.
* cli/cli-dump.c (dump_memory_command, dump_value_command):
Constify.
(struct dump_context): Constify.
(add_dump_command, restore_command): Constify.
* cli/cli-script.c (get_command_line): Constify.
* cli/cli-script.h (get_command_line): Constify.
* cli/cli-utils.c (check_for_argument): Constify.
* cli/cli-utils.h (check_for_argument): Constify.
* coff-pe-read.c (struct read_pe_section_data): Constify.
* command.h (lookup_cmd): Constify.
* common/print-utils.c (decimal2str): Constify.
* completer.c (gdb_print_filename): Constify.
* corefile.c (set_gnutarget): Constify.
* cp-name-parser.y (yyerror): Constify.
* cp-valprint.c (cp_print_class_member): Constify.
* cris-tdep.c (cris_register_name, crisv32_register_name):
Constify.
* d-exp.y (yyerror): Constify.
(struct token::oper): Constify.
* d-lang.h (d_yyerror): Constify.
* dbxread.c (struct header_file_location::name): Constify.
(add_old_header_file, add_new_header_file, last_function_name)
(dbx_next_symbol_text, add_bincl_to_list)
(find_corresponding_bincl_psymtab, set_namestring)
(find_stab_function_addr, read_dbx_symtab, start_psymtab)
(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
* defs.h (command_line_input, print_address_symbolic)
(deprecated_readline_begin_hook): Constify.
* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
Constify.
* event-top.c (handle_line_of_input): Constify and add cast.
* exceptions.c (catch_errors): Constify.
* exceptions.h (catch_errors): Constify.
* expprint.c (print_subexp_standard, op_string, op_name)
(op_name_standard, dump_raw_expression, dump_raw_expression):
* expression.h (op_name, op_string, dump_raw_expression):
Constify.
* f-exp.y (yyerror): Constify.
(struct token::oper): Constify.
(struct f77_boolean_val::name): Constify.
* f-lang.c (f_word_break_characters): Constify.
* f-lang.h (f_yyerror): Constify.
* fork-child.c (fork_inferior): Add cast.
* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
(new_variant): Constify.
* gdbarch.sh (pstring_ptr, pstring_list): Constify.
* gdbarch.c: Regenerate.
* gdbcore.h (set_gnutarget): Constify.
* go-exp.y (yyerror): Constify.
(token::oper): Constify.
* go-lang.h (go_yyerror): Constify.
* go32-nat.c (go32_sysinfo): Constify.
* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
* guile/scm-cmd.c (cmdscm_function): Constify.
* guile/scm-param.c (pascm_param_value): Constify.
* h8300-tdep.c (h8300_register_name, h8300s_register_name)
(h8300sx_register_name): Constify.
* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
Constify.
* ia64-tdep.c (ia64_register_names): Constify.
* infcmd.c (construct_inferior_arguments): Constify.
(path_command, attach_post_wait): Constify.
* language.c (show_range_command, show_case_command)
(unk_lang_error): Constify.
* language.h (language_defn::la_error)
(language_defn::la_name_of_this): Constify.
* linespec.c (decode_line_2): Constify.
* linux-thread-db.c (thread_db_err_str): Constify.
* lm32-tdep.c (lm32_register_name): Constify.
* m2-exp.y (yyerror): Constify.
* m2-lang.h (m2_yyerror): Constify.
* m32r-tdep.c (m32r_register_names): Constify and make static.
* m68hc11-tdep.c (m68hc11_register_names): Constify.
* m88k-tdep.c (m88k_register_name): Constify.
* macroexp.c (appendmem): Constify.
* mdebugread.c (fdr_name, add_data_symbol, parse_type)
(upgrade_type, parse_external, parse_partial_symbols)
(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
(new_symbol): Constify.
* memattr.c (mem_info_command): Constify.
* mep-tdep.c (register_name_from_keyword): Constify.
* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
Constify.
* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
* mi/mi-main.c (captured_mi_execute_command): Constify and add
cast.
(mi_execute_async_cli_command): Constify.
* mips-tdep.c (mips_register_name): Constify.
* mn10300-tdep.c (register_name, mn10300_generic_register_name)
(am33_register_name, am33_2_register_name)
* moxie-tdep.c (moxie_register_names): Constify.
* nat/linux-osdata.c (osdata_type): Constify fields.
* nto-tdep.c (nto_parse_redirection): Constify.
* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
(lookup_child_selector): Constify.
(objc_methcall::name): Constify.
* objc-lang.h (lookup_objc_class, lookup_child_selector)
(lookup_struct_typedef): Constify.
* objfiles.c (pc_in_section): Constify.
* objfiles.h (pc_in_section): Constify.
* p-exp.y (struct token::oper): Constify.
(yyerror): Constify.
* p-lang.h (pascal_yyerror): Constify.
* parser-defs.h (op_name_standard): Constify.
(op_print::string): Constify.
(exp_descriptor::op_name): Constify.
* printcmd.c (print_address_symbolic): Constify.
* psymtab.c (print_partial_symbols): Constify.
* python/py-breakpoint.c (stop_func): Constify.
(bppy_get_expression): Constify.
* python/py-cmd.c (cmdpy_completer::name): Constify.
(cmdpy_function): Constify.
* python/py-event.c (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-event.h (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-evts.c (add_new_registry): Constify.
* python/py-finishbreakpoint.c (outofscope_func): Constify.
* python/py-framefilter.c (get_py_iter_from_func): Constify.
* python/py-inferior.c (get_buffer): Add cast.
* python/py-param.c (parm_constant::name): Constify.
* python/py-unwind.c (fprint_frame_id): Constify.
* python/python.c (gdbpy_parameter_value): Constify.
* remote-fileio.c (remote_fio_func_map): Make 'name' const.
* remote.c (memory_packet_config::name): Constify.
(show_packet_config_cmd, remote_write_bytes)
(remote_buffer_add_string):
* reverse.c (exec_reverse_once): Constify.
* rs6000-tdep.c (variant::name, variant::description): Constify.
* rust-exp.y (rustyyerror): Constify.
* rust-lang.c (rust_op_name): Constify.
* rust-lang.h (rustyyerror): Constify.
* serial.h (serial_ops::name): Constify.
* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
(sh_sh3e_register_name, sh_sh2e_register_name)
(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
(sh_sh4_register_name, sh_sh4_nofpu_register_name)
(sh_sh4al_dsp_register_name): Constify.
* sh64-tdep.c (sh64_register_name): Constify.
* solib-darwin.c (lookup_symbol_from_bfd): Constify.
* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
* stabsread.c (patch_block_stabs, read_type_number)
(ref_map::stabs, ref_add, process_reference)
(symbol_reference_defined, define_symbol, define_symbol)
(error_type, read_type, read_member_functions, read_cpp_abbrev)
(read_one_struct_field, read_struct_fields, read_baseclasses)
(read_tilde_fields, read_struct_type, read_array_type)
(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
(read_huge_number, read_range_type, read_args, common_block_start)
(find_name_end): Constify.
* stabsread.h (common_block_start, define_symbol)
(process_one_symbol, symbol_reference_defined, ref_add):
* symfile.c (get_section_index, add_symbol_file_command):
* symfile.h (get_section_index): Constify.
* target-descriptions.c (tdesc_type::name): Constify.
(tdesc_free_type): Add cast.
* target.c (find_default_run_target):
(add_deprecated_target_alias, find_default_run_target)
(target_announce_detach): Constify.
(do_option): Constify.
* target.h (add_deprecated_target_alias): Constify.
* thread.c (print_thread_info_1): Constify.
* top.c (deprecated_readline_begin_hook, command_line_input):
Constify.
(init_main): Add casts.
* top.h (handle_line_of_input): Constify.
* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
(tfind_command): Rename to ...
(tfind_command_1): ... this and constify.
(tfind_command): New function.
(tfind_end_command, tfind_start_command): Adjust.
(encode_source_string): Constify.
* tracepoint.h (encode_source_string): Constify.
* tui/tui-data.c (tui_partial_win_by_name): Constify.
* tui/tui-data.h (tui_partial_win_by_name): Constify.
* tui/tui-source.c (tui_set_source_content_nil): Constify.
* tui/tui-source.h (tui_set_source_content_nil): Constify.
* tui/tui-win.c (parse_scrolling_args): Constify.
* tui/tui-windata.c (tui_erase_data_content): Constify.
* tui/tui-windata.h (tui_erase_data_content): Constify.
* tui/tui-winsource.c (tui_erase_source_content): Constify.
* tui/tui.c (tui_enable): Add cast.
* utils.c (defaulted_query): Constify.
(init_page_info): Add cast.
(puts_debug, subset_compare): Constify.
* utils.h (subset_compare): Constify.
* varobj.c (varobj_format_string): Constify.
* varobj.h (varobj_format_string): Constify.
* vax-tdep.c (vax_register_name): Constify.
* windows-nat.c (windows_detach): Constify.
* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
* xml-support.c (gdb_xml_end_element): Constify.
* xml-tdesc.c (tdesc_start_reg): Constify.
* xstormy16-tdep.c (xstormy16_register_name): Constify.
* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
* xtensa-tdep.h (xtensa_register_t::name): Constify.
gdb/gdbserver/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* gdbreplay.c (sync_error): Constify.
* linux-x86-low.c (push_opcode): Constify.
2017-04-05 20:21:37 +02:00
static const char *
2017-03-07 16:49:10 +01:00
pstring_ptr ( char **string)
{
if ( string = = NULL || *string = = NULL)
return "(null)" ;
return *string;
}
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
/* Helper function to print a list of strings, represented as " const
char *const *" . The list is printed comma-separated. */
-Wwrite-strings: The Rest
This is the remainder boring constification that all looks more of less
borderline obvious IMO.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* ada-exp.y (yyerror): Constify.
* ada-lang.c (bound_name, get_selections)
(ada_variant_discrim_type)
(ada_variant_discrim_name, ada_value_struct_elt)
(ada_lookup_struct_elt_type, is_unchecked_variant)
(ada_which_variant_applies, standard_exc, ada_get_next_arg)
(catch_ada_exception_command_split)
(catch_ada_assert_command_split, catch_assert_command)
(ada_op_name): Constify.
* ada-lang.h (ada_yyerror, get_selections)
(ada_variant_discrim_name, ada_value_struct_elt): Constify.
* arc-tdep.c (arc_print_frame_cache): Constify.
* arm-tdep.c (arm_skip_stub): Constify.
* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
(gen_aggregate_elt_ref): Constify.
* bcache.c (print_bcache_statistics): Constify.
* bcache.h (print_bcache_statistics): Constify.
* break-catch-throw.c (catch_exception_command_1):
* breakpoint.c (struct ep_type_description::description):
Constify.
(add_solib_catchpoint): Constify.
(catch_fork_command_1): Add cast.
(add_catch_command): Constify.
* breakpoint.h (add_catch_command, add_solib_catchpoint):
Constify.
* bsd-uthread.c (bsd_uthread_state): Constify.
* buildsym.c (patch_subfile_names): Constify.
* buildsym.h (next_symbol_text_func, patch_subfile_names):
Constify.
* c-exp.y (yyerror): Constify.
(token::oper): Constify.
* c-lang.h (c_yyerror, cp_print_class_member): Constify.
* c-varobj.c (cplus_describe_child): Constify.
* charset.c (find_charset_names): Add cast.
(find_charset_names): Constify array and add const_cast.
* cli/cli-cmds.c (complete_command, cd_command): Constify.
(edit_command): Constify.
* cli/cli-decode.c (lookup_cmd): Constify.
* cli/cli-dump.c (dump_memory_command, dump_value_command):
Constify.
(struct dump_context): Constify.
(add_dump_command, restore_command): Constify.
* cli/cli-script.c (get_command_line): Constify.
* cli/cli-script.h (get_command_line): Constify.
* cli/cli-utils.c (check_for_argument): Constify.
* cli/cli-utils.h (check_for_argument): Constify.
* coff-pe-read.c (struct read_pe_section_data): Constify.
* command.h (lookup_cmd): Constify.
* common/print-utils.c (decimal2str): Constify.
* completer.c (gdb_print_filename): Constify.
* corefile.c (set_gnutarget): Constify.
* cp-name-parser.y (yyerror): Constify.
* cp-valprint.c (cp_print_class_member): Constify.
* cris-tdep.c (cris_register_name, crisv32_register_name):
Constify.
* d-exp.y (yyerror): Constify.
(struct token::oper): Constify.
* d-lang.h (d_yyerror): Constify.
* dbxread.c (struct header_file_location::name): Constify.
(add_old_header_file, add_new_header_file, last_function_name)
(dbx_next_symbol_text, add_bincl_to_list)
(find_corresponding_bincl_psymtab, set_namestring)
(find_stab_function_addr, read_dbx_symtab, start_psymtab)
(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
* defs.h (command_line_input, print_address_symbolic)
(deprecated_readline_begin_hook): Constify.
* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
Constify.
* event-top.c (handle_line_of_input): Constify and add cast.
* exceptions.c (catch_errors): Constify.
* exceptions.h (catch_errors): Constify.
* expprint.c (print_subexp_standard, op_string, op_name)
(op_name_standard, dump_raw_expression, dump_raw_expression):
* expression.h (op_name, op_string, dump_raw_expression):
Constify.
* f-exp.y (yyerror): Constify.
(struct token::oper): Constify.
(struct f77_boolean_val::name): Constify.
* f-lang.c (f_word_break_characters): Constify.
* f-lang.h (f_yyerror): Constify.
* fork-child.c (fork_inferior): Add cast.
* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
(new_variant): Constify.
* gdbarch.sh (pstring_ptr, pstring_list): Constify.
* gdbarch.c: Regenerate.
* gdbcore.h (set_gnutarget): Constify.
* go-exp.y (yyerror): Constify.
(token::oper): Constify.
* go-lang.h (go_yyerror): Constify.
* go32-nat.c (go32_sysinfo): Constify.
* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
* guile/scm-cmd.c (cmdscm_function): Constify.
* guile/scm-param.c (pascm_param_value): Constify.
* h8300-tdep.c (h8300_register_name, h8300s_register_name)
(h8300sx_register_name): Constify.
* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
Constify.
* ia64-tdep.c (ia64_register_names): Constify.
* infcmd.c (construct_inferior_arguments): Constify.
(path_command, attach_post_wait): Constify.
* language.c (show_range_command, show_case_command)
(unk_lang_error): Constify.
* language.h (language_defn::la_error)
(language_defn::la_name_of_this): Constify.
* linespec.c (decode_line_2): Constify.
* linux-thread-db.c (thread_db_err_str): Constify.
* lm32-tdep.c (lm32_register_name): Constify.
* m2-exp.y (yyerror): Constify.
* m2-lang.h (m2_yyerror): Constify.
* m32r-tdep.c (m32r_register_names): Constify and make static.
* m68hc11-tdep.c (m68hc11_register_names): Constify.
* m88k-tdep.c (m88k_register_name): Constify.
* macroexp.c (appendmem): Constify.
* mdebugread.c (fdr_name, add_data_symbol, parse_type)
(upgrade_type, parse_external, parse_partial_symbols)
(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
(new_symbol): Constify.
* memattr.c (mem_info_command): Constify.
* mep-tdep.c (register_name_from_keyword): Constify.
* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
Constify.
* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
* mi/mi-main.c (captured_mi_execute_command): Constify and add
cast.
(mi_execute_async_cli_command): Constify.
* mips-tdep.c (mips_register_name): Constify.
* mn10300-tdep.c (register_name, mn10300_generic_register_name)
(am33_register_name, am33_2_register_name)
* moxie-tdep.c (moxie_register_names): Constify.
* nat/linux-osdata.c (osdata_type): Constify fields.
* nto-tdep.c (nto_parse_redirection): Constify.
* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
(lookup_child_selector): Constify.
(objc_methcall::name): Constify.
* objc-lang.h (lookup_objc_class, lookup_child_selector)
(lookup_struct_typedef): Constify.
* objfiles.c (pc_in_section): Constify.
* objfiles.h (pc_in_section): Constify.
* p-exp.y (struct token::oper): Constify.
(yyerror): Constify.
* p-lang.h (pascal_yyerror): Constify.
* parser-defs.h (op_name_standard): Constify.
(op_print::string): Constify.
(exp_descriptor::op_name): Constify.
* printcmd.c (print_address_symbolic): Constify.
* psymtab.c (print_partial_symbols): Constify.
* python/py-breakpoint.c (stop_func): Constify.
(bppy_get_expression): Constify.
* python/py-cmd.c (cmdpy_completer::name): Constify.
(cmdpy_function): Constify.
* python/py-event.c (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-event.h (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-evts.c (add_new_registry): Constify.
* python/py-finishbreakpoint.c (outofscope_func): Constify.
* python/py-framefilter.c (get_py_iter_from_func): Constify.
* python/py-inferior.c (get_buffer): Add cast.
* python/py-param.c (parm_constant::name): Constify.
* python/py-unwind.c (fprint_frame_id): Constify.
* python/python.c (gdbpy_parameter_value): Constify.
* remote-fileio.c (remote_fio_func_map): Make 'name' const.
* remote.c (memory_packet_config::name): Constify.
(show_packet_config_cmd, remote_write_bytes)
(remote_buffer_add_string):
* reverse.c (exec_reverse_once): Constify.
* rs6000-tdep.c (variant::name, variant::description): Constify.
* rust-exp.y (rustyyerror): Constify.
* rust-lang.c (rust_op_name): Constify.
* rust-lang.h (rustyyerror): Constify.
* serial.h (serial_ops::name): Constify.
* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
(sh_sh3e_register_name, sh_sh2e_register_name)
(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
(sh_sh4_register_name, sh_sh4_nofpu_register_name)
(sh_sh4al_dsp_register_name): Constify.
* sh64-tdep.c (sh64_register_name): Constify.
* solib-darwin.c (lookup_symbol_from_bfd): Constify.
* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
* stabsread.c (patch_block_stabs, read_type_number)
(ref_map::stabs, ref_add, process_reference)
(symbol_reference_defined, define_symbol, define_symbol)
(error_type, read_type, read_member_functions, read_cpp_abbrev)
(read_one_struct_field, read_struct_fields, read_baseclasses)
(read_tilde_fields, read_struct_type, read_array_type)
(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
(read_huge_number, read_range_type, read_args, common_block_start)
(find_name_end): Constify.
* stabsread.h (common_block_start, define_symbol)
(process_one_symbol, symbol_reference_defined, ref_add):
* symfile.c (get_section_index, add_symbol_file_command):
* symfile.h (get_section_index): Constify.
* target-descriptions.c (tdesc_type::name): Constify.
(tdesc_free_type): Add cast.
* target.c (find_default_run_target):
(add_deprecated_target_alias, find_default_run_target)
(target_announce_detach): Constify.
(do_option): Constify.
* target.h (add_deprecated_target_alias): Constify.
* thread.c (print_thread_info_1): Constify.
* top.c (deprecated_readline_begin_hook, command_line_input):
Constify.
(init_main): Add casts.
* top.h (handle_line_of_input): Constify.
* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
(tfind_command): Rename to ...
(tfind_command_1): ... this and constify.
(tfind_command): New function.
(tfind_end_command, tfind_start_command): Adjust.
(encode_source_string): Constify.
* tracepoint.h (encode_source_string): Constify.
* tui/tui-data.c (tui_partial_win_by_name): Constify.
* tui/tui-data.h (tui_partial_win_by_name): Constify.
* tui/tui-source.c (tui_set_source_content_nil): Constify.
* tui/tui-source.h (tui_set_source_content_nil): Constify.
* tui/tui-win.c (parse_scrolling_args): Constify.
* tui/tui-windata.c (tui_erase_data_content): Constify.
* tui/tui-windata.h (tui_erase_data_content): Constify.
* tui/tui-winsource.c (tui_erase_source_content): Constify.
* tui/tui.c (tui_enable): Add cast.
* utils.c (defaulted_query): Constify.
(init_page_info): Add cast.
(puts_debug, subset_compare): Constify.
* utils.h (subset_compare): Constify.
* varobj.c (varobj_format_string): Constify.
* varobj.h (varobj_format_string): Constify.
* vax-tdep.c (vax_register_name): Constify.
* windows-nat.c (windows_detach): Constify.
* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
* xml-support.c (gdb_xml_end_element): Constify.
* xml-tdesc.c (tdesc_start_reg): Constify.
* xstormy16-tdep.c (xstormy16_register_name): Constify.
* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
* xtensa-tdep.h (xtensa_register_t::name): Constify.
gdb/gdbserver/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* gdbreplay.c (sync_error): Constify.
* linux-x86-low.c (push_opcode): Constify.
2017-04-05 20:21:37 +02:00
static const char *
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-19 21:53:40 +01:00
pstring_list ( const char *const *list)
{
static char ret[ 100] ;
const char *const *p;
size_t offset = 0;
if ( list = = NULL)
return "(null)" ;
ret[ 0] = '\0' ;
for ( p = list; *p != NULL && offset < sizeof ( ret) ; ++p)
{
size_t s = xsnprintf ( ret + offset, sizeof ( ret) - offset, "%s, " , *p) ;
offset += 2 + s;
}
if ( offset > 0)
{
gdb_assert ( offset - 2 < sizeof ( ret) ) ;
ret[ offset - 2] = '\0' ;
}
return ret;
2010-03-08 20:28:27 +01:00
}
1999-08-31 03:14:27 +02:00
EOF
# gdbarch open the gdbarch object
2000-09-04 13:40:20 +02:00
printf "\n"
2011-01-07 20:36:19 +01:00
printf "/* Maintain the struct gdbarch object. */\n"
2000-09-04 13:40:20 +02:00
printf "\n"
printf "struct gdbarch\n"
printf "{\n"
2002-06-08 20:09:01 +02:00
printf " /* Has this architecture been fully initialized? */\n"
printf " int initialized_p;\n"
2003-07-22 21:49:58 +02:00
printf "\n"
printf " /* An obstack bound to the lifetime of the architecture. */\n"
printf " struct obstack *obstack;\n"
printf "\n"
2011-01-07 20:36:19 +01:00
printf " /* basic architectural information. */\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_info_p
then
2000-09-04 13:40:20 +02:00
printf " ${ returntype } ${ function } ;\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
2000-09-04 13:40:20 +02:00
printf "\n"
2011-01-07 20:36:19 +01:00
printf " /* target specific vector. */\n"
2000-09-04 13:40:20 +02:00
printf " struct gdbarch_tdep *tdep;\n"
printf " gdbarch_dump_tdep_ftype *dump_tdep;\n"
printf "\n"
2011-01-07 20:36:19 +01:00
printf " /* per-architecture data-pointers. */\n"
2001-02-07 03:17:48 +01:00
printf " unsigned nr_data;\n"
2000-09-04 13:40:20 +02:00
printf " void **data;\n"
printf "\n"
1999-08-31 03:14:27 +02:00
cat <<EOF
/* Multi-arch values.
When extending this structure you must:
Add the field below.
Declare set/get functions and define the corresponding
macro in gdbarch.h.
gdbarch_alloc( ) : If zero/NULL is not a suitable default,
initialize the new field.
verify_gdbarch( ) : Confirm that the target updated the field
correctly.
2000-10-27 17:02:42 +02:00
gdbarch_dump( ) : Add a fprintf_unfiltered call so that the new
1999-08-31 03:14:27 +02:00
field is dumped out
get_gdbarch( ) : Implement the set/get functions ( probably using
the macro' s as shortcuts) .
*/
EOF
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_variable_p
then
2000-09-04 13:40:20 +02:00
printf " ${ returntype } ${ function } ;\n "
2000-04-21 06:17:18 +02:00
elif class_is_function_p
then
2004-08-08 22:50:57 +02:00
printf " gdbarch_ ${ function } _ftype * ${ function } ;\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
2000-09-04 13:40:20 +02:00
printf "};\n"
1999-08-31 03:14:27 +02:00
# Create a new gdbarch struct
cat <<EOF
2003-11-10 03:50:04 +01:00
2000-08-11 04:55:38 +02:00
/* Create a new \` \` struct gdbarch'' based on information provided by
2011-01-07 20:36:19 +01:00
\` \` struct gdbarch_info'' . */
1999-08-31 03:14:27 +02:00
EOF
2000-09-04 13:40:20 +02:00
printf "\n"
1999-08-31 03:14:27 +02:00
cat <<EOF
struct gdbarch *
gdbarch_alloc ( const struct gdbarch_info *info,
struct gdbarch_tdep *tdep)
{
2007-11-12 07:47:56 +01:00
struct gdbarch *gdbarch;
2003-07-22 21:49:58 +02:00
/* Create an obstack for allocating all the per-architecture memory,
then use that to allocate the architecture vector. */
2013-12-28 23:31:23 +01:00
struct obstack *obstack = XNEW ( struct obstack) ;
2003-07-22 21:49:58 +02:00
obstack_init ( obstack) ;
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
gdbarch = XOBNEW ( obstack, struct gdbarch) ;
2007-11-12 07:47:56 +01:00
memset ( gdbarch, 0, sizeof ( *gdbarch) ) ;
gdbarch->obstack = obstack;
2001-09-30 18:54:28 +02:00
2007-11-12 07:47:56 +01:00
alloc_gdbarch_data ( gdbarch) ;
2001-09-30 18:54:28 +02:00
2007-11-12 07:47:56 +01:00
gdbarch->tdep = tdep;
1999-08-31 03:14:27 +02:00
EOF
2000-09-04 13:40:20 +02:00
printf "\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_info_p
then
2007-11-12 07:47:56 +01:00
printf " gdbarch-> ${ function } = info-> ${ function } ;\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
2000-09-04 13:40:20 +02:00
printf "\n"
2011-01-07 20:36:19 +01:00
printf " /* Force the explicit initialization of these. */\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_function_p || class_is_variable_p
then
2001-06-07 22:52:47 +02:00
if [ -n " ${ predefault } " -a " x ${ predefault } " != "x0" ]
1999-08-31 03:14:27 +02:00
then
2007-11-12 07:47:56 +01:00
printf " gdbarch-> ${ function } = ${ predefault } ;\n "
1999-08-31 03:14:27 +02:00
fi
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
cat <<EOF
/* gdbarch_alloc( ) */
2007-11-12 07:47:56 +01:00
return gdbarch;
1999-08-31 03:14:27 +02:00
}
EOF
2000-03-21 21:40:43 +01:00
# Free a gdbarch struct.
2000-09-04 13:40:20 +02:00
printf "\n"
printf "\n"
2000-03-21 21:40:43 +01:00
cat <<EOF
2003-07-22 21:49:58 +02:00
Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:
foo *f = obstack_alloc (obstack, sizeof (foo));
f = new (f) foo;
It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap. This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:
foo *f = obstack_new<foo> (obstack);
Right now there's only one usage (in tdesc_data_init).
To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:
- OBSTACK_ZALLOC/OBSTACK_CALLOC
- XOBNEW/XOBNEW
- GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC
Unfortunately, there's no way to catch wrong usages of obstack_alloc.
By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC. The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD. Because it inherits from struct symbol, template_symbol is
not a POD. This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0. We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5. So here I considered
two alternatives:
1. Relax that criterion to use std::is_trivially_constructible and add a
bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
are allocated and initialized
I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused. When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.
gdb/ChangeLog:
* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
obstack *gdbarch_obstack ( gdbarch *arch)
2003-07-22 21:49:58 +02:00
{
Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:
foo *f = obstack_alloc (obstack, sizeof (foo));
f = new (f) foo;
It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap. This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:
foo *f = obstack_new<foo> (obstack);
Right now there's only one usage (in tdesc_data_init).
To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:
- OBSTACK_ZALLOC/OBSTACK_CALLOC
- XOBNEW/XOBNEW
- GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC
Unfortunately, there's no way to catch wrong usages of obstack_alloc.
By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC. The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD. Because it inherits from struct symbol, template_symbol is
not a POD. This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0. We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5. So here I considered
two alternatives:
1. Relax that criterion to use std::is_trivially_constructible and add a
bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
are allocated and initialized
I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused. When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.
gdb/ChangeLog:
* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
return arch->obstack;
2003-07-22 21:49:58 +02:00
}
2015-08-30 00:07:50 +02:00
/* See gdbarch.h. */
char *
gdbarch_obstack_strdup ( struct gdbarch *arch, const char *string)
{
return obstack_strdup ( arch->obstack, string) ;
}
2003-07-22 21:49:58 +02:00
2000-03-21 21:40:43 +01:00
/* Free a gdbarch struct. This should never happen in normal
operation --- once you' ve created a gdbarch, you keep it around.
However, if an architecture' s init function encounters an error
building the structure, it may need to clean up a partially
constructed gdbarch. */
2000-06-10 07:37:47 +02:00
2000-03-21 21:40:43 +01:00
void
gdbarch_free ( struct gdbarch *arch)
{
2003-07-22 21:49:58 +02:00
struct obstack *obstack;
2010-05-13 23:56:58 +02:00
2001-02-07 03:17:48 +01:00
gdb_assert ( arch != NULL) ;
2003-07-22 21:49:58 +02:00
gdb_assert ( !arch->initialized_p) ;
obstack = arch->obstack;
obstack_free ( obstack, 0) ; /* Includes the ARCH. */
xfree ( obstack) ;
2000-03-21 21:40:43 +01:00
}
EOF
1999-08-31 03:14:27 +02:00
# verify a new architecture
cat <<EOF
2003-11-10 02:10:55 +01:00
/* Ensure that all values in a GDBARCH are reasonable. */
1999-08-31 03:14:27 +02:00
static void
2007-11-12 07:47:56 +01:00
verify_gdbarch ( struct gdbarch *gdbarch)
1999-08-31 03:14:27 +02:00
{
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
string_file log;
2010-05-13 23:56:58 +02:00
1999-08-31 03:14:27 +02:00
/* fundamental */
2007-11-12 07:47:56 +01:00
if ( gdbarch->byte_order = = BFD_ENDIAN_UNKNOWN)
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
log.puts ( "\n\tbyte-order" ) ;
2007-11-12 07:47:56 +01:00
if ( gdbarch->bfd_arch_info = = NULL)
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
log.puts ( "\n\tbfd_arch_info" ) ;
2011-01-07 20:36:19 +01:00
/* Check those that need to be defined for the given multi-arch level. */
1999-08-31 03:14:27 +02:00
EOF
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_function_p || class_is_variable_p
then
2001-06-07 22:52:47 +02:00
if [ " x ${ invalid_p } " = "x0" ]
2000-04-03 02:00:32 +02:00
then
2000-09-04 13:40:20 +02:00
printf " /* Skip verify of ${ function } , invalid_p == 0 */\n "
2000-04-21 06:17:18 +02:00
elif class_is_predicate_p
then
2011-01-07 20:36:19 +01:00
printf " /* Skip verify of ${ function } , has predicate. */\n "
2000-06-02 03:59:13 +02:00
# FIXME: See do_read for potential simplification
2001-06-07 22:52:47 +02:00
elif [ -n " ${ invalid_p } " -a -n " ${ postdefault } " ]
2000-06-02 03:59:13 +02:00
then
2000-09-04 13:40:20 +02:00
printf " if ( ${ invalid_p } )\n "
2007-11-12 07:47:56 +01:00
printf " gdbarch-> ${ function } = ${ postdefault } ;\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ predefault } " -a -n " ${ postdefault } " ]
2000-06-02 03:59:13 +02:00
then
2007-11-12 07:47:56 +01:00
printf " if (gdbarch-> ${ function } == ${ predefault } )\n "
printf " gdbarch-> ${ function } = ${ postdefault } ;\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ postdefault } " ]
2000-06-02 03:59:13 +02:00
then
2007-11-12 07:47:56 +01:00
printf " if (gdbarch-> ${ function } == 0)\n "
printf " gdbarch-> ${ function } = ${ postdefault } ;\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ invalid_p } " ]
1999-08-31 03:14:27 +02:00
then
2004-09-02 18:01:33 +02:00
printf " if ( ${ invalid_p } )\n "
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
printf " log.puts (\"\\\\n\\\\t ${ function } \");\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ predefault } " ]
1999-08-31 03:14:27 +02:00
then
2007-11-12 07:47:56 +01:00
printf " if (gdbarch-> ${ function } == ${ predefault } )\n "
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
printf " log.puts (\"\\\\n\\\\t ${ function } \");\n "
1999-08-31 03:14:27 +02:00
fi
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
cat <<EOF
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
if ( !log.empty ( ) )
2001-11-05 22:34:33 +01:00
internal_error ( __FILE__, __LINE__,
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
_( "verify_gdbarch: the following are invalid ...%s" ) ,
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 12:11:47 +01:00
log.c_str ( ) ) ;
1999-08-31 03:14:27 +02:00
}
EOF
# dump the structure
2000-09-04 13:40:20 +02:00
printf "\n"
printf "\n"
1999-08-31 03:14:27 +02:00
cat <<EOF
2011-01-07 20:36:19 +01:00
/* Print out the details of the current architecture. */
2000-06-10 07:37:47 +02:00
1999-08-31 03:14:27 +02:00
void
2007-11-12 07:47:56 +01:00
gdbarch_dump ( struct gdbarch *gdbarch, struct ui_file *file)
1999-08-31 03:14:27 +02:00
{
2004-09-02 19:22:08 +02:00
const char *gdb_nm_file = "<not-defined>" ;
2010-05-13 23:56:58 +02:00
2004-09-02 19:22:08 +02:00
#if defined (GDB_NM_FILE)
gdb_nm_file = GDB_NM_FILE;
#endif
fprintf_unfiltered ( file,
"gdbarch_dump: GDB_NM_FILE = %s\\n" ,
gdb_nm_file) ;
1999-08-31 03:14:27 +02:00
EOF
2017-05-02 19:30:07 +02:00
function_list | sort '-t;' -k 3 | while do_read
1999-08-31 03:14:27 +02:00
do
2002-12-05 16:19:45 +01:00
# First the predicate
if class_is_predicate_p
then
2003-08-17 03:06:47 +02:00
printf " fprintf_unfiltered (file,\n"
2004-06-21 19:54:57 +02:00
printf " \"gdbarch_dump: gdbarch_ ${ function } _p() = %%d\\\\n\",\n "
2007-11-12 07:47:56 +01:00
printf " gdbarch_ ${ function } _p (gdbarch));\n "
2001-09-30 00:35:53 +02:00
fi
2004-06-21 19:54:57 +02:00
# Print the corresponding value.
2004-06-21 17:01:04 +02:00
if class_is_function_p
2000-06-10 07:37:47 +02:00
then
2003-08-17 03:06:47 +02:00
printf " fprintf_unfiltered (file,\n"
2009-01-09 12:06:48 +01:00
printf " \"gdbarch_dump: ${ function } = <%%s>\\\\n\",\n "
printf " host_address_to_string (gdbarch-> ${ function } ));\n "
2000-06-10 07:37:47 +02:00
else
2004-06-21 19:54:57 +02:00
# It is a variable
2004-08-08 22:50:57 +02:00
case " ${ print } : ${ returntype } " in
:CORE_ADDR )
2008-09-05 14:57:16 +02:00
fmt = "%s"
print = " core_addr_to_string_nz (gdbarch-> ${ function } ) "
2004-06-21 19:54:57 +02:00
; ;
2004-08-08 22:50:57 +02:00
:* )
2004-06-21 19:54:57 +02:00
fmt = "%s"
2008-09-05 00:49:30 +02:00
print = " plongest (gdbarch-> ${ function } ) "
2004-06-21 19:54:57 +02:00
; ;
* )
2004-08-08 22:50:57 +02:00
fmt = "%s"
2004-06-21 19:54:57 +02:00
; ;
esac
2000-09-04 13:40:20 +02:00
printf " fprintf_unfiltered (file,\n"
2004-06-21 19:54:57 +02:00
printf " \"gdbarch_dump: ${ function } = %s\\\\n\",\n " " ${ fmt } "
2000-09-04 13:40:20 +02:00
printf " ${ print } );\n "
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
2000-05-11 13:49:21 +02:00
cat <<EOF
2007-11-12 07:47:56 +01:00
if ( gdbarch->dump_tdep != NULL)
gdbarch->dump_tdep ( gdbarch, file) ;
2000-05-11 13:49:21 +02:00
}
EOF
1999-08-31 03:14:27 +02:00
# GET/SET
2000-09-04 13:40:20 +02:00
printf "\n"
1999-08-31 03:14:27 +02:00
cat <<EOF
struct gdbarch_tdep *
gdbarch_tdep ( struct gdbarch *gdbarch)
{
if ( gdbarch_debug >= 2)
2000-09-04 13:40:20 +02:00
fprintf_unfiltered ( gdb_stdlog, "gdbarch_tdep called\\n" ) ;
1999-08-31 03:14:27 +02:00
return gdbarch->tdep;
}
EOF
2000-09-04 13:40:20 +02:00
printf "\n"
2000-08-01 12:31:19 +02:00
function_list | while do_read
1999-08-31 03:14:27 +02:00
do
2000-04-21 06:17:18 +02:00
if class_is_predicate_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf "int\n"
printf " gdbarch_ ${ function } _p (struct gdbarch *gdbarch)\n "
printf "{\n"
2002-05-03 23:05:36 +02:00
printf " gdb_assert (gdbarch != NULL);\n"
2003-07-11 05:01:38 +02:00
printf " return ${ predicate } ;\n "
2000-09-04 13:40:20 +02:00
printf "}\n"
2000-04-21 06:17:18 +02:00
fi
if class_is_function_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf " ${ returntype } \n "
2001-06-07 22:52:47 +02:00
if [ " x ${ formal } " = "xvoid" ]
1999-08-31 03:14:27 +02:00
then
2000-09-04 13:40:20 +02:00
printf " gdbarch_ ${ function } (struct gdbarch *gdbarch)\n "
1999-08-31 03:14:27 +02:00
else
2000-09-04 13:40:20 +02:00
printf " gdbarch_ ${ function } (struct gdbarch *gdbarch, ${ formal } )\n "
1999-08-31 03:14:27 +02:00
fi
2000-09-04 13:40:20 +02:00
printf "{\n"
2002-05-03 23:05:36 +02:00
printf " gdb_assert (gdbarch != NULL);\n"
2003-07-11 00:01:14 +02:00
printf " gdb_assert (gdbarch-> ${ function } != NULL);\n "
2003-07-11 05:01:38 +02:00
if class_is_predicate_p && test -n " ${ predefault } "
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
then
# Allow a call to a function with a predicate.
2003-07-11 00:01:14 +02:00
printf " /* Do not check predicate: ${ predicate } , allow call. */\n "
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbarch.sh (DEPRECATED_PC_IN_CALL_DUMMY): Rename
PC_IN_CALL_DUMMY. Change to predicate. Always allow call.
* gdbarch.h, gdbarch.c: Re-generate.
* config/sparc/tm-sparc.h, config/sparc/tm-sp64.h: Update.
* config/mn10200/tm-mn10200.h, config/h8500/tm-h8500.h: Update.
* config/pa/tm-hppa.h, frame.h: Update.
* x86-64-tdep.c, vax-tdep.c, sparc-tdep.c: Update.
* s390-tdep.c, ns32k-tdep.c, mn10300-tdep.c: Update.
* m68k-tdep.c, i386-tdep.c, frv-tdep.c: Update.
* cris-tdep.c, alpha-tdep.c: Update.
* frame.c (set_unwind_by_pc, create_new_frame): Use either
DEPRECATED_PC_IN_CALL_DUMMY or pc_in_dummy_frame.
(get_prev_frame): Ditto.
Index: doc/ChangeLog
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Delete
PC_IN_CALL_DUMMY.
2002-12-01 20:07:16 +01:00
fi
2000-09-04 13:40:20 +02:00
printf " if (gdbarch_debug >= 2)\n"
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_ ${ function } called\\\\n\");\n "
2001-06-07 22:52:47 +02:00
if [ " x ${ actual } " = "x-" -o " x ${ actual } " = "x" ]
2001-03-17 01:31:22 +01:00
then
if class_is_multiarch_p
then
params = "gdbarch"
else
params = ""
fi
else
if class_is_multiarch_p
then
params = " gdbarch, ${ actual } "
else
params = " ${ actual } "
fi
fi
2001-06-07 22:52:47 +02:00
if [ " x ${ returntype } " = "xvoid" ]
1999-08-31 03:14:27 +02:00
then
2001-03-17 01:31:22 +01:00
printf " gdbarch-> ${ function } ( ${ params } );\n "
1999-08-31 03:14:27 +02:00
else
2001-03-17 01:31:22 +01:00
printf " return gdbarch-> ${ function } ( ${ params } );\n "
1999-08-31 03:14:27 +02:00
fi
2000-09-04 13:40:20 +02:00
printf "}\n"
printf "\n"
printf "void\n"
printf " set_gdbarch_ ${ function } (struct gdbarch *gdbarch,\n "
printf " `echo ${ function } | sed -e 's/./ /g'` gdbarch_ ${ function } _ftype ${ function } )\n "
printf "{\n"
printf " gdbarch-> ${ function } = ${ function } ;\n "
printf "}\n"
2000-04-21 06:17:18 +02:00
elif class_is_variable_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf " ${ returntype } \n "
printf " gdbarch_ ${ function } (struct gdbarch *gdbarch)\n "
printf "{\n"
2002-05-03 23:05:36 +02:00
printf " gdb_assert (gdbarch != NULL);\n"
2001-06-07 22:52:47 +02:00
if [ " x ${ invalid_p } " = "x0" ]
2000-04-03 02:00:32 +02:00
then
2000-09-04 13:40:20 +02:00
printf " /* Skip verify of ${ function } , invalid_p == 0 */\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ invalid_p } " ]
1999-08-31 03:14:27 +02:00
then
2003-07-11 00:01:14 +02:00
printf " /* Check variable is valid. */\n"
printf " gdb_assert (!( ${ invalid_p } ));\n "
2001-06-07 22:52:47 +02:00
elif [ -n " ${ predefault } " ]
1999-08-31 03:14:27 +02:00
then
2003-07-11 00:01:14 +02:00
printf " /* Check variable changed from pre-default. */\n"
printf " gdb_assert (gdbarch-> ${ function } != ${ predefault } );\n "
1999-08-31 03:14:27 +02:00
fi
2000-09-04 13:40:20 +02:00
printf " if (gdbarch_debug >= 2)\n"
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_ ${ function } called\\\\n\");\n "
printf " return gdbarch-> ${ function } ;\n "
printf "}\n"
printf "\n"
printf "void\n"
printf " set_gdbarch_ ${ function } (struct gdbarch *gdbarch,\n "
printf " `echo ${ function } | sed -e 's/./ /g'` ${ returntype } ${ function } )\n "
printf "{\n"
printf " gdbarch-> ${ function } = ${ function } ;\n "
printf "}\n"
2000-04-21 06:17:18 +02:00
elif class_is_info_p
then
2000-09-04 13:40:20 +02:00
printf "\n"
printf " ${ returntype } \n "
printf " gdbarch_ ${ function } (struct gdbarch *gdbarch)\n "
printf "{\n"
2002-05-03 23:05:36 +02:00
printf " gdb_assert (gdbarch != NULL);\n"
2000-09-04 13:40:20 +02:00
printf " if (gdbarch_debug >= 2)\n"
printf " fprintf_unfiltered (gdb_stdlog, \"gdbarch_ ${ function } called\\\\n\");\n "
printf " return gdbarch-> ${ function } ;\n "
printf "}\n"
2000-04-21 06:17:18 +02:00
fi
1999-08-31 03:14:27 +02:00
done
# All the trailing guff
cat <<EOF
2000-11-09 00:58:46 +01:00
/* Keep a registry of per-architecture data-pointers required by GDB
2011-01-07 20:36:19 +01:00
modules. */
1999-08-31 03:14:27 +02:00
struct gdbarch_data
{
2001-02-07 03:17:48 +01:00
unsigned index;
2002-06-08 20:09:01 +02:00
int init_p;
2004-03-15 21:38:08 +01:00
gdbarch_data_pre_init_ftype *pre_init;
gdbarch_data_post_init_ftype *post_init;
1999-08-31 03:14:27 +02:00
} ;
struct gdbarch_data_registration
{
struct gdbarch_data *data;
struct gdbarch_data_registration *next;
} ;
2000-11-09 00:58:46 +01:00
struct gdbarch_data_registry
1999-08-31 03:14:27 +02:00
{
2001-02-07 03:17:48 +01:00
unsigned nr;
1999-08-31 03:14:27 +02:00
struct gdbarch_data_registration *registrations;
} ;
2000-11-09 00:58:46 +01:00
struct gdbarch_data_registry gdbarch_data_registry =
1999-08-31 03:14:27 +02:00
{
0, NULL,
} ;
2004-03-15 21:38:08 +01:00
static struct gdbarch_data *
gdbarch_data_register ( gdbarch_data_pre_init_ftype *pre_init,
gdbarch_data_post_init_ftype *post_init)
1999-08-31 03:14:27 +02:00
{
struct gdbarch_data_registration **curr;
2010-05-13 23:56:58 +02:00
/* Append the new registration. */
2000-11-09 00:58:46 +01:00
for ( curr = & gdbarch_data_registry.registrations;
1999-08-31 03:14:27 +02:00
( *curr) != NULL;
curr = & ( *curr) ->next) ;
2013-12-28 23:31:23 +01:00
( *curr) = XNEW ( struct gdbarch_data_registration) ;
1999-08-31 03:14:27 +02:00
( *curr) ->next = NULL;
2013-12-28 23:31:23 +01:00
( *curr) ->data = XNEW ( struct gdbarch_data) ;
2000-11-09 00:58:46 +01:00
( *curr) ->data->index = gdbarch_data_registry.nr++;
2004-03-15 21:38:08 +01:00
( *curr) ->data->pre_init = pre_init;
( *curr) ->data->post_init = post_init;
2002-06-08 20:09:01 +02:00
( *curr) ->data->init_p = 1;
1999-08-31 03:14:27 +02:00
return ( *curr) ->data;
}
2004-03-15 21:38:08 +01:00
struct gdbarch_data *
gdbarch_data_register_pre_init ( gdbarch_data_pre_init_ftype *pre_init)
{
return gdbarch_data_register ( pre_init, NULL) ;
}
struct gdbarch_data *
gdbarch_data_register_post_init ( gdbarch_data_post_init_ftype *post_init)
{
return gdbarch_data_register ( NULL, post_init) ;
}
1999-08-31 03:14:27 +02:00
2011-01-07 20:36:19 +01:00
/* Create/delete the gdbarch data vector. */
2001-02-07 03:17:48 +01:00
static void
2001-06-06 16:46:30 +02:00
alloc_gdbarch_data ( struct gdbarch *gdbarch)
2001-02-07 03:17:48 +01:00
{
2001-06-06 16:46:30 +02:00
gdb_assert ( gdbarch->data = = NULL) ;
gdbarch->nr_data = gdbarch_data_registry.nr;
2003-07-22 21:49:58 +02:00
gdbarch->data = GDBARCH_OBSTACK_CALLOC ( gdbarch, gdbarch->nr_data, void *) ;
2001-06-06 16:46:30 +02:00
}
2001-06-02 05:50:56 +02:00
2002-06-08 20:09:01 +02:00
/* Initialize the current value of the specified per-architecture
2011-01-07 20:36:19 +01:00
data-pointer. */
2001-06-06 16:46:30 +02:00
2001-02-07 03:17:48 +01:00
void
2004-03-15 21:38:08 +01:00
deprecated_set_gdbarch_data ( struct gdbarch *gdbarch,
struct gdbarch_data *data,
void *pointer)
2001-02-07 03:17:48 +01:00
{
gdb_assert ( data->index < gdbarch->nr_data) ;
2003-07-22 21:49:58 +02:00
gdb_assert ( gdbarch->data[ data->index] = = NULL) ;
2004-03-15 21:38:08 +01:00
gdb_assert ( data->pre_init = = NULL) ;
2001-02-07 03:17:48 +01:00
gdbarch->data[ data->index] = pointer;
}
1999-08-31 03:14:27 +02:00
/* Return the current value of the specified per-architecture
2011-01-07 20:36:19 +01:00
data-pointer. */
1999-08-31 03:14:27 +02:00
void *
2002-05-12 03:02:58 +02:00
gdbarch_data ( struct gdbarch *gdbarch, struct gdbarch_data *data)
1999-08-31 03:14:27 +02:00
{
2002-05-12 03:02:58 +02:00
gdb_assert ( data->index < gdbarch->nr_data) ;
2004-03-15 21:38:08 +01:00
if ( gdbarch->data[ data->index] = = NULL)
2002-06-08 20:09:01 +02:00
{
2004-03-15 21:38:08 +01:00
/* The data-pointer isn' t initialized, call init( ) to get a
value. */
if ( data->pre_init != NULL)
/* Mid architecture creation: pass just the obstack, and not
the entire architecture, as that way it isn' t possible for
pre-init code to refer to undefined architecture
fields. */
gdbarch->data[ data->index] = data->pre_init ( gdbarch->obstack) ;
else if ( gdbarch->initialized_p
&& data->post_init != NULL)
/* Post architecture creation: pass the entire architecture
( as all fields are valid) , but be careful to also detect
recursive references. */
{
gdb_assert ( data->init_p) ;
data->init_p = 0;
gdbarch->data[ data->index] = data->post_init ( gdbarch) ;
data->init_p = 1;
}
else
/* The architecture initialization hasn' t completed - punt -
hope that the caller knows what they are doing. Once
deprecated_set_gdbarch_data has been initialized, this can be
changed to an internal error. */
return NULL;
2002-06-08 20:09:01 +02:00
gdb_assert ( gdbarch->data[ data->index] != NULL) ;
}
2002-05-12 03:02:58 +02:00
return gdbarch->data[ data->index] ;
1999-08-31 03:14:27 +02:00
}
2011-01-07 20:36:19 +01:00
/* Keep a registry of the architectures known by GDB. */
1999-08-31 03:14:27 +02:00
2000-06-10 07:37:47 +02:00
struct gdbarch_registration
1999-08-31 03:14:27 +02:00
{
enum bfd_architecture bfd_architecture;
gdbarch_init_ftype *init;
2000-06-10 07:37:47 +02:00
gdbarch_dump_tdep_ftype *dump_tdep;
1999-08-31 03:14:27 +02:00
struct gdbarch_list *arches;
2000-06-10 07:37:47 +02:00
struct gdbarch_registration *next;
1999-08-31 03:14:27 +02:00
} ;
2000-11-09 00:58:46 +01:00
static struct gdbarch_registration *gdbarch_registry = NULL;
1999-08-31 03:14:27 +02:00
2000-06-07 06:38:02 +02:00
static void
append_name ( const char ***buf, int *nr, const char *name)
{
2015-08-26 23:31:47 +02:00
*buf = XRESIZEVEC ( const char *, *buf, *nr + 1) ;
2000-06-07 06:38:02 +02:00
( *buf) [ *nr] = name;
*nr += 1;
}
const char **
gdbarch_printable_names ( void)
{
2003-08-17 03:06:47 +02:00
/* Accumulate a list of names based on the registed list of
2011-01-07 20:36:19 +01:00
architectures. */
2003-08-17 03:06:47 +02:00
int nr_arches = 0;
const char **arches = NULL;
struct gdbarch_registration *rego;
2010-05-13 23:56:58 +02:00
2003-08-17 03:06:47 +02:00
for ( rego = gdbarch_registry;
rego != NULL;
rego = rego->next)
2000-06-07 06:38:02 +02:00
{
2003-08-17 03:06:47 +02:00
const struct bfd_arch_info *ap;
ap = bfd_lookup_arch ( rego->bfd_architecture, 0) ;
if ( ap = = NULL)
internal_error ( __FILE__, __LINE__,
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
_( "gdbarch_architecture_names: multi-arch unknown" ) ) ;
2003-08-17 03:06:47 +02:00
do
{
append_name ( & arches, & nr_arches, ap->printable_name) ;
ap = ap->next;
}
while ( ap != NULL) ;
2000-06-07 06:38:02 +02:00
}
2003-08-17 03:06:47 +02:00
append_name ( & arches, & nr_arches, NULL) ;
return arches;
2000-06-07 06:38:02 +02:00
}
1999-08-31 03:14:27 +02:00
void
2000-06-10 07:37:47 +02:00
gdbarch_register ( enum bfd_architecture bfd_architecture,
gdbarch_init_ftype *init,
gdbarch_dump_tdep_ftype *dump_tdep)
1999-08-31 03:14:27 +02:00
{
2000-06-10 07:37:47 +02:00
struct gdbarch_registration **curr;
1999-08-31 03:14:27 +02:00
const struct bfd_arch_info *bfd_arch_info;
2010-05-13 23:56:58 +02:00
2000-10-27 21:17:57 +02:00
/* Check that BFD recognizes this architecture */
1999-08-31 03:14:27 +02:00
bfd_arch_info = bfd_lookup_arch ( bfd_architecture, 0) ;
if ( bfd_arch_info = = NULL)
{
2001-02-08 07:03:54 +01:00
internal_error ( __FILE__, __LINE__,
2011-01-07 20:36:19 +01:00
_( "gdbarch: Attempt to register "
"unknown architecture (%d)" ) ,
2001-02-08 07:03:54 +01:00
bfd_architecture) ;
1999-08-31 03:14:27 +02:00
}
2011-01-07 20:36:19 +01:00
/* Check that we haven' t seen this architecture before. */
2000-11-09 00:58:46 +01:00
for ( curr = & gdbarch_registry;
1999-08-31 03:14:27 +02:00
( *curr) != NULL;
curr = & ( *curr) ->next)
{
if ( bfd_architecture = = ( *curr) ->bfd_architecture)
2001-02-08 07:03:54 +01:00
internal_error ( __FILE__, __LINE__,
2011-06-04 01:47:46 +02:00
_( "gdbarch: Duplicate registration "
2011-01-07 20:36:19 +01:00
"of architecture (%s)" ) ,
2001-02-08 07:03:54 +01:00
bfd_arch_info->printable_name) ;
1999-08-31 03:14:27 +02:00
}
/* log it */
if ( gdbarch_debug)
2009-01-09 12:06:48 +01:00
fprintf_unfiltered ( gdb_stdlog, "register_gdbarch_init (%s, %s)\n" ,
1999-08-31 03:14:27 +02:00
bfd_arch_info->printable_name,
2009-01-09 12:06:48 +01:00
host_address_to_string ( init) ) ;
1999-08-31 03:14:27 +02:00
/* Append it */
2013-12-28 23:31:23 +01:00
( *curr) = XNEW ( struct gdbarch_registration) ;
1999-08-31 03:14:27 +02:00
( *curr) ->bfd_architecture = bfd_architecture;
( *curr) ->init = init;
2000-06-10 07:37:47 +02:00
( *curr) ->dump_tdep = dump_tdep;
1999-08-31 03:14:27 +02:00
( *curr) ->arches = NULL;
( *curr) ->next = NULL;
2000-06-10 07:37:47 +02:00
}
void
register_gdbarch_init ( enum bfd_architecture bfd_architecture,
gdbarch_init_ftype *init)
{
gdbarch_register ( bfd_architecture, init, NULL) ;
1999-08-31 03:14:27 +02:00
}
2006-11-28 23:10:26 +01:00
/* Look for an architecture using gdbarch_info. */
1999-08-31 03:14:27 +02:00
struct gdbarch_list *
gdbarch_list_lookup_by_info ( struct gdbarch_list *arches,
const struct gdbarch_info *info)
{
for ( ; arches != NULL; arches = arches->next)
{
if ( info->bfd_arch_info != arches->gdbarch->bfd_arch_info)
continue ;
if ( info->byte_order != arches->gdbarch->byte_order)
continue ;
2003-01-05 00:38:46 +01:00
if ( info->osabi != arches->gdbarch->osabi)
continue ;
2006-11-28 23:10:26 +01:00
if ( info->target_desc != arches->gdbarch->target_desc)
continue ;
1999-08-31 03:14:27 +02:00
return arches;
}
return NULL;
}
2003-11-10 05:39:17 +01:00
/* Find an architecture that matches the specified INFO. Create a new
2009-07-02 19:29:17 +02:00
architecture if needed. Return that new architecture. */
1999-08-31 03:14:27 +02:00
2009-07-02 19:29:17 +02:00
struct gdbarch *
gdbarch_find_by_info ( struct gdbarch_info info)
1999-08-31 03:14:27 +02:00
{
struct gdbarch *new_gdbarch;
2000-06-10 07:37:47 +02:00
struct gdbarch_registration *rego;
1999-08-31 03:14:27 +02:00
2001-05-14 18:43:35 +02:00
/* Fill in missing parts of the INFO struct using a number of
2006-11-10 20:20:37 +01:00
sources: "set ..." ; INFOabfd supplied; and the global
defaults. */
gdbarch_info_fill ( & info) ;
2003-01-05 00:38:46 +01:00
2011-01-07 20:36:19 +01:00
/* Must have found some sort of architecture. */
2001-05-14 18:43:35 +02:00
gdb_assert ( info.bfd_arch_info != NULL) ;
1999-08-31 03:14:27 +02:00
if ( gdbarch_debug)
{
fprintf_unfiltered ( gdb_stdlog,
2009-07-02 19:29:17 +02:00
"gdbarch_find_by_info: info.bfd_arch_info %s\n" ,
1999-08-31 03:14:27 +02:00
( info.bfd_arch_info != NULL
? info.bfd_arch_info->printable_name
: "(null)" ) ) ;
fprintf_unfiltered ( gdb_stdlog,
2009-07-02 19:29:17 +02:00
"gdbarch_find_by_info: info.byte_order %d (%s)\n" ,
1999-08-31 03:14:27 +02:00
info.byte_order,
2002-01-05 05:30:46 +01:00
( info.byte_order = = BFD_ENDIAN_BIG ? "big"
2001-12-15 17:53:24 +01:00
: info.byte_order = = BFD_ENDIAN_LITTLE ? "little"
1999-08-31 03:14:27 +02:00
: "default" ) ) ;
2003-01-05 00:38:46 +01:00
fprintf_unfiltered ( gdb_stdlog,
2009-07-02 19:29:17 +02:00
"gdbarch_find_by_info: info.osabi %d (%s)\n" ,
2003-01-05 00:38:46 +01:00
info.osabi, gdbarch_osabi_name ( info.osabi) ) ;
1999-08-31 03:14:27 +02:00
fprintf_unfiltered ( gdb_stdlog,
2009-07-02 19:29:17 +02:00
"gdbarch_find_by_info: info.abfd %s\n" ,
2009-01-09 12:06:48 +01:00
host_address_to_string ( info.abfd) ) ;
1999-08-31 03:14:27 +02:00
fprintf_unfiltered ( gdb_stdlog,
2009-07-02 19:29:17 +02:00
"gdbarch_find_by_info: info.tdep_info %s\n" ,
2009-01-09 12:06:48 +01:00
host_address_to_string ( info.tdep_info) ) ;
1999-08-31 03:14:27 +02:00
}
2003-11-10 05:39:17 +01:00
/* Find the tdep code that knows about this architecture. */
2001-05-14 18:43:35 +02:00
for ( rego = gdbarch_registry;
rego != NULL;
rego = rego->next)
if ( rego->bfd_architecture = = info.bfd_arch_info->arch)
break;
if ( rego = = NULL)
{
if ( gdbarch_debug)
2009-07-02 19:29:17 +02:00
fprintf_unfiltered ( gdb_stdlog, "gdbarch_find_by_info: "
2003-11-10 05:39:17 +01:00
"No matching architecture\n" ) ;
2001-05-14 18:43:35 +02:00
return 0;
}
2003-11-10 05:39:17 +01:00
/* Ask the tdep code for an architecture that matches "info" . */
1999-08-31 03:14:27 +02:00
new_gdbarch = rego->init ( info, rego->arches) ;
2003-11-10 05:39:17 +01:00
/* Did the tdep code like it? No. Reject the change and revert to
the old architecture. */
1999-08-31 03:14:27 +02:00
if ( new_gdbarch = = NULL)
{
if ( gdbarch_debug)
2009-07-02 19:29:17 +02:00
fprintf_unfiltered ( gdb_stdlog, "gdbarch_find_by_info: "
2003-11-10 05:39:17 +01:00
"Target rejected architecture\n" ) ;
return NULL;
1999-08-31 03:14:27 +02:00
}
2003-11-10 05:39:17 +01:00
/* Is this a pre-existing architecture ( as determined by already
being initialized) ? Move it to the front of the architecture
list ( keeping the list sorted Most Recently Used) . */
if ( new_gdbarch->initialized_p)
1999-08-31 03:14:27 +02:00
{
2003-11-10 05:39:17 +01:00
struct gdbarch_list **list;
2015-02-27 17:33:07 +01:00
struct gdbarch_list *self;
1999-08-31 03:14:27 +02:00
if ( gdbarch_debug)
2009-07-02 19:29:17 +02:00
fprintf_unfiltered ( gdb_stdlog, "gdbarch_find_by_info: "
2009-01-09 12:06:48 +01:00
"Previous architecture %s (%s) selected\n" ,
host_address_to_string ( new_gdbarch) ,
1999-08-31 03:14:27 +02:00
new_gdbarch->bfd_arch_info->printable_name) ;
2003-11-10 05:39:17 +01:00
/* Find the existing arch in the list. */
for ( list = & rego->arches;
( *list) != NULL && ( *list) ->gdbarch != new_gdbarch;
list = & ( *list) ->next) ;
/* It had better be in the list of architectures. */
gdb_assert ( ( *list) != NULL && ( *list) ->gdbarch = = new_gdbarch) ;
2015-02-27 17:33:07 +01:00
/* Unlink SELF. */
self = ( *list) ;
( *list) = self->next;
/* Insert SELF at the front. */
self->next = rego->arches;
rego->arches = self;
2003-11-10 05:39:17 +01:00
/* Return it. */
return new_gdbarch;
1999-08-31 03:14:27 +02:00
}
2003-11-10 05:39:17 +01:00
/* It' s a new architecture. */
if ( gdbarch_debug)
2009-07-02 19:29:17 +02:00
fprintf_unfiltered ( gdb_stdlog, "gdbarch_find_by_info: "
2009-01-09 12:06:48 +01:00
"New architecture %s (%s) selected\n" ,
host_address_to_string ( new_gdbarch) ,
2003-11-10 05:39:17 +01:00
new_gdbarch->bfd_arch_info->printable_name) ;
/* Insert the new architecture into the front of the architecture
list ( keep the list sorted Most Recently Used) . */
2002-04-20 19:41:18 +02:00
{
2015-02-27 17:33:07 +01:00
struct gdbarch_list *self = XNEW ( struct gdbarch_list) ;
self->next = rego->arches;
self->gdbarch = new_gdbarch;
rego->arches = self;
2002-04-20 19:41:18 +02:00
}
1999-08-31 03:14:27 +02:00
2000-06-10 07:37:47 +02:00
/* Check that the newly installed architecture is valid. Plug in
any post init values. */
new_gdbarch->dump_tdep = rego->dump_tdep;
1999-08-31 03:14:27 +02:00
verify_gdbarch ( new_gdbarch) ;
2003-11-10 05:39:17 +01:00
new_gdbarch->initialized_p = 1;
1999-08-31 03:14:27 +02:00
2000-06-10 07:37:47 +02:00
if ( gdbarch_debug)
2003-11-10 05:39:17 +01:00
gdbarch_dump ( new_gdbarch, gdb_stdlog) ;
return new_gdbarch;
}
* gdbarch.sh (gdbarch_swap_ftype, deprecated_register_gdbarch_swap,
DEPRECATED_REGISTER_GDBARCH_SWAP): Remove.
(struct gdbarch_swap, struct gdbarch_swap_registration,
struct gdbarch_swap_registry, gdbarch_swap_registry,
current_gdbarch_swap_init_hack, current_gdbarch_swap_out_hack,
current_gdbarch_swap_in_hack): Remove.
(find_arch_by_info): Do not call current_gdbarch_swap_init_hack.
(gdbarch_find_by_info): Do not call current_gdbarch_swap_in_hack
and current_gdbarch_swap_out_hack, update current_gdbarch directly.
(deprecated_current_gdbarch_select_hack): Likewise.
* gdbarch.h, gdbarch.c: Regenerate.
2007-06-22 14:45:38 +02:00
/* Make the specified architecture current. */
2003-11-10 05:39:17 +01:00
void
2012-11-14 16:40:35 +01:00
set_target_gdbarch ( struct gdbarch *new_gdbarch)
2003-11-10 05:39:17 +01:00
{
gdb_assert ( new_gdbarch != NULL) ;
gdb_assert ( new_gdbarch->initialized_p) ;
2012-11-09 02:47:20 +01:00
current_inferior ( ) ->gdbarch = new_gdbarch;
2018-04-09 16:34:48 +02:00
gdb::observers::architecture_changed.notify ( new_gdbarch) ;
2008-08-22 15:35:00 +02:00
registers_changed ( ) ;
2003-11-10 05:39:17 +01:00
}
1999-08-31 03:14:27 +02:00
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 20:58:03 +01:00
/* Return the current inferior' s arch. */
2012-11-09 02:47:20 +01:00
struct gdbarch *
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-09 20:58:03 +01:00
target_gdbarch ( void)
2012-11-09 02:47:20 +01:00
{
return current_inferior ( ) ->gdbarch;
}
2020-01-22 00:30:07 +01:00
void _initialize_gdbarch ( ) ;
1999-08-31 03:14:27 +02:00
void
2020-01-22 00:30:07 +01:00
_initialize_gdbarch ( )
1999-08-31 03:14:27 +02:00
{
2012-08-02 11:36:40 +02:00
add_setshow_zuinteger_cmd ( "arch" , class_maintenance, & gdbarch_debug, _( " \\
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
Set architecture debugging."), _(" \\
Show architecture debugging."), _(" \\
When non-zero, architecture debugging is enabled." ),
NULL,
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
show_gdbarch_debug,
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 19:58:56 +01:00
& setdebuglist, & showdebuglist) ;
1999-08-31 03:14:27 +02:00
}
EOF
# close things off
exec 1>& 2
#../move-if-change new-gdbarch.c gdbarch.c
2000-03-30 07:32:23 +02:00
compare_new gdbarch.c