Commit Graph

92532 Commits

Author SHA1 Message Date
Simon Marchi 41bd68f52c Show optimized out local variables in "info locals"
Currently, optimized out variables are not shown when doing "info
locals".  Some users found that confusing, thinking GDB forgot to print
their variable.  This patch adds them to the "info locals" output.  I
added a test in gdb.dwarf2 to test for that behavior.  I think doing a
synthetic DWARF test is the easiest way to have an optimized out local
variable for sure.

However, this change reveals what I think is a bug in GDB, see:

http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2017-September/004394.html

This patch marks the tests in inline-locals.exp that start failing as
KFAIL.  I'd like to tackle this bug eventually, but I don't have the
time right now.  I think it's still better to show an extra erroneous
entry than to not show the optimized out variables at all.  I haven't
created a bug in bugzilla yet, but if we agree it's indeed a bug,  I'll
create one and update the setup_kfail lines with the actual bug number
before pushing.

gdb/ChangeLog:

	* stack.c (iterate_over_block_locals): Add LOC_OPTIMIZED_OUT
	case in switch.

gdb/testsuite/ChangeLog:

	* gdb.opt/inline-locals.exp: Mark tests as KFAIL.
	* gdb.dwarf2/info-locals-optimized-out.exp: New file.
	* gdb.dwarf2/info-locals-optimized-out.c: New file.
2017-11-22 15:51:44 -05:00
Simon Marchi 7e2fd2f47b Remove DEF_VEC_P (varobj_p)
The last patch removed the last usage of this type, so we can remove it.

gdb/ChangeLog:

	* varobj.h (DEF_VEC_P (varobj_p)): Remove.
2017-11-22 15:08:07 -05:00
Simon Marchi 0604393c22 Replace VEC (varobj_update_result) with std::vector
This patch replaces makes varobj_update return an std::vector, and
updates the fallouts.

To make that easier, the varobj_update_result is c++ified a bit.  I
added a constructor and initialized its fields in-class.  The newobj
vector is also made an std::vector, so that it's automatically freed
when varobj_update_result is destroyed and handled correctly by the
default move constructor.  I disabled copy constructor and assignment
for that structure, because normally it never needs to be copied, only
moved.

As a result, the newobj parameter of update_dynamic_varobj_children must
be changed to an std::vector.  The patch converts the other vector
parameters of update_dynamic_varobj_children to std::vector.  It's not
strictly necessary to do it in the same patch, but I think it makes
sense to do it.

gdb/ChangeLog:

	* varobj.h (struct varobj_update_result): Add constructor, add
	move constructor, disable copy and assign, initialize fields.
	<newobj>: Change type to std::vector.
	(varobj_update): Return std::vector.
	* varobj.c (install_dynamic_child): Change VEC parameters to
	std::vector and adjust.
	(update_dynamic_varobj_children): Likewise.
	(varobj_update): Return std::vector and adjust.
	* mi/mi-cmd-var.c (varobj_update_one): Adjust to vector changes.
2017-11-22 15:08:06 -05:00
Simon Marchi ddf0ea085b Make varobj::children an std::vector
This patch makes the children field of varobj an std::vector, and
updates the fallout.

One note is that varobj::parent must be made non-const.  The reason is
that when a child deletes itself, it modifies its writes NULL to its
slot in its parent's children vector.  With the VEC, the const didn't
made the parent's children vector content const, only the pointer to it,
but with std::vector, even the content is.

gdb/ChangeLog:

	* varobj.h (struct varobj) <parent>: Remove const.
	<children>: Change type to std::vector.
	(varobj_list_children): Return std::vector const reference.
	(varobj_restrict_range): Change parameter type to std::vector
	const reference.
	* varobj.c (varobj_has_more): Adjust.
	(varobj_restrict_range): Change parameter type to std::vector
	const reference and adjust.
	(install_dynamic_child): Adjust.
	(update_dynamic_varobj_children): Adjust.
	(varobj_list_children): Return std::vector const reference and
	adjust.
	(varobj_add_child): Adjust.
	(update_type_if_necessary): Adjust.
	(varobj_update): Adjust.
	(delete_variable_1): Adjust.
	* ada-varobj.c (ada_value_has_mutated): Adjust.
	* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust.
2017-11-22 15:08:06 -05:00
Simon Marchi 9e5b9d2b29 Basic c++ification of varobj
This patch does a basic c++ification or the varobj data structure.

  - varobj: add constructor and destructor, initialize fields
  - varobj_root: initialize fields
  - varobj_dynamic: initialize fields

This allows getting rid of new_variable, new_root_variable.
free_variable essentially becomes varobj's destructor.  This also allows
getting rid of a cleanup, make_cleanup_free_variable, which was only
used in varobj_create in case the varobj creation fails.  It is replaced
with a unique_ptr.

gdb/ChangeLog:

	* varobj.h (struct varobj): Add constructor and destructor,
	initialize fields.
	* varobj.c (struct varobj_root): Initialize fields.
	(struct varobj_dynamic): Initialize fields.
	(varobj_create): Use unique_ptr instead of cleanup.  Create
	varobj with new instead of new_root_variable.
	(delete_variable_1): Free variable with delete instead of
	free_variable.
	(create_child_with_value): Create variable with new instead of
	new_variable.
	(varobj::varobj): New.
	(varobj::~varobj): New (body mostly coming from free_variable).
	(new_variable): Remove.
	(free_variable): Remove.
	(do_free_variable_cleanup): Remove.
	(make_cleanup_free_variable): Remove.
