Simon Marchi [Mon, 16 Mar 2020 20:56:36 +0000 (16:56 -0400)]
gdb: select "Cygwin" OS ABI for Cygwin binaries
Before this patch, the "Windows" OS ABI is selected for all Windows
executables, including Cygwin ones. This patch makes GDB differentiate
Cygwin binaries from non-Cygwin ones, and selects the "Cygwin" OS ABI
for the Cygwin ones.
To check whether a Windows PE executable is a Cygwin one, we check the
library list in the .idata section, see if it contains "cygwin1.dll".
I had to add code to parse the .idata section, because BFD doesn't seem
to expose this information. BFD does parse this information, but only
to print it in textual form (function pe_print_idata):
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/peXXigen.c;h=
e42d646552a0ca1e856e082256cd3d943b54ddf0;hb=HEAD#l1261
Here's the relevant portion of the PE format documentation:
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section
This page was also useful:
https://blog.kowalczyk.info/articles/pefileformat.html#
9ccef823-67e7-4372-9172-
045d7b1fb006
With this patch applied, this is what I get:
(gdb) file some_mingw_x86_64_binary.exe
Reading symbols from some_mingw_x86_64_binary.exe...
(gdb) show osabi
The current OS ABI is "auto" (currently "Windows").
The default OS ABI is "GNU/Linux".
(gdb) file some_mingw_i386_binary.exe
Reading symbols from some_mingw_i386_binary.exe...
(gdb) show osabi
The current OS ABI is "auto" (currently "Windows").
The default OS ABI is "GNU/Linux".
(gdb) file some_cygwin_x86_64_binary.exe
Reading symbols from some_cygwin_x86_64_binary.exe...
(gdb) show osabi
The current OS ABI is "auto" (currently "Cygwin").
The default OS ABI is "GNU/Linux".
gdb/ChangeLog:
* windows-tdep.h (is_linked_with_cygwin_dll): New declaration.
* windows-tdep.c (CYGWIN_DLL_NAME): New.
(pe_import_directory_entry): New struct type.
(is_linked_with_cygwin_dll): New function.
* amd64-windows-tdep.c (amd64_windows_osabi_sniffer): Select
GDB_OSABI_CYGWIN if the BFD is linked with the Cygwin DLL.
* i386-windows-tdep.c (i386_windows_osabi_sniffer): Likewise.
Simon Marchi [Mon, 16 Mar 2020 20:56:35 +0000 (16:56 -0400)]
gdb: rename content of i386-windows-tdep.c, cygwin to windows
i386-cygwin-tdep.c has just been renamed to i386-windows-tdep.c, this
patch now renames everything in it that is not Cygwin-specific to
replace "cygwin" with "windows".
Note that I did not rename i386_cygwin_core_osabi_sniffer, since that
appears to be Cygwin-specific.
gdb/ChangeLog:
* i386-windows-tdep.c: Mass-rename "cygwin" to "windows", except
i386_cygwin_core_osabi_sniffer.
Simon Marchi [Mon, 16 Mar 2020 20:56:35 +0000 (16:56 -0400)]
gdb: rename i386-cygwin-tdep.c to i386-windows-tdep.c
Since this file contains things that apply not only to Cygwin binaries,
but also to non-Cygwin Windows binaries, I think it would make more
sense for it to be called i386-windows-tdep.c. It is analogous to
amd64-windows-tdep.c, which we already have.
gdb/ChangeLog:
* i386-cygwin-tdep.c: Rename to...
* i386-windows-tdep.c: ... this.
* Makefile.in (ALL_TARGET_OBS): Rename i386-cygwin-tdep.c to
i386-windows-tdep.c.
* configure.tgt: Likewise.
Simon Marchi [Mon, 16 Mar 2020 20:56:34 +0000 (16:56 -0400)]
gdb: add Windows OS ABI
GDB currently uses the "Cygwin" OS ABI (GDB_OSABI_CYGWIN) for everything
related to Windows. If you build a GDB for a MinGW or Cygwin target, it
will have "Cygwin" as the default OS ABI in both cases (see
configure.tgt). If you load either a MinGW or Cygwin binary, the
"Cygwin" OS ABI will be selected in both cases.
This is misleading, because Cygwin binaries are a subset of the binaries
running on Windows. When building something with MinGW, the resulting
binary has nothing to do with Cygwin. Cygwin binaries are only special
in that they are Windows binaries that link to the cygwin1.dll library
(if my understanding is correct).
Looking at i386-cygwin-tdep.c, we can see that GDB does nothing
different when dealing with Cygwin binaries versus non-Cygwin Windows
binaries. However, there is at least one known bug which would require
us to make a distinction between the two OS ABIs, and that is the size
of the built-in "long" type on x86-64. On native Windows, this is 4,
whereas on Cygwin it's 8.
So, this patch adds a new OS ABI, "Windows", and makes GDB use it for
i386 and x86-64 PE executables, instead of the "Cygwin" OS ABI. A
subsequent patch will improve the OS ABI detection so that GDB
differentiates the non-Cygwin Windows binaries from the Cygwin Windows
binaries, and applies the "Cygwin" OS ABI for the latter.
The default OS ABI remains "Cygwin" for the GDBs built with a Cygwin
target.
I've decided to split the i386_cygwin_osabi_sniffer function in two,
I think it's cleaner to have a separate sniffer for Windows binaries and
Cygwin cores, each checking one specific thing.
gdb/ChangeLog:
* osabi.h (enum gdb_osabi): Add GDB_OSABI_WINDOWS.
* osabi.c (gdb_osabi_names): Add "Windows".
* i386-cygwin-tdep.c (i386_cygwin_osabi_sniffer): Return
GDB_OSABI_WINDOWS when the binary's target is "pei-i386".
(i386_cygwin_core_osabi_sniffer): New function, extracted from
i386_cygwin_osabi_sniffer.
(_initialize_i386_cygwin_tdep): Register OS ABI
GDB_OSABI_WINDOWS for i386.
* amd64-windows-tdep.c (amd64_windows_osabi_sniffer): Return
GDB_OSABI_WINDOWS when the binary's target is "pei-x86-64".
(_initialize_amd64_windows_tdep): Register OS ABI GDB_OSABI_WINDOWS
for x86-64.
* configure.tgt: Use GDB_OSABI_WINDOWS as the default OS ABI
when the target matches '*-*-mingw*'.
Simon Marchi [Mon, 16 Mar 2020 20:56:34 +0000 (16:56 -0400)]
gdb: move enum gdb_osabi to osabi.h
I think it makes sense to have it there instead of in the catch-all
defs.h.
gdb/ChangeLog:
* defs.h (enum gdb_osabi): Move to...
* osabi.h (enum gdb_osabi): ... here.
* gdbarch.sh: Include osabi.h in gdbarch.h.
* gdbarch.h: Re-generate.
Simon Marchi [Mon, 16 Mar 2020 20:56:33 +0000 (16:56 -0400)]
gdb: recognize 64 bits Windows executables as Cygwin osabi
If I generate two Windows PE executables, one 32 bits and one 64 bits:
$ x86_64-w64-mingw32-gcc test.c -g3 -O0 -o test_64
$ i686-w64-mingw32-gcc test.c -g3 -O0 -o test_32
$ file test_64
test_64: PE32+ executable (console) x86-64, for MS Windows
$ file test_32
test_32: PE32 executable (console) Intel 80386, for MS Windows
When I load the 32 bits binary in my GNU/Linux-hosted GDB, the osabi is
correctly recognized as "Cygwin":
$ ./gdb --data-directory=data-directory -nx test_32
(gdb) show osabi
The current OS ABI is "auto" (currently "Cygwin").
When I load the 64 bits binary in GDB, the osabi is incorrectly
recognized as "GNU/Linux":
$ ./gdb --data-directory=data-directory -nx test_64
(gdb) show osabi
The current OS ABI is "auto" (currently "GNU/Linux").
The 32 bits one gets recognized by the i386_cygwin_osabi_sniffer
function, by its target name:
if (strcmp (target_name, "pei-i386") == 0)
return GDB_OSABI_CYGWIN;
The target name for the 64 bits binaries is "pei-x86-64". It doesn't
get recognized by any osabi sniffer, so GDB falls back on its default
osabi, "GNU/Linux".
This patch adds an osabi sniffer function for the Windows 64 bits
executables in amd64-windows-tdep.c. With it, the osabi is recognized
as "Cygwin", just like with the 32 bits binary.
Note that it may seems strange to have a binary generated by MinGW
(which has nothing to do with Cygwin) be recognized as a Cygwin binary.
This is indeed not accurate, but at the moment GDB uses the Cygwin for
everything Windows. Subsequent patches will add a separate "Windows" OS
ABI for Windows binaries that are not Cygwin binaries.
gdb/ChangeLog:
* amd64-windows-tdep.c (amd64_windows_osabi_sniffer): New
function.
(_initialize_amd64_windows_tdep): Register osabi sniffer.
Tom de Vries [Mon, 16 Mar 2020 13:39:07 +0000 (14:39 +0100)]
[gdb/testsuite] Add cache_verify option for gdb_caching_procs
Test-case gdb.base/gdb-caching-proc.exp tests whether procs declared using
gdb_caching_proc give the same results when called more than once.
While this tests consistency of the procs in the context of that test-case, it
doesn't test consistency across the call sites.
Add a local variable cache_verify to proc gdb_do_cache, that can be set to 1
to verify gdb_caching_proc consistency across the call sites.
Likewise, add a local variable cache_verify_proc to set to the name of the
gdb_caching_proc to verify. This can f.i. be used when changing an existing
proc into a gdb_caching_proc.
Tested on x86_64-linux, with cache_verify set to both 0 and 1.
gdb/testsuite/ChangeLog:
2020-03-16 Tom de Vries <tdevries@suse.de>
* lib/cache.exp (gdb_do_cache): Add and handle local variables
cache_verify and cache_verify_proc.
Alan Modra [Mon, 16 Mar 2020 09:04:00 +0000 (19:34 +1030)]
PR25675: SIGSEGV in bfd_octets_per_byte
PR 25675
* elf.c (elf_sort_segments): Don't call bfd_octets_per_byte unless
we have a non-zero section count. Do lma comparison in octets.
Alan Modra [Mon, 16 Mar 2020 00:01:45 +0000 (10:31 +1030)]
asan: readelf leak in hppa_process_unwind
This extracts code reading symbol tables into a common function that
tidies up after errors. I've also changed an error reporting multiple
string tables to an error on multiple symbol tables.
* readelf.c (get_symbols): New function.
(process_relocs, ia64_process_unwind, hppa_process_unwind),
(arm_process_unwind, get_symbol_for_build_attribute): Use it.
Alan Modra [Sun, 15 Mar 2020 22:24:16 +0000 (08:54 +1030)]
ubsan: shift exponent 70 is too large
* unwind-ia64.c (unw_decode_uleb128): Prevent overlarge shifts.
Detect shift overflows and check that terminating byte is found.
Print an error on a bad uleb128.
Alan Modra [Sun, 15 Mar 2020 22:14:38 +0000 (08:44 +1030)]
asan: alpha-vms: null dereference
* vms-alpha.c (dst_restore_location): Validate index into
dst_ptr_offsets array before accessing. Return status.
(dst_retrieve_location): Similarly, making "loc" parameter a
pointer to return value.
(_bfd_vms_slurp_etir): Update calls to above functions.
Tom de Vries [Sun, 15 Mar 2020 14:15:56 +0000 (15:15 +0100)]
[gdb/testsuite] Fix solib-list.exp test-case for exec with debug-info
Since commit
a2fedca99c "Implement 'set/show exec-file-mismatch'.", I see the
following regression on openSUSE Leap 15.1:
...
FAIL: gdb.server/solib-list.exp: non-stop 0: target remote \
(got interactive prompt)
FAIL: gdb.server/solib-list.exp: non-stop 1: target remote \
(got interactive prompt)
...
The first FAIL in more detail:
...
(gdb) PASS: gdb.server/solib-list.exp: non-stop 0: file binfile
target remote localhost:2346
Remote debugging using localhost:2346
warning: Mismatch between current exec-file /data/gdb_versions/devel/build/\
gdb/testsuite/outputs/gdb.server/solib-list/solib-list
and automatically determined exec-file /lib64/ld-2.26.so
exec-file-mismatch handling is currently "ask"
Load new symbol table from "/lib64/ld-2.26.so"? (y or n) n
warning: loading /lib64/ld-2.26.so Not confirmed.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
warning: File transfers from remote targets can be slow. \
Use "set sysroot" to access files locally instead.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading symbols from target:/lib64/ld-linux-x86-64.so.2...
Reading /lib64/ld-2.26.so-2.26-lp151.18.7.x86_64.debug from remote target...
Reading /lib64/.debug/ld-2.26.so-2.26-lp151.18.7.x86_64.debug from remote \
target...
Reading /data/gdb_versions/devel/install/lib64/debug//lib64/\
ld-2.26.so-2.26-lp151.18.7.x86_64.debug from remote target...
Reading /data/gdb_versions/devel/install/lib64/debug/lib64/\
/ld-2.26.so-2.26-lp151.18.7.x86_64.debug from remote target...
Reading target:/data/gdb_versions/devel/install/lib64/debug/lib64/\
/ld-2.26.so-2.26-lp151.18.7.x86_64.debug from remote target...
(No debugging symbols found in target:/lib64/ld-linux-x86-64.so.2)
0x00007ffff7dd7ea0 in ?? ()
(gdb) FAIL: gdb.server/solib-list.exp: non-stop 0: target remote (got \
interactive prompt)
...
The commit introduces the "Load new symbol table from" question, and
gdb_test_multiple defaults to answering "no" and reporting the
"got interactive prompt" FAIL.
This FAIL is not seen on f.i. debian 10.2. The difference originates from the
fact that the solib-list executable has debug-info in the openSUSE case, while
it doesn't in the debian case.
We can prevent the failure on openSUSE by stripping the executable from
debug-info:
...
+ exec strip --strip-debug ${binfile}
...
The difference in behaviour is a bug or improvement opportunity in the
exec-file-mismatch, filed as PR25475.
This patch fixes the FAIL by handling the question in the test-case.
Tested on x86_64-linux.
Tested on x86_64-linux with the gdbserver part of the patch introducing the
test-case reverted to ensure that this still FAILs.
gdb/testsuite/ChangeLog:
2020-03-15 Tom de Vries <tdevries@suse.de>
* gdb.server/solib-list.exp: Handle
'Load new symbol table from "/lib64/ld-2.26.so"? (y or n)'.
Tom de Vries [Sun, 15 Mar 2020 09:43:43 +0000 (10:43 +0100)]
[gdb/testsuite] Fix check-read1 FAIL with gdb.base/maint.exp
When running test-case gdb.base/maint.exp with check-read1, I run into:
...
FAIL: gdb.base/maint.exp: (timeout) maint print objfiles
...
The FAIL happens because command output contains long lines like this:
...
file1 at $hex, file2 at $hex, ..., $file$n at $hex,
...
F.i., such a line for libc.so.debug contains 82000 chars.
Fix this this by reading long lines bit by bit.
Also, replace the testing of the command output formulated using a gdb_send
combined with gdb_expect-in-a-loop, with a regular gdb_test_multiple with
exp_continue.
Tested on x86_64-linux, with make targets check and check-read1.
gdb/testsuite/ChangeLog:
2020-03-15 Tom de Vries <tdevries@suse.de>
* gdb.base/maint.exp: Use exp_continue in long lines for "maint print
objfiles".
Tom Tromey [Sat, 14 Mar 2020 18:11:42 +0000 (12:11 -0600)]
Add C parser support for "restrict" and "_Atomic"
A user noticed that "watch -location" would fail with a "restrict"
pointer. The issue here is that if the DWARF mentions "restrict", gdb
will put this into the type name -- but then the C parser will not be
able to parse this type.
This patch adds support for "restrict" and "_Atomic" to the C parser.
C++ doesn't have "restrict", but does have some GCC extensions. The
type printer is changed to handle this difference as well, so that
watch expressions will work properly.
gdb/ChangeLog
2020-03-14 Tom Tromey <tom@tromey.com>
* c-typeprint.c (cp_type_print_method_args): Print "__restrict__"
for C++.
(c_type_print_modifier): Likewise. Add "language" parameter.
(c_type_print_varspec_prefix, c_type_print_base_struct_union)
(c_type_print_base_1): Update.
* type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New
constants.
* type-stack.c (type_stack::insert): Handle tp_atomic and
tp_restrict.
(type_stack::follow_type_instance_flags): Likewise.
(type_stack::follow_types): Likewise. Merge type-following code.
* c-exp.y (RESTRICT, ATOMIC): New tokens.
(space_identifier, cv_with_space_id)
(const_or_volatile_or_space_identifier_noopt)
(const_or_volatile_or_space_identifier): Remove.
(single_qualifier, qualifier_seq_noopt, qualifier_seq): New
rules.
(ptr_operator, typebase): Update.
(enum token_flag) <FLAG_C>: New constant.
(ident_tokens): Add "restrict", "__restrict__", "__restrict", and
"_Atomic".
(lex_one_token): Handle FLAG_C.
gdb/testsuite/ChangeLog
2020-03-14 Tom Tromey <tom@tromey.com>
* gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
Tom de Vries [Sat, 14 Mar 2020 17:03:39 +0000 (18:03 +0100)]
[gdb/testsuite] Fix check-read1 FAILs in mi-fortran-modules.exp
When running test-case gdb.mi/mi-fortran-modules.exp with check-read1, I run
into:
...
FAIL: gdb.mi/mi-fortran-modules.exp: -symbol-info-module-functions (timeout)
FAIL: gdb.mi/mi-fortran-modules.exp: -symbol-info-module-functions \
--name _all (unexpected output)
FAIL: gdb.mi/mi-fortran-modules.exp: -symbol-info-module-functions \
--module mod[123] (unexpected output)
FAIL: gdb.mi/mi-fortran-modules.exp: -symbol-info-module-variables \
(unexpected output)
...
Fix this by using exp_continue.
Tested on x86_64, using make target check and check-read1.
gdb/testsuite/ChangeLog:
2020-03-14 Tom de Vries <tdevries@suse.de>
* gdb.mi/mi-fortran-modules.exp: Use exp_continue.
Kamil Rytarowski [Sat, 14 Mar 2020 16:13:38 +0000 (17:13 +0100)]
Add support for NetBSD threads in m68k-bsd-nat.c
NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
gdb/ChangeLog:
* m68k-bsd-nat.c (fetch_registers): New variable lwp and pass
it to the ptrace call.
* m68k-bsd-nat.c (store_registers): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 16:07:18 +0000 (17:07 +0100)]
m68k: bsd: Change type from char * to gdb_byte *
* m68k-bsd-nat.c (m68kbsd_supply_gregset): Change type of regs to
gdb_byte *.
* m68k-bsd-nat.c (m68kbsd_supply_fpregset): Likewise.
* m68k-bsd-nat.c (m68kbsd_collect_gregset): Likewise.
* m68k-bsd-nat.c (m68kbsd_supply_pcb): Cast &tmp to gdb_byte *.
Kamil Rytarowski [Sat, 14 Mar 2020 15:54:42 +0000 (16:54 +0100)]
Inherit m68k_bsd_nat_target from nbsd_nat_target
gdb/ChangeLog:
* m68k-bsd-nat.c (m68k_bsd_nat_target): Inherit from
nbsd_nat_target instead of inf_ptrace_target.
* m68k-bsd-nat.c: Include "nbsd-nat.h", as we are now using
nbsd_nat_target.
Kamil Rytarowski [Sat, 14 Mar 2020 15:49:41 +0000 (16:49 +0100)]
Define _KERNTYPES in m68k-bsd-nat.c
Fixes build on NetBSD. types.h does not define register_t by default.
gdb/ChangeLog:
* m68k-bsd-nat.c: Define _KERNTYPES to get the declaration of
register_t.
Kamil Rytarowski [Sat, 14 Mar 2020 15:36:16 +0000 (16:36 +0100)]
Add support for NetBSD threads in alpha-bsd-nat.c
NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
gdb/ChangeLog:
* alpha-bsd-nat.c (fetch_registers): New variable lwp and pass
it to the ptrace call.
* alpha-bsd-nat.c (store_registers): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 15:23:11 +0000 (16:23 +0100)]
Remove unused code from alpha-bsd-nat.c
gdb/ChangeLog:
* alpha-bsd-nat.c: Remove <sys/procfs.h> and "gregset.h" from
includes.
* alpha-bsd-nat.c (gregset_t, fpregset_t): Remove.
* alpha-bsd-nat.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 15:05:24 +0000 (16:05 +0100)]
Inherit alpha_netbsd_nat_target from nbsd_nat_target
gdb/ChangeLog:
* alpha-bsd-nat.c (alpha_netbsd_nat_target): Inherit from
nbsd_nat_target instead of inf_ptrace_target.
* alpha-bsd-nat.c: Include "nbsd-nat.h", as we are now using
nbsd_nat_target.
Kamil Rytarowski [Sat, 14 Mar 2020 14:53:47 +0000 (15:53 +0100)]
Define _KERNTYPES in alpha-bsd-nat.c
Fixes build on NetBSD. types.h does not define register_t by default.
gdb/ChangeLog:
* alpha-bsd-nat.c: Define _KERNTYPES to get the declaration of
register_t.
Tom de Vries [Sat, 14 Mar 2020 14:48:26 +0000 (15:48 +0100)]
[gdb/testsuite] Fix check-read1 FAIL in attach-many-short-lived-threads.exp
When running test-case gdb.threads/attach-many-short-lived-threads.exp with
check-read1, I ran into:
...
FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 1: \
no new threads (timeout)
...
Fix this by rewriting the gdb_test_multiple call using -lbl and exp_continue.
Tested on x86_64-linux, with make targets check and check-read1.
gdb/testsuite/ChangeLog:
2020-03-14 Tom de Vries <tdevries@suse.de>
* gdb.threads/attach-many-short-lived-threads.exp: Read "info threads"
result in line-by-line fashion.
Kamil Rytarowski [Sat, 14 Mar 2020 14:44:28 +0000 (15:44 +0100)]
Add support for NetBSD threads in arm-nbsd-nat.c
NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
gdb/ChangeLog:
* arm-nbsd-nat.c (fetch_register): New variable lwp and pass
it to the ptrace call.
* arm-nbsd-nat.c (fetch_fp_register): Likewise.
* arm-nbsd-nat.c (fetch_fp_regs): Likewise.
* arm-nbsd-nat.c (store_register): Likewise.
* arm-nbsd-nat.c (store_regs): Likewise.
* arm-nbsd-nat.c (store_fp_register): Likewise.
* arm-nbsd-nat.c (store_fp_regs): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 13:50:51 +0000 (14:50 +0100)]
Inherit arm_netbsd_nat_target from nbsd_nat_target
gdb/ChangeLog:
* arm-nbsd-nat.c (arm_netbsd_nat_target): Inherit from
nbsd_nat_target instead of inf_ptrace_target.
* arm-nbsd-nat.c: Include "nbsd-nat.h", as we are now using
nbsd_nat_target.
Kamil Rytarowski [Sat, 14 Mar 2020 13:17:16 +0000 (14:17 +0100)]
Add support for NetBSD threads in x86-bsd-nat.c
NetBSD ptrace(2) PT_GETDBREGS/PT_SETDBREGS accepts thread id (LWP)
as the 4th argument for threads.
gdb/ChangeLog:
* x86-bsd-nat.c (x86bsd_dr_get): New variable lwp and pass
it to the ptrace call.
* x86-bsd-nat.c (x86bsd_dr_set): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 12:38:30 +0000 (13:38 +0100)]
Add support for threads in vax_bsd_nat_target
ptrace(2) PT_GETREGS/PT_SETREGS accepts thread id (LWP) as the 4th
argument for threads.
gdb/ChangeLog:
* vax-bsd-nat.c (vaxbsd_supply_gregset): New variable lwp and pass
it to the ptrace call.
* vax-bsd-nat.c (vaxbsd_collect_gregset): Likewise.
Kamil Rytarowski [Sat, 14 Mar 2020 12:33:14 +0000 (13:33 +0100)]
Add explicit cast to fix build of vax-bsd-nat.c
gdb/ChangeLog:
* vax-bsd-nat.c (vaxbsd_supply_gregset): Cast gregs to const gdb_byte *.
* vax-bsd-nat.c (vaxbsd_collect_gregset): Cast gregs to void *.
Kamil Rytarowski [Sat, 14 Mar 2020 12:21:58 +0000 (13:21 +0100)]
Inherit vax_bsd_nat_target from nbsd_nat_target
gdb/ChangeLog:
* vax-bsd-nat.c (vax_bsd_nat_target): Inherit from nbsd_nat_target
instead of inf_ptrace_target.
* vax-bsd-nat.c: Include "nbsd-nat.h", as we are now using
nbsd_nat_target.
Kamil Rytarowski [Sat, 14 Mar 2020 11:54:47 +0000 (12:54 +0100)]
Define _KERNTYPES in mips-nbsd-nat.c
Fixes build on NetBSD. types.h does not define register_t by default.
gdb/ChangeLog:
* mips-nbsd-nat.c: Define _KERNTYPES to get the declaration of
register_t.
Kamil Rytarowski [Sat, 14 Mar 2020 11:51:15 +0000 (12:51 +0100)]
Define _KERNTYPES in ppc-nbsd-nat.c
Fixes build on NetBSD. types.h does not define register_t by default.
gdb/ChangeLog:
* ppc-nbsd-nat.c: Define _KERNTYPES to get the declaration of
register_t.
Kamil Rytarowski [Sat, 14 Mar 2020 11:20:01 +0000 (12:20 +0100)]
Define _KERNTYPES in vax-bsd-nat.c
Fixes build on NetBSD. types.h does not define register_t by default.
gdb/ChangeLog:
* vax-bsd-nat.c: Define _KERNTYPES to get the declaration of
register_t.
Kamil Rytarowski [Sat, 14 Mar 2020 10:50:43 +0000 (11:50 +0100)]
Include netbsd-core.lo for all arm/mips NetBSD targets
bfd/ChangeLog:
* configure.ac: Include netbsd-core.lo for all NetBSD arm and mips
targets.
* configure: Regenerated.
Alan Modra [Sat, 14 Mar 2020 08:28:11 +0000 (18:58 +1030)]
Re: asan: more readelf leaks
In git commit
fd486f32d15e I put some static variables used by
get_symbol_for_build_attribute in a file scope ba_cache struct. This
was to prevent leaks in get_symbol_for_build_attribute, and to tidy up
before readelf exited. The patch wasn't quite right though. When
readelf processes more than one file it was possible to double free
arrays allocated in get_symbol_for_build_attribute.
* readelf.c (process_file): Clean ba_cache.
Tom de Vries [Sat, 14 Mar 2020 09:41:46 +0000 (10:41 +0100)]
[gdb/testsuite] Fix unrecognized debug output level 'statement-frontiers' message
When running testcase gdb.cp/step-and-next-inline.exp, I get:
...
Running src/gdb/testsuite/gdb.cp/step-and-next-inline.exp ...
gdb compile failed, g++: error: unrecognized debug output level \
'statement-frontiers'
gdb compile failed, g++: error: unrecognized debug output level \
'statement-frontiers'
=== gdb Summary ===
# of untested testcases 2
...
Fix this by using a new gdb_caching_proc supports_statement_frontiers.
Tested on x86_64-linux, with gcc 7.5.0 (which does not support
-gstatement-frontiers) and with gcc 8.4.0 (which does support
-gstatement-frontiers).
gdb/testsuite/ChangeLog:
2020-03-14 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (supports_statement_frontiers): New proc.
* gdb.cp/step-and-next-inline.exp: Use supports_statement_frontiers.
Tom de Vries [Sat, 14 Mar 2020 09:17:10 +0000 (10:17 +0100)]
[gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp
With test-case gdb.base/printcmds.exp, I run into:
...
(gdb) print teststring2^M
$563 = (charptr) "more contents"^M
(gdb) FAIL: gdb.base/printcmds.exp: print teststring2
...
The corresponding test is:
...
gdb_test "print teststring2" " = (charptr) \"more contents\""
...
Fix the FAIL by adding the missing quoting for the parentheses around charptr.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-03-14 Tom de Vries <tdevries@suse.de>
* gdb.base/printcmds.exp: Add missing quoting for "print
teststring2".
Alan Modra [Sat, 14 Mar 2020 01:20:22 +0000 (11:50 +1030)]
readelf large memory allocation
* elfcomm.h (setup_archive): Update prototype.
* elfcomm.c (setup_archive): Add file_size parameter and sanity
check longnames_size.
(setup_nested_archive): Get file size and pass to setup_archive.
* elfedit.c (process_archive): Likewise.
* readelf.c (process_archive): Pass filedata->file_size to
setup_archive.
Alan Modra [Sat, 14 Mar 2020 00:41:28 +0000 (11:11 +1030)]
asan: readelf: memory leaks
* readelf.c (dump_section_as_strings): Free memory on error exit.
(dump_section_as_bytes, process_notes_at): Likewise.
(get_build_id): Free enote.
Alan Modra [Sat, 14 Mar 2020 04:17:15 +0000 (14:47 +1030)]
non-contiguous elf test
This test XPASSes on the generic ELF targets, so adjusting. I also
made xtensa an xfail instead of a skip, since skip is hiding some
nastiness.
* testsuite/ld-elf/non-contiguous.d: Don't xfail generic ELF
targets. Don't skip xtensa, xfail instead.
Alan Modra [Sat, 14 Mar 2020 01:20:57 +0000 (11:50 +1030)]
BFD_FAKE_SECTIONS formatting
After the ld non-contiguous memory support my regen of bfd-in2.h
didn't match exactly what was committed, so I took the opportunity to
line up all the comments.
* section.c (BFD_FAKE_SECTIONS): Formatting.
* bfd-in2.h: Regenerate.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Remove val_print
We can finally remove val_print and various helper functions that are
no longer needed.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* value.h (val_print): Don't declare.
* valprint.h (val_print_array_elements)
(val_print_scalar_formatted, generic_val_print): Don't declare.
* valprint.c (generic_val_print_array): Take a struct value.
(generic_val_print_ptr, generic_val_print_memberptr)
(generic_val_print_bool, generic_val_print_int)
(generic_val_print_char, generic_val_print_complex)
(generic_val_print): Remove.
(generic_value_print): Update.
(do_val_print): Remove unused parameters. Don't call
la_val_print.
(val_print): Remove.
(common_val_print): Update. Don't call value_check_printable.
(val_print_scalar_formatted, val_print_array_elements): Remove.
* rust-lang.c (rust_val_print): Remove.
(rust_language_defn): Update.
* p-valprint.c (pascal_val_print): Remove.
(pascal_value_print_inner): Update.
(pascal_object_print_val_fields, pascal_object_print_val):
Remove.
(pascal_object_print_static_field): Update.
* p-lang.h (pascal_val_print): Don't declare.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove.
* m2-lang.h (m2_val_print): Don't declare.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_val_print>: Remove.
* language.c (unk_lang_value_print_inner): Rename. Change
argument types.
(unknown_language_defn, auto_language_defn): Update.
* go-valprint.c (go_val_print): Remove.
* go-lang.h (go_val_print): Don't declare.
* go-lang.c (go_language_defn): Update.
* f-valprint.c (f_val_print): Remove.
* f-lang.h (f_value_print): Don't declare.
* f-lang.c (f_language_defn): Update.
* d-valprint.c (d_val_print): Remove.
* d-lang.h (d_value_print): Don't declare.
* d-lang.c (d_language_defn): Update.
* cp-valprint.c (cp_print_value_fields)
(cp_print_value_fields_rtti, cp_print_value): Remove.
(cp_print_static_field): Update.
* c-valprint.c (c_val_print_array, c_val_print_ptr)
(c_val_print_struct, c_val_print_union, c_val_print_int)
(c_val_print_memberptr, c_val_print): Remove.
* c-lang.h (c_val_print_array, cp_print_value_fields)
(cp_print_value_fields_rtti): Don't declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove.
(ada_val_print_enum): Take a struct value.
(ada_val_print_flt, ada_val_print_array, ada_val_print_1)
(ada_val_print): Remove.
(ada_value_print_1): Update.
(printable_val_type): Remove.
* ada-lang.h (ada_val_print): Don't declare.
* ada-lang.c (ada_language_defn): Update.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Change extension language pretty-printers to use value API
This changes the extension language pretty-printers to use the value
API.
Note that new functions were needed, for both Guile and Python.
Currently both languages always wrap values by removing the values
from the value chain. This makes sense to avoid strange behavior with
watchpoints, and to avoid excessive memory use. However, when
printing, it's important to leave the passed-in value untouched, in
case pretty-printing does nothing -- that way the caller can still
access it.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (do_val_print): Update.
* python/python-internal.h (gdbpy_apply_val_pretty_printer): Take
a struct value.
(value_to_value_object_no_release): Declare.
* python/py-value.c (value_to_value_object_no_release): New
function.
* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Take a
struct value.
* guile/scm-value.c (vlscm_scm_from_value_no_release): New
function.
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Take
a struct value.
* guile/guile-internal.h (vlscm_scm_from_value_no_release):
Declare.
(gdbscm_apply_val_pretty_printer): Take a struct value.
* extension.h (apply_ext_lang_val_pretty_printer): Take a struct
value.
* extension.c (apply_ext_lang_val_pretty_printer): Take a struct
value.
* extension-priv.h (struct extension_language_ops)
<apply_val_pretty_printer>: Take a struct value.
* cp-valprint.c (cp_print_value): Create a struct value.
(cp_print_value): Update.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Change print_field_values to use value-based API
This converts print_field_values to use the value-based API, by having
it call common_val_print rather than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (print_field_values): Call common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce ada_value_print_array
This adds ada_value_print_array, a value-based analogue of
ada_val_print_array. It also removes some unused parameters from a
couple of helper functions.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (val_print_packed_array_elements): Remove
bitoffset and val parameters. Call common_val_print.
(ada_val_print_string): Remove offset, address, and original_value
parameters.
(ada_val_print_array): Update.
(ada_value_print_array): New function.
(ada_value_print_1): Call it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert ada_value_print to value-based API
This converts ada_value_print to the value-based API by using
common_val_print rather than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_value_print): Use common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert ada_val_print_ref to value-based API
This converts ada_val_print_ref to the value-based API by using
common_val_print rather than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_val_print_ref): Use common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce ada_value_print_num
This adds ada_value_print_num, a value-based analogue of
ada_val_print_num.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_value_print_num): New function.
(ada_value_print_1): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Rewrite ada_value_print_1 floating point case
This rewrites the TYPE_CODE_FLT case in ada_value_print_1 to be purely
value-based.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_value_print_1) <TYPE_CODE_FLT>: Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce ada_value_print_ptr
This adds ada_value_print_ptr, a value-based analogue of
ada_val_print_ptr.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_value_print_ptr): New function.
(ada_value_print_1): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Rewrite ada_value_print_inner
This rewrites ada_value_print_inner, introducing a new
ada_value_print_1, an analogue of ada_val_print_1. Because it was
simple to do, this also converts ada_val_print_gnat_array to be
valued-based and updates the uses.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_val_print_gnat_array): Take a struct value;
call common_val_print.
(ada_val_print_1): Update.
(ada_value_print_1): New function.
(ada_value_print_inner): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce cp_print_value
This adds cp_print_value, a value-based analogue of cp_print_val, and
changes cp_print_value_fields to use it.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* cp-valprint.c (cp_print_value_fields): Update.
(cp_print_value): New function.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce cp_print_value_fields and c_value_print_struct
This adds cp_print_value_fields and c_value_print_struct, value-based
analogues of the corresponding val-printing functions. Note that the
Modula-2 printing code also calls cp_print_val_fields, and so is
updated to call the function function.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* m2-valprint.c (m2_value_print_inner): Use
cp_print_value_fields.
* cp-valprint.c (cp_print_value_fields): New function.
* c-valprint.c (c_value_print_struct): New function.
(c_value_print_inner): Use c_value_print_struct.
* c-lang.h (cp_print_value_fields): Declare.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce c_value_print_array
This adds c_value_print_array, a value-based analogue of
c_val_print_array.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print_array): New function.
(c_value_print_inner): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce c_value_print_memberptr
This adds c_value_print_memberptr, a value-based analogue of
c_val_print_memberptr.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print_memberptr): New function.
(c_value_print_inner): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce c_value_print_int
This adds c_value_print_int, a value-based analogue of
c_val_print_int.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print_int): New function.
(c_value_print_inner): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce c_value_print_ptr
This adds c_value_print_ptr, a value-based analogue of
c_val_print_ptr.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print_ptr): New function.
(c_value_print_inner): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Rewrite c_value_print_inner
This rewrites c_value_print_inner, copying in the body of
c_val_print_inner and adusting as needed. This will form the base of
future changes to fully convert this to using the value-based API
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print_inner): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print_complex
This adds generic_value_print_complex, a value-based analogue of
generic_val_print_complex.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_complex): New function.
(generic_value_print): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Simplify generic_val_print_float
This changes generic_val_print_float not to call
val_print_scalar_formatted. This lets generic_value_print then use
value_print_scalar_formatted instead.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print_float): Don't call
val_print_scalar_formatted.
(generic_val_print, generic_value_print): Update.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print_char
This adds generic_value_print_char, a value-based analogue of
generic_val_print_char.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_char): New function
(generic_value_print): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print_int
This adds generic_value_print_int, a value-based analogue of
generic_val_print_int.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_int): New function.
(generic_value_print): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print_bool
This adds generic_value_print_bool, a value-based analogue of
generic_val_print_bool.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_bool): New function.
(generic_value_print): Use it.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Simplify generic_val_print_func
This removes the call to val_print_scalar_formatted from
generic_val_print_func, allowing generic_value_print to call the
value-based variant instead.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print_func): Simplify.
(generic_val_print, generic_value_print): Update.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Remove generic_val_print_flags
This remove generic_val_print_flags in favor of using the value-based
API where possible.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print_flags): Remove.
(generic_val_print, generic_value_print): Update.
(val_print_type_code_flags): Add original_value parameter.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Fix generic_val_print_enum for value-based printing
This removes a call to val_print_scalar_formatted from
generic_val_print_enum, preferring to do the work in the callers.
This lets generic_value_print use the value-based API.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print): Update.
(generic_value_print): Update.
* valprint.c (generic_val_print_enum): Don't call
val_print_scalar_formatted.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print_ptr
This introduces generic_value_print_ptr, a value-based analogue of
generic_val_print_ptr, and changes generic_value_print to use it.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print): Call generic_value_print_ptr.
* valprint.c (generic_value_print_ptr): New function.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Initial rewrite of generic_value_print
This rewrites generic_value_print, by copying in the body of
generic_val_print and making the needed adjustments.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert Pascal to value-based API
This finishes the conversion of Pascal to the value-based API, by
introducing two more value-based analogues of existing val-print
functions.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* p-valprint.c (pascal_object_print_value_fields)
(pascal_object_print_value): New functions.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Rewrite pascal_value_print_inner
This rewrites pascal_value_print_inner, copying in the body of
pascal_val_print_inner and adusting as needed. This will form the
base of future changes to fully convert this to using the value-based
API.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* p-valprint.c (pascal_value_print_inner): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert Fortran printing to value-based API
This finishes the conversion of the Fortran printing code to the
value-based API. The body of f_val_print is copied into
f_value_print_innner, and then modified as needed to use the value
API.
Note that not all calls must be updated. For example, f77_print_array
remains "val-like", because it does not result in any calls to
val_print (f77_print_array_1 calls common_val_print, which is
nominally value-based).
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* f-valprint.c (f_value_print_innner): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert Modula-2 printing to value-based API
This finishes the conversion of Modula-2 printing to the value-based
API. It does so by copying the body of m2_val_print into
m2_value_print_inner, and then introducing new functions as needed to
use the value API.
The "val_" API code continues to exist, because it's still possible
for it to be called via some paths. This code will all be removed at
the end of the series.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* m2-valprint.c (m2_print_unbounded_array): New overload.
(m2_print_unbounded_array): Update.
(m2_print_array_contents): Take a struct value.
(m2_value_print_inner): Rewrite.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert D printing to value-based API
As with Rust and Go, it was straightforward to convert D to the
value-based API directly.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* d-valprint.c (dynamic_array_type): Call d_value_print_inner.
(d_value_print_inner): New function.
* d-lang.h (d_value_print_inner): Declare.
* d-lang.c (d_language_defn): Use d_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert Go printing to value-based API
This introduces go_value_print_inner, a modified copy of go_val_print.
Unlike some of the other languages, Go was straightforward to convert
to the value-based API all at once, so this patch takes that approach.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* go-valprint.c (go_value_print_inner): New function.
* go-lang.h (go_value_print_inner): Declare.
* go-lang.c (go_language_defn): Use go_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Convert Rust printing to value-based API
For Rust, it was simple to convert the printing code to the
value-based API all at once.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* rust-lang.c (val_print_struct, rust_print_enum): Use the value
API.
(rust_val_print): Rewrite.
(rust_value_print_inner): New function, from rust_val_print.
(rust_language_defn): Use rust_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce ada_value_print_inner
This introduces ada_value_print_inner.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* ada-valprint.c (ada_value_print_inner): New function.
* ada-lang.h (ada_value_print_inner): Declare.
* ada-lang.c (ada_language_defn): Use ada_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce f_value_print_innner
This introduces f_value_print_innner.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* f-valprint.c (f_value_print_innner): New function.
* f-lang.h (f_value_print_innner): Declare.
* f-lang.c (f_language_defn): Use f_value_print_innner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce pascal_value_print_inner
This introduces pascal_value_print_inner.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* p-valprint.c (pascal_value_print_inner): New function.
* p-lang.h (pascal_value_print_inner): Declare.
* p-lang.c (pascal_language_defn): Use pascal_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce m2_value_print_inner
This introduces m2_value_print_inner.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* m2-valprint.c (m2_value_print_inner): New function.
* m2-lang.h (m2_value_print_inner): Declare.
* m2-lang.c (m2_language_defn): Use m2_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce c_value_print_inner
This introduces c_value_print_inner, which implements the
la_value_print_inner method for the C family of languages. In this
patch, it is just a simple wrapper of c_val_print. However,
subsequent patches will convert it to use the value API. The
transformation is done this way to make each patch easier to review.
Future patches will apply this same treatment to other languages as
well.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* opencl-lang.c (opencl_language_defn): Use c_value_print_inner.
* objc-lang.c (objc_language_defn): Use c_value_print_inner.
* c-valprint.c (c_value_print_inner): New function.
* c-lang.h (c_value_print_inner): Declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Use
c_value_print_inner.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Make pascal_object_print_value_fields static
pascal_object_print_value_fields is only needed in p-valprint.c, so
make it static.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* p-valprint.c (pascal_object_print_value_fields): Now static.
* p-lang.h (pascal_object_print_value_fields): Don't declare.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Simplify c_val_print_array
This slightly simplifies c_val_print_array by moving a variable to a
more inner scope and removing a dead assignment.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_val_print_array): Simplify.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce value_print_array_elements
This introduces value_print_array_elements, which is an analogue of
val_print_array_elements that uses the value API.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (value_print_array_elements): New function.
* valprint.h (value_print_array_elements): Declare.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Two simple uses of value_print_scalar_formatted
A couple of spots could be easily converted to use
value_print_scalar_formatted. This patch makes this change.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* printcmd.c (print_formatted): Use value_print_scalar_formatted.
* mips-tdep.c (mips_print_register): Use
value_print_scalar_formatted.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce value_print_scalar_formatted
This introduces a value_print_scalar_formatted, which is an analogue
of val_print_scalar_formatted that uses the value API.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.h (value_print_scalar_formatted): Declare.
* valprint.c (value_print_scalar_formatted): New function.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce generic_value_print
This introduces generic_value_print, which is a value-based analogue
to generic_val_print. For now this is unused and simply calls
generic_val_print, but subsequent patches will both change this
function to work using the value API directly, and convert callers of
generic_val_print to call this instead.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.h (generic_value_print): Declare.
* valprint.c (generic_value_print): New function.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce la_value_print_inner
The plan for removing val_print is, essentially, to first duplicate
printing code as needed to use the value API; and then remove the
val_print code. This makes it possible to do the changes
incrementally while keeping everything working.
This adds a new la_value_print_inner function pointer to struct
language_defn. Eventually this will replace la_val_print. This patch
also changes printing to prefer this API, when available -- but no
language defines it yet.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (do_val_print): Call la_value_print_inner, if
available.
* rust-lang.c (rust_language_defn): Update.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_value_print_inner>: New
member.
* language.c (unknown_language_defn, auto_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* d-lang.c (d_language_defn): Update.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_language_defn): Update.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in c-valprint.c
This changes c_value_print to call common_val_print. This is more
complicated than the usual sort of common_val_print change, due to the
handling of RTTI.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_value_print): Use common_val_print.
gdb/testsuite/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* gdb.base/printcmds.exp (test_print_strings): Add regression
test.
* gdb.base/printcmds.c (charptr): New typedef.
(teststring2): New global.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in cp-valprint.c
This changes a spot in cp-valprint.c to use common_val_print rather
than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* cp-valprint.c (cp_print_static_field): Use common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in f-valprint.c
This changes a couple spots in f-valprint.c to use common_val_print
rather than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* f-valprint.c (f77_print_array_1, f_val_print): Use
common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in riscv-tdep.c
This changes some spots in riscv-tdep.c to use common_val_print rather
than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* riscv-tdep.c (riscv_print_one_register_info): Use
common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in mi-main.c
This changes a spot in mi-main.c to use common_val_print rather than
val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (output_register): Use common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use common_val_print in infcmd.c
This changes some spots in infcmd.c to use common_val_print (which,
despite its name, is a value-based API) rather than val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* infcmd.c (default_print_one_register_info): Use
common_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Introduce common_val_print_checked
A (much) later patch will remove the call to value_check_printable
from common_val_print. This will needed to preserve some details of
how optimized-out structures are printed.
However, doing this will also break dw2-op-out-param.exp. Making the
change causes "bt" to print:
However, the test wants to see:
... operand2=<optimized out>
That is, a wholly-optimized out structure should not print its fields.
So, this patch introduces a new common_val_print_checked, which calls
value_check_printable first, and then arranges to use it in the one
spot that affects the test suite.
I was not completely sure if it would be preferable to change the
test. However, I reasoned that, assuming this output was intentional
in the first place, in a backtrace space is at a premium and so this
is a reasonable approach. In other spots calling common_val_print,
this behavior is probably unintended, or at least a "don't care".
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.h (common_val_print_checked): Declare.
* valprint.c (common_val_print_checked): New function.
* stack.c (print_frame_arg): Use common_val_print_checked.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Refactor val_print and common_val_print
This changes val_print and common_val_print to use a new helper
function. A theme in the coming patches is that calls to val_print
itself should be removed. This is the first such patch; at the end of
the series, we'll remove val_print and simplify do_val_print.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (do_val_print): New function, from val_print.
(val_print): Use do_val_print.
(common_val_print): Use do_val_print.
Tom Tromey [Fri, 13 Mar 2020 23:39:52 +0000 (17:39 -0600)]
Use scoped_value_mark in value_print
Switching the low-level printing to use the value API means we will be
using more temporary values. This adds a scoped_value_mark to
value_print, so that these intermediates are destroyed in a timely
way.
gdb/ChangeLog
2020-03-13 Tom Tromey <tom@tromey.com>
* valprint.c (value_print): Use scoped_value_mark.
Andrew Burgess [Fri, 13 Mar 2020 23:28:46 +0000 (23:28 +0000)]
gdb/testsuite: Remove paths and make test names unique
Removes paths from some test names, and make the test names unique in
the gdb.base/break-interp.exp test file.
gdb/testsuite/ChangeLog:
* gdb.base/break-interp.exp: Use the tail of the filename, not the
full path in the test name.
(test_ld): Add some with_test_prefix blocks to make test names
unique.
Kamil Rytarowski [Fri, 13 Mar 2020 22:37:10 +0000 (23:37 +0100)]
Implement NT_NETBSDCORE_LWPSTATUS (NetBSD-Core)
bfd/ChangeLog:
* elf.c (elfcore_grok_netbsd_note): Add support for
NT_NETBSDCORE_LWPSTATUS notes.
binutils/ChangeLog:
* readelf.c (get_netbsd_elfcore_note_type): Add support for
NT_NETBSDCORE_LWPSTATUS notes.
include/ChangeLog:
* elf/common.h (NT_NETBSDCORE_LWPSTATUS): New define.
Kamil Rytarowski [Fri, 13 Mar 2020 20:27:40 +0000 (21:27 +0100)]
Register NT_NETBSDCORE_AUXV (NetBSD-Core)
* elf/common.h (NT_NETBSDCORE_AUXV): New define.
Christophe Lyon [Mon, 25 Nov 2019 08:55:37 +0000 (08:55 +0000)]
Add support for non-contiguous memory regions
2020-01-06 Christophe Lyon <christophe.lyon@linaro.org>
bfd/
* bfd-in2.h: Regenerate.
* section.c (asection): Add already_assigned field.
(BFD_FAKE_SECTION): Add default initializer for it.
* ecoff.c (bfd_debug_section): Initialize already_assigned field.
* elf32-arm.c (arm_build_one_stub): Add support for
non_contiguous_regions.
* elf32-csky.c (csky_build_one_stub): Likewise.
* elf32-hppa.c (hppa_build_one_stub): Likewise.
* elf32-m68hc11.c (m68hc11_elf_build_one_stub): Likewise.
* elf32-m68hc12.c (m68hc12_elf_build_one_stub): Likewise.
* elf32-metag.c (metag_build_one_stub): Likewise.
* elf32-nios2.c (nios2_build_one_stub): Likewise.
* elf64-ppc.c (ppc_build_one_stub): Likewise.
(ppc_size_one_stub): Likewise.
* elfnn-aarch64.c (aarch64_build_one_stub): Likewise.
* elflink.c (elf_link_input_bfd): Likewise.
include/
* bfdlink.h (bfd_link_info): Add non_contiguous_regions and
non_contiguous_regions_warnings fields.
ld/
* ldlang.c (lang_add_section): Add support for
non_contiguous_regions.
(size_input_section): Likewise.
(lang_size_sections_1): Likewise.
(process_insert_statements): Likewise.
* ldlex.h (option_values): Add OPTION_NON_CONTIGUOUS_REGIONS and
OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS.
* lexsup.c (ld_options): Add entries for
--enable-non-contiguous-regions and
--enable-non-contiguous-regions-warnings.
(parse_args): Handle it.
* NEWS: Add --enable-non-contiguous-regions and
--enable-non-contiguous-regions-warnings.
* ld.texi: Add --enable-non-contiguous-regions and
--enable-non-contiguous-regions-warnings documentation.
* emultempl/armelf.em (elf32_arm_add_stub_section): Add
SEC_LINKER_CREATED flag.
* emultempl/xtensaelf.em (ld_build_required_section_dependence):
Emit an error when --enable-non-contiguous-regions is used.
* testsuite/ld-elf/non-contiguous.d: New.
* testsuite/ld-elf/non-contiguous.ld: New.
* testsuite/ld-elf/non-contiguous.s: New.
* testsuite/ld-arm/arm-elf.exp: Run the new tests.
* testsuite/ld-arm/arm-elf/non-contiguous-arm.s: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm.ld: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm2.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm3.ld: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm3.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm3.ld: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm4.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm4.ld: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm5.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm5.ld: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm6.d: New.
* testsuite/ld-arm/arm-elf/non-contiguous-arm6.ld: New.
* testsuite/ld-powerpc/powerpc.exp: Run new tests.
* testsuite/ld-powerpc/non-contiguous-powerpc.d: New.
* testsuite/ld-powerpc/non-contiguous-powerpc.ld: New.
* testsuite/ld-powerpc/non-contiguous-powerpc.sd: New.
* testsuite/ld-powerpc/non-contiguous-powerpc64.d: New.