Commit Graph

101093 Commits

Author SHA1 Message Date
Martin Liska 40bd13ced9 include: Sync plugin-api.h with GCC
Fix typo in a macro usage.

	PR lto/94249
	* plugin-api.h: Fix a typo.
2020-04-01 02:36:11 -07:00
Hans-Peter Nilsson 41ff29bf5d ld/testsuite/ld-scripts/defined4.d: Don't xfail mmix-*-*.
A recent fix for the mmo input reader caused symbol-to-type mapping
(which is heuristic for the mmo format) to change (as in "corrected"),
and this test-case now passes.

Before that change, the comment was actually wrong: the symbol type
was mistakenly set to as B for uninitialized data, not T for text
section.
2020-04-01 04:10:18 +02:00
Hans-Peter Nilsson 7b948a2580 mmo.c: Fix ld testsuite regression "objcopy executable (pr25662)".
* mmo.c (mmo_scan): Create .text section only when needed, not
	from the start.

For the test-case at hand, the .data section is created and output
first by the linker, but the mmo input-reader mmo_scan always creates
a .text section.  Since sections are output in the order in which
they're created, it's output first, breaking the assumption that
obcopy without options (or with -p) creates output identical to its
input.  The point of creating it at the top of mmo_scan is a trivial
default assignment for the current section variable "sec".  Instead we
now defer the default, creating it only when needed and sec is NULL.
2020-04-01 04:03:46 +02:00
GDB Administrator 283b7aa134 Automatic date update in version.in 2020-04-01 00:00:09 +00:00
Maciej W. Rozycki 876678f05e PR 25611, PR 25614: GAS: Remove a double inclusion of "bignum.h"
Correct an issue with commit 5496f3c635 ("Add support for generating
DWARF-5 format directory and file name tables from the assembler.") and
remove a duplicate direct inclusion of "bignum.h" from dwarf2dbg.c that
causes a GAS compilation error:

In file included from .../gas/dwarf2dbg.c:33:
.../gas/bignum.h:42: error: redefinition of typedef 'LITTLENUM_TYPE'
.../gas/bignum.h:42: error: previous declaration of 'LITTLENUM_TYPE' was here
make[4]: *** [dwarf2dbg.o] Error 1

with some GCC versions, as this header has been already included via
"as.h" and then "flonum.h".

	gas/
	PR 25611
	PR 25614
	* dwarf2dbg.c: Do not include "bignum.h".
2020-03-31 23:01:36 +01:00
Tom Tromey 6f29a53415 Fix py-tui.c build problem
py-tui.c can fail to build if the ncurses development headers are not
installed, but if Python was built against ncurses.  In this case, the
Python headers will define HAVE_NCURSES_H, confusing gdb_curses.h.

This patch fixes the problem by moving this include inside
"#ifdef TUI".

gdb/ChangeLog
2020-03-31  Joel Jones  <joelkevinjones@gmail.com>

	PR tui/25597:
	* python/py-tui.c: Include gdb_curses.h inside of #ifdef TUI.
2020-03-31 14:09:36 -06:00
Tom Tromey af62665e13 Don't pass NULL to memcpy in gdb
I compiled gdb with -fsanitize=undefined and ran the test suite.

A couple of reports came from passing NULL to memcpy, e.g.:

[...]btrace-common.cc:176:13: runtime error: null pointer passed as argument 2, which is declared to never be null

While it would be better to fix this in the standard, in the meantime
it seems easy to avoid this error.

gdb/ChangeLog
2020-03-31  Tom Tromey  <tromey@adacore.com>

	* dwarf2/abbrev.c (abbrev_table::read): Conditionally call
	memcpy.

gdbsupport/ChangeLog
2020-03-31  Tom Tromey  <tromey@adacore.com>

	* btrace-common.cc (btrace_data_append): Conditionally call
	memcpy.
2020-03-31 07:29:53 -06:00
Tom de Vries 16b0db75af [gdb/testsuite] Fix c-linkage-name.exp with -flto
When running test-case gdb.base/c-linkage-name.exp with target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects, I run into:
...
PASS: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: no
FAIL: gdb.base/c-linkage-name.exp: print symada__cS before partial symtab \
  expansion
...

The test-case tries to print a symbol before and after symtab expansion.

And it tries to ensure (since commit 13c3a74afb) that the symtab containing
the symbol is not yet expanded when doing the 'before' print, by placing the
symbol in a different CU (c-linkage-name-2.c) from the one containing main
(c-linkage-name.c), such that when we load the exec and expand the symtab
containing main, the symtab containing the symbol isn't.

The generated debug info for the test-case when using mentioned target board
however is structured like this:
...
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d8>   DW_AT_name        : <artificial>
 <1><f4>: Abbrev Number: 2 (DW_TAG_imported_unit)
    <f5>   DW_AT_import      : <0x16b>  [Abbrev Number: 1]
 <1><f9>: Abbrev Number: 2 (DW_TAG_imported_unit)
    <fa>   DW_AT_import      : <0x19c>  [Abbrev Number: 1]
 <1><fe>: Abbrev Number: 3 (DW_TAG_subprogram)
    <ff>   DW_AT_abstract_origin: <0x17d>
 <1><115>: Abbrev Number: 4 (DW_TAG_variable)
    <116>   DW_AT_abstract_origin: <0x1ce>
 <0><16b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <171>   DW_AT_name        : c-linkage-name.c
 <1><17d>: Abbrev Number: 2 (DW_TAG_subprogram)
    <17e>   DW_AT_name        : main
 <0><19c>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <1a2>   DW_AT_name        : c-linkage-name-2.c
 <1><1ce>: Abbrev Number: 5 (DW_TAG_variable)
    <1cf>   DW_AT_name        : mundane
    <1d6>   DW_AT_linkage_name: symada__cS
...

So, the CU named <artificial> contains both the concrete main and the concrete
symbol, which explains the FAIL.

The first test should fail, but passes for two reasons.

First of all, due to PR symtab/25700, we have two regular partial symtabs
c-linkage-name-2.c instead of one, and one of them is expanded, the other one
not:
...
  { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38d6f60)
    readin yes
  { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38d6fe0)
    readin no
...

And then there's the include symtab, which is also not expanded:
...
  { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38143e0)
    readin no
...

Fix the FAIL by explicitly setting the language before load, changing the
language setting from auto/c to manual/c, such that the symtab containing main
is no longer expanded.

And make the symtab expansion testing more robust by using the output of
"maint info symtabs" instead of "maint info psymtabs".

Tested on x86_64-linux, using native and target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp, readnow.exp and
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects.

gdb/testsuite/ChangeLog:

2020-03-31  Tom de Vries  <tdevries@suse.de>

	* gdb.base/c-linkage-name.exp: Fix test-case comment.  Set language to
	c.  Use "maint info symtabs" to check symtab expansion.
2020-03-31 12:17:27 +02:00
Alan Modra 89b599df37 alpha-coff: unitialised read
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Correct bfd_bread
	return value check.
2020-03-31 15:04:21 +10:30
Alan Modra 8169954446 alpha-vms: sanity checks for image_write
* vms-alpha.c (image_write): Check bounds for sections without
	contents too.  Error on non-zero write to section without
	contents.
	(_bfd_vms_slurp_etir): Check return of image_write* functions.
2020-03-31 15:04:21 +10:30
Alan Modra b3b360dec7 tekhex: Uninitialised read
* tekhex.c (pass_over): Check is_eof before reading buffer.
2020-03-31 15:04:21 +10:30
GDB Administrator d262797294 Automatic date update in version.in 2020-03-31 00:00:06 +00:00
Nelson Chu d1a89da5de RISC-V: Update CSR to privileged spec 1.11.
gas/
	* testsuite/gas/riscv/alias-csr.d: Move this to priv-reg-pseudo.
	* testsuite/gas/riscv/alias-csr.s: Likewise.
	* testsuite/gas/riscv/no-aliases-csr.d: Move this
	to priv-reg-pseudo-noalias.
	* testsuite/gas/riscv/bad-csr.d: Rename to priv-reg-fail-nonexistent.
	* testsuite/gas/riscv/bad-csr.l: Likewise.
	* testsuite/gas/riscv/bad-csr.s: Likewise.
	* testsuite/gas/riscv/satp.d: Removed.  Already included in priv-reg.
	* testsuite/gas/riscv/satp.s: Likewise.
	* testsuite/gas/riscv/priv-reg-pseudo.d: New testcase for all pseudo
	csr instruction, including alias-csr testcase.
	* testsuite/gas/riscv/priv-reg-pseudo.s: Likewise.
	* testsuite/gas/riscv/priv-reg-pseudo-noalias.d: New testcase for all
	pseudo instruction with objdump -Mno-aliases.
	* testsuite/gas/riscv/priv-reg-fail-nonexistent.d: New testcase.
	* testsuite/gas/riscv/priv-reg-fail-nonexistent.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-nonexistent.s: Likewise.
	* testsuite/gas/riscv/priv-reg.d: Update CSR to 1.11.
	* testsuite/gas/riscv/priv-reg.s: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
	* testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
	* testsuite/gas/riscv/csr-dw-regnums.s: Likewise.

	include/
	* opcode/riscv-opc.h: Update CSR to 1.11.

	gdb/
	* features/riscv/32bit-csr.xml: Regenerated.
	* features/riscv/64bit-csr.xml: Regenerated.
2020-03-30 12:24:53 -07:00
Tom Tromey d8af906814 Change ada_which_variant_applies to value API
While debugging an Ada regression, I noticed that all the callers of
ada_which_variant_applies desconstruct a value, only to have it be
reconstructed by this function.

This patch removes this inefficiency in favor of simply passing in the
value directly.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-03-30  Tom Tromey  <tromey@adacore.com>

	* ada-valprint.c (print_variant_part): Update.
	* ada-lang.h (ada_which_variant_applies): Update.
	* ada-lang.c (ada_which_variant_applies): Remove outer_type and
	outer_valaddr parameters; replace with "outer" value parameter.
	(to_fixed_variant_branch_type): Update.
2020-03-30 11:54:50 -06:00
Nick Clifton 00386881a3 Fix objcopy's --preserve-dates command line option so that it will work with PE format files.
PR binutils/pr25662
bfd	* libcoff-in.h (struct pe_tdata): Rename the insert_timestamp
	field to timestamp and make it an integer.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp
	field in the pe_data structure rather than the insert_timestamp
	field.

binutils* objcopy.c (copy_object): When copying PE format files set the
	timestamp field in the pe_data structure if the preserve_dates
	flag is set.
	* testsuite/binutils-all/objcopy.exp (objcopy_test) Use
	--preserve-dates in place of the -p option, in order to make its
	effect more obvious.

ld	* emultempl/pe.em (after_open): Replace initialisation of the
	insert_timestamp field in the pe_data structure with an
	initialisation of the timestamp field.
	* emultemp/pep.em: Likewise.
	* pe-dll.c (fill_edata): Use the timestamp field in the pe_data
	structure instead of the insert_timestamp field.
2020-03-30 16:30:02 +01:00
Pedro Franco de Carvalho 227c0bf4b3 [PowerPC] Fix debug register issues in ppc-linux-nat
This patch fixes some issues with debug register handling for the powerpc
linux native target.

Currently, the target methods for installing and removing hardware
breakpoints and watchpoints in ppc-linux-nat.c affect all threads known to
linux-nat, including threads of different processes.

This patch changes ppc-linux-nat.c so that only the process of
inferior_ptid is affected by these target methods, as GDB expects.

This is done in the same way as various other architectures.  The
install/remove target methods only register a hardware breakpoint or
watchpoint, and then send a stop signal to the threads.  The debug
registers are only changed with ptrace right before each thread is next
resumed, using low_prepare_to_resume.

There are two interfaces to modify debug registers for linux running on
powerpc, with different sets of ptrace requests:

- PPC_PTRACE_GETHWDBGINFO, PPC_PTRACE_SETHWDEBUG, and
  PPC_PTRACE_DELHWDEBUG.

   Or

- PTRACE_SET_DEBUGREG and PTRACE_GET_DEBUGREG

The first set (HWDEBUG) is the more flexible one and allows setting
watchpoints with a variable watched region length and, for certain
embedded processors, multiple types of debug registers (e.g. hardware
breakpoints and hardware-assisted conditions for watchpoints).
Currently, server processors only provide one watchpoint.  The second one
(DEBUGREG) only allows setting one debug register, a watchpoint, so we
only use it if the first one is not available.

The HWDEBUG interface handles debug registers with slot numbers.  Once a
hardware watchpoint or breakpoint is installed (with
PPC_PTRACE_SETHWDEBUG), ptrace returns a slot number.  This slot number
can then be used to remove the watchpoint or breakpoint from the inferior
(with PPC_PTRACE_DELHWDEBUG).  The first interface also provides a
bitmask of available debug register features, which can be obtained with
PPC_PTRACE_GETHWDBGINFO.

When GDB first tries to use debug registers, we try the first interface
with a ptrace call, and if it isn't available, we fall back to the second
one, if available.  We use EIO as an indicator that an interface is not
available in the kernel.  For simplicity, with any other error we
immediately assume no interface is available.  Unfortunately this means
that if a process is killed by a signal right before we try to detect the
interface, we might get an ESRCH, which would prevent debug registers to
be used in the GDB session.  However, it isn't clear that we can safely
raise an exception and try again in the future in all the contexts where
we try to detect the interface.

If the HWDEBUG interface works but provides no feature bits, the target
falls back to the DEBUGREG interface.  When the kernel is configured
without CONFIG_HW_BREAKPOINTS (selected by CONFIG_PERF_EVENTS), there is
a bug that causes watchpoints installed with the HWDEBUG interface not to
trigger.  When this is the case, the feature bits will be zero, which is
used as the indicator to fall back to the DEBUGREG interface.  This isn't
ideal, but has always been the behavior of GDB before this patch, so I
decided not to change it.

A flag indicates for each thread if its debug registers need to be
updated the next time it is resumed.  The flag is set whenever the upper
layers request or remove a hardware watchpoint or breakpoint, or when a
new thread is detected.  Because some kernel configurations disable
watchpoints after they are hit, we also use the last stop reason of the
LWP to determine whether we should update the debug registers.  It isn't
clear that this is also true of BookE hardware breakpoints, but we also
check their stop reason to be on the safe side, since it doesn't hurt.

A map from process numbers to hardware watchpoint or breakpoint objects
keeps track of what has been requested by the upper layers of GDB, since
for GDB installing a hardware watchpoint or breakpoint means doing so for
the whole process.

When using the HWDEBUG interface we also have to keep track of which
slots were last installed in each thread with a map from threads to the
slots, so that they can be removed when needed.  When resuming a thread,
we remove all the slots using this map, then we install all the hardware
watchpoints and breakpoints from the per-process map of requests, and
then update the per-thread map accordingly.

This per-thread state is also used for copying the debug register state
after a fork or a clone is detected.  The kernel might do this depending
on the configuration.  Recent kernels running on server processors that
were configured with CONFIG_PERF_EVENTS (and therefore
CONFIG_HW_BREAKPOINTS) don't copy debug registers across forks and
clones.  Recent kernels without CONFIG_HW_BREAKPOINTS copy this state.  I
believe that on embedded processors (e.g. a ppc440) the debug register
state is copied, but I haven't been able to test this.  To handle both
cases, the per-thread state is always copied when forks and clones are
detected, and when we resume the thread and delete the debug register
slots before updating them, we ignore ENOENT errors.

We don't need to handle this when using the DEBUGREG interface since it
only allows one hardware watchpoint and doesn't return slot numbers, we
just set or clear this watchpoint when needed.

Since we signal running threads to stop after a request is processed, so
that we can update their debug registers when they are next resumed,
there will be a time between signalling the threads and their stop during
which the debug registers haven't been updated, even if the target
methods completed.

The tests in gdb.threads/watchpoint-fork.exp no longer fail with this
patch.

gdb/ChangeLog:
2020-03-30  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* ppc-linux-nat.c: Include <algorithm>, <unordered_map>, and
	<list>.  Remove inclusion of observable.h.
	(PPC_DEBUG_CURRENT_VERSION): Move up define.
	(struct arch_lwp_info): New struct.
	(class ppc_linux_dreg_interface): New class.
	(struct ppc_linux_process_info): New struct.
	(struct ppc_linux_nat_target) <low_delete_thread, low_new_fork>
	<low_new_clone, low_forget_process, low_prepare_to_resume>
	<copy_thread_dreg_state, mark_thread_stale>
	<mark_debug_registers_changed, register_hw_breakpoint>
	<clear_hw_breakpoint, register_wp, clear_wp>
	<can_use_watchpoint_cond_accel, calculate_dvc, check_condition>
	<num_memory_accesses, get_trigger_type>
	<create_watchpoint_request, hwdebug_point_cmp>
	<init_arch_lwp_info, get_arch_lwp_info>
	<low_stopped_by_watchpoint, low_stopped_data_address>: Declare as
	methods.
	<struct ptid_hash>: New inner struct.
	<m_dreg_interface, m_process_info, m_installed_hw_bps>: Declare
	members.
	(saved_dabr_value, hwdebug_info, max_slots_number)
	(struct hw_break_tuple, struct thread_points, ppc_threads)
	(have_ptrace_hwdebug_interface)
	(hwdebug_find_thread_points_by_tid)
	(hwdebug_insert_point, hwdebug_remove_point): Remove.
	(ppc_linux_nat_target::can_use_hw_breakpoint): Use
	m_dreg_interface, remove call to PTRACE_SET_DEBUGREG.
	(ppc_linux_nat_target::region_ok_for_hw_watchpoint): Add comment,
	use m_dreg_interface.
	(hwdebug_point_cmp): Change to...
	(ppc_linux_nat_target::hwdebug_point_cmp): ...this method.  Use
	reference arguments instead of pointers.
	(ppc_linux_nat_target::ranged_break_num_registers): Use
	m_dreg_interface.
	(ppc_linux_nat_target::insert_hw_breakpoint): Add comment, use
	m_dreg_interface.  Call register_hw_breakpoint.
	(ppc_linux_nat_target::remove_hw_breakpoint): Add comment, use
	m_dreg_interface.  Call clear_hw_breakpoint.
	(get_trigger_type): Change to...
	(ppc_linux_nat_target::get_trigger_type): ...this method.  Add
	comment.
	(ppc_linux_nat_target::insert_mask_watchpoint): Update comment,
	use m_dreg_interface.  Call register_hw_breakpoint.
	(ppc_linux_nat_target::remove_mask_watchpoint): Update comment,
	use m_dreg_interface.  Call clear_hw_breakpoint.
	(can_use_watchpoint_cond_accel): Change to...
	(ppc_linux_nat_target::can_use_watchpoint_cond_accel): ...this
	method.  Update comment, use m_dreg_interface and
	m_process_info.
	(calculate_dvc): Change to...
	(ppc_linux_nat_target::calculate_dvc): ...this method.  Use
	m_dreg_interface.
	(num_memory_accesses): Change to...
	(ppc_linux_nat_target::num_memory_accesses): ...this method.
	(check_condition): Change to...
	(ppc_linux_nat_target::check_condition): ...this method.
	(ppc_linux_nat_target::can_accel_watchpoint_condition): Update
	comment, use m_dreg_interface.
	(create_watchpoint_request): Change to...
	(ppc_linux_nat_target::create_watchpoint_request): ...this
	method.  Use m_dreg_interface.
	(ppc_linux_nat_target::insert_watchpoint): Add comment, use
	m_dreg_interface.  Call register_hw_breakpoint or register_wp.
	(ppc_linux_nat_target::remove_watchpoint): Add comment, use
	m_dreg_interface.  Call clear_hw_breakpoint or clear_wp.
	(ppc_linux_nat_target::low_forget_process)
	(ppc_linux_nat_target::low_new_fork)
	(ppc_linux_nat_target::low_new_clone)
	(ppc_linux_nat_target::low_delete_thread)
	(ppc_linux_nat_target::low_prepare_to_resume): New methods.
	(ppc_linux_nat_target::low_new_thread): Remove previous logic,
	only call mark_thread_stale.
	(ppc_linux_thread_exit): Remove.
	(ppc_linux_nat_target::stopped_data_address): Change to...
	(ppc_linux_nat_target::low_stopped_data_address): This. Add
	comment, use m_dreg_interface and m_thread_hw_breakpoints.
	(ppc_linux_nat_target::stopped_by_watchpoint): Change to...
	(ppc_linux_nat_target::stopped_by_watchpoint): This.  Add
	comment.  Call low_stopped_data_address.
	(ppc_linux_nat_target::watchpoint_addr_within_range): Use
	m_dreg_interface.
	(ppc_linux_nat_target::masked_watch_num_registers): Use
	m_dreg_interface.
	(ppc_linux_nat_target::copy_thread_dreg_state)
	(ppc_linux_nat_target::mark_thread_stale)
	(ppc_linux_nat_target::mark_debug_registers_changed)
	(ppc_linux_nat_target::register_hw_breakpoint)
	(ppc_linux_nat_target::clear_hw_breakpoint)
	(ppc_linux_nat_target::register_wp)
	(ppc_linux_nat_target::clear_wp)
	(ppc_linux_nat_target::init_arch_lwp_info)
	(ppc_linux_nat_target::get_arch_lwp_info): New methods.
	(_initialize_ppc_linux_nat): Remove observer callback.
2020-03-30 12:10:13 -03:00
Pedro Franco de Carvalho 4db10d8f49 [PowerPC] Move up some register access routines
Keep the routines related to register access grouped together.

gdb/ChangeLog:
2020-03-30  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* ppc-linux-nat.c (ppc_linux_nat_target::store_registers)
	(ppc_linux_nat_target::auxv_parse)
	(ppc_linux_nat_target::read_description)
	(supply_gregset, fill_gregset, supply_fpregset, fill_fpregset):
	Move up.
2020-03-30 12:08:24 -03:00
Pedro Franco de Carvalho 1310c1b066 Add low_new_clone method to linux_nat_target.
This patch adds a low_new_clone method to linux_nat_target, called after
a PTRACE_EVENT_CLONE is detected, similar to how low_new_fork is called
after PTRACE_EVENT_(V)FORK.

This is useful for targets that need to copy state associated with a
thread that is inherited across clones.

gdb/ChangeLog:
2020-03-30  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* linux-nat.h (low_new_clone): New method.
	* linux-nat.c (linux_handle_extended_wait): Call low_new_clone.
2020-03-30 12:06:43 -03:00
Tom de Vries c0502da688 [gdb/testsuite] Fix c-linkage-name.exp with {cc-with-gdb-index,readnow}.exp
When running test-case gdb.base/c-linkage-name.exp with target board
cc-with-gdb-index.exp, I see:
...
FAIL: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: no
FAIL: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: yes
...
The FAILs are due to the fact that partial symbol tables are not generated for
indexed executables.

When running the same test-case with target board readnow.exp, I see:
...
FAIL: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: no
FAIL: gdb.base/c-linkage-name.exp: print symada__cS before partial symtab \
  expansion
FAIL: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: yes
...
The "maint info psymtab" FAILs are also due to fact that the partial symbol
tables not generated, but in this case it's because the symtabs are fully
expanded upon load due to using -readnow.  The "print symada__cS before
partial symtab expansion" test intends to test the state before symbol table
expansion, and with -readnow that's not possible.

Mark these FAILs as UNSUPPORTED.

Tested on x86_64-linux, with native, and target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.

gdb/testsuite/ChangeLog:

2020-03-30  Tom de Vries  <tdevries@suse.de>

	* gdb.base/c-linkage-name.exp: Use readnow call to mark a test
	unsupported.
	(verify_psymtab_expanded): Move ...
	* lib/gdb.exp (verify_psymtab_expanded): ... here.  Add unsupported
	test.
	(readnow): New proc.
2020-03-30 10:52:59 +02:00
GDB Administrator c9fef64dab Automatic date update in version.in 2020-03-30 00:00:05 +00:00
Alan Modra 988b7300bc PR25745, powerpc64-ld overflows string buffer in --stats mode
PR 25745
	* elf64-ppc.c (ppc64_elf_build_stubs): Use asprintf to form
	statistics message.
2020-03-30 09:30:32 +10:30
Simon Marchi 69b037c30c gdb: rename partial symtab expand functions of debug info readers using legacy_psymtab
As I am trying to understand the dynamic of partial_symtab::read_symtab
and partial_symtab::expand_psymtab, I think that renaming these
functions helps make it clear that they are effectively implementations
of the partial_symtab::expand_psymtab method.

gdb/ChangeLog:

	* dbxread.c (dbx_psymtab_to_symtab_1): Rename to...
	(dbx_expand_psymtab): ... this.
	(start_psymtab): Update.
	* mdebugread.c (psymtab_to_symtab_1): Rename to...
	(mdebug_expand_psymtab): ... this.
	(parse_partial_symbols): Update.
	(new_psymtab): Update.
	* xcoffread.c (xcoff_psymtab_to_symtab_1): Rename to...
	(xcoff_expand_psymtab): ... this.
	(xcoff_start_psymtab): Update.
2020-03-29 15:24:48 -04:00
Simon Marchi 48993951ce gdb: rename partial_symtab::read_dependencies to expand_dependencies
This method calls partial_symtab::expand_psymtab on all dependencies of
a psymtab.  Given that there is also a partial_symtab::read_symtab
method, I think it would be clearer to name this function
expand_dependencies, rather than read_dependencies.

gdb/ChangeLog:

	* psympriv.h (partial_symtab) <read_dependencies>: Rename to...
	<expand_dependencies>: ... this.
	* psymtab.c (partial_symtab::read_dependencies): Rename to...
	(partial_symtab::expand_dependencies): ... this.
	* dwarf2/read.c (dwarf2_include_psymtab) <expand_psymtab>:
	Update.
	(dwarf2_psymtab::expand_psymtab): Update.
	* dbxread.c (dbx_psymtab_to_symtab_1): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
2020-03-29 15:23:48 -04:00
Simon Marchi 3ad830466f gdb: remove discard_psymtab function
This function does not add much value, compared to calling the method on
the psymtab_storage object directly.

gdb/ChangeLog:

	* psympriv.h (discard_psymtab): Remove.
	* dbxread.c (dbx_end_psymtab): Update.
	* xcoffread.c (xcoff_end_psymtab): Update.
2020-03-29 15:23:32 -04:00
GDB Administrator 37d59eacfe Automatic date update in version.in 2020-03-29 00:00:06 +00:00
Tom Tromey 4d1b9ab645 Fix comment in dwarf2/attribute.h
I noticed that a comment in dwarf2/attribute.h still referred to
dwarf2_get_attr_constant_value.  However, this is now a method on
struct attribute.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* dwarf2/attribute.h (struct attribute) <form_is_constant>: Update
	comment.
2020-03-28 09:25:41 -06:00
Tom Tromey f1749218ff Fix formatting of read_attribute_reprocess
I noticed that the start of read_attribute_reprocess had the wrong
formatting.  This patch fixes it.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (read_attribute_reprocess): Fix formatting.
2020-03-28 09:22:53 -06:00
H.J. Lu 767be9d907 ld: Set COMMONPAGESIZE for i386 Solaris
Since COMMONPAGESIZE is set for other Solaris targets, including x86-64
Solaris, also set COMMONPAGESIZE for i386 Solaris to fix

FAIL: Build pr20995-2.so
FAIL: pr20995-2

	PR 25732
	* emulparams/elf_i386_ldso.sh (COMMONPAGESIZE): New.
	* testsuite/ld-elf/shared.exp:Don't xfail pr20995-2 tests for
	Solaris.
2020-03-28 05:06:58 -07:00
Alan Modra 0a6a8b596b Re: Adjust objcopy_test
Last patch didn't manage to xfail spu due to clear_xfail *-*-*elf*.
Clearing *-*-*elf* dates back to a time when we had rather a lot more
setup_xfail patterns, so limiting it to hppa*-*-*elf*.  Also,
mips-*-irix ought to have been mips-*-irix* and I'm having second
thoughts about xfailing mips and hiding what looks like a problem: If
the mips target is supposed to emit names for local section symbols
and does so for objcopy, why isn't it doing the same for ld?  Also,
lots more mips targets would be subject to this test failing.  So I'm
backing out those xfails and leaving it to someone more knowledgeable
about mips.

	* testsuite/binutils-all/objcopy.exp (objcopy_test): Only
	clear_xfail hppa*-*-*elf*.  Revert mips xfails.
2020-03-28 14:40:58 +10:30
Alan Modra 6a81c59be7 Adjust objcopy_test
xfails spu due to a note section getting a different vma, and some
mips targets that give section symbols a name string.  I added -p
for the executable test in an attempt to fix all the pe target fails,
but that doesn't preserve the date/time for some reason.

	* testsuite/binutils-all/objcopy.exp (objcopy_test): Move xfails
	from here to calls.  Remove "m8*-*-*" entry.  Don't xfail tic54x
	but do xfail spu, mipstx39 and mips-sgi-irix for the executable
	test.  Pass "-p" to objcopy for the executable test.
2020-03-28 11:23:45 +10:30
GDB Administrator 8f4afc7112 Automatic date update in version.in 2020-03-28 00:00:09 +00:00
Hannes Domani ebea762639 Always fix system DLL paths for 32bit programs
GetModuleFileNameEx might also return the 64bit system directory for 32bit
programs even for a 32bit gdb:

(gdb) info sharedlibrary
From        To          Syms Read   Shared Object Library
0x779d0000  0x77b34d20  Yes (*)     C:\Windows\SysWOW64\ntdll.dll
0x76850000  0x7694ad9c  Yes (*)     C:\Windows\syswow64\kernel32.dll
0x75421000  0x75466a18  Yes (*)     C:\Windows\syswow64\KernelBase.dll
0x6fbe1000  0x6fcca1c0  Yes (*)     C:\Windows\system32\dbghelp.dll
0x76d31000  0x76ddb2c4  Yes (*)     C:\Windows\syswow64\msvcrt.dll

So this makes the path conversion for all 32bit programs.

gdb/ChangeLog:

2020-03-27  Hannes Domani  <ssbssa@yahoo.de>

	* windows-nat.c (windows_add_all_dlls): Fix system dll paths.
2020-03-27 22:48:03 +01:00
H.J. Lu 258e884429 ld: Xfail pr20995-2 tests for Solaris
Xfail pr20995-2 tests for Solaris since Solaris doesn't support RELRO.

	PR 25732
	* testsuite/ld-elf/shared.exp: Xfail pr20995-2 tests for Solaris.
2020-03-27 07:35:22 -07:00
H.J. Lu cacb9d8713 ld: Skip some x86 IFUNC tests for Solaris
Since Solaris ld.so.1 doesn't support ifunc and never will, skip some
x86 IFUNC tests for Solaris.

	PR 25732
	* testsuite/ld-ifunc/ifunc-23a-x86.d: Add notarget for Solaris.
	* testsuite/ld-ifunc/ifunc-24a-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-25a-x86.d: Likewise.
2020-03-27 07:01:54 -07:00
Andrew Burgess 8f2dae6a6a gdbsupport: Resolve shellcheck issues in create-version.sh script
Run shellcheck (version 0.4.7) on the create-version.sh script, and
resolve the issues it highlighter - they all seemed reasonable.

gdbsupport/ChangeLog:

	* create-version.sh: Resolve issues highlighted by shellcheck.
2020-03-27 13:52:00 +00:00
Jozef Lawrynowicz 1fafefd594 Add testcase for PR 25662 invalid sh_offset for section
binutils/ChangeLog:

2020-03-27  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	PR binutils/25662
	* testsuite/binutils-all/objcopy.exp (objcopy_test): Add argument to
	specify whether an object file or executable should be built and tested.
	Change test names to report whether an object file or executable is
	being tested.
	* testsuite/binutils-all/pr25662.ld: New test.
	* testsuite/binutils-all/pr25662.s: New test.
2020-03-27 10:54:26 +00:00
Alan Modra 80e2a3b66e Re: readelf looping in process_archive
This patch fixes a leak of qualified_name caused by 4c83662712 and a
double free introduced by fd486f32d1.  Not breaking out of the loop
results in an error: "failed to seek to next archive header".  That's
slightly better than silently preventing the possibility of endless
loops.

	* readelf.c (process_archive): Don't double free qualified_name.
	Don't break out of loop with "negative" archive_file_size, just
	set file offset to max.
2020-03-27 10:37:18 +10:30
GDB Administrator 89ff19d45e Automatic date update in version.in 2020-03-27 00:00:14 +00:00
John Baldwin a879b4d5a6 Support AT_BSDFLAGS on FreeBSD.
FreeBSD's kernel recently added a new ELF auxiliary vector entry
holding a mask of software features provided by the kernel.  This
change fixes 'info auxv' to report the name and description for this
vector entry instead of '???'.

include/ChangeLog:

	* elf/common.h (AT_FREEBSD_BSDFLAGS): Define.

gdb/ChangeLog:

	* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_FREEBSD_BSDFLAGS.
2020-03-26 09:48:28 -07:00
Tom Tromey 0826b30a9f Change two functions to be methods on struct attribute
This changes dwarf2_get_ref_die_offset and
dwarf2_get_attr_constant_value to be methods on struct attribute.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (handle_data_member_location, dwarf2_add_field)
	(mark_common_block_symbol_computed, read_tag_string_type)
	(attr_to_dynamic_prop, read_subrange_type): Update.
	(dwarf2_get_ref_die_offset, dwarf2_get_attr_constant_value): Move
	to be methods on struct attribute.
	(skip_one_die, process_imported_unit_die, read_namespace_alias)
	(read_call_site_scope, partial_die_info::read)
	(partial_die_info::read, lookup_die_type, follow_die_ref):
	Update.
	* dwarf2/attribute.c (attribute::get_ref_die_offset): New method,
	from dwarf2_get_ref_die_offset.
	(attribute::constant_value): New method, from
	dwarf2_get_attr_constant_value.
	* dwarf2/attribute.h (struct attribute) <get_ref_die_offset>:
	Declare method.
	<constant_value>: New method.
2020-03-26 09:28:28 -06:00
Tom Tromey 2b2558bfac Move DWARF-constant stringifying code to new file
This moves the DWARF debugging functions that stringify various
constants to a new file, dwarf2/stringify.c.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf_unit_type_name, dwarf_tag_name)
	(dwarf_attr_name, dwarf_form_name, dwarf_bool_name)
	(dwarf_type_encoding_name): Move to stringify.c.
	* Makefile.in (COMMON_SFILES): Add dwarf2/stringify.c.
	* dwarf2/stringify.c: New file.
	* dwarf2/stringify.h: New file.