2017-11-22 15:08:05 -05:00
Jim Wilson 2469b3c584 Riscv ld-elf/stab failure and fake label cleanup.
* as.c: Include write.h.
	(common_emul_init): Use FAKE_LABEL_NAME.
	* ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
	Likewise.
	(ecoff_build_symbols): Use FAKE_LABEL_CHAR.
	* expr.c (get_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
	input_from_string is TRUE.
	* read.c (input_from_string): New.
	(read_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
	input_from_string is TRUE.
	(temp_ilp): Set input_from_string to TRUE.
	(restore_ilp): Set input_from_string to FALSE.
	* read.h (input_from_string): Declare.
	* symbols.c: Include write.h
	(S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
	(symbol_relc_make_sym): Fix comment refering to default fake label
	string.
	* write.h (FAKE_LABEL_CHAR): New.
	* config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
	* testsuite/gas/all/err-fakelabel.s: New.
2017-11-22 11:20:48 -08:00
Jim Wilson 2ca23e65f5 Update docs on filling text with nops.
gas/
	* doc/as.texinfo (.align): Change some to most for text nop fill.
	(.balign, .p2align): Likewise.
2017-11-22 11:09:30 -08:00
Ulrich Weigand fc35dab1a6 Remove obsolete core-regset.c
The last target that used core-regset.c (FreeBSD/alpha) has been
removed with GDB 8.0, and since then this file is obsolete.
2017-11-22 19:57:05 +01:00
Yao Qi 1daad298d6 [testsuite] Pass pthreads in prepare_for_testing
"pthreads" in the right flag to pass in prepare_for_testing to linker,
instead of additional_flags.  Without this patch, the test case can't be
complied by clang.

gdb compile failed, clang: warning: -lpthread: 'linker' input unused

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/info-os.exp: Pass pthreads.
	* gdb.multi/multi-attach.exp: Likewise.
2017-11-22 16:50:53 +00:00
Yao Qi 88465e872c [testsuite] Don't skip gdb.dwarf2/pr10770.exp for non-gcc compiler
gdb.dwarf2/pr10770.exp can be used for non-gcc compiler, at least clang.
This patch removes the restriction to only use gcc.  If other compilers,
like xlc or icc, can't compile the .c file, test result is not changed.

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* gdb.dwarf2/pr10770.exp: Remove code skipping non-gcc
	compiler.
2017-11-22 14:47:42 +00:00
Igor Tsimbalist 94b98370de Remove Vec_Disp8 field for vgf2p8mulb for AVX flavor.
* i386-opc.tbl: Remove Vec_Disp8 from vgf2p8mulb.
	* i386-tbl.h: Regenerate.
2017-11-22 17:41:04 +03:00
Yao Qi dc196b230b [testsuite] Pass -pie in ldflags
-pie is a linker flag, it should be passed via "ldflags", instead
of "additional_flags".  Otherwise, clang complains,

clang: warning: argument unused during compilation: '-pie'

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/attach-pie-noexec.exp: Pass "-pie" in ldflags.
	* gdb.base/break-interp.exp: Likewise.
	* gdb.base/jit-attach-pie.exp: Likewise.
2017-11-22 14:35:01 +00:00
Igor Tsimbalist 6f19e86dac Update ChangeLog 2017-11-22 17:23:38 +03:00
Igor Tsimbalist c7478d028e Remove Vec_Disp8 from vpcompressb and vpexpandb.
* i386-opc.tbl: Remove Vec_Disp8 from vpcompressb and vpexpandb.
	* i386-tbl.h: Regenerate.
2017-11-22 17:13:55 +03:00
Thomas Preud'homme 5aa75429d0 [GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type
Uses of reg_expected_msgs rely on each arm_reg_type enumerator to have a
message entry in the same order as the enumerator declaration. This is
not clearly stated in the definition of both the arm_reg_type enum and
the reg_expected_msgs. Worse, there is nothing to ensure both are kept
in sync.

As an attempt towards this, this patch uses C99 array designators to
ensure that each message is associated with the right arm_reg_type. A
comment is also added near the definition of arm_reg_type to point to
the reg_expected_msgs array. Finally, the array is synced with
arm_reg_type by adding the missing error message for REG_TYPE_RNB.

2017-11-22  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
	* config/tc-arm.c (arm_reg_type): Comment on the link with
	reg_expected_msgs.
	(reg_expected_msgs): Initialize using array designators with
	arm_reg_type index.
2017-11-22 14:02:49 +00:00
Ulrich Weigand 2400729ecf Target FP: Make use of MPFR if available
This second patch introduces mfpr_float_ops, an new implementation
of target_float_ops.  This implements precise emulation of target
floating-point formats using the MPFR library.  This is then used
to perform operations on types that do not match any host type.

Note that use of MPFR is still not required.  The patch adds
a configure option --with-mpfr similar to --with-expat.  If use of
MPFR is disabled via the option or MPFR is not available, code will
fall back to current behavior.  This means that operations on types
that do not match any host type will be implemented on the host
long double type instead.

A new test case verifies that we can correctly print the largest
__float128 value now.

gdb/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

	* NEWS: Document use of GNU MPFR.
	* README: Likewise.

	* Makefile.in (LIBMPFR): Add define.
	(CLIBS): Add $(LIBMPFR).
	* configure.ac: Add --with-mpfr configure option.
	* configure: Regenerate.
	* config.in: Regenerate.

	* target-float.c [HAVE_LIBMPFR]: Include <mpfr.h>.
	(class mpfr_float_ops): New type.
	(mpfr_float_ops::from_target): Two new overloaded functions.
	(mpfr_float_ops::to_target): Likewise.
	(mpfr_float_ops::to_string): New function.
	(mpfr_float_ops::from_string): Likewise.
	(mpfr_float_ops::to_longest): Likewise.
	(mpfr_float_ops::from_longest): Likewise.
	(mpfr_float_ops::from_ulongest): Likewise.
	(mpfr_float_ops::to_host_double): Likewise.
	(mpfr_float_ops::from_host_double): Likewise.
	(mpfr_float_ops::convert): Likewise.
	(mpfr_float_ops::binop): Likewise.
	(mpfr_float_ops::compare): Likewise.
	(get_target_float_ops): Use mpfr_float_ops if available.

gdb/doc/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.texinfo (Requirements): Document use of GNU MPFR.

gdb/testsuite/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.base/float128.c (large128): New variable.
	* gdb.base/float128.exp: Add test to print largest __float128 value.
2017-11-22 13:53:43 +01:00
Ulrich Weigand 7a26362d36 Target FP: Refactor use of host floating-point arithmetic
Prepare for using MPFR to implement floating-point arithmetic by
refactoring the way host floating-point arithmetic is currently used.

In particular, fix the following two problems that cause different
(and incorrect) results due to using host arithmetic:

- Current processing always uses host "long double", and then converts
  back to the actual target format.  This may introduce rounding errors.

- Conversion of FP values to LONGEST simply does a host C++ type cast.
  However the result of such a cast is undefined if the source value
  is outside the representable range.  MPFR always has defined behavior
  here (returns the minimum or maximum representable value).

To fix the first issue, I've now created not just one set of routines
using host FP arithmetic (on long double), but instead three different
sets of routines, one each for host float, double, and long double.
Operations can then be performed in the desired type directly, avoiding
the extra rounding step.  Using C++ templates, the three sets can all
share the same source code without duplication.

To fix the second issue, I'm simply enforcing the same conversion rule
(which makes sense anyway) when converting out-of-range values from
FP to LONGEST.

To contain the code complexity with the variety of options now possible,
I've created a new class "target_float_ops".  There are a total of five
separate implementations of this:

  host_float_ops<float>        Implemented via host FP in given type
  host_float_ops<double>
  host_float_ops<long double>
  mpfr_float_ops               Implemented via MPFR if available
  decimal_float_ops            Implemented via libdecnumber

Note instead of using the DOUBLEST define, this always just uses the
"long double" data type.  But since we now require C++11 anyway, this
type must in any case be avaialble unconditionally.

Most target floating-point operations simply dispatch to a (virtual)
member routine of this class.  Which implementation to choose is
determined from the target types involved, and whether they match
some host type or not.  E.g. any operation on a single type that
matches a host type is performed in that type.  Operations involving
two types that both match host types are performed in the larger one
(according to C/C++ implicit conversion rules).  Operations that
involve any type that does not match a host type are performed using
MPFR.  (And of course operations involving decimal FP are performed
using libdecnumber.)

This first patch implements the refactoring of target-float.c as
described above, introduing the host_float_ops and decimal_float_ops
classes, and using them.  Use of MPFR is introduced in the second patch.
A bit of special-case handling code is moved around to as to avoid
code duplication between host_float_ops and mpfr_float_ops.

Note that due to the changes mentioned above, I've had to update (fix)
the floating-point register values tested in the gdb.arch/vsx-regs.exp
test case.  (The new values now work both with host arithmetic and MPFR.)

gdb/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

	* target-float.c: Do not include <math.h>.
	Include <cmath> and <limits>.
	(DOUBLEST): Do not define.
	(class target_float_ops): New type.
	(class host_float_ops): New templated type.
	(class decimal_float_ops): New type.

	(floatformat_to_doublest): Rename to ...
	(host_float_ops<T>::from_target): ... this.  Use template type T
	instead of DOUBLEST.  Use C++ math routines.  Update recursive calls.
	(host_float_ops<T>::from_target): New overload using a type argument.
	(floatformat_from_doublest): Rename to ...
	(host_float_ops<T>::to_target): ... this.  Use template type T
	instead of DOUBLEST.  Use C++ math routines.  Update recursive calls.
	(host_float_ops<T>::to_target): New overload using a type argument.
	(floatformat_printf_format): New function.
	(struct printf_length_modifier): New templated type.
	(floatformat_to_string): Rename to ...
	(host_float_ops<T>::to_string): ... this.  Use type instead of
	floatformat argument.  Use floatformat_printf_format and
	printf_length_modifier.  Remove special handling of invalid numbers,
	infinities and NaN (moved to target_float_to_string).
	(struct scanf_length_modifier): New templated type.
	(floatformat_from_string): Rename to ...
	(host_float_ops<T>::from_string): ... this.  Use type instead of
	floatformat argument.  Use scanf_length_modifier.
	(floatformat_to_longest): Rename to ...
	(host_float_ops<T>::to_longest): ... this.  Use type instead of
	floatformat argument.  Handle out-of-range values deterministically.
	(floatformat_from_longest): Rename to ...
	(host_float_ops<T>::from_longest): ... this.  Use type instead of
	floatformat argument.
	(floatformat_from_ulongest): Rename to ...
	(host_float_ops<T>::from_ulongest): ... this.  Use type instead of
	floatformat argument.
	(floatformat_to_host_double): Rename to ...
	(host_float_ops<T>::to_host_double): ... this.  Use type instead of
	floatformat argument.
	(floatformat_from_host_double): Rename to ...
	(host_float_ops<T>::from_host_double): ... this.  Use type instead of
	floatformat argument.
	(floatformat_convert): Rename to ...
	(host_float_ops<T>::convert): ... this.  Use type instead of
	floatformat arguments.  Remove handling of no-op conversions.
	(floatformat_binop): Rename to ...
	(host_float_ops<T>::binop): ... this.  Use type instead of
	floatformat arguments.
	(floatformat_compare): Rename to ...
	(host_float_ops<T>::compare): ... this.  Use type instead of
	floatformat arguments.

	(match_endianness): Use type instead of length/byte_order arguments.
	(set_decnumber_context): Likewise.
	(decimal_from_number): Likewise.  Update calls.
	(decimal_to_number): Likewise.
	(decimal_is_zero): Likewise.  Update calls.  Move to earlier in file.
	(decimal_float_ops::to_host_double): New dummy function.
	(decimal_float_ops::from_host_double): Likewise.
	(decimal_to_string): Rename to ...
	(decimal_float_ops::to_string): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_from_string): Rename to ...
	(decimal_float_ops::from_string): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_from_longest): Rename to ...
	(decimal_float_ops::from_longest): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_from_ulongest): Rename to ...
	(decimal_float_ops::from_ulongest): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_to_longest): Rename to ...
	(decimal_float_ops::to_longest): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_binop): Rename to ...
	(decimal_float_ops::binop): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_compare): Rename to ...
	(decimal_float_ops::compare): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.
	(decimal_convert): Rename to ...
	(decimal_float_ops::convert): ... this.  Use type instead of
	length/byte_order arguments.  Update calls.

	(target_float_same_category_p): New function.
	(target_float_same_format_p): Likewise.
	(target_float_format_length): Likewise.
	(enum target_float_ops_kind): New type.
	(get_target_float_ops_kind): New function.
	(get_target_float_ops): Three new overloaded functions.

	(target_float_is_zero): Update call.
	(target_float_to_string): Add special handling of invalid numbers,
	infinities and NaN (moved from floatformat_to_string).  Use
	target_float_ops callback.
	(target_float_from_string): Use target_float_ops callback.
	(target_float_to_longest): Likewise.
	(target_float_from_longest): Likewise.
	(target_float_from_ulongest): Likewise.
	(target_float_to_host_double): Likewise.
	(target_float_from_host_double): Likewise.
	(target_float_convert): Add special case for no-op conversions.
	Use target_float_ops callback.
	(target_float_binop): Use target_float_ops callback.
	(target_float_compare): Likewise.

