Commit Graph

104659 Commits

Author SHA1 Message Date
Simon Marchi
85be4f5a8c gdb/doc: fix "show check range" command name
gdb/doc/ChangeLog:

	PR gdb/27088
	* gdb.texinfo (Range Checking): Fix "show check range" command
	name.

Change-Id: I0248ef76d205ac49ed71b813aafe3e630c2ffc2e
2020-12-17 09:42:35 -05:00
Tom Tromey
c5c412054e Change parameters to language_defn::post_parser
In the expression rewrite, Ada type resolution will be done at parse
time rather than in a post-parse pass.  At this point,
language_defn::post_parser will be removed.  However, for this to
work, the information available to post_parser must be made available
during the actual parse.

This patch refactors this code slightly to make this possible.  In
particular, "void_context_p" is passed to the parser_state
constructor, and the parser state is then passed to the post_parser
method.

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

	* rust-exp.y (rust_lex_tests): Update.
	* parser-defs.h (parser_state): Add void_p parameter.
	<void_context_p>: New member.
	* parse.c (parse_exp_in_context): Update.
	* language.h (language_defn::post_parser): Remove void_context_p,
	completing, tracker parameters.  Add parser state.
	* ada-lang.c (ada_language::post_parser): Update.
2020-12-16 17:35:37 -07:00
GDB Administrator
f81baa0863 Automatic date update in version.in 2020-12-17 00:00:18 +00:00
Tom Tromey
35c1ab606d Change void_context_p to bool
This patch changes void_context_p to bool, as a prerequisite to the
change to post_parser that I submitted here:

https://sourceware.org/pipermail/gdb-patches/2020-December/174080.html

Tested by rebuilding.

Note that nothing in-tree passes true here.  I don't know why this is,
but there is a use of this internally in AdaCore's tree.  I will try
to submit that patch, if it is needed.  (And if not, I will come back
around and remove this.)

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

	* parse.c (parse_exp_1, parse_expression_for_completion): Update.
	(parse_exp_in_context): Change void_context_p to bool.
	* language.h (struct language_defn) <post_parser>: Change
	void_context_p to bool.
	* ada-lang.c (class ada_language) <post_parser>: Update.