2020-03-26 09:28:26 -06:00
Tom Tromey eeb647814f Rewrite new die_info methods
This rewrites the two new die_info methods to iterate over attributes
rather than to do two separate searches.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/die.h (struct die_info) <addr_base, ranges_base>:
	Rewrite.
2020-03-26 09:28:26 -06:00
Tom Tromey a39fdb411d Change two more functions to be methods on die_info
This changes lookup_addr_base and lookup_ranges_base to be methods on
die_info.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/die.h (struct die_info) <addr_base, ranges_base>: New
	methods.
	* dwarf2/read.c (lookup_addr_base): Move to die.h.
	(lookup_ranges_base): Likewise.
	(read_cutu_die_from_dwo, read_full_die_1): Update.
2020-03-26 09:28:25 -06:00
Tom Tromey 436c571c6a Remove sibling_die
The sibling_die helper function does not seem to add much value,
considering that many other fields of die_info are directly accessed.
So, this removes it.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (read_import_statement, read_file_scope)
	(read_type_unit_scope, inherit_abstract_dies, read_func_scope)
	(read_lexical_block_scope, read_call_site_scope)
	(dwarf2_get_subprogram_pc_bounds, get_scope_pc_bounds)
	(handle_struct_member_die, process_structure_scope)
	(update_enumeration_type_from_children)
	(process_enumeration_scope, read_array_type, read_common_block)
	(read_namespace, read_module, read_subroutine_type): Update.
	(sibling_die): Remove.