gdb/testsuite/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.arch/vsx-regs.exp: Update register content checks.
2017-11-22 13:51:49 +01:00
Yao Qi a9f26f609e Fix build with GCC 8: strncpy ->strcpy
Recent gcc 8 trunk emits the warning below,

../../binutils-gdb/gdb/python/py-gdb-readline.c:79:15: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
       strncpy (q, p, n);
       ~~~~~~~~^~~~~~~~~
../../binutils-gdb/gdb/python/py-gdb-readline.c:73:14: note: length computed here
   n = strlen (p);
       ~~~~~~~^~~

gdb:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.
2017-11-22 12:22:11 +00:00
Yao Qi 29f9a56737 Fix build with GCC 8: strncpy -> memcpy
Recent gcc 8 trunk emits the warning below,

../../../binutils-gdb/gdb/gdbserver/remote-utils.c:1204:14: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation]
      strncpy (buf, "watch:", 6);
      ~~~~~~~~^~~~~~~~~~~~~~~~~~

../../binutils-gdb/gdb/cli/cli-decode.c:1118:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       strncpy (cmdtype1 + 1, cmdtype, len - 1);
       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here
   len = strlen (cmdtype);
         ~~~~~~~^~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1120:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       strncpy (cmdtype2, cmdtype, len - 1);
       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here
   len = strlen (cmdtype);
         ~~~~~~~^~~~~~~~~