2020-12-16 15:17:43 -07:00
Simon Marchi
93df4a1d07 gdb/testsuite: make some tests in gdb.base enable non-stop using GDBFLAGS
For the same reason as explained in commit 7cb2893dfa ("gdb/testsuite:
gdb.mi/mi-nonstop-exit.exp: enable non-stop using GDBFLAGS").

Note that the use of

    set GDBFLAGS "$GDBFLAGS ..."

instead of

    append GDBFLAGS "..."

is intentional.  "append" is silent when appending to a non-existent
variable.  So if this code if moved to a proc (as is the case already
for step-sw-breakpoint-adjust-pc.exp) and we forget to add "global
GDBFLAGS", the flag won't be added to the global GDBFLAGS, and we won't
actually enable non-stop, and it might go unnoticed.  Using the "set"
version will turn into an error if we forget the "global".

This makes these test work correctly with native-extended-gdbserver.
Some of them were silently failing because we runto_main is silent when
it fails.

gdb/testsuite/ChangeLog:

	* gdb.base/async-shell.exp: Enable non-stop through GDBFLAGS.
	* gdb.base/continue-all-already-running.exp: Likewise.
	* gdb.base/moribund-step.exp: Likewise.
	* gdb.base/step-sw-breakpoint-adjust-pc.exp: Likewise.

Change-Id: I19ef05d07a0ec4a9c9476af2ba6e1ea1159ee437
2020-12-16 16:46:53 -05:00
H.J. Lu
bcac599f73 ld: Skip libdep plugin if not all plugin hooks are available
Skip plugin if not all required plugin hooks are available.

2020-12-16  Howard Chu <hyc@symas.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/27081
	* libdep_plugin.c (onload): Skip if not all required plugin hooks
	are available.
	* testsuite/config/default.exp (dep_plug_opt): New.
	* testsuite/ld-elf/elf.exp: Pass $dep_plug_opt to nm.
	* testsuite/ld-elf/pr26391.fd: New file.
2020-12-16 13:40:51 -08:00
Tom de Vries
592995fadd [gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp
On openSUSE Leap 15.2, when running test-case
gdb.base/batch-preserve-term-settings.exp I get:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$ PASS: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell
...
but on Ubuntu 18.04.5, I get instead:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
$ gdb-subshell$ FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell (timeout)
...

Fix this by making the regexp recognize the second pattern as well.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

	* gdb.base/batch-preserve-term-settings.exp:
2020-12-16 21:32:59 +01:00
Martin Liska
d6f26c9d28 [gdb] Print progress for debuginfod
Prints progress like:

Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20.
Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5.
Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1.
Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so.
[###                                                                    ]

Tested on x86_64-linux.

ChangeLog:

2020-12-16  Martin Liska  <mliska@suse.cz>
	    Tom de Vries  <tdevries@suse.de>

	* gdb/debuginfod-support.c (struct user_data): Remove has_printed
	field.  Add meter field.
	(progressfn): Print progress using meter.
2020-12-16 18:18:40 +01:00
Tom Tromey
2f2287318b [gdb/cli] Add a progress meter
Add a progress meter.  It's not used anywhere yet.

gdb/ChangeLog:

2020-12-16  Tom Tromey  <tom@tromey.com>
	    Tom Tromey  <tromey@redhat.com>
	    Tom de Vries  <tdevries@suse.de>

	* utils.h (get_chars_per_line): Declare.
	* utils.c (get_chars_per_line): New function.
	(fputs_maybe_filtered): Handle '\r'.
	* ui-out.h (ui_out::progress_meter): New class.
	(ui_out::progress, ui_out::do_progress_start)
	(ui_out::do_progress_notify, ui_out::do_progress_end): New
	methods.
	* ui-out.c (do_progress_end)
	(make_cleanup_ui_out_progress_begin_end, ui_out_progress): New
	functions.
	* mi/mi-out.h (mi_ui_out::do_progress_start)
	(mi_ui_out::do_progress_notify, mi_ui_out::do_progress_end): New
	methods.
	* cli-out.h (struct cli_ui_out) <do_progress_start,
	do_progress_notify, do_progress_end>: New methods.
	<enum meter_stat, struct cli_progress_info>: New.
	<m_meters>: New member.
	* cli-out.c (cli_ui_out::do_progress_start)
	(cli_ui_out::do_progress_notify, cli_ui_out::do_progress_end): New
	methods.
2020-12-16 18:18:40 +01:00
Tom de Vries
1e61189d0a [gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE
When running test-case gdb.base/info-shared.exp with target board
unix/-pie/-fPIE, we run into:
...
spawn -ignore SIGHUP gcc -fno-stack-protector \
  outputs/gdb.base/info-shared/info-shared-solib1.c.o \
  -fdiagnostics-color=never -fPIC -shared -Wl,-soname,info-shared-solib1.so \
  -lm -fPIE -pie -o outputs/gdb.base/info-shared/info-shared-solib1.so^M
ld: Scrt1.o: in function `_start':^M
start.S:104: undefined reference to `main'^M
collect2: error: ld returned 1 exit status^M
compiler exited with status 1
...

The intention of the -pie/-fPIE flags is to build and test PIE executables on
platforms where that is not the default.  However, the flags clash with the
flags required to build shared libraries.

Fix this by filtering out PIE-related flags out of the multilib_flags settings
in compile_shared_lib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_compile_shlib_1): Factor out of ...
	(gdb_compile_shlib): ... here.  Filter out PIE-related flags.
2020-12-16 18:18:40 +01:00
Luis Machado
bfbe4b8460 Record FPSR for SIMD/FP data instructions
I noticed this failure in gdb.reverse/reverse-insn.exp:

FAIL: gdb.reverse/insn-reverse.exp: adv_simd_vect_shift: compare registers on insn 0:fcvtzs     s0, s0, #1

Turns out we're not recording changes to the FPSR.  The SIMD/FP data
instructions may set bits in the FPSR, so it needs to be recorded for
proper reverse operations.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

	* aarch64-tdep.c (aarch64_record_data_proc_simd_fp): Record FPSR.
2020-12-16 10:08:47 -03:00
Luis Machado
19007d9556 Fix TBI handling for watchpoints
When inserting hw watchpoints, we take care of masking off the top byte
of the address (and sign-extending it if needed).  This guarantees we won't
pass tagged addresses to the kernel via ptrace.

However, from the kernel documentation on tagged pointers...

"Non-zero tags are not preserved when delivering signals. This means that
signal handlers in applications making use of tags cannot rely on the tag
information for user virtual addresses being maintained for fields inside
siginfo_t.

One exception to this rule is for signals raised in response to watchpoint
debug exceptions, where the tag information will be preserved."

So the stopped data address after a hw watchpoint hit can be potentially
tagged, and we don't handle this in GDB at the moment.  This results in
GDB missing a hw watchpoint hit and attempting to step over an unsteppable
hw watchpoint, causing it to spin endlessly.

The following patch fixes this by adjusting the stopped data address and adds
some tests to expose the problem.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

	* aarch64-linux-nat.c
	(aarch64_linux_nat_target::stopped_data_address): Handle the TBI.

gdbserver/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

	* linux-aarch64-low.cc (address_significant): New function.
	(aarch64_target::low_stopped_data_address): Handle the TBI.

gdb/testsuite/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

	* gdb.arch/aarch64-tagged-pointer.c (main): Add a few more
	pointer-based memory accesses.
	* gdb.arch/aarch64-tagged-pointer.exp: Exercise additional
	hw watchpoint cases.
2020-12-16 10:05:56 -03:00
Alan Modra
c410035d37 constify elfNN_bed
elfNN_bed was made writable as an expedient means of communicating
ld -z max-page-size and ld -z common-page-size values to BFD linker
code, and even for objcopy to communicate segment alignment between
copy_private_bfd_data, rewrite_elf_program_header and
assign_file_positions_for_load_sections.  Some time later elfNN_bed
elf_osabi was written by gas.  It turns out none of these
modifications to elfNN_bed was necessary, so make it const again.

include/
	* bfdlink.h (struct bfd_link_info): Add maxpagesize and
	commonpagesize.
bfd/
	* elfxx-target.h (elfNN_bed): Constify.
	* bfd.c (bfd_elf_set_pagesize): Delete.
	(bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete.
	* elf.c (get_program_header_size): Get commonpagesize from
	link info.
	(_bfd_elf_map_sections_to_segments): Get maxpagesize from link info.
	(assign_file_positions_for_load_sections): Likewise.
	(assign_file_positions_for_non_load_sections): Likewise.
	(rewrite_elf_program_header): Add maxpagesize param.  Set map_p_align.
	(copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize.
	Instead pass maxpagesize to rewrite_elf_program_header.
	* elf32-nds32.c (relax_range_measurement): Add link_info param.
	Get maxpagesize from link_info.  Adjust caller.
	* bfd-in2.h: Regenerate.
gas/
	* config/obj-elf.c (obj_elf_section): Don't set elf_osabi here.
	(obj_elf_type): Likewise.
ld/
	* ld.h (ld_config_type): Delete maxpagesize and commonpagesize.
	* emultempl/elf.em: Use link_info rather than config
	for maxpagesize and commonpagesize.
	* emultempl/ppc32elf.em: Likewise.
	* ldexp.c (fold_binary, fold_name): Likewise.
	* ldemul.c (after_parse_default): Likewise.
	(set_output_arch_default): Don't call bfd_emul_set_maxpagesize
	or bfd_emul_set_commonpagesize.
2020-12-16 15:17:53 +10:30
Alan Modra
3f75e1d67f elflink.c constify
* elflink.c (elf_flags_to_names): Constify.
2020-12-16 15:17:53 +10:30
Alan Modra
342371d54c XCOFF constify
There are occasions where it is reasonable to use a macro defining
function parameters, but this isn't one of them.  Use typedefs
instead, which also simplifies declaring a const array of function
pointers.

	* libxcoff.h (struct xcoff_backend_data_rec): Constify
	_xcoff_glink_code.
	(XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete.
	(xcoff_reloc_function, xcoff_complain_function): New typedef.
	(xcoff_calculate_relocation, xcoff_complain_overflow),
	(xcoff_reloc_type_noop, xcoff_reloc_type_fail),
	(xcoff_reloc_type_pos, xcoff_reloc_type_neg),
	(xcoff_reloc_type_rel, xcoff_reloc_type_toc),
	(xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration.
	* coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef.
	(xcoff_complain_overflow_dont_func): Likewise.
	(xcoff_complain_overflow_bitfield_func): Likewise.
	(xcoff_complain_overflow_signed_func): Likewise.
	(xcoff_complain_overflow_unsigned_func): Likewise.
	(xcoff_calculate_relocation, xcoff_complain_overflow): Constify.
	(xcoff_glink_code): Constify.
	* coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef.
	(xcoff64_calculate_relocation, xcoff64_glink_code): Constify.
2020-12-16 15:17:53 +10:30
Alan Modra
61d2295d72 xtensa constify
Move lots of read-only arrays to .rodata.

include/
	* xtensa-isa-internal.h (xtensa_format_internal),
	(xtensa_slot_internal, xtensa_operand_internal),
	(xtensa_arg_internal, xtensa_iclass_internal),
	(xtensa_opcode_internal, xtensa_regfile_internal),
	(xtensa_interface_internal, xtensa_funcUnit_internal),
	(xtensa_state_internal, xtensa_sysreg_internal): Constify.
bfd/
	* elf32-xtensa.c (narrowable, widenable): Constify.
	* xtensa-modules.c: Constify many arrays.
2020-12-16 15:17:53 +10:30
Alan Modra
8cb1c2c857 ppc64 constify
Nothing to see here.

	* elf64-ppc.c (synthetic_opd): Constify.
2020-12-16 15:17:52 +10:30
Alan Modra
14aa7c52a3 arc constify
Move a read-only array to .rodata.

	* arc-plt.h (plt_versions): Constify.
	* elf32-arc.c (arc_get_plt_version): Constify return pointer,
	adjust uses throughout.
2020-12-16 15:17:52 +10:30
Alan Modra
cf7a3c01d8 Lose some COFF/PE static vars, and peicode.h constify
This patch tidies some COFF and PE code that unnecessarily used static
variables to communicate between functions.

	* coffcode.h (pelength, peheader): Delete static variables.
	(coff_apply_checksum): Instead, define them as auto vars, and pass..
	(coff_read_word, coff_compute_checksum): ..to here.  Delete
	unnecessary forward declarations.
	* pei-x86_64.c (pdata_count): Delete static variable.
	(struct pex64_paps): New.
	(pex64_print_all_pdata_sections, pex64_bfd_print_pdata): Pass
	a pex64_paps for counting.
	* peicode.h (jtab): Constify.
2020-12-16 15:17:52 +10:30
Rae Kim
a33fc9aed4 gdb: multi-line support for "document" command
"document" command executed in python, gdb.execute("document
<comname>\n...\nend\n"), will wait for user input. Python extension stops
working from that point.

multi-line suport was introduced in commit 56bcdbea2. But "document" support
seem to be implemented.

gdb/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>

	* cli/cli-script.c (do_document_command): Rename from
	document_command. Handle multi-line input.
	(multi_line_command_p): Handle document_control.
	(build_command_line): Likewise.
	(execute_control_command_1): Likewise.
	(process_next_line): Likewise.
	(document_command): Call do_document_command.
	* cli/cli-script.h (enum command_control_type): Add
	document_control.

gdb/testsuite/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>
	* gdb.base/document.exp: New test.

Change-Id: Ice262b980c05051de4c106af9f3fde5b2a6df6fe
2020-12-15 23:04:04 -05:00
Tom Tromey
efd7ff149a Add expected type parameter to evaluate_expression
While working on the expression rewrite, I found a few spots that
called the internal functions of the expression evaluator, just to
pass in an expected type.  This patch adds a parameter to
evaluate_expression so that these functions can avoid this dependency.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

	* stap-probe.c (stap_probe::evaluate_argument): Use
	evaluate_expression.
	* dtrace-probe.c (dtrace_probe::evaluate_argument): Use
	evaluate_expression.
	* value.h (evaluate_expression): Add expect_type parameter.
	* objc-lang.c (print_object_command): Call evaluate_expression.
	* eval.c (evaluate_expression): Add expect_type parameter.
2020-12-15 18:57:07 -07:00
Tom Tromey
2adab65cc0 Introduce expression::first_opcode
This adds a new helper method, expression::first_opcode, that extracts
the outermost opcode of an expression.  This simplifies some patches
in the expression rewrite series.

Note that this patch requires the earlier patch to avoid manual
dissection of OP_TYPE operations.

2020-12-15  Tom Tromey  <tom@tromey.com>

	* varobj.c (varobj_create): Use first_opcode.
	* value.c (init_if_undefined_command): Use first_opcode.
	* typeprint.c (whatis_exp): Use first_opcode.
	* tracepoint.c (validate_actionline): Use first_opcode.
	(encode_actions_1): Use first_opcode.
	* stack.c (return_command): Use first_opcode.
	* expression.h (struct expression) <first_opcode>: New method.
	* eval.c (parse_and_eval_type): Use first_opcode.
	* dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.
2020-12-15 18:24:02 -07:00
Tom Tromey
1ab8280d7d Clean up arguments to evaluate_subexp_do_call
I noticed hat evaluate_subexp_do_call takes an array of arguments and
a count -- but, unlike the usual convention, the count does not
include the first element.

This patch changes this function to match call_function_by_hand --
passing the callee separately, and using an array_view for the
arguments.  This makes it simpler to understand.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

	* f-lang.c (evaluate_subexp_f): Update.
	* expression.h (evaluate_subexp_do_call): Update.
	* eval.c (evaluate_subexp_do_call): Add callee parameter.  Replace
	nargs, argvec with array_view.
	(evaluate_funcall): Update.
2020-12-15 17:53:34 -07:00
Tom Tromey
cf608cc40c C++-ify Ada component interval handling
The Ada component interval handling code, used for aggregate
assignments, does a pre-pass over the sub-expressions so that it can
size an array.  For my expression rewrite, it was handy to C++-ify
this.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (num_component_specs): Remove.
	(assign_aggregate): Update.
	(aggregate_assign_positional, aggregate_assign_from_choices)
	(aggregate_assign_others, add_component_interval): Change
	arguments.
2020-12-15 17:41:29 -07:00
GDB Administrator
e1b2362cbf Automatic date update in version.in 2020-12-16 00:00:15 +00:00
Cary Coutant
2b2d74f4a1 Cosmetic improvements for OSABI access.
Add accessor methods to elfcpp::Ehdr class for EI_OSABI and EI_ABIVERSION;
use those to simplify initialization of Osabi class and eliminate the need
to template the class.

elfcpp/
	* elfcpp.h (class Ehdr): Add get_ei_osabi and get_ei_abiversion methods.

gold/
	* dwp.cc (class Dwo_file): Use new Ehdr::get_ei_osabi and
	get_ei_abiversion methods.
	* incremental.cc (make_sized_incremental_binary): Likewise.
	* object.cc (Sized_relobj_file::Sized_relobj_file): Likewise.
	(make_elf_sized_object): Likewise.
	* object.h (class Osabi): Make the class untemplated.
2020-12-15 14:37:22 -08:00
H.J. Lu
8947abe6bf gold: Add missing ChangeLog entries for commit ff4bc37d7 2020-12-15 07:39:16 -08:00
Tom Tromey
0e5ad4426a Highlight deprecated commands using title style
After Andrew's latest patch, I noticed that the deprecation warnings
could use the (so-called) title style when printing command names.
This patch implements this idea.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

	* cli/cli-decode.c (deprecated_cmd_warning): Use title style for
	command names.

gdb/testsuite/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

	* gdb.base/style.exp: Add deprecation tests.
2020-12-15 08:07:32 -07:00
Alan Modra
7bed846687 PR27071, gas bugs uncovered by fuzzing
PR 27071
	* config/obj-elf.c (elf_obj_symbol_clone_hook): New function.
	(elf_format_ops): Set symbol_clone_hook.
	* config/obj-elf.h (elf_obj_symbol_clone_hook): Declare.
	(obj_symbol_clone_hook): Define.
	* listing.c (buffer_line): Avoid integer overflow on paper_width
	set to zero.
2020-12-16 01:13:58 +10:30
Jens Bauer
9f132af9e1 Add support for the SDIV and UDIV instructions to the ARM simulator.
* armemu.c (handle_v6_insn): Add support for SDIV and UDIV.
	* thumbemu.c (handle_T2_insn): Likewise.
2020-12-15 12:40:35 +00:00
Tom de Vries
77c8aaf716 [gdb/testsuite] Handle PS1 quirk in gdb.base/multi-line-starts-subshell.exp
On SLE-11, I run into:
...
(gdb) if 1^M
 >shell HOME=/dev/null PS1="gdb-subshell$ " /bin/sh^M
 >end^M
hostname:/dir> FAIL: gdb.base/multi-line-starts-subshell.exp: \
  spawn subshell from multi-line (timeout)
...

The problem is that the PS1 setting has no effect, due to a bug on older
openSUSE/SLE version.  The mechanism there is:
- /etc/profile sets ENV=/etc/bash.bashrc
- /bin/sh is started
- /bin/sh executes ENV, in other words /etc/bash.bashrc
- during the execution of /etc/bash.bashrc, PS1 is set unconditionally

Fix this by setting PS1 after spawning the subshell.

Tested on x86_64-linux.

2020-12-15  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26952
	* gdb.base/multi-line-starts-subshell.exp: Set PS1 after spawning
	shell.
2020-12-15 10:18:23 +01:00
Vivek Das Mohapatra
8a87b27911 Implement and document -z unique / -z nounique handling in gold
* layout.cc (Layout::finish_dynamic_section): Set DF_GNU_1_UNIQUE.
	* options.h (class General_options): Handle -z unique, -z nounique.
2020-12-15 18:45:24 +10:30
Vivek Das Mohapatra
af3c233bdb Define DT_GNU_FLAGS_1 and DF_GNU_1_UNIQUE for gold
* elfcpp.h (enum DT): New enum member DT_GNU_FLAGS_1.
	(enum DF_GNU_1): New enum DF_GNU_1 containing DF_GNU_1_UNIQUE.
2020-12-15 18:45:16 +10:30
Vivek Das Mohapatra
a5da3dee21 Handle DT_GNU_FLAGS_1 in readelf
* readelf.c (get_dynamic_type): Handle DT_GNU_FLAGS_1.
	(process_dynamic_section): Likewise.
2020-12-15 18:45:09 +10:30
Vivek Das Mohapatra
c3805e4cef Document -z unique/-z nounique in the ld man page and help output
* ld.texi (Options): Document -z unique and -z nounique.
	* lexsup.c (elf_shlib_list_options): Likewise.
2020-12-15 18:45:03 +10:30
Vivek Das Mohapatra
6a0a0dd0cc Handle -z unique/-z nounique in ld
Add (or suppress) a DT_GNU_FLAGS_1 dynamic section
with a bit flag value of DF_GNU_1_UNIQUE.

bfd/
	* elflink.c (bfd_elf_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section.
include/
	* bfdlink.h (struct bfd_link_info): New field gnu_flags_1.
ld/
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
	Parse -z unique / -z nounique options.
2020-12-15 18:44:56 +10:30
Vivek Das Mohapatra
ee0688c233 Define a new DT_GNU_FLAGS_1 dynamic section for ld, readelf et al
DT_GNU_FLAGS_1 added to the DT_VALRNGLO-DT_VALRNGHI range.
DT_GNU_FLAGS_1 value DF_GNU_1_UNIQUE added.

	* elf/common.h (DT_GNU_FLAGS_1, DF_GNU_1_UNIQUE): Define.
2020-12-15 18:44:43 +10:30
Simon Marchi
60598dbd58 gdb/testsuite: fix typo in gdb_test_multiple doc
gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_test_multiple): Fix typo in doc.

Change-Id: Ieb188b3382395ce951bfba5a5f25aaea0f89ebf9
2020-12-14 23:45:17 -05:00
GDB Administrator
2eef5098e9 Automatic date update in version.in 2020-12-15 00:00:17 +00:00
Cary Coutant
ff4bc37d77 Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD ELFOSABIs.
2020-12-14  H.J. Lu  <hjl.tools@gmail.com>
	    Cary Coutant  <ccoutant@gmail.com>

elfcpp/
	PR gold/27039
	* elfcpp.h (SHF): Add SHF_GNU_RETAIN.

gold/
    	PR gold/27039
	* layout.cc (Layout::layout): Strip SHF_GNU_RETAIN.
	* object.cc (Sized_relobj_file::Sized_relobj_file): Initialize osabi_.
	(Sized_relobj_file::do_layout): Keep SHF_GNU_RETAIN sections for
	GNU/FreBSD ELFOSABIs.
	* object.h (Osabi) New class.
	(Sized_relobj_file): Add osabi() and osabi_.
	* testsuite/Makefile.am (check_SCRIPTS): Add retain.sh.
	(check_DATA): Add retain_1.out retain_2.out.
	(MOSTLYCLEANFILES): Add retain_1 retain_2.
	(retain_1.out): New target.
	(retain_1): Likewise.
	(retain_1.o): Likewise.
	(retain_2.out): Likewise.
	(retain_2): Likewise.
	(retain_2.o): Likewise.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/retain.sh: New file.
	* testsuite/retain_1.s: Likewise.
	* testsuite/retain_2.s: Likewise.
2020-12-14 15:49:27 -08:00
Mark Wielaard
8cd6d968de Add form used for SPECIAL_expr as comment in testsuite Dwarf Assembler
Replace the "SPECIAL_expr" comment with either "DW_FORM_block" or
"DW_FORM_exprloc" in the abbrev.

gdb/testsuite/ChangeLog:

	* lib/dwarf.exp (Dwarf::_handle_attribute): Handle SPECIAL_expr
	specially, set attr_form_comment to the actual FORM string used.
2020-12-14 22:06:30 +01:00
Mark Wielaard
eab9267c33 Use DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+.
Since DWARF version 4 expressions are represented by DW_FORM_exprloc
instead of a block form. Support this in the testsuite Dwarf Assembler
by setting the SPECIAL_expr form once we know the CU version.

This doesn't change any testsuite results, it just makes the produced
DWARF valid. gdb also accepts expressions in block form for DWARF
version 4 and above, but this is technically incorrect.

gdb/testsuite/ChangeLog:

	* lib/dwarf.exp (Dwarf::_read_constants): Don't set
	_constants(SPECIAL_expr) here, but set it...
	(Dwarf::cu): ...here based on _cu_version.
2020-12-14 20:16:33 +01:00
Tom de Vries
2f4132646d [gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib
When running test-case gdb.base/info-shared.exp, I see in gdb.log:
...
Executing on host: \
  gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c
...

The -fPIC comes from the test-case:
...
if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
         [list additional_flags=-fPIC]] != "" } {
...
but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib.

The proc gdb_compile_shlib adds the -fpic or similar dependent on platform
and compiler.  However, in some cases it doesn't add anything, which is
probably why all those test-case pass -fPIC.

Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and
ensuring that gdb_compile_shlib takes care of adding it, if required.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
	pass -fPIC.
	* gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
	* gdb.base/break-probes.exp: Same.
	* gdb.base/ctxobj.exp: Same.
	* gdb.base/dso2dso.exp: Same.
	* gdb.base/global-var-nested-by-dso.exp: Same.
	* gdb.base/info-shared.exp: Same.
	* gdb.base/jit-reader-simple.exp: Same.
	* gdb.base/print-file-var.exp: Same.
	* gdb.base/skip-solib.exp: Same.
	* gdb.btrace/dlopen.exp: Same.
2020-12-14 18:16:40 +01:00
Tom Tromey
a6f3c8a1a8 Do not manually dissect OP_TYPE operations
Some code in GDB will examine the structure of an expression to see if
it starts with OP_TYPE, and then proceed to extract the type by hand.

There is no need to do this dissection manually.  evaluate_type does
the same thing via an "allowed" API.

This patch changes such code to use evaluate_type.  In two cases this
simplifies the code.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tom@tromey.com>

	* dtrace-probe.c (dtrace_process_dof_probe): Use value_type.
	* typeprint.c (whatis_exp): Always use evaluate_type.
	(maintenance_print_type): Likewise.  Simplify.
2020-12-14 09:43:20 -07:00
Tom de Vries
18f1cb1fc5 [gdb/testsuite] Handle missing xz in gdb.base/gnu-debugdata.exp
When running test-case gdb.base/gnu-debugdata.exp on SLE-11, I run into:
...
FAIL: gdb.base/gnu-debugdata.exp: xz
...

The fact that xz is not installed does not mean there's a fail, merely that
the test is unsupported.

Fix this by detecting the "spawn failed" reply in run_on_host and issuing
UNSUPPORTED instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26963
	* lib/gdb.exp (run_on_host): Declare test unsupported if spawn fails.
2020-12-14 17:05:11 +01:00
Tom de Vries
519155c9f6 [gdb/testsuite] Handle no glibc debuginfo in gdb.base/solib-corrupted.exp
When running test-case gdb.base/solib-corrupted.exp on SLE-11, I get:
...
(gdb) PASS: gdb.base/solib-corrupted.exp: normal list
p/x _r_debug->r_map->l_next = _r_debug->r_map^M
'_r_debug' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/solib-corrupted.exp: make solibs looping
...

The reason that _r_debug has unknown type is that glibc debuginfo is not
installed.  The test-case attempts to detect this but doesn't handle this
particular error string.

Fix this by adding the "unknown type" line to the regexp detecting missing
glibc debuginfo.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26962
	* gdb.base/solib-corrupted.exp: Handle "'_r_debug' has unknown type;
	cast it to its declared type".
2020-12-14 17:05:11 +01:00
Tom de Vries
153f6e6cb0 [gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
On SLE-11, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell \
  (timeout)
...

The problem is that the shell prompt has PS1="\h:\w> ", but the test expects
a shell prompt ending in a space preceded by either '$' or '#':
...
set shell_prompt_re "\[$#\] "
...

We could easily fix this by adding '>' to shell_prompt_re, but this wouldn't
work for other PS1 setting.

Fix this instead by setting the shell prompt to "gdb-subshell$ " (as in
gdb.base/multi-line-starts-subshell.exp).

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26951
	* gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
	shell prompt.
2020-12-14 17:05:11 +01:00
Tom Tromey
86b442599b Handle block-local names for Ada
GNAT can generate a mangled name with "B_N" (where N is a number) in
the middle, like "hello__B_1__fourth.0".  This is used for names local
to a block.  Multiple levels of block-local name can also occur, a
possibility that was neglected by v1 of this patch.  This patch
changes gdb to handle these names.

The wild name matcher is updated a straightforward way.  The full
matcher is rewritten.  The hash function is updated to ensure that
this works.

This version does not seem to have the performance problems that
affected v1.  In particular, the previously-slow "bt" problem has been
fixed.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* dictionary.c (language_defn::search_name_hash): Ignore "B".
	* ada-lang.c (advance_wild_match): Ignore "B".
	(full_match): Remove.
	(do_full_match): Rewrite.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/nested.exp: Add new tests.
	* gdb.ada/nested/hello.adb (Fourth, Fifth): New procedures.
2020-12-14 08:14:06 -07:00
Tom Tromey
25a1127be7 Use exact match in get_var_value
get_var_value is only used when an exact match is needed.  This
changes this function to ensure this sort of matching is done.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (get_var_value): Only consider exact matches.
2020-12-14 08:14:06 -07:00
Tom Tromey
e26624c669 Be more careful when rewriting thick pointer array type
To handle thick pointers with -fgnat-encodings=minimal, gdb will
rewrite the underlying array type to remove the bounds.  However, if
the same DWARF type is used both for a thick pointer and for an
ordinary array, this will have the side effect of removing the bounds
from the array.  This breaks the printing of objects of this type.

This patch fixes the problem by copying the array type, its range, and
its bounds.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* dwarf2/read.c (rewrite_array_type): New function.
        (quirk_ada_thick_pointer_struct): Use rewrite_array_type.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

	* gdb.dwarf2/ada-thick-pointer.exp: New file.
2020-12-14 07:42:23 -07:00