Ulrich Weigand [Mon, 6 Nov 2017 15:04:03 +0000 (16:04 +0100)]
Target FP: Merge doublest.c and dfp.c into target-float.c
Now that all target FP operations are performed via target-float.c,
this file remains the sole caller of functions in doublest.c and dfp.c.
Therefore, this patch merges the latter files into the former and
makes all their function static there.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* Makefile.in (SFILES): Remove doublest.c and dfp.c.
(HFILES_NO_SRCDIR): Remove doublest.h and dfp.h.
(COMMON_OBS): Remove doublest.o and dfp.o.
Do not build target-float.c (instead of doublest.c)
with -Wformat-nonliteral.
* doublest.c: Remove file.
* doublest.h: Remove file.
* dfp.c: Remove file.
* dfp.h: Remove file.
* target-float.c: Do not include "doublest.h" and "dfp.h".
(DOUBLEST): Move here from doublest.h.
(enum float_kind): Likewise.
(FLOATFORMAT_CHAR_BIT): Likewise.
(FLOATFORMAT_LARGEST_BYTES): Likewise.
(floatformat_totalsize_bytes): Move here from doublest.c. Make static.
(floatformat_precision): Likewise.
(floatformat_normalize_byteorder, get_field, put_field): Likewise.
(floatformat_is_negative, floatformat_classify, floatformat_mantissa):
Likewise.
(host_float_format, host_double_format, host_long_double_format):
Likewise.
(floatformat_to_string, floatformat_from_string): Likewise.
(floatformat_to_doublest): Likewise. Also, inline the original
convert_floatformat_to_doublest.
(floatformat_from_doublest): Likewise. Also, inline the original
convert_floatformat_from_doublest.
Include "dpd/decimal128.h", "dpd/decimal64.h", and "dpd/decimal32.h".
(MAX_DECIMAL_STRING): Move here from dfp.c.
(match_endianness): Likewise.
(set_decnumber_context, decimal_check_errors): Likewise.
(decimal_from_number, decimal_to_number): Likewise.
(decimal_to_string, decimal_from_string): Likewise. Make static.
(decimal_from_longest, decimal_from_ulongest): Likewise.
(decimal_to_longest): Likewise.
(decimal_binop, decimal_is_zero, decimal_compare): Likewise.
(decimal_convert): Likewise.
Ulrich Weigand [Mon, 6 Nov 2017 15:02:33 +0000 (16:02 +0100)]
Target FP: Remove unused floating-point routines
This patch removes the following routines, which now have no remaining
users in GDB:
- extract_typed_floating
- store_typed_floating
- convert_typed_floating
- decimal_from_doublest
- decimal_to_doublest
- value_as_double
- unpack_double
- value_from_double
- value_from_decfloat
This completes removal of DOUBLEST from all files except doublest.{c,h}
and target-float.c.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c: Do not include "gdbtypes.h".
(extract_typed_floating): Remove.
(store_typed_floating): Remove.
(convert_typed_floating): Remove.
* doublest.h (struct type): Remove.
(DOUBLEST_PRINT_FORMAT): Remove.
(DOUBLEST_SCAN_FORMAT): Remove.
(extract_typed_floating): Remove.
(store_typed_floating): Remove.
(convert_typed_floating): Remove.
* dfp.c (decimal_from_doublest): Remove.
(decimal_to_doublest): Remove.
* dfp.h: Do not include "doublest.h".
(decimal_from_doublest): Remove.
(decimal_to_doublest): Remove.
* value.c: Do not include "doublest.h" and "dfp.h".
(value_as_double): Remove.
(unpack_double): Remove.
(value_from_double): Remove.
(value_from_decfloat): Remove.
* value.h: Do not include "doublest.h".
(value_as_double): Remove.
(unpack_double): Remove.
(value_from_double): Remove.
(value_from_decfloat): Remove.
Ulrich Weigand [Mon, 6 Nov 2017 15:01:37 +0000 (16:01 +0100)]
Target FP: Remove convert_typed_floating from tdep files
This patch mechanically replaces convert_typed_floating with the
equivalent target_float_convert throughout tdep files, to prepare
for the removal of doublest.{c,h}.
No functional change intended.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* i386-tdep.c: Include "target-float.h". Do not include "doublest.h".
(i386_extract_return_value): Use target_float_convert.
(i386_store_return_value): Likewise.
* i387-tdep.c (i387_register_to_value): Use target_float_convert.
(i387_value_to_register): Likewise.
* ia64-tdep.c: Include "target-float.h". Do not include "doublest.h".
(ia64_register_to_value): Use target_float_convert.
(ia64_value_to_register): Likewise.
(ia64_extract_return_value): Likewise.
(ia64_store_return_value): Likewise.
(ia64_push_dummy_call): Likewise.
* m68k-tdep.c: Include "target-float.h".
(m68k_register_to_value): Use target_float_convert.
(m68k_value_to_register): Likewise.
(m68k_svr4_extract_return_value): Likewise.
(m68k_svr4_store_return_value): Likewise.
* ppc-sysv-tdep.c: Include "target-float.h".
(ppc_sysv_abi_push_dummy_call): Use target_float_convert.
(do_ppc_sysv_return_value): Likewise.
(ppc64_sysv_abi_push_freg): Likewise.
(ppc64_sysv_abi_return_value_base): Likewise.
* rs6000-aix-tdep.c: Include "target-float.h".
(rs6000_push_dummy_call): Use target_float_convert.
(rs6000_return_value): Likewise.
* rs6000-lynx178-tdep.c: Include "target-float.h".
(rs6000_lynx178_push_dummy_call): Use target_float_convert.
(rs6000_lynx178_return_value): Likewise.
* rs6000-tdep.c: Include "target-float.h". Do not include "doublest.h".
(rs6000_register_to_value): Use target_float_convert.
(rs6000_value_to_register): Likewise.
* arm-tdep.c: Include "target-float.h". Do not include "doublest.h".
(arm_extract_return_value): Use target_float_convert.
(arm_store_return_value): Likewise.
* sh-tdep.c: Include "target-float.h". Do not include "doublest.h".
(sh_register_convert_to_virtual): Use target_float_convert.
(sh_register_convert_to_raw): Likewise.
* sh64-tdep.c: Include "target-float.h".
(sh64_extract_return_value): Use target_float_convert.
(sh64_register_convert_to_virtual): Likewise.
(sh64_register_convert_to_raw): Likewise. Fix argument types.
Ulrich Weigand [Mon, 6 Nov 2017 15:00:47 +0000 (16:00 +0100)]
Target FP: Handle interfaces to scripting languages
The last remaing use for DOUBLEST is in the code that interfaces to the
scripting languages (Python and Guile). The problem here is that we
expose interfaces to convert a GDB value to and from native values of
floating-point type in those languages, and those by definition use
the host floating-point format.
While we cannot completely eliminate conversions to/from the host
floating-point format here, we still need to get rid of the uses
of value_as_double / value_from_double, since those will go away.
This patch implements two new target-float.c routine:
- target_float_to_host_double
- target_float_from_host_double
which convert to/from a host "double". Those should only ever be
used where a host "double" is mandated by an external interface.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_host_double): New function.
(floatformat_from_host_double): Likewise.
(target_float_to_host_double): Likewise.
(target_float_from_host_double): Likewise.
* target-float.h (target_float_to_host_double): Add prototype.
(target_float_from_host_double): Likewise.
* guile/scm-value.c: Include "target-float.h".
(gdbscm_value_to_real): Use target_float_to_host_double.
Handle integer source values via value_as_long.
* guile/scm-math.c: Include "target-float.h". Do not include
"doublest.h", "dfp.h", and "expression.h".
(vlscm_convert_typed_number): Use target_float_from_host_double.
(vlscm_convert_number): Likewise.
* python/py-value.c (valpy_float): Use target_float_to_host_double.
(convert_value_from_python): Use target_float_from_host_double.
Ulrich Weigand [Mon, 6 Nov 2017 14:59:36 +0000 (15:59 +0100)]
Target FP: Perform Ada fixed-point scaling in target format
One of the few still remaining uses of DOUBLEST in GDB is the Ada front-end
code that handles scaling of Ada fixed-point types. The target format for
those types is some integer format; to convert those values to standard
floating-point representation, that integer needs to be multiplied by a
rational scale factor, given as a pair of numerator and denominator.
To avoid having to deal with long integer arithmetic, the current Ada
front-end code currently performs those scaling operations in host
DOUBLEST arithmetic. To eliminate this use of DOUBLEST, this patch
changes the front-end to instead perform those operations in the
*target* floating-point format (chosing to use the target "long double").
The implementation is mostly straight-forward, using value_cast and
value_binop to perform the target operations.
Scanning in the scale numerator and denominator is now done into
a host "long long" instead of a DOUBLEST, which should be large
enough to hold all possible values. (Otherwise, this can be replaced
by target-format target_float_from_string operations as well.)
Printing fixed-point types and values should be completely unchanges,
using target_float_to_string with the same format strings as current code.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* ada-lang.c (cast_to_fixed): Reimplement in target arithmetic.
(cast_from_fixed): Likewise.
(ada_scaling_type): New function.
(ada_delta): Return value instead of DOUBLEST. Perform target
arithmetic instead of host arithmetic.
(scaling_factor): Rename to ...
(ada_scaling_factor) ... this. Make non-static. Return value instead
of DOUBLEST. Perform target arithmetic instead of host arithmetic.
(ada_fixed_to_float): Remove.
(ada_float_to_fixed): Remove.
* ada-lang.h (ada_fixed_to_float): Remove.
(ada_float_to_fixed): Remove.
(ada_delta): Return value instead of DOUBLEST.
(ada_scaling_factor): Add prototype.
* ada-typeprint.c: Include "target-float.h".
(print_fixed_point_type): Perform target arithmetic instead of
host arithmetic.
* ada-valprint.c: Include "target-float.h".
(ada_val_print_num): Perform target arithmetic instead of
host arithmetic for fixed-point types.
Ulrich Weigand [Mon, 6 Nov 2017 14:58:46 +0000 (15:58 +0100)]
Target FP: Add binop and compare routines to target-float.{c,h}
This patch adds the following target floating-point routines:
- target_float_binop
- target_float_compare
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP (derived from current valarith.c code).
These routines are used to handle both binary and decimal FP types
in scalar_binop, value_equal, and value_less, mostly following the
method currently used for decimal FP. The existing value_args_as_decimal
helper is renamed to value_args_as_target_float and extended to handle
both binary and decimal types.
The unary operations value_pos and value_neg are also simplified,
the former by using a simple copy for all scalar types, the latter
by using value_binop (... BINOP_SUB) to implement negation as
subtraction from zero.
ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c: Include <math.h>.
(floatformat_binop): New function.
(floatformat_compare): Likewise.
(target_float_binop): Likewise.
(target_float_compare): Likewise.
* target-float.h: Include "expression.h".
(target_float_binop): Add prototype.
(target_float_compare): Likewise.
* valarith.c: Do not include "doublest.h" and "dfp.h".
Include "common/byte-vector.h".
(value_args_as_decimal): Remove, replace by ...
(value_args_as_target_float): ... this function. Handle both
binary and decimal target floating-point formats.
(scalar_binop): Handle both binary and decimal FP using
value_args_as_target_float and target_float_binop.
(value_equal): Handle both binary and decimal FP using
value_args_as_target_float and target_float_compare.
(value_less): Likewise.
(value_pos): Handle all scalar types as simple copy.
(value_neg): Handle all scalar types via BINOP_SUB from 0.
* dfp.c (decimal_binop): Throw error instead of internal_error
when called with an unsupported operation code.
Ulrich Weigand [Mon, 6 Nov 2017 14:57:31 +0000 (15:57 +0100)]
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
Ulrich Weigand [Mon, 6 Nov 2017 14:56:35 +0000 (15:56 +0100)]
Target FP: Add string routines to target-float.{c,h}
This adds target_float_to_string and target_float_from_string,
which dispatch to the corresponding floatformat_ or decimal_ routines.
Existing users of those routines are changed to use the new
target-float routines instead (most of those places already handle
both binary and decimal FP).
In addition, two other places are changes to use target_float_from_string:
- define_symbol in stabsread.c, when parsing a floating-point literal
from stabs debug info
- gdbarch-selftest.c when initializing a target format values (to
eliminate use of DOUBLEST there).
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (target_float_to_string): New function.
(target_float_from_string): New function.
* target-float.h (target_float_to_string): Add prototype.
(target_float_from_string): Add prototype.
* valprint.c: Include "target-float.h". Do not include
"doublest.h" and "dfp.h".
(print_floating): Use target_float_to_string.
* printcmd.c: Include "target-float.h". Do not include "dfp.h".
(printf_floating): Use target_float_to_string.
* i387-tdep.c: Include "target-float.h". Do not include "doublest.h".
(print_i387_value): Use target_float_to_string.
* mips-tdep.c: Include "target-float.h".
(mips_print_fp_register): Use target_float_to_string.
* sh64-tdep.c: Include "target-float.h".
(sh64_do_fp_register): Use target_float_to_string.
* parse.c: Include "target-float.h". Do not include
"doublest.h" and "dfp.h".
(parse_float): Use target_float_from_string.
* stabsread.c: Include "target-float.h". Do not include "doublest.h".
(define_symbol): Use target_float_from_string.
* gdbarch-selftests.c: Include "target-float.h".
(register_to_value_test): Use target_float_from_string.
Ulrich Weigand [Mon, 6 Nov 2017 14:55:11 +0000 (15:55 +0100)]
Target FP: Introduce target-float.{c,h}
This patch introduces the new set of target floating-point handling routines
in target-float.{c,h}. In the end, the intention is that this file will
contain support for all operations in target FP format, fully replacing
both the current doublest.{c,h} and dfp.{c,h}.
To begin with, this patch only adds a target_float_is_zero routine,
which handles the equivalent of decimal_is_zero for both binary and
decimal FP. For the binary case, to avoid conversion to DOUBLEST,
this is implemented using the floatformat_classify routine.
However, it turns out that floatformat_classify actually has a bug
(it was not used to check for zero before), so this is fixed as well.
The new routine is used in both value_logical_not and valpy_nonzero.
There is one extra twist: the code previously used value_as_double
to convert to DOUBLEST and then compare against zero. That routine
performs an extra task: it detects invalid floating-point values
and raises an error. In any place where value_as_double is removed
in favor of some target-float.c routine, we need to replace that check.
To keep this check centralized in one place, I've added a new routine
is_floating_value, which returns a boolean determining whether a
value's type is floating point (binary or decimal), and if so, also
performs the validity check. Since we need to check whether a value
is FP before calling any of the target-float routines anyway, this
seems a good place to add the check without much code size overhead.
In some places where we only want to check for floating-point types
and not perform a validity check (e.g. for the *output* of an operation),
we can use the new is_floating_type routine (in gdbarch) instead.
The validity check itself is done by a new target_float_is_valid
routine in target-float, encapsulating floatformat_is_valid.
ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* Makefile.c (SFILES): Add target-float.c.
(HFILES_NO_SRCDIR): Add target-float.h.
(COMMON_OBS): Add target-float.o.
* target-float.h: New file.
* target-float.c: New file.
* doublest.c (floatformat_classify): Fix detection of float_zero.
* gdbtypes.c (is_floating_type): New function.
* gdbtypes.h (is_floating_type): Add prototype.
* value.c: Do not include "floatformat.h".
(unpack_double): Use target_float_is_valid.
(is_floating_value): New function.
* value.h (is_floating_value): Add prototype-
* valarith.c: Include "target-float.h".
(value_logical_not): Use target_float_is_zero.
* python/py-value.c: Include "target-float.h".
(valpy_nonzero): Use target_float_is_zero.
GDB Administrator [Mon, 6 Nov 2017 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sun, 5 Nov 2017 09:22:13 +0000 (19:52 +1030)]
Proper bound check in _bfd_doprnt_scan
While an abort after storing out of bounds by one to an array in our
caller is probably OK in practice, it's better to check before storing.
PR 22397
* bfd.c (_bfd_doprnt_scan): Check args index before storing, not
after.
Alan Modra [Sun, 5 Nov 2017 05:52:55 +0000 (16:22 +1030)]
PR22397, BFD internal error when message locale isn't C
This adds positional parameter support to the bfd error handler,
something that was lost 2017-04-13 when _doprnt was added with commit
c08bb8dd. The number of format args is now limited to 9, which is
sufficient for current _bfd_error_handler messages. If someone
exceeds 9 args they get the joy of modifying this code to support more
args (shouldn't be too difficult).
PR 22397
* bfd.c (union _bfd_doprnt_args): New.
(PRINT_TYPE): Add FIELD arg. Take value from args.
(_bfd_doprnt): Replace ap parameter with args. Adjust all
PRINT_TYPE invocations and reading of format args to suit.
Move "%%" handling out of switch handling args. Support
positional parameters.
(_bfd_doprnt_scan): New function.
(error_handler_internal): Call _bfd_doprnt_scan and read args.
GDB Administrator [Sun, 5 Nov 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sat, 4 Nov 2017 03:11:29 +0000 (13:41 +1030)]
powerpc TLS in PIEs
This patch removes unnecessary GOT IE TLS relocations in PIEs. Useful
with --no-tls-optimize, or with an enormous TLS segment. With the
default --tls-optimize in effect IE code sequences will be edited to
LE under the same circumstances we can remove the GOT reloc.
* elf32-ppc.c (got_entries_needed, got_relocs_needed): New functions.
(allocate_dynrelocs, ppc_elf_size_dynamic_sections): Use them here.
(ppc_elf_relocate_section): Don't output a dynamic relocation
for IE GOT entries in an executable.
* elf64-ppc.c (allocate_got): Trim unnecessary TPREL relocs.
(ppc64_elf_size_dynamic_sections): Likewise.
(ppc64_elf_relocate_section): Likewise.
Alan Modra [Wed, 1 Nov 2017 21:35:03 +0000 (08:05 +1030)]
PowerPC readonly_dynrelocs
PowerPC64 lacked the mapfile textrel warning on finding dynamic relocs
in read-only sections. This patch adds it, and tidies the
readonly_dynrelocs interface. PowerPC doesn't need a SEC_ALLOC test
because !SEC_ALLOC sections are excluded by check_relocs so will never
have dyn_relocs.
* elf32-ppc.c (readonly_dynrelocs): Delete info param. Update all
callers. Don't bother with SEC_ALLOC test. Return section pointer.
Move minfo call to..
(maybe_set_textrel): ..here.
* elf64-ppc.c (readonly_dynrelocs): Return section pointer.
(maybe_set_textrel): Call minfo to print textrel warning to map file.
Alan Modra [Thu, 2 Nov 2017 01:39:34 +0000 (12:09 +1030)]
hppa-linux TLS relocs
This patch fixes various problems with TLS relocations.
1) Report an error if a symbol has both TLS and normal GOT entries.
2) The GOT entry size calculation was obscure and made use of the fact
that a symbol shouldn't have both normal and TLS GOT entries.
3) The second word of a GD GOT entry sometimes omitted a dynamic
reloc, which was fine except that doing so makes it impossible for
ld.so to differentiate GD and LD entries. Also, a NONE reloc was
emitted.
4) Unnecessary relocs were emitted for GOT entries.
5) GOT relocs didn't take note of UNDEFWEAK_NO_DYNAMIC_RELOC.
* elf32-hppa.c (enum _tls_type): Move.
(struct elf32_hppa_link_hash_entry): Make tls_type a bitfield.
(elf32_hppa_check_relocs): Set DF_STATIC_TLS only for shared libraries.
Tidy tls_type handling. Set symbol tls_type for GOT_TLS_LDM too.
(got_entries_needed, got_relocs_needed): New functions.
(allocate_dynrelocs): Use them.
(elf32_hppa_size_dynamic_sections): Likewise.
(elf32_hppa_relocate_section): Delete bogus FIXME. Formatting.
Correct code emitting relocs on GD/IE got entries. Report an
error when a symbol has both normal and TLS GOT relocs.
Alan Modra [Tue, 31 Oct 2017 07:43:03 +0000 (18:13 +1030)]
PR22394, hppa-linux-ld fails to emit dynamic relocations
gcc -mfast-indirect-calls emits a function pointer initialization
without a P% (plabel) modifier. ld does not create the necessary
dynamic relocations for this to work. It turns out that the problem
is caused by the non_got_ref symbol flag. This flag is set for
non-pic by check_relocs to indicate that the symbol might need copy
relocations or dynamic relocations. Later, the backend
adjust_dynamic_symbol clears the flag to indicate dynamic relocations
are needed, but leaves it set when copy relocations were created. The
inversion in meaning is insane, but it's that way because the backend
adjust_dynamic_symbol function doesn't get to look at all symbols..
Anyway, the insanity works for non-function symbols. However, the
flag is left set on any function symbol with a dynamic relocation.
This patch fixes the non_got_ref handling for function symbols, adds
-z nocopyreloc for hppa-elf, reports where textrel occurs, and expands
comments. The check_relocs change just stops creation of dyn_relocs
we always threw away later.
PR 22394
* elf32-hppa.c (elf32_hppa_check_relocs): Don't create dyn_relocs
for plabels when non-pic.
(maybe_set_textrel): New function.
(readonly_dynrelocs): Move and rewrite.
(elf32_hppa_adjust_dynamic_symbol): Use it. Don't create copy
relocs when def_regular or -z nocopyreloc. Handle non_got_ref
for functions. Expand non_got_ref comments.
(elf32_hppa_size_dynamic_sections): Use maybe_set_textrel.
Tom Tromey [Thu, 2 Nov 2017 04:46:40 +0000 (22:46 -0600)]
Use std::vector in h8300-tdep.c
This changes h8300-tdep.c to use std::vector, allowing the removal of
a cleanup.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* h8300-tdep.c (h8300_push_dummy_call): Use std::vector.
Tom Tromey [Thu, 2 Nov 2017 04:32:45 +0000 (22:32 -0600)]
Introduce gdb_breakpoint_up
This introduces gdb_breakpoint_up, a unique_ptr typedef that owns a
breakpoint. It then changes set_momentary_breakpoint to return a
gdb_breakpoint_up and fixes up the fallout. This then allows the
removal of make_cleanup_delete_breakpoint.
Once breakpoints are fully C++-ified, this typedef can be removed in
favor of a plain std::unique_ptr.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* breakpoint.c (set_momentary_breakpoint): Return
breakpoint_up.
(until_break_command): Update.
(new_until_break_fsm): Change argument types to
breakpoint_up.
(set_momentary_breakpoint_at_pc): Return breakpoint_up.
(do_delete_breakpoint_cleanup, make_cleanup_delete_breakpoint):
Remove.
* infcmd.c (finish_forward): Update.
* breakpoint.h (set_momentary_breakpoint)
(set_momentary_breakpoint_at_pc): Return breakpoint_up.
(make_cleanup_delete_breakpoint): Remove.
(struct breakpoint_deleter): New.
(breakpoint_up): New typedef.
* infrun.c (insert_step_resume_breakpoint_at_sal_1): Update.
(insert_exception_resume_breakpoint): Update.
(insert_exception_resume_from_probe): Update.
(insert_longjmp_resume_breakpoint): Update.
* arm-linux-tdep.c (arm_linux_copy_svc): Update.
* elfread.c (elf_gnu_ifunc_resolver_stop): Update.
* infcall.c (call_function_by_hand_dummy): Update
Tom Tromey [Thu, 2 Nov 2017 01:16:58 +0000 (19:16 -0600)]
Use unique_xmalloc_ptr in c_type_print_base
This changes c_type_print_base to use unique_xmalloc_ptr, removing a
cleanup.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
Tom Tromey [Thu, 2 Nov 2017 01:11:20 +0000 (19:11 -0600)]
Remove cleanups from linux-tdep.c
This removes some cleanups from linux-tdep.c, replacing them with
def_vector or byte_vector as appropriate.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* linux-tdep.c (linux_core_info_proc_mappings): Use
gdb::def_vector.
(linux_get_siginfo_data): Return gdb::byte_vector. Remove
"size" argument.
(linux_corefile_thread): Update.
(linux_make_corefile_notes): Remove unused variable.
Tom Tromey [Thu, 2 Nov 2017 00:52:30 +0000 (18:52 -0600)]
Use gdb::byte_vector in ppc-linux-tdep.c
This removes a cleanup from ppc-linux-tdep.c, replacing it with
gdb::byte_vector.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* ppc-linux-tdep.c (ppc_linux_get_syscall_number): Use
gdb::byte_vector.
Tom Tromey [Thu, 2 Nov 2017 00:51:15 +0000 (18:51 -0600)]
Remove make_cleanup_free_objfile
This replaces make_cleanup_free_objfile with std::unique_ptr.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* objfiles.c (do_free_objfile_cleanup): Remove.
* compile/compile-object-load.c (compile_object_load): Update.
* objfiles.h (make_cleanup_free_objfile): Remove.
Tom Tromey [Wed, 1 Nov 2017 22:37:27 +0000 (16:37 -0600)]
Use gdb::def_vector in sparc64-tdep.c
This removes a cleanup from sparc64-tdep.c, replacing it with
gdb::def_vector.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* sparc64-tdep.c (do_examine): Use gdb::def_vector.
(adi_read_versions): Change "tags" to "gdb_byte *".
(adi_print_versions): Likewise.
Tom Tromey [Wed, 1 Nov 2017 15:00:09 +0000 (09:00 -0600)]
Replace start_rbreak_breakpoints and end_rbreak_breakpoints
This replaces start_rbreak_breakpoints and end_rbreak_breakpoints with
a new scoped class. This allows the removal of a cleanup.
This also fixes an earlier memory leak regression, by changing
"string" to be a std::string.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* breakpoint.c
(scoped_rbreak_breakpoints::scoped_rbreak_breakpoints): Rename
from start_rbreak_breakpoints.
(scoped_rbreak_breakpoints): Rename from end_rbreak_breakpoints.
* breakpoint.h (class scoped_rbreak_breakpoints): New.
(start_rbreak_breakpoints, end_rbreak_breakpoints): Remove.
* symtab.c (do_end_rbreak_breakpoints): Remove.
(rbreak_command): Use scoped_rbreak_breakpoints, std::string.
Tom Tromey [Wed, 1 Nov 2017 14:32:13 +0000 (08:32 -0600)]
Remove directive-searched cleanups
This removes a few cleanups related to the "searched" field in
struct using_direct, replacing these with scoped_restore.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* cp-namespace.c (reset_directive_searched): Remove.
(cp_lookup_symbol_via_imports): Use scoped_restore.
* cp-support.c (reset_directive_searched): Remove.
(make_symbol_overload_list_using): Use scoped_restore.
* d-namespace.c (d_lookup_symbol_imports): Use scoped_restore.
(reset_directive_searched): Remove.
Tom Tromey [Wed, 25 Oct 2017 21:52:23 +0000 (15:52 -0600)]
Use unique_xmalloc_ptr in find_separate_debug_file_by_debuglink
This changes find_separate_debug_file_by_debuglink to use
unique_xmalloc_ptr, removing some cleanups.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* symfile.c (find_separate_debug_file_by_debuglink): Use
unique_xmalloc_ptr.
Tom Tromey [Wed, 25 Oct 2017 21:46:31 +0000 (15:46 -0600)]
Use std::vector in compile-loc2c.c
This changes compile-loc2c.c to use std::vector, removing some
cleanups.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* compile/compile-loc2c.c (compute_stack_depth_worker): Change
type of "info".
(compute_stack_depth): Likewise.
(do_compile_dwarf_expr_to_c): Use std::vector.
Tom Tromey [Wed, 25 Oct 2017 21:44:56 +0000 (15:44 -0600)]
Remove cleanups from link_callbacks_einfo
This removes a cleanup from link_callbacks_einfo by using std::string.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* compile/compile-object-load.c (link_callbacks_einfo): Use
std::string.
Tom Tromey [Fri, 20 Oct 2017 15:30:48 +0000 (09:30 -0600)]
Replace really_free_pendings with a scoped_ class
This introduces scoped_free_pendings, and changes users of
really_free_pendings to use it instead, removing some clenaups.
I tried to examine the affected code to ensure there aren't dangling
cleanups in the vicinity.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
Use scoped_free_pendings.
* dbxread.c (dbx_symfile_read, dbx_psymtab_to_symtab_1): Use
scoped_free_pendings.
* xcoffread.c (xcoff_psymtab_to_symtab_1): Use scoped_free_pendings.
(xcoff_initial_scan): Likewise.
* buildsym.c (reset_symtab_globals): Update comment.
(scoped_free_pendings): Rename from really_free_pendings.
(prepare_for_building): Update comment.
(buildsym_init): Likewise.
* buildsym.h (class scoped_free_pendings): New class.
(really_free_pendings): Don't declare.
GDB Administrator [Sat, 4 Nov 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Fri, 3 Nov 2017 18:14:56 +0000 (11:14 -0700)]
x86: Remove func_pointer_refcount
Since check_reloc is running after gc_sections, there is no need for
reference count. If a function pointer relocation can be resolved at
run-time, there is no need for PLT and it doesn't count as non-GOT/PLT
relocation. func_pointer_refcount can be removed.
* elf32-i386.c (elf_i386_check_relocs): Set plt.refcount to 1.
Don't use func_pointer_refcount. Don't set plt.refcount nor
non_got_ref for function pointer reference.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Don't use
func_pointer_refcount.
(_bfd_x86_elf_copy_indirect_symbol): Don't copy
func_pointer_refcount.
(_bfd_x86_elf_hide_symbol): Don't use func_pointer_refcount.
* elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): Likewise.
(elf_x86_link_hash_entry): Remove func_pointer_refcount.
Ulrich Weigand [Fri, 3 Nov 2017 15:07:23 +0000 (16:07 +0100)]
Fix regression on ARM after Target FP patches
Commit
edd079d9f6ca2f9ad21322b742269aec5de61190 exposed a pre-existing bug
in convert_doublest_to_floatformat. In the specific case of converting
a zero value to a floatformat using a "special" byteorder (i.e. neither
floatformat_little nor floatformat_big), the output buffer was actually
left uninitialized.
gdb/ChangeLog:
2017-11-03 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (convert_doublest_to_floatformat): Fix uninitialized
output when converting a zero value to a special byteorder format.
claziss [Fri, 3 Nov 2017 14:36:42 +0000 (15:36 +0100)]
[ARC] Force the disassam to use the hexadecimal number for printing
Force printing of the short/signed values using hexadecimal
representation via disassembler option.
opcode/
2017-11-03 Claudiu Zissulescu <claziss@synopsys.com>
* arc-dis.c (print_hex): New variable.
(parse_option): Check for hex option.
(print_insn_arc): Use hexadecimal representation for short
immediate values when requested.
(print_arc_disassembler_options): Add hex option to the list.
binutils/
2017-11-03 Claudiu Zissulescu <claziss@synopsys.com>
* doc/binutils.texi (ARC): Update disassembler options.
* testsuite/binutils-all/arc/hexprint.s: New file.
* testsuite/binutils-all/arc/objdump.exp: Test hex printing feature.
Siddhesh Poyarekar [Fri, 3 Nov 2017 14:03:03 +0000 (19:33 +0530)]
Add option for Qualcomm Saphira part
This adds an option for the Qualcomm saphira core, the corresponding
gcc patch is here:
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg02055.html
This was tested with an aarch64 build and make check and also by
building and running SPEC2006.
gas/
* config/tc-aarch64.c (aarch64_cpus): Add saphira.
* doc/c-aarch64.texi: Likewise.
Nick Clifton [Fri, 3 Nov 2017 13:57:15 +0000 (13:57 +0000)]
Fix integer overflow problems when reading an ELF binary with corrupt augmentation data.
PR 22386
* dwarf.c (read_cie): Use bfd_size_type for
augmentation_data_len.
(display_augmentation_data): New function.
(display_debug_frames): Use it.
Check for integer overflow when testing augmentation_data_len.
claziss [Fri, 3 Nov 2017 13:38:05 +0000 (14:38 +0100)]
[ARC] Sync opcode data base.
New EM and HS variants are developed, sync the data base to match them.
opcodes/
2017-11-03 Claudiu Zissulescu <claziss@synopsys.com>
* arc-tbl.h (abss, abssh, adc, adcs, adds, aslacc, asls, aslsacc)
(asrs, asrsr, cbflyhf0r, cbflyhf1r, cmacchfr, cmacchnfr, cmachfr)
(cmachnfr, cmpychfr, cmpychnfr, cmpyhfmr, cmpyhfr, cmpyhnfr, divf)
(dmachbl, dmachbm, dmachf, dmachfr, dmacwhf, dmpyhbl, dmpyhbm)
(dmpyhf, dmpyhfr, dmpyhwf, dmpywhf, dsync, flagacc, getacc, macdf)
(macf, macfr, macwhfl, macwhflr, macwhfm, macwhfmr, macwhkl)
(macwhkul, macwhl, macwhul, mpydf, mpyf, mpyfr, mpywhfl, mpywhflr)
(mpywhfm, mpywhfmr, mpywhkl, mpywhkul, mpywhl, mpywhul, msubdf)
(msubf, msubfr, msubwhfl, msubwhflr, msubwhfm, msubwhfmr, mul64)
(negs, negsh, normacc, qmachf, qmpyh, qmpyhf, rndh, satf, sath)
(sbcs, setacc, sflag, sqrt, sqrtf, subs, swi_s, vabs2h, vabss2h)
(vadd4b, vadds2, vadds2h, vadds4h, vaddsubs, vaddsubs2h)
(vaddsubs4h, valgn2h, vasl2h, vasls2h, vasr2h, vasrs2h, vasrsr2h)
(vext2bhl, vext2bhlf, vext2bhm, vext2bhmf, vlsr2h, vmac2hf)
(vmac2hfr, vmac2hnfr, vmax2h, vmin2h, vmpy2h, vmpy2hf, vmpy2hfr)
(vmpy2hwf, vmsub2hf, vmsub2hfr, vmsub2hnfr, vneg2h, vnegs2h)
(vnorm2h, vpack2hbl, vpack2hblf, vpack2hbm, vpack2hbmf, vpack2hl)
(vpack2hm, vperm, vrep2hl, vrep2hm, vsext2bhl, vsext2bhm, vsub4b)
(vsubadds, vsubadds2h, vsubadds4h, vsubs2, vsubs2h, vsubs4h):
Changed opcodes.
(prealloc, prefetch*): Place them before ld instruction.
* arc-opc.c (skip_this_opcode): Add ARITH class.
Yao Qi [Fri, 3 Nov 2017 12:53:53 +0000 (12:53 +0000)]
Skip gdb.mi/list-thread-groups-available.exp if no xml support
I see the following test fail in gdb (configured --with-expat=no),
-list-thread-groups --available^M
&"warning: Can not parse XML OS data; XML support was disabled at compile time\n"^M
^error,msg="Can not fetch data now."^M
(gdb) ^M
FAIL: gdb.mi/list-thread-groups-available.exp: list available thread groups (unexpected output)
This patch skips it if XML parsing in GDB is disabled, like what you did
in gdb.mi/mi-info-os.exp.
gdb/testsuite:
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.mi/list-thread-groups-available.exp: Skip it if XML parsing
in GDB is disabled.
Nick Clifton [Fri, 3 Nov 2017 11:55:21 +0000 (11:55 +0000)]
Fix excessive memory allocation attempts and possible integer overfloaws when attempting to read a COFF binary with a corrupt symbol count.
PR 22385
* coffgen.c (_bfd_coff_get_external_symbols): Check for an
overlarge raw syment count.
(coff_get_normalized_symtab): Likewise.
Yao Qi [Fri, 3 Nov 2017 10:36:42 +0000 (10:36 +0000)]
Skip gdb.python/py-thrhandle.exp if python is not enabled.
gdb/testsuite:
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.python/py-thrhandle.exp: Skip it if python is not
enabled.
GDB Administrator [Fri, 3 Nov 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Siddhesh Poyarekar [Thu, 2 Nov 2017 17:19:32 +0000 (22:49 +0530)]
aarch64: Remove AARCH64_FEATURE_F16 from AARCH64_ARCH_V8_2
The FP16 feature is optional in ARMv8.2, so it is wrong to add it to
the default AARCH64_ARCH_V8_2 feature flags. This patch makes the
behaviour consistent with that of gcc, which also does not assume FP16
for ARMv8.2.
include/
* opcode/aarch64.h (AARCH64_ARCH_V8_2): Drop
AARCH64_FEATURE_F16.
Mingi Cho [Thu, 2 Nov 2017 17:01:08 +0000 (17:01 +0000)]
Work around integer overflows when readelf is checking for corrupt ELF notes when run on a 32-bit host.
PR 22384
* readelf.c (print_gnu_property_note): Improve overflow checks so
that they will work on a 32-bit host.
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
Construct readonly regcache without address space
The address space is useless to readonly regcache, so this patch removes
the parameter to construct readonly regcache.
address_space was added in regcache by 6c95b8d, but for read-write
regcache. regcache::aspace is used for various breakpoint/watchpoint
checking, and these regcache are not read-only regcache.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* frame.c (do_frame_register_read): Remove aspace.
* jit.c (jit_frame_sniffer): Likwise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
* regcache.c (regcache::regcache): Pass nullptr.
(regcache_print): Caller updated.
* regcache.h (regcache::regcache): Remove one constructor
parameter aspace.
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
const-fy regcache::m_readonly_p
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* regcache.h (regcache) <m_readonly_p>: Change it to const bool.
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
const-fy regcache::m_aspace
regcache::m_aspace is a const, never changed during the lifetime of
regcache object. The address_space object is a const object too.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* breakpoint.c (insert_single_step_breakpoints): Update.
* frame.c (struct frame_info) <aspace>: Add const.
(frame_save_as_regcache): Add const.
(get_frame_address_space): Return const address_space *.
* frame.h (get_frame_address_space): Update declaration.
* infrun.c (struct step_over_info) <aspace>: Add const.
(set_step_over_info): Make aspace const.
(displaced_step_prepare_throw): Change variable const.
(resume): Likewise.
(proceed): Likewise.
(adjust_pc_after_break): Likewise.
(save_waitstatus): Likewise.
(handle_signal_stop): Likewise.
(keep_going_pass_signal): Likewise.
* jit.c (jit_frame_sniffer): Add const.
* mips-tdep.c (mips_single_step_through_delay): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
* record-full.c (record_full_wait_1): Likewise.
* regcache.c (regcache::regcache): Change parameter to const.
* regcache.h (regcache::regcache): Likewise.
(regcache::aspace): Return const address_space *.
(regcache) <m_aspace>: Add const.
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
s/get_regcache_aspace (regcache)/regcache->aspace ()/g
and remove get_regcache_aspace.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* darwin-nat.c (cancel_breakpoint): Use regcache->aspace ().
* frame.c (create_sentinel_frame): Likewise.
* infrun.c (displaced_step_prepare_throw): Likewise.
(resume): Likewise.
(thread_still_needs_step_over_bp): Likewise.
(proceed): Likewise.
(do_target_wait): Likewise.
(adjust_pc_after_break): Likewise.
(handle_syscall_event): Likewise.
(save_waitstatus): Likewise.
(handle_inferior_event_1): Likewise.
(handle_signal_stop): Likewise.
(keep_going_pass_signal): Likewise.
* linux-nat.c (status_callback): Likewise.
(save_stop_reason): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* record-full.c (record_full_exec_insn): Likewise.
(record_full_wait_1): Likewise.
* regcache.c (get_regcache_aspace): Remove.
* regcache.h (get_regcache_aspace): Remove.
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
Remove regcache_descr::nr_raw_registers
struct regcache_descr has fields nr_raw_registers and gdbarch, and
nr_raw_registers can be got via gdbarch_num_regs (gdbarch), so it looks
nr_raw_registers is redundant. This patch removes it and adds a protected
method num_raw_registers.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* regcache.c (struct regcache_descr) <nr_raw_registers>: Remove.
(init_regcache_descr): Use gdbarch_num_regs.
(regcache::regcache): Likewise.
(regcache::get_register_status): Likewise.
(regcache::assert_raw_regnum): Likewise.
(regcache::cooked_read): Likewise.
(regcache::cooked_read_value): Likewise.
(regcache::cooked_write): Likewise.
(regcache::dump): Likewise.
(regcache::num_raw_registers): New method.
* regcache.h (class regcache) <num_raw_registers>: New.
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
New method regcache::assert_regnum
class regcache has some methods checking the range of register number,
this patch is to move it in a new method assert_regnum.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache::assert_regnum): New method.
(regcache::invalidate): Call assert_regnum.
(regcache::raw_update): Likewise.
(regcache::raw_write): Likewise.
(regcache::raw_read_part): Likewise.
(regcache::raw_write_part): Likewise.
(regcache::raw_supply): Likewise.
(regcache::raw_supply_integer): Likewise.
(regcache::raw_supply_zeroed): Likewise.
(regcache::raw_collect): Likewise.
(regcache::raw_collect_integer): Likewise.
* regcache.h (regcache::assert_regnum): Declare.
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
Remove code wrapped by "#if 0"
These code wrapped by "#if 0" was added by
af030b9a, which added the new
command to dump registers in 2002. The email didn't mention this either
https://sourceware.org/ml/gdb-patches/2002-08/msg00227.html It was there
for 15 years, and nobody needs it, so we can remove it.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache::dump): Remove code.
Yao Qi [Thu, 2 Nov 2017 15:05:12 +0000 (15:05 +0000)]
Remove regcache_descr fields sizeof_raw_register_status and sizeof_cooked_register_status
struct regcache_descr has two fields sizeof_raw_register_status
and sizeof_cooked_register_status, but they equal to nr_cooked_registers
and nr_raw_registers respectively, so this patch removes them.
gdb:
2017-11-02 Yao Qi <yao.qi@linaro.org>
* regcache.c (struct regcache_descr) <sizeof_raw_register_status>:
Remove.
<sizeof_cooked_register_status>: Remove.
(init_regcache_descr): Update.
(regcache::regcache): Use nr_cooked_registers and nr_raw_registers.
(regcache::save): Likewise.
(regcache::dump): Likewise.
Thomas Preud'homme [Thu, 2 Nov 2017 14:16:22 +0000 (14:16 +0000)]
[ARM] Help wince objdump on coproc tests
Object files other than ELF do not have mapping symbols to indicate the
type of data for objdump to work reliably. This is why the following
tests FAIL on arm-wince-pe targets:
ARMv6T2 Thumb CoProcessor Instructions (1)
ARMv6T2 Thumb CoProcessor Instructions (2)
This patch adds the force-thumb disassembler option to objdump for this
test to PASS on these targets as well.
2017-11-02 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-1.d: Add
--disassembler-options=force-thumb to objdump options.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-2.d: Likewise.
James Bowman [Thu, 2 Nov 2017 01:34:25 +0000 (18:34 -0700)]
FT32: support for FT32B processor - part 2/2
FT32B is a new FT32 family member.
This patch adds support for the compressed instructions to gdb and sim.
gdb/ChangeLog:
* ft32-tdep.c (ft32_fetch_instruction): New function.
(ft32_analyze_prologue): Use ft32_fetch_instruction().
sim/ChangeLog:
* ft32/interp.c (step_once): Add ft32 shortcode decoder.
GDB Administrator [Thu, 2 Nov 2017 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
James Bowman [Wed, 1 Nov 2017 15:33:24 +0000 (15:33 +0000)]
FT32B is a new FT32 family member. It has a code compression scheme, which requires the use of linker relaxations. The change is quite large, so submission is in several parts.
Part 2 adds a relaxation pass, which actually implements the code compression scheme.
bfd * archures.c: Add bfd_mach_ft32b.
* cpu-ft32.c: Add arch_info_struct.
* elf32-ft32.c: Add R_FT32_RELAX, SC0, SC1,
DIFF32. (ft32_elf_relocate_section): Add clauses
for R_FT32_SC0, SC1, DIFF32. (ft32_reloc_shortable,
elf32_ft32_is_diff_reloc, elf32_ft32_adjust_diff_reloc_value,
elf32_ft32_adjust_reloc_if_spans_insn,
elf32_ft32_relax_delete_bytes, elf32_ft32_relax_is_branch_target,
ft32_elf_relax_section): New function.
* reloc.c: Add BFD_RELOC_FT32_RELAX, SC0, SC1, DIFF32.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
gas * config/tc-ft32.c (md_assemble): add relaxation reloc
BFD_RELOC_FT32_RELAX. (md_longopts): Add "norelax" and
"no-relax". (md_apply_fix): Add reloc BFD_RELOC_FT32_DIFF32.
(relaxable_section, ft32_validate_fix_sub, ft32_force_relocation,
ft32_allow_local_subtract): New function.
* config/tc-ft32.h: remove unused MD_PCREL_FROM_SECTION.
* testsuite/gas/ft32/insnsc.s: New test exercising all FT32B
shortcodes.
include * elf/ft32.h: Add R_FT32_RELAX, SC0, SC1, DIFF32.
Nick Clifton [Wed, 1 Nov 2017 15:21:46 +0000 (15:21 +0000)]
Prevent illegal memory accesses when attempting to read excessively large COFF line number tables.
PR 22376
* coffcode.h (coff_slurp_line_table): Check for an excessively
large line number count.
Nick Clifton [Wed, 1 Nov 2017 12:37:33 +0000 (12:37 +0000)]
Update check for invalid values in pe_bfd_read_buildid function.
PR 22373
* peicode.h (pe_bfd_read_buildid): Revise check for invalid size
and offset in light of further possible bogus values.
Nick Clifton [Wed, 1 Nov 2017 11:35:42 +0000 (11:35 +0000)]
Fix an invalid free called when attempting to link a COFF object against an ELF archive with --no-keep-memory enabled.
PR 22369
* coffgen.c (_bfd_coff_free_symbols): Fail if called on a non-COFF
file.
* cofflink.c (coff_link_check_archive_element): Skip non-COFF
members of an archive.
Thomas Preud'homme [Wed, 1 Nov 2017 09:49:13 +0000 (09:49 +0000)]
[ARM] Fix Coprocessor instructions availability
A few coprocessor instructions introduced in ARMv2 are currently
accepted by GAS when targeting ARMv1 due to a typo in the code. This
patch fixes the issue and introduce a more fine grained testing for
coprocessor instructions availability. Coprocessor instructions are
grouped as follows:
* ARM coprocessor instructions introduced in ARMv2
Includes: ldc, stc, mcr, mrc, cdp, ldcl, stcl
Guarded by: ARM_EXT_V2
Tests: copro-arm_v2plus-arm_v*.d
* ARM coprocessor instructions introduced in ARMv5
Includes: ldc2, ldc2l, stc2, stc2l, cdp2, mcr2, mrc2
Guarded by: ARM_EXT_V5
Tests: copro-arm_v5plus-arm_v*.d
* ARM coprocessor instructions introduced in ARMv5TE
Includes: mcrr, mrrc
Guarded by: ARM_EXT_V5E
Tests: copro-arm_v5teplus-arm_v*.d
* ARM coprocessor instructions introduced in ARMv6
Includes: mcrr2, mrrc2
Guarded by: ARM_EXT_V6
Tests: copro-arm_v6plus-arm_v*.d
* Thumb coprocessor instructions introduced in ARMv6T2
Includes: ldc, ldcl, stc, stcl, mcr, mrc, mcrr, mrrc, cdp, ldc2,
ldc2l, stc2, stc2l, cdp2, mcr2, mrc2, mcrr2, mrrc2
Guarded by: ARM_EXT_V6T2
Tests: copro-thumb_v6t2plus-thumb_v*.d
For each of these groups, at least 2 tests are performed:
* instructions are not available in earlier architecture
* instructions are available in architecture where they were introduced
More tests need to be performed when instructions in a group span
several assembly files.
Note that an instruction in the original coprocessor testcase is
changed to unified syntax to allow the testcase to be assembled for ARM
and Thumb state. Correct processing of legacy syntax is covered in other
testcases.
2017-11-01 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (arm_ext_v2): Define to ARM_EXT_V2 feature bit.
* testsuite/gas/arm/copro.s: Split into ...
* testsuite/gas/arm/copro-arm_v2plus-thumb_v6t2plus.s: This while
changing it to unified syntax and ...
* testsuite/gas/arm/copro-arm_v5plus-thumb_v6t2plus.s: this and ...
* testsuite/gas/arm/copro-arm_v5teplus-thumb_v6t2plus.s: This and ...
* testsuite/gas/arm/copro-arm_v6plus-thumb_v6t2plus.s: This.
* testsuite/gas/arm/copro.d: Split into ...
* testsuite/gas/arm/copro-arm_v2plus-arm_v2.d: This but target ARMv2
and ...
* testsuite/gas/arm/copro-arm_v5plus-arm_v5.d: this but target ARMv5
and ...
* testsuite/gas/arm/copro-arm_v5teplus-arm_v5te.d: This but target
ARMv5TE and ...
* testsuite/gas/arm/copro-arm_v6plus-arm_v6.d: This but target ARMv6.
* testsuite/gas/arm/copro-arm_v2plus-arm_v1.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-1.d: New testcase.
* testsuite/gas/arm/copro-arm_v2plus-thumb_v6t2plus-unavail.l: Expected
errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-1.d: New testcase.
* testsuite/gas/arm/copro-arm_v5plus-arm_v4.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-2.d: New testcase.
* testsuite/gas/arm/copro-arm_v5plus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-2.d: New testcase.
* testsuite/gas/arm/copro-arm_v5teplus-arm_v5.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-3.d: New testcase.
* testsuite/gas/arm/copro-arm_v5teplus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-3.d: New testcase.
* testsuite/gas/arm/copro-arm_v6plus-arm_v5te.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-4.d: New testcase.
* testsuite/gas/arm/copro-arm_v6plus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-4.d: New testcase.
Alan Modra [Tue, 31 Oct 2017 11:43:21 +0000 (22:13 +1030)]
PR22374, PowerPC unnecessary PLT entries
We don't need a PLT entry when function pointer initialization in a
read/write section is the only reference to a given function symbol.
This patch prevents the unnecessary PLT entry, and ensures no dynamic
relocs are emitted when UNDEFWEAK_NO_DYNAMIC_RELOC says so.
bfd/
PR 22374
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't create a plt
entry when just a dynamic reloc can serve. Ensure no dynamic
relocations when UNDEFWEAK_NO_DYNAMIC_RELOC by setting non_got_ref.
Expand and move the non_got_ref comment.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
ld/
* testsuite/ld-powerpc/ambiguousv2.d: Remove FIXME.
Alan Modra [Tue, 31 Oct 2017 00:43:30 +0000 (11:13 +1030)]
PR22374 testcase, function pointer references in .data
Function pointer references in .data ought to use a dynamic reloc.
There shouldn't be any need for a PLT entry and definitely no copy
reloc.
This test fails on quite a few targets, but isn't something that
anyone should worry about too much. It's really just a missed
optimization.
PR 22374
* testsuite/ld-elf/pr22374a.s,
* testsuite/ld-elf/pr22374b.s,
* testsuite/ld-elf/pr22374-1.r,
* testsuite/ld-elf/pr22374-2.r: New test.
* testsuite/ld-elf/elf.exp: Run it.
Alan Modra [Tue, 31 Oct 2017 07:49:21 +0000 (18:19 +1030)]
Tidy elf.exp
* testsuite/ld-elf/elf.exp: Merge some conditionals, a better
name than "shared library for next test", and use xfail arg
of run_ld_link_tests in a few places.
Simon Marchi [Wed, 1 Nov 2017 01:30:24 +0000 (21:30 -0400)]
Use console uiout when executing breakpoint commands
As reported here
https://sourceware.org/ml/gdb/2017-10/msg00020.html
the output of certain commands, like backtrace, doesn't appear anywhere
when it is run as a breakpoint command and when using MI.
The reason is that the current_uiout is set to the mi_ui_out while these
commands run, whereas we want the output as CLI output. Some commands
like "print" work, because they use printf_filtered (gdb_stdout, ...)
directly, bypassing the current ui_out.
The fix I did is to force setting the cli_uiout as the current_uiout
when calling execute_control_command. I am not sure if this is the
right way to fix the problem, comments about the approach would be
appreciated.
I enhanced gdb.mi/mi-break.exp to test the backtrace command.
Regtested on the buildbot.
gdb/ChangeLog:
* cli/cli-script.c (execute_control_command): Rename to ...
(execute_control_command_1): ... this.
(execute_control_command): New function.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-break.exp (test_breakpoint_commands): Test backtrace
as a breakpoint command.
GDB Administrator [Wed, 1 Nov 2017 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 31 Oct 2017 18:29:25 +0000 (14:29 -0400)]
tracepoint: Remove unnecessary const_cast
We are passing a const char * to a const char * parameter, the
const_cast is not necessary.
gdb/ChangeLog:
* tracepoint.c (tfind_command): Remove const_cast.
Nick Clifton [Tue, 31 Oct 2017 14:29:40 +0000 (14:29 +0000)]
Fix illegal memory access triggered when parsing a PE binary with a corrupt data dictionary.
PR 22373
* peicode.h (pe_bfd_read_buildid): Check for invalid size and data
offset values.
Nick Clifton [Tue, 31 Oct 2017 13:48:03 +0000 (13:48 +0000)]
Remind users to use the --use-dynamic command line option to dump dynamic relocations.
* readelf.c (process_relocs): Tell users if no static relocs were
found, but if they had added --use-dynamic to the command line
then relocs would have been displayed.
Mike Gulick [Tue, 31 Oct 2017 00:11:52 +0000 (20:11 -0400)]
gdb/Makefile.in: fix 'make tags' failure
'make tags' fails with the following error:
make[2]: Entering directory '/local-ssd/mgulick/gdb/git/binutils-gdb/gdb'
make[2]: *** No rule to make target 'gdb.h', needed by 'TAGS'. Stop.
make[2]: Leaving directory '/local-ssd/mgulick/gdb/git/binutils-gdb/gdb'
The file gdb/gdb.h was removed in commit
65630365f7d073430e62b4fe65f34dcdc0a4b05e.
gdb/ChangeLog:
2017-10-30 Mike Gulick <mgulick@mathworks.com>
* Makefile.in (HFILES_NO_SRCDIR): Remove reference to gdb.h.
GDB Administrator [Tue, 31 Oct 2017 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 30 Oct 2017 18:27:30 +0000 (14:27 -0400)]
Introduce in_inclusive_range, fix -Wtautological-compare warnings
When compiling with clang or gcc 8, we see warnings like this:
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:10013:13: error: comparison of 0 <= unsigned expression is always true [-Werror,-Wtautological-compare]
if (0 <= insn_op1 && 3 >= insn_op1)
~ ^ ~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:11722:20: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]
else if (opB >= 0 && opB <= 2)
~~~ ^ ~
This is because an unsigned integer (opB in this case) will always be >=
0. It is still useful to keep both bounds of the range in the
expression, even if one is at the edge of the data type range. This
patch introduces a utility function in_inclusive_range that gets rid of
the warning while conveying that we are checking for a range.
Tested by rebuilding.
gdb/ChangeLog:
* common/common-utils.h (in_inclusive_range): New function.
* arm-tdep.c (arm_record_extension_space): Use
in_inclusive_range.
(thumb_record_ld_st_reg_offset): Use in_inclusive_range.
* cris-tdep.c (cris_spec_reg_applicable): Use
in_inclusive_range.
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
remote.c, QCatchSyscalls: Build std::string instead of unique_xmalloc_ptr
Simplify the code a little bit using std::string + string_appendf.
gdb/ChangeLog:
2017-10-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* remote.c (remote_set_syscall_catchpoint): Build a std::string
instead of a gdb::unique_xmalloc_ptr, using string_appendf.
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
Introduce string_appendf/string_vappendf
string_appendf is like string_printf, but instead of allocating a new
string, it appends to an existing string. This allows reusing a
std::string's memory buffer across several calls, for example.
gdb/ChangeLog:
2017-10-30 Pedro Alves <palves@redhat.com>
* common/common-utils.c (string_appendf, string_vappendf): New
functions.
* common/common-utils.h (string_appendf, string_vappendf): New
declarations.
* unittests/common-utils-selftests.c (string_appendf_func)
(test_appendf_func, string_vappendf_wrapper, string_appendf_tests)
(string_vappendf_tests): New functions.
(_initialize_common_utils_selftests): Register "string_appendf" and
"string_vappendf tests".
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
Merge/shared string_printf and string_vprintf unit tests
Merge the string_printf and string_vprintf tests, running them all
against both functions.
gdb/ChangeLog:
2017-10-30 Pedro Alves <palves@redhat.com>
* unittests/common-utils-selftests.c (format_func): New typedef.
(string_printf_tests, string_vprintf_tests): Tests factored out
and merged to ...
(test_format_func): ... this new function.
(string_printf_tests, string_vprintf_tests): Reimplement on top of
test_format_func.
Simon Marchi [Mon, 30 Oct 2017 02:37:11 +0000 (22:37 -0400)]
darwin-nat: Remove gdb.h include
gdb.h has been removed in
Eliminate catch_exceptions/catch_exceptions_with_msg
65630365f7d073430e62b4fe65f34dcdc0a4b05e
Remove the include in darwin-nat.c. Tested by rebuilding.
gdb/ChangeLog:
* darwin-nat.c: Remove include of gdb.h.
Alan Modra [Mon, 30 Oct 2017 01:32:42 +0000 (12:02 +1030)]
frv-elf --gc-sections failures
git commit
81742b83e9 exposed an frv-elf bug, with the object id not
matching the hash table id.
* elf32-frv.c (ELF_TARGET_ID): Don't define for generic
elf target.
Alan Modra [Sun, 29 Oct 2017 23:50:29 +0000 (10:20 +1030)]
relocs_compatible test for gc-sections
I noticed when looking at pr22300 that before calling check_relocs we
have an elf_object_id test (added for pr11933) as well as the
relocs_compatible test. I believe backend gc_mark_hook and
gc_sweep_hook ought to be protected similarly from being confused by
unexpected relocations (for example, both elf64-ppc.c and elf32-ppc.c
use _bfd_elf_relocs_compatible, so I think it would be possible for
the ppc64 gc_mark_hook to be presented with a ppc32 relocatable
object).
* elflink.c (elf_gc_sweep): Test elf_object_id in addition to
relocs_compatible.
(bfd_elf_gc_sections): Likewise.
Alan Modra [Fri, 27 Oct 2017 04:34:25 +0000 (15:04 +1030)]
Fix hppa-linux pr22269-1 fail
Adds UNDEFWEAK_NO_DYNAMIC_RELOC in the rest of places needed in this
file, reduces dynamic relocations in a number of cases, and removes
some bogus code that was attempting to handle dynamic common symbols
specially.
PR 22269
* elf32-hppa.c (elf32_hppa_check_relocs): Move SEC_ALLOC test to
ensure non_got_ref is not set due to debug references.
(elf32_hppa_adjust_dynamic_symbol): Tidy plabel handling. Use
SYMBOL_CALLS_LOCAL and UNDEFWEAK_NO_DYNAMIC_RELOC when determining
need for a plt entry.
(allocate_dynrelocs): Similarly for got entries. Tidy code discarding
dynamic relocs when pic. Remove bogus code attempting to handle
commons.
(elf32_hppa_relocate_section): Similarly. Delete resolved_to_zero
and simplify.
(elf32_hppa_finish_dynamic_symbol): Use UNDEFWEAK_NO_DYNAMIC_RELOC
and SYMBOL_REFERENCES_LOCAL in GOT handling.
GDB Administrator [Mon, 30 Oct 2017 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sun, 29 Oct 2017 17:01:19 +0000 (13:01 -0400)]
xtensa-xtregs: Fix formatting issues
Fix a few formatting issues in that file.
gdb/ChangeLog:
* xtensa-xtregs.c: Fix formatting issues.
Simon Marchi [Sun, 29 Oct 2017 05:13:33 +0000 (01:13 -0400)]
xtensa-xtregs: Constify field
Fix:
In file included from /home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c:46:0:
/home/emaisin/src/binutils-gdb/gdb/xtensa-xtregs.c:37:1: error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
};
^
gdb/ChangeLog:
* xtensa-xtregs.c (xtensa_regtable_t) <name>: Constify.
GDB Administrator [Sun, 29 Oct 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Maksim Dzabraev [Sat, 28 Oct 2017 18:14:34 +0000 (01:14 +0700)]
Make gdb.selected_thread().inferior return a new reference
thpy_get_inferior function should return a new reference to the
existing inferior object, and therefore should increment its refcount.
Fixed bug looks like this.
If multiple time call gdb.selected_thread ().inferior, gdb throws exception:
(gdb) pi gdb.selected_thread().inferior
<gdb.Inferior object at 0x7f1952bea698>
(gdb) pi gdb.selected_thread().inferior
Python Exception <type 'exceptions.AttributeError'> 'NoneType' object
has no attribute 'inferior':
Error while executing Python code.
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in
Alan Modra [Sat, 28 Oct 2017 11:01:16 +0000 (21:31 +1030)]
PR22361 readelf buffer overflow on fuzzed archive header
PR 22361
* readelf.c (process_archive_index_and_symbols): Ensure ar_size
field is zero terminated for strtoul.
(setup_archive, get_archive_member_name): Likewise.
Alan Modra [Sat, 28 Oct 2017 03:40:55 +0000 (14:10 +1030)]
PR22300, Abort in elf32_hppa_relocate_section building polyml
polyml produces object files with the wrong OS/ABI for hppa-linux.
This, along with the fact that elf32-hppa.c is using the strictest
backend relocs_compatible, results in wrong merging of ELF symbols.
So, remove the relocs_compatible check in _bfd_elf_merge_symbol.
_bfd_elf_merge_symbol is only called nowadays from within blocks
protected by is_elf_hash_table, so "we are doing an ELF link" as the
removed comment says, is true.
Also relax relocs_compatible for hppa and powerpc. relocs_compatible
is used for more than just merging symbols, as the name suggests.
This allows objects that are in fact reasonably compatible to be
linked.
PR 22300
* elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check.
* elf32-hppa.c (elf_backend_relocs_compatible): Define.
* elf32-ppc.c (elf_backend_relocs_compatible): Define.
* elf64-ppc.c (elf_backend_relocs_compatible): Define.
Simon Marchi [Sat, 28 Oct 2017 03:44:12 +0000 (23:44 -0400)]
Remove find_inferior usage for thread_search
Replace it with for_each_thread. While at it, we can inline the
callback code. One little change is that I am using the
prev_general_thread variable instead of current_gen_ptid, since they
should have the same value.
gdb/gdbserver/ChangeLog:
* target.c (struct thread_search): Remove.
(thread_search_callback): Remove.
(prepare_to_access_memory): Use for_each_thread instead of
find_inferior. Inline code from thread_search_callback.
Simon Marchi [Sat, 28 Oct 2017 03:43:11 +0000 (23:43 -0400)]
Remove usage of find_inferior in resume
Change find_inferior with find_thread. Since we can now pass arguments
directly instead of through a void pointer, we don't need the
visit_actioned_threads_data structure anymore.
gdb/gdbserver/ChangeLog:
* server.c (struct visit_actioned_threads_data): Remove.
(visit_actioned_threads): Change prototype to take arguments
directly.
(resume): Use find_thread instead of find_inferior.
Simon Marchi [Sat, 28 Oct 2017 03:41:49 +0000 (23:41 -0400)]
Remove usages of find_inferior in handle_status
Replace one with find_thread, the other with for_each_thread.
gdb/gdbserver/ChangeLog:
* server.c (queue_stop_reply_callback): Change prototype, return
void.
(find_status_pending_thread_callback): Remove.
(handle_status): Replace find_inferior with find_thread and
for_each_thread.
Simon Marchi [Sat, 28 Oct 2017 03:36:19 +0000 (23:36 -0400)]
common-utils-selftests.c: Add ATTRIBUTE_PRINTF
Fix this, when building with clang:
/home/emaisin/src/binutils-gdb/gdb/unittests/common-utils-selftests.c:50:40: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
std::string result = string_vprintf (fmt, vp);
^~~
gdb/ChangeLog:
* unittests/common-utils-selftests.c (format): Add
ATTRIBUTE_PRINTF.
Simon Marchi [Sat, 28 Oct 2017 02:23:33 +0000 (22:23 -0400)]
C++ify xml-syscall.c
This patch C++ifies the structures in xml-syscall.c, by using
std::vector instead of VEC, and std::string instead of char*.
Using a unique_ptr in syscall_parse_xml allows to remove a cleanup.
Something that seems strange with the existing code, if you look at
syscalls_info_free_syscalls_desc and
syscalls_info_free_syscall_group_desc, they free the structure elements
(the strings and vectors), but they don't free the syscall_desc and
syscall_group_desc structure themselves. I don't see anything freeing
those currently. Any idea why? According to the comment above
syscalls_info_free_syscall_group_desc, it kinda looks like it's on
purpose. With this patch, those structures are deleted when the vector
that contains them gets deleted.
The only time I'm aware a syscalls_info structure gets deleted is in the
case the data directory changes during runtime, in init_syscalls_info.
If tried that use case (including under valgrind):
(gdb) catch syscall
(gdb) set data-directory another-data-directory
(gdb) catch syscall
I confirmed that the syscalls_info structure got deleted and recreated,
and everything seemed fine.
Regtested on the buildbot.
gdb/ChangeLog:
* xml-syscall.c (struct syscall_desc): Add constructor.
<name>: Change type to std::string.
(syscall_desc_up): New typedef.
(syscall_desc_p): Remove typeder.
(DEF_VEC_P(syscall_desc_p)): Remove.
(struct syscall_group_desc): Add constructor.
<name>: Change type to std::string.
<syscalls>: Change type to std::vector.
(syscall_group_desc_up): New typedef.
(syscall_group_desc_p): Remove typedef.
(DEF_VEC_P(syscall_group_desc_p)): Remove.
(struct syscalls_info) <syscalls>: Change type to std::vector of
unique_ptr.
<groups>: Likewise.
<my_gdb_datadir>: Change type to std::string.
(syscalls_info_up): New typedef.
(allocate_syscalls_info): Remove.
(syscalls_info_free_syscalls_desc): Remove.
(syscalls_info_free_syscall_group_desc): Remove.
(free_syscalls_info): Remove.
(make_cleanup_free_syscalls_info): Remove.
(syscall_group_create_syscall_group_desc): Adjust.
(syscall_group_add_syscall): Adjust.
(syscall_create_syscall_desc): Adjust.
(syscall_parse_xml): Adjust, use unique_ptr instead of cleanup.
(init_syscalls_info): Adjust.
(syscall_group_get_group_by_name): Adjust.
(xml_get_syscall_number): Adjust.
(xml_get_syscall_name): Adjust.
(xml_list_of_syscalls): Adjust.
(xml_list_syscalls_by_group): Adjust.
(xml_list_of_groups): Adjust.
Simon Marchi [Sat, 28 Oct 2017 02:05:42 +0000 (22:05 -0400)]
Get rid of VEC(probe_p)
Replace the remaining usages of VEC(probe_p) with std::vector.
Regtested on the buildbot.
gdb/ChangeLog:
* probe.h: Don't include gdb_vecs.h.
(DEF_VEC_P (probe_p)): Remove.
(find_probes_in_objfile): Return an std::vector.
* probe.c (find_probes_in_objfile): Likewise.
* breakpoint.c (breakpoint_objfile_data)
<longjmp_probes>: Change type to std::vector.
<exception_probes>: Likewise.
(free_breakpoint_probes): Don't manually free vectors.
(create_longjmp_master_breakpoint): Adjust.
(create_exception_master_breakpoint): Adjust.
* solib-svr4.c (svr4_create_probe_breakpoints): Change
parameter type, adjust.
(svr4_create_solib_event_breakpoints): Adjust.
Simon Marchi [Sat, 28 Oct 2017 02:01:21 +0000 (22:01 -0400)]
Allocate breakpoint_objfile_data with new
Allocate with new and free with delete. This allows using an
std::vector in the following patch.
I renamed free_breakpoint_probes to free_breakpoint_objfile_data,
because it now doesn't only free the probes vector, but also the
breakpoint_objfile_data structure itself.
gdb/ChangeLog:
* breakpoint.c (breakpoint_objfile_data): Initialize fields.
(get_breakpoint_objfile_data): Allocate breakpoint_objfile_data
with new.
(free_breakpoint_probes): Rename to ...
(free_breakpoint_objfile_data): ... this, and call delete on
bp_objfile_data..
Simon Marchi [Sat, 28 Oct 2017 01:55:42 +0000 (21:55 -0400)]
Get rid of VEC(loaded_script_ptr)
Direct replacement with std::vector. This allows removing a cleanup as
well.
Regtested on the buildbot.
gdb/ChangeLog:
* auto-load.c: Don't include gdb_vecs.h, include algorithm.
(loaded_script_ptr): Remove typedef.
(DEF_VEC_P (loaded_script_ptr)): Remove.
(struct collect_matching_scripts_data): Add constructor.
<scripts_p>: Change type to (pointer to) std::vector.
(collect_matching_scripts_data): Adjust.
(sort_scripts_by_name): Make suitable for std::sort.
(print_scripts): Don't sort vector, adjust to std::vector.
(auto_load_info_scripts): Sort vectors, adjust to std::vector.
Simon Marchi [Sat, 28 Oct 2017 01:47:30 +0000 (21:47 -0400)]
Get rid of VEC(filename_language)
This patch removes VEC(filename_language), replacing its usage with
std::vector. filename_language::ext is changed to an std::string at the
same time.
Regtested on the buildbot.
gdb/ChangeLog:
* symfile.c (filename_language): Make struct, not typedef. Add
constructor.
<ext>: Change type to std::string.
(DEF_VEC_O (filename_language)): Remove.
(filename_language_table): Change type to std::vector.
(add_filename_language): Adjust.
(set_ext_lang_command): Adjust.
(info_ext_lang_command): Adjust.
(deduce_language_from_filename): Adjust.
(class scoped_restore_filename_language_table): Remove.
(test_filename_language): Use scoped_restore.
(test_set_ext_lang_command): Use scoped_restore, adjust to
std::vector change.
Simon Marchi [Sat, 28 Oct 2017 01:46:49 +0000 (21:46 -0400)]
Add tests for filename_language
The next patch touches the filename_language area, but I noticed there
is no test exercising that. This patch adds some selftests for
add_filename_language, deduce_language_from_filename and
set_ext_lang_command. Because these tests add entries to the global
filename_language_table vector, it is not possible to run them
successfully multiple times in a same GDB instance. They can
potentially interfere with each other for the same reason. I therefore
added the scoped_restore_filename_language_table class that is used to
make sure tests leave that global vector in the same state they found it
(it is replaced in the following patch by a simple scoped_restore).
gdb/ChangeLog:
* symfile.c: Include selftest.h.
(class scoped_restore_filename_language_table): New.
(test_filename_language): New test.
(test_set_ext_lang_command): New test.
(_initialize_symfile): Register tests.
GDB Administrator [Sat, 28 Oct 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
Keith Seitz [Fri, 27 Oct 2017 17:57:23 +0000 (10:57 -0700)]
Use SaL symbol name when reporting breakpoint locations
Currently, "info break" can show some (perhaps) unexpected results when
setting a breakpoint on an inlined function:
(gdb) list
1 #include <stdio.h>
2
3 static inline void foo()
4 {
5 printf("Hello world\n");
6 }
7
8 int main()
9 {
10 foo();
11 return 0;
12 }
13
(gdb) b foo
Breakpoint 1 at 0x400434: file foo.c, line 5.
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400434 in main at foo.c:5
GDB reported that we understood what "foo" was, but we then report that the
breakpoint is actually set in main. While that is literally true, we can
do a little better.
This is accomplished by copying the symbol for which the breakpoint was set
into the bp_location. From there, print_breakpoint_location can use this
information to print out symbol information (if available) instead of calling
find_pc_sect_function.
With the patch installed,
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400434 in foo at foo.c:5
gdb/ChangeLog:
* breakpoint.c (print_breakpoint_location): Use the symbol saved
in the bp_location, falling back to find_pc_sect_function when
needed.
(add_location_to_breakpoint): Save sal->symbol.
* breakpoint.h (struct bp_location) <symbol>: New field.
* symtab.c (find_function_start_sal): Save the symbol into the SaL.
* symtab.h (struct symtab_and_line) <symbol>: New field.
gdb/testsuite/ChangeLog:
* gdb.opt/inline-break.exp (break_info_1): New procedure.
Test "info break" for every inlined function breakpoint.
Yao Qi [Fri, 27 Oct 2017 14:29:24 +0000 (15:29 +0100)]
[AArch64] Mark LR clobbered by BL in inline asm
LR is a caller-save register, so, if inline asm does BL (which touches
LR), we should mark LR clobbered.
gdb/testsuite:
2017-10-27 Yao Qi <yao.qi@linaro.org>
* gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.
Simon Marchi [Fri, 27 Oct 2017 13:01:36 +0000 (09:01 -0400)]
dwarf: Read register number as unsigned in DW_CFA_def_cfa*
When displaying the .debug_frame section, the register numbers in the
DW_CFA_def_cfa* statements are read as signed numbers. I have come
across a target that has register 121, encoded as 0x79 in unsigned LEB128.
Interpreting this as signed results in -7, which makes readelf display
"r-7".
The DWARF5 standard (6.4.2.2) states that the register numbers should be
treated as unsigned LEB128.
Simply replacing READ_SLEB with READ_ULEB resulted in warnings like
these:
/home/emaisin/src/binutils-gdb/binutils/dwarf.c: In function ‘display_debug_frames’:
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:355:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if ((var) != _val) \
^
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:7866:8: note: in expansion of macro ‘READ_ULEB’
READ_ULEB (fc->cfa_reg);
^
... so I also changed Frame_Chunk::cfa_reg to an unsigned int.
binutils/ChangeLog:
* dwarf.c (struct Frame_Chunk) <cfa_reg>: Change type to
unsigned int.
(display_debug_frames): Read CFA reg as an unsigned number.
Simon Marchi [Fri, 27 Oct 2017 12:57:10 +0000 (08:57 -0400)]
Add PR mention to previous commit
Patrick Frants [Fri, 27 Oct 2017 02:26:08 +0000 (22:26 -0400)]
Fix broken recursion detection when printing static members
Recursion detection for static members was broken. The implementation
uses a growing (and shrinking) obstack object to simulate a stack of
addresses (CORE_ADDR). Pushing addresses is implemented by calling
obstack_grow(), while popping is implemented by calling obstack_free().
The latter is problematic because obstack_free() expects a pointer to
the base of an object. When popping elements of the stack however,
obstack_free() was called with the new top, which potentially is not the
same as the base of the stack. This is unintended use and the effect is
that obstack->next_free and obstack->object_base members are assigned
the value of the new top, which equals an empty stack. Summary: popping
elements would always result in an empty stack, which breaks the
recursion detection.
The fix shrinks the stack using obstack_blank_fast() with a negative
value as described at the bottom of this page:
https://gcc.gnu.org/onlinedocs/libiberty/Extra-Fast-Growing.html "You
can use obstack_blank_fast with a “negative” size argument to make the
current object smaller. Just don’t try to shrink it beyond zero
length—there’s no telling what will happen if you do that. Earlier
versions of obstacks allowed you to use obstack_blank to shrink objects.
This will no longer work."
The reproducer is added to gdb.cp/classes.exp, which fails without this
patch.
gdb/ChangeLog:
* cp-valprint.c (cp_print_value_fields): Use obstack_blank_fast
to rewind obstack.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.exp (test_static_members): Test printing
Outer::instance.
* gdb.cp/classes.c (struct Inner, struct Outer): New.
(Inner::instance, Outer::instance): New.