../../binutils-gdb/gdb/cp-namespace.c:1071:11: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation]
   strncpy (full_name + scope_length, "::", 2);
   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes it by using memcpy instead of strncpy.

gdb:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* cli/cli-decode.c (help_list): Use memcpy instead of strncpy.
	* cp-namespace.c (cp_lookup_transparent_type_loop): Likewise.

gdb/gdbserver:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

	* remote-utils.c (prepare_resume_reply): Use memcpy.
2017-11-22 12:22:11 +00:00
claziss dc95848142 [ARC] Fix handling of ARCv2 H-register class.
For ARCv2, h-regs are only valid unitl r31.

gas/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

        * testsuite/gas/arc/hregs-err.s: New test.

opcodes/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

        * arc-opc.c (insert_rhv2): Check h-regs range.
2017-11-22 10:46:45 +01:00
H.J. Lu 0ad71725d9 x86: Add tests for -n option of x86 assembler
The -n command-line of x86 assembler disables optimization of alignment
directives, like ".balign 8, 0x90", with multi-byte nop instructions
such as leal 0(%esi),%esi.

	PR gas/22464
	* testsuite/gas/i386/align-1.s: New file.
	* testsuite/gas/i386/align-1a.d: Likewise.
	* testsuite/gas/i386/align-1b.d: Likewise.
	* testsuite/gas/i386/i386.exp: Run align-1a and align-1b.
2017-11-21 16:44:29 -08:00
GDB Administrator c757658ed6 Automatic date update in version.in 2017-11-22 00:00:23 +00:00
Jerome Guitton 3b1b69bffe ravenscar: update inferior ptid with event ptid
When debugging a program using a ravenscar runtime, the thread
layer sometimes gets confused, and even missing some threads.
This was traced to an assumption that ravenscar_wait was making,
which is that calling the "to_wait" target_ops method would
set the inferior_ptid, so that we could then use that assumption
to update our thread_list and current ptid. However, this has not
been the case for quite a while now. This patch fixes the problem
by assigning inferior_ptid the ptid returned by "to_wait".

gdb/ChangeLog:

	* ravenscar-thread.c (ravenscar_wait): Update inferior ptid
	with event ptid from the lower layer before doing the
	ravenscar-specific update.