2020-03-26 09:28:23 -06:00
Tom Tromey 052c8bb83a Change dwarf2_attr_no_follow to be a method
This changes dwarf2_attr_no_follow to be a method on die_info.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (lookup_addr_base, lookup_ranges_base)
	(build_type_psymtabs_reader, read_structure_type)
	(read_enumeration_type, read_full_die_1): Update.
	(dwarf2_attr_no_follow): Move to die.h.
	* dwarf2/die.h (struct die_info) <attr>: New method.
2020-03-26 09:28:22 -06:00
Tom Tromey 2b24b6e4a6 Remove dwarf2_cu::base_known
This removes dwarf2_cu::base_known, changing base_address to be a
gdb::optional.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (struct dwarf2_cu) <base_known>: Remove.
	<base_address>: Now an optional.
	(dwarf2_find_base_address, dwarf2_rnglists_process)
	(dwarf2_ranges_process, fill_in_loclist_baton)
	(dwarf2_symbol_mark_computed): Update.
2020-03-26 09:28:21 -06:00
Tom Tromey c2d50fd0b3 Move die_info to new header
This moves struct die_info to a new header, dwarf2/die.h.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (struct die_info): Move to die.h.
	* dwarf2/die.h: New file.
2020-03-26 09:28:21 -06:00
Tom Tromey 0df7ad3a67 Move more code to line-header.c
This moves some more code out of read.c and into line-header.c.
dwarf_decode_line_header is split into two -- the part remaining in
read.c handles interfacing to the dwarf2_cu; while the part in
line-header.c (more or less) purely handles the actual decoding.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/line-header.h (dwarf_decode_line_header): Declare.
	* dwarf2/read.c
	(dwarf2_statement_list_fits_in_line_number_section_complaint):
	Move to line-header.c.
	(read_checked_initial_length_and_offset, read_formatted_entries):
	Likewise.
	(dwarf_decode_line_header): Split into two.
	* dwarf2/line-header.c
	(dwarf2_statement_list_fits_in_line_number_section_complaint):
	Move from read.c.
	(read_checked_initial_length_and_offset, read_formatted_entries):
	Likewise.
	(dwarf_decode_line_header): New function, split from read.c.
2020-03-26 09:28:20 -06:00
Tom Tromey 86c0bb4c57 Convert read_indirect_line_string to a method
This changes read_indirect_line_string to be a method on
dwarf2_per_objfile.  This makes it a bit simpler to share between
files.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_objfile) <read_line_string>:
	Declare method.
	* dwarf2/read.c (read_attribute_value): Update.
	(dwarf2_per_objfile::read_line_string): Rename from
	read_indirect_line_string.
	(read_formatted_entries): Update.
2020-03-26 09:28:19 -06:00
Tom Tromey 2ef46c2fbb Trivial fix in dwarf_decode_macro_bytes
One spot in dwarf_decode_macro_bytes could use the existing "objfile"
local variable.

gdb/ChangeLog
2020-03-26  Tom Tromey  <tom@tromey.com>

	* dwarf2/macro.c (dwarf_decode_macro_bytes): Use objfile local
	variable.
2020-03-26 09:28:18 -06:00