2017-11-21 14:34:30 -08:00
Joel Brobecker 54aa6c67f5 (Ada) crash connecting to TSIM simulator
Connecting to a TSIM simulator over the remote protocol causes GDB
to crash with the following failed assertion:

    (gdb) tar remote :1234
    Remote debugging using :1234
    /[...]/gdb/ravenscar-thread.c:182: internal-error: ravenscar_update_inferior_ptid: Assertion `!is_ravenscar_task (inferior_ptid)' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n) y

What happens is the following. Upon connection to the target, GDB
sends a 'qfThreadInfo' query, which is the query asking the target
for the ID of the first thread, and TSIM replies 'm0':

    Sending packet: $qfThreadInfo#bb...Ack
    Packet received: m0

As a result of this, GDB takes the '0' as the TID, and because of it,
constructs a ptid whose value is {42000, 0, 0}. This trips our
!is_ravenscar_task check, because all it does to identify threads
corresponding to ravenscar tasks is that their lwp is null, because
that's how we construct their ptid.

But this is unfortunatly not sufficient when debugging with TSIM,
because the thread ID that TSIM returns causes the creation of
a ptid whose lwp is zero, which matches the current identification
scheme and yet is clearly not a ravenscar task.

The fix is to also make sure that the ptid's tid field is nonzero.

gdb/ChangeLog:

        * ravenscar-thread.c (is_ravenscar_task): Also verify that
        the ptid's TID is nonzero.
2017-11-21 14:33:31 -08:00
Joel Brobecker cf3fbed4a0 problem debugging ravenscar programs if runtime is stripped
Trying to debug a program using a stripped version of the ravenscar
runtime, we can get the following error:

    (gdb) cont
    Continuing.
    Cannot find Ada_Task_Control_Block type. Aborting

This is because the ravenscar-thread layer makes the assumption that
the runtime is built the way we expect it, meaning that the Ada tasking
units we rely on for Ada tasking debugging, are built with debugging
information, and that this debug information has not been stripped from
the runtime.

When this assumption is not true, resuming such a program can trigger
the error above, which then leads GDB a little confused. For instance,
we can see things like:

     (gdb) bt
     Target is executing.

This patch fixes the issue by disabling the ravenscar thread layer
if we detect that the runtime is missing some of the debugging info
we need in order to support Ada task debugging. This is the best
we can do, as the ravenscar-thread layer actually depends on the
ada-tasks layer to implement thread debugging.

gdb/ChangeLog:

        * ada-lang.h (ada_get_tcb_types_info): Add declaration.
        * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info.
        Make non-static.  Change return type to char *.  Adjust code
        accordingly.  Rewrite the function's documentation.
        (read_atcb): Adjust call to get_tcb_types_info accordingly.
        * ravenscar-thread.c (ravenscar_inferior_created): Check that
        we have enough debugging information in the runtime to support
        Ada task debugging before we enable the ravenscar-thread layer.
2017-11-21 14:32:48 -08:00
Joel Brobecker 9edcc12f9b Add multiple-CPU support in ravenscar-thread.c
This patch reworks the ravenscar-thread layer to remove the
assumption that the target only has 1 CPU. In particular,
when connected to a QEMU target over the remote protocol,
QEMU reports each CPU as one thread. This patch adapts
the ravenscar-thread layer to this, and adds a large comment
explaining the general design of this unit.

gdb/ChangeLog:

        * ada-lang.h (ada_get_task_info_from_ptid): Add declaration.
        * ada-tasks.c (ada_get_task_info_from_ptid): New function.
        * ravenscar-thread.c: Add into comment.
        (base_magic_null_ptid): Delete.
        (base_ptid): Change documentation.
        (ravenscar_active_task): Renames ravenscar_running_thread.
        All callers updated throughout.
        (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function.
        (ravenscar_task_is_currently_active): Likewise.
        (get_base_thread_from_ravenscar_task): Ditto.
        (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs.
        (ravenscar_runtime_initialized): Likewise.
        (get_running_thread_id): Add new parameter "cpu".  Adjust
        implementation to handle this new parameter.
        (ravenscar_fetch_registers): Small adjustment to use
        is_ravenscar_task and ravenscar_task_is_currently_active in
        order to decide whether to use the target beneath or this
        module's arch_ops.
        (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise.
        (ravenscar_stopped_by_sw_breakpoint): Use
        get_base_thread_from_ravenscar_task to get the underlying
        thread, rather than using base_ptid.
        (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint)
        (ravenscar_stopped_data_address, ravenscar_core_of_thread):
        Likewise.
        (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 14:32:10 -08:00
Joel Brobecker 65d40437e2 Provide the "Base CPU" in output of "info task" (if set by runtime).
At the user level, this patch enhances the debugger to print the ID
of the base CPU a task is running on:

        (gdb) info task 3
        Ada Task: 0x13268
        Name: raven1
        Thread: 0x13280
        LWP: 0
 !!!->  Base CPU: 1
        No parent
        Base Priority: 127
        State: Runnable

This new field is only printed when the base CPU is nonzero or, in
other words, if the base CPU info is being provided by the runtime.
For instance, on native systems, where threads/processes can "jump"
from CPU to CPU, the info is not available, and the output of the
command above then remains unchanged.

At the internal level, the real purpose of this change is to prepare
the way for ravenscar-thread to start handling SMP systems. For that,
we'll need to know which CPU each task is running on...  More info
on that in the commit that actually adds support for it.

gdb/ChangeLog:

        * ada-lang.h (struct ada_task_info) <base_cpu>: New field.
        * ada-lang.c (struct atcb_fieldno) <base_cpu>: New field.
        (get_tcb_types_info): Set fieldnos.base_cpu.
        (read_atcb): Set task_info->base_cpu.
        (info_task): Print "Base CPU" info if set by runtime.
2017-11-21 14:31:32 -08:00
Joel Brobecker e02544b292 watchpoint regression debugging with remote protocol (bare metal)
We have noticed a regression in our watchpoint support when debugging
through the remote protocol a program running on a bare metal platform,
when the program uses what we call the Ravenscar Runtime.

This runtime is a subset of the Ada runtime defined by the Ravenscar
Profile.  One of the nice things about this runtime is that it provides
tasking, which is equivalent to the concept of threads in C (it is
actually often mapped to threads, when available). For bare metal
targets, however, there is no OS, and therefore no thread layer.
What we did, then, was add a ravenscar-thread layer, which has insider
knowledge of the runtime to get the list of threads, but also all
necessary info to perform thread switching.

For the record, the commit which caused the regression is:

    commit 799a2abe61
    Date:   Mon Nov 30 16:05:16 2015 +0000
    Subject: remote: stop reason and watchpoint data address per thread

    Running local-watch-wrong-thread.exp with "maint set target-non-stop
    on" exposes that gdb/remote.c only records whether the target stopped
    for a breakpoint/watchpoint plus the watchpoint data address *for the
    last reported remote event*.  But in non-stop mode, we need to keep
    that info per-thread, as each thread can end up with its own
    last-status pending.

Our testcase is very simple. We have a package defining a global
variable named "Watch"...

    package Pck is
       Watch : Integer := 1974;
    end Pck;

... and a main subprogram which changes its value

    procedure Foo is
    begin
       Pck.Watch := Pck.Watch + 1;
    end Foo;

To reproduce, we built our program as usual, started it in QEMU,
and then connected GDB to QEMU...

    (gdb) target remote :4444
    (gdb) break _ada_foo
    (gdb) cont  <--- this is to make sure the program is started
                     and the variable we want to watch is initialized

... at which point we try to use a watchpoint on our global variable:

    (gdb) watch watch

... but, upon resuming the execution with a "cont", we expected to
get a watchpoint-hit notification, such as...

    (gdb) cont
    Hardware watchpoint 2: watch

    Old value = 1974
    New value = 1975
    0xfff00258 in foo () at /[...]/foo.adb:6
    6       end Foo;

... but unfortunately, we get a SIGTRAP instead:

    (gdb) cont
    Program received signal SIGTRAP, Trace/breakpoint trap.
    foo () at /[...]/foo.adb:6
        6   end Foo;

What happens is that, on the one hand, the change in remote.c
now stores the watchpoint-hit notification info in the thread
that received it; and on the other hand, we have a ravenscar-thread
layer which manages the thread list on top of the remote protocol
layer. The two of them get disconnected, and this eventually results
in GDB not realizing that we hit a watchpoint.  Below is how:

First, once connected and just before inserting our watchpoint,
we have the ravenscar-thread layer which built the list of threads
by extracting some info from inferior memory, giving us the following
two threads:

      (gdb) info threads
      Id   Target Id         Frame
      1    Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5
    * 2    Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5

The first thread is the only thread QEMU told GDB about. The second
one is a thread that the ravenscar-thread added. QEMU has now way
to know about those threads, since they are really embedded inside
the program; that's why we have the ravenscar layer, which uses
inside-knowledge to extract the list of threads.

Next, we insert a watchpoint, which applies to all threads. No problem
so far.

Then, we continue; meaning that GDB sends a Z2 packet to QEMU to
get the watchpoint inserted, then a vCont to resume the program's
execution. The program hits the watchpoints, and thererfore QEMU
reports it back:

        Packet received: T05thread:01;watch:000022c4;

Since QEMU knows about one thread and one thread only, it stands
to reason that it would say that the event applies to thread:01,
which is our first thread in the "info threads" listing. That
thread has a ptid of {42000, lwp=1, tid=0}.

This is where Pedro's change kicks in: Seeing this event, and
having determined that the event was reported for thread 01,
and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit
event info in the private area of that thread/ptid. Once this is
done, remote.c's event-wait layer returns.

Enter the ravenscar-thread layer of the event-wait, which does
a little dance to delegate the wait to underlying layers with
ptids that those layers know about, and then when the target_beneath's
to_wait is done, tries to figure out which thread is now the active
thread. The code looks like this:

  1.    inferior_ptid = base_ptid;
  2.    beneath->to_wait (beneath, base_ptid, status, 0);
  3.    [...]
  4.        ravenscar_update_inferior_ptid ();
  5.
  6.    return inferior_ptid;

Line 1 is where we reset inferior_ptid to the ptid that
the target_beneath layer knows about, allowing us to then
call its to_wait implementation (line 2). And then, upon
return, we call ravenscar_update_inferior_ptid, which reads
inferior memory to determine which thread is actually active,
setting inferior_ptid accordingly. Then we return that
inferior_ptid (which, again, neither QEMU and therefore nor
the remote.c layer knows about).

Upon return, we eventually arrive to the part where we try
to handle the inferior event: we discover that we got a SIGTRAP
and, as part of its handling, we call watchpoints_triggered,
which calls target_stopped_by_watchpoint, which eventually
remote_stopped_by_watchpoint, where Pedro's change kicks in
again:

    struct thread_info *thread = inferior_thread ();
    return (thread->priv != NULL
            && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT);

Because the ravenscar-thread layer changed the inferior_ptid
to the ptid of the active thread, inferior_thread now returns
the private data of that thread. This is not the thread that
QEMU reported the watchpoint-hit on, and thus, the function
returns "no watchpoint hit, mister". Hence GDB not understanding
the SIGTRAP, thus reporting it verbatim.

The way we chose to fix the issue is by making sure that the
ravenscar-thread layer doesn't let the remote layer be called
with inferior_ptid being set to a thread that the remote layer
does not know about.

gdb/ChangeLog:

        * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint)
        (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint)
        (ravenscar_stopped_data_address, ravenscar_core_of_thread):
        New functions.
        (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint,
        to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint,
        to_stopped_data_address and to_core_of_thread fields of
        ravenscar_ops.
2017-11-21 14:30:55 -08:00
H.J. Lu d6251545e2 Add a test for PR binutils/22451
Check in the object file generated from the older assembler as a
compressed file.

	PR binutils/22451
	* testsuite/binutils-all/x86-64/objects.exp: New file.
	* testsuite/binutils-all/x86-64/pr22451.o.bz2: Likewise.
2017-11-21 13:41:51 -08:00
Ulrich Weigand ed0f427344 [PowerPC] Detect different long double floating-point formats
Current versions of GCC support switching the format used for "long double"
to either IBM double double or IEEE-128.  The resulting binary is marked
via different setting of the Tag_GNU_Power_ABI_FP GNU attribute.

This patch checks this attribute to detect the format of the default
"long double" type and sets GDB's notion of the format accordingly.

The patch also adds support for the "__ibm128" type, which always uses
IBM double double format independent of the format used for "long double".

A new test case verifies that all three types, "long double", "__float128",
and "__ibm128" are correctly detected in all three compiler settings,
the default setting, -mabi=ieeelongdouble, and -mabi=ibmlongdouble.

gdb/ChangeLog:
2017-11-21  Ulrich Weigand  <uweigand@de.ibm.com>

	* ppc-tdep.h (enum powerpc_long_double_abi): New data type.
	(struct gdbarch_tdep): New member long_double_abi.
	* rs6000-tdep.c (rs6000_gdbarch_init): Initialize long_double_abi
	member of tdep struct based on Tag_GNU_Power_ABI_FP attribute.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Install long double data
	format depending on long_double_abi tdep member.
	(ppc_floatformat_for_type): Handle __ibm128 type.

gdb/testsuite/ChangeLog:
2017-11-21  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.arch/ppc-longdouble.exp: New file.
	* gdb.arch/ppc-longdouble.c: Likewise.
2017-11-21 18:50:59 +01:00
Pedro Alves a25d69c6dc gdb.ada/minsyms.exp: Don't hardcode the variable's address
This new testcase has a test that fails like this here:

  $1 = (<data variable, no debug info> *) 0x60208c <some_minsym>
  (gdb) FAIL: gdb.ada/minsyms.exp: print &some_minsym

The problem is that the testcase hardcodes an expected address for the
"some_minsym" variable, which obviously isn't stable.

Fix that by expecting $hex instead.

gdb/testsuite/ChangeLog:
2017-11-21  Pedro Alves  <palves@redhat.com>

	* gdb.ada/minsyms.exp: Accept any address for 'some_minsym'.
2017-11-21 16:04:42 +00:00
Nick Clifton 2824e1bd4f Stop the v850 linker from converting to other output formats whilst linking.
PR 22419
	* emultempl/v850elf.em (v850_create_output_section_statements):
	New function.  Generate an error if attempting to convert the
	format of the output file.
	* testsuite/ld-unique/pr21529.d: Skip for the V850.
	* testsuite/ld-elf/pr21884.d: Skip for the V850.
2017-11-21 14:15:51 +00:00
claziss bd560f571f [ARC] [COMMITTED] Update test pattern patching.
2017-11-21  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/binutils-all/arc/objdump.exp: Update pattern matching
	expression.
2017-11-21 15:04:22 +01:00
claziss 50d2740d56 [ARC] Improve printing of pc-relative instructions.
opcodes/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

	* arc-dis.c (print_insn_arc): Pretty print pc-relative offsets.
	* arc-opc.c (SIMM21_A16_5): Make it pc-relative.

gas/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

	* testsuite/gas/arc/b.d : Update test.
	* testsuite/gas/arc/bl.d: Likewise.
	* testsuite/gas/arc/jli-1.d: Likewise.
	* testsuite/gas/arc/lp.d: Likewise.
	* testsuite/gas/arc/pcl-relocs.d: Likewise.
	* testsuite/gas/arc/pcrel-relocs.d: Likewise.
	* testsuite/gas/arc/pic-relocs.d: Likewise.
	* testsuite/gas/arc/plt-relocs.d: Likewise.
	* testsuite/gas/arc/pseudos.d: Likewise.
	* testsuite/gas/arc/relax-avoid2.d: Likewise.
	* testsuite/gas/arc/relax-avoid3.d: Likewise.
	* testsuite/gas/arc/relax-b.d: Likewise.
	* testsuite/gas/arc/tls-relocs.d: Likewise.
	* testsuite/gas/arc/relax-add01.d: Likewise.
	* testsuite/gas/arc/relax-add04.d: Likewise.
	* testsuite/gas/arc/relax-ld01.d: Likewise.
	* testsuite/gas/arc/relax-sub01.d: Likewise.
	* testsuite/gas/arc/relax-sub02.d: Likewise.
	* testsuite/gas/arc/relax-sub04.d: Likewise.
	* testsuite/gas/arc/pcl-print.s: New file.
	* testsuite/gas/arc/pcl-print.d: Likewise.
	* testsuite/gas/arc/nps400-12.d: Likewise.

ld/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

	* testsuite/ld-arc/jli-simple.d: Update test.
2017-11-21 14:56:16 +01:00
Nick Clifton d85bf2ba86 Add ability to follow dwo links to readelf/objdump.
* dwarf.c (dwo_name, dwo_dir, dwo_id, dwo_id_len): New variables.
	(read_and_display_attr_value): Record dwo variables if requested.
	(display_augmentation_data): Rename to display_data and make
	generic.
	(load_dwo_file): New function.  Loads a separate dwarf object
	file.
	(load_separate_debug_file): Add reporting and loading of separate
	dwarf objet files.
	* readelf.c (process_section_headers): Add do_debug_links to list
	of flags requiring a debug dump.
	(display_debug_section): Tidy up code.
	* doc/debug.options.texi: Add note that dwo links will also be
	followed.
	* testsuite/binutils-all/debuglink.s: Tidy code.
	* testsuite/binutils-all/dwo.s: New test file.
	* testsuite/binutils-all/readelf.wk2: New file - expected output
	from readelf.
	* testsuite/binutils-all/readelf.exp: Run the new test.
2017-11-21 13:12:04 +00:00
Simon Marchi 0fc7642151 Fix build failure in darwin-nat.c
Fix:

/Users/simark/src/binutils-gdb/gdb/darwin-nat.c:2404:3: error: no matching function for call to 'add_setshow_boolean_cmd'
  add_setshow_boolean_cmd ("mach-exceptions", class_support,
  ^~~~~~~~~~~~~~~~~~~~~~~

gdb/ChangeLog:

	* darwin-nat.c (set_enable_mach_exceptions): Constify parameter.
2017-11-20 23:29:10 -05:00
Alan Modra 0ee5a0e483 Add NULL bfd test to elf_symbol_from
A followup to PR22443.

	* elf-bfd.h (elf_symbol_from): Check for NULL symbol bfd.
	* elfcode.h (elf_slurp_reloc_table_from_section): Add FIXME comment.
2017-11-21 11:20:24 +10:30
Alan Modra bf3d139947 xtensa error message
* config/tc-xtensa.c (finish_vinsn): Avoid multiple ngettext calls
	in error message.
2017-11-21 11:20:24 +10:30
Pedro Alves e6b2f5efa9 Fix mapped_index::find_name_components_bounds upper bound computation
Here we want to find where we'd insert "after", so we want
std::lower_bound, not std::upper_bound.

gdb/ChangeLog:
2017-11-21  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (mapped_index::find_name_components_bounds)
	<completion mode, upper bound>: Use std::lower_bound instead of
	std::upper_bound.
	(test_mapped_index_find_name_component_bounds): Remove incorrect
	"t1_fund" from expected symbols.
2017-11-21 00:03:27 +00:00
Pedro Alves 5c58de74c9 Unit test name-component bounds searching directly
This commit factors out the name-components-vector building and bounds
searching out of dw2_expand_symtabs_matching_symbol into separate
functions, and adds unit tests that:

 - expose both the latent bug mentioned in the previous commit, and
   also,

 - for completeness exercise the 0xff character handling fixed in the
   previous commit more directly.

The actual fix for the now-exposed bug is left for the following
patch.

gdb/ChangeLog:
2017-11-21  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (mapped_index::name_components_casing): New field.
	(mapped_index) <build_name_components,
	find_name_components_bounds): Declare new methods.
	(mapped_index::find_name_components_bounds)
	(mapped_index::build_name_components): New methods, factored out
	from dw2_expand_symtabs_matching_symbol.
	(check_find_bounds_finds)
	(test_mapped_index_find_name_component_bounds): New.
	(run_test): Rename to ...
	(test_dw2_expand_symtabs_matching_symbol): ... this.
	(run_test): Reimplement.
2017-11-21 00:03:10 +00:00
Pedro Alves e1ef7d7a51 0xff chars in name components table; cp-name-parser lex UTF-8 identifiers
The find-upper-bound-for-completion algorithm in the name components
accelerator table in dwarf2read.c increments a char in a string, and
asserts that it's not incrementing a 0xff char, but that's incorrect.

First, we shouldn't be calling gdb_assert on input.

Then, if "char" is signed, comparing a caracther with "0xff" will
never yield true, which is caught by Clang with:

  error: comparison of constant 255 with expression of type '....' (aka 'char') is always true [-Werror,-Wtautological-constant-out-of-range-compare]
	    gdb_assert (after.back () != 0xff);
			~~~~~~~~~~~~~ ^  ~~~~

And then, 0xff is a valid character on non-UTF-8/ASCII character sets.
E.g., it's 'ÿ' in Latin1.  While GCC nor Clang support !ASCII &&
!UTF-8 characters in identifiers (GCC supports UTF-8 characters only
via UCNs, see https://gcc.gnu.org/onlinedocs/cpp/Character-sets.html),
but other compilers might (Visual Studio?), so it doesn't hurt to
handle it correctly.  Testing is covered by extending the
dw2_expand_symtabs_matching unit tests with relevant cases.

However, without further changes, the unit tests still fail...  The
problem is that cp-name-parser.y assumes that identifiers are ASCII
(via ISALPHA/ISALNUM).  This commit fixes that too, so that we can
unit test the dwarf2read.c changes.  (The regular C/C++ lexer in
c-lang.y needs a similar treatment, but I'm leaving that for another
patch.)

While doing this, I noticed a thinko in the computation of the upper
bound for completion in dw2_expand_symtabs_matching_symbol.  We're
using std::upper_bound but we should use std::lower_bound.  I extended
the unit test with a case that I thought would expose it, this one:

 +  /* These are used to check that the increment-last-char in the
 +     matching algorithm for completion doesn't match "t1_fund" when
 +     completing "t1_func".  */
 +  "t1_func",
 +  "t1_func1",
 +  "t1_fund",
 +  "t1_fund1",

The algorithm actually returns "t1_fund1" as lower bound, so "t1_fund"
matches incorrectly.  But turns out the problem is masked because
later here:

  for (;lower != upper; ++lower)
    {
      const char *qualified = index.symbol_name_at (lower->idx);

      if (!lookup_name_matcher.matches (qualified)

the lookup_name_matcher.matches check above filters out "t1_fund"
because that doesn't start with "t1_func".

I'll fix the latent bug in follow up patches, after factoring things
out a bit in a way that allows unit testing the relevant code more
directly.

gdb/ChangeLog:
2017-11-21  Pedro Alves  <palves@redhat.com>

	* cp-name-parser.y (cp_ident_is_alpha, cp_ident_is_alnum): New.
	(symbol_end): Use cp_ident_is_alnum.
	(yylex): Use cp_ident_is_alpha and cp_ident_is_alnum.
	* dwarf2read.c (make_sort_after_prefix_name): New function.
	(dw2_expand_symtabs_matching_symbol): Use it.
	(test_symbols): Add more symbols.
	(run_test): Add tests.
2017-11-21 00:02:46 +00:00
GDB Administrator 9752982420 Automatic date update in version.in 2017-11-21 00:00:14 +00:00
Pedro Alves 73fcf6418d Fix gdb.base/whatis-ptype-typedefs.exp on 32-bit archs
The gdb.base/whatis-ptype-typedefs.exp testcase has several tests that
fail on 32-bit architectures.  E.g., on 'x86-64 -m32', I see:

 ...
 FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: whatis (float_typedef) v_uchar_array_t_struct_typedef (invalid)
 FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: ptype (float_typedef) v_uchar_array_t_struct_typedef (invalid)
 ...

gdb.log:

 (gdb) whatis (float_typedef) v_uchar_array_t_struct_typedef
 type = float_typedef
 (gdb) FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: whatis (float_typedef) v_uchar_array_t_struct_typedef (invalid)

As Simon explained [1], the issue boils down to the fact that on
64-bit, this is an invalid cast:

 (gdb) p (float_typedef) v_uchar_array_t_struct_typedef
 Invalid cast.

while on 32 bits it is valid:

 (gdb) p (float_typedef) v_uchar_array_t_struct_typedef
 $1 = 1.16251721e-41

The expression basically tries to cast an array (which decays to a
pointer) to a float.  The cast works on 32 bits because a float and a
pointer are of the same size, and value_cast works in that case:

~~~
   More general than a C cast: accepts any two types of the same length,
   and if ARG2 is an lvalue it can be cast into anything at all.  */
~~~

On 64 bits, they are not the same size, so it ends throwing the
"Invalid cast" error.

The testcase is expecting the invalid cast behavior, thus the FAILs.

A point of these tests was to cover as many code paths in value_cast
as possible, as a sort of documentation of the current behavior:

    # The main idea here is testing all the different paths in the
    # value casting code in GDB (value_cast), making sure typedefs are
    # preserved.
...
    # We try all combinations, even those that don't parse, or are
    # invalid, to catch the case of a regression making them
    # inadvertently valid.  For example, these convertions are
    # invalid:
...

In that spirit, this commit makes the testcase adjust itself depending
on size of floats and pointers, and also test floats of different
sizes.

Passes cleanly on x86-64 GNU/Linux both -m64/-m32.

[1] - https://sourceware.org/ml/gdb-patches/2017-11/msg00382.html

gdb/ChangeLog:
2017-11-20  Pedro Alves  <palves@redhat.com>

	* gdb.base/whatis-ptype-typedefs.c (double_typedef)
	(long_double_typedef): New typedefs.
	Use DEF on double and long double.
	* gdb.base/whatis-ptype-typedefs.exp: Add double and long double
	cases.
	(run_tests): New 'float_ptr_same_size', 'double_ptr_same_size',
	and 'long_double_ptr_same_size' locals.  Use them to decide
	whether cast from array/function to float is valid/invalid.
2017-11-20 23:03:17 +00:00
Nick Clifton b77db948f4 Fix handling of GNU Property notes that are not in a GNU NOTE PROPERTY section.
PR 22450
gas	* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Skip
	objects without a GNU_PROPERTY note section when looking for a bfd
	onto which notes can be accumulated.

ld	* testsuite/ld-elf/elf.exp: Add --defsym ALIGN=2|3 to assembler
	command line depending upon the size of the target address space.
	* testsuite/ld-elf/pr22450.s: New test file.
	* testsuite/ld-elf/pr22450.d: New test driver.
	* testsuite/config/default.exp: Add note that LD_CLASS refers to
	the size of the host linker not the size of the target linker.
2017-11-20 15:32:55 +00:00
Alan Modra b7486a74a6 mingw gas testsuite fix
Some x86_64 targets pad sections with nops.

	* testsuite/gas/i386/x86-64-reg-bad.l: Accept trailing padding.
2017-11-21 00:09:23 +10:30
Alan Modra 28e07a0510 PR22451, strip no longer works on older object files
Setting SHF_GROUP unconditionally on rel/rela sections associated with
SHF_GROUP sections fails badly with objcopy/strip and ld -r if the
input file SHT_GROUP section didn't specify the rel/rela sections.
This patch rearranges where SHF_GROUP is set for rel/rela sections.

	PR 22451
	PR 22460
	* elf.c (_bfd_elf_init_reloc_shdr): Delete "sec_hdr" parameter
	and leave rel_hdr->sh_flags zero.  Update calls.
	(bfd_elf_set_group_contents): Check input rel/rela SHF_GROUP
	flag when !gas before adding rel/rela section to group.  Set
	output rel/rela SHF_GROUP flags.
2017-11-21 00:09:07 +10:30
Simon Marchi 578290ecaf Remove usage of find_inferior when calling kill_one_lwp_callback
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (kill_one_lwp_callback): Return void, take
	argument directly, don't filter on pid.
	(linux_kill): Use for_each_thread.
2017-11-19 22:23:28 -05:00
Simon Marchi eca55aec1d Remove usages of find_thread when calling need_step_over_p
Replace with find_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (need_step_over_p): Return bool, remove dummy
	argument.
	(linux_resume, proceed_all_lwps): Use find_thread.
2017-11-19 22:23:27 -05:00
Simon Marchi 25c28b4d15 Remove usage of find_thread when calling resume_status_pending_p
Replace with find_thread.  Instead of setting the flag in the callback,
make the callback return true/false, and check the result against NULL
in the caller.

gdb/gdbserver/ChangeLog:

	* linux-low.c (resume_status_pending_p): Return bool, remove
	flag_p argument.
	(linux_resume): Use find_thread.
2017-11-19 22:23:27 -05:00
Simon Marchi 5fdda39248 Remove usage of find_inferior when calling linux_set_resume_request
Replace it with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (struct thread_resume_array): Remove.
	(linux_set_resume_request): Return void, take arguments
	directly.
	(linux_resume): Use for_each_thread.
2017-11-19 22:23:26 -05:00