Alan Modra [Thu, 16 Apr 2020 01:13:25 +0000 (10:43 +0930)]
PowerPC64 GOT reloc optimisation
When the symbol referenced by a GOT reloc is an ifunc, we can't
optimise away the GOT indirection. Well, we can, but only if a global
entry stub is created with the ifunc symbol redefined to the stub.
But that results in slower code and an indirection via the PLT so
there isn't much to like about that solution.
* elf64-ppc.c (ppc64_elf_edit_toc): Exclude ifunc from GOT
optimisation.
(ppc64_elf_relocate_section): Likewise.
Alan Modra [Thu, 16 Apr 2020 01:48:05 +0000 (11:18 +0930)]
Extend objdump --no-addresses info
* doc/binutils.texi: Mention --no-show-raw-insn in objdump
--no-addresses description.
Simon Marchi [Thu, 16 Apr 2020 01:09:17 +0000 (21:09 -0400)]
gdbserver: fix format string warning in win32-low.cc
When compiling on Cygwin, we get:
CXX win32-low.o
/home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc: In function ‘int get_child_debug_event(DWORD*, target_waitstatus*)’:
/home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1459:17: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long int’ [-Werror=format=]
1459 | OUTMSG2 (("get_windows_debug_event - "
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1460 | "unexpected stop in 0x%x (expecting 0x%x)\n",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1461 | ptid.lwp (), desired_stop_thread_id));
| ~~~~~~~~~~~
| |
| long int
/home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:52:11: note: in definition of macro ‘OUTMSG2’
52 | printf X; \
| ^
/home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1460:26: note: format string is defined here
1460 | "unexpected stop in 0x%x (expecting 0x%x)\n",
| ~^
| |
| unsigned int
| %lx
`ptid.lwp ()` is a `long` value, so it indeed needs the `l` size modifier.
gdbserver/ChangeLog:
* win32-low.cc (get_child_debug_event): Fix format string warning.
GDB Administrator [Thu, 16 Apr 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Kamil Rytarowski [Wed, 15 Apr 2020 19:23:30 +0000 (14:23 -0500)]
Fix OpenBSD build error.
This was likely introduced by
5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2
gdb/ChangeLog:
2020-04-15 Kamil Rytarowski <n54@gmx.com>
* obsd-nat.c (obsd_nat_target::update_thread_list): Pass "this" to
thread functions.
(obsd_nat_target::wait): Likewise.
Change-Id: Ib8d11238c55e0ebdbcf127d1f28c9693c785527a
Tom Tromey [Wed, 15 Apr 2020 18:37:29 +0000 (12:37 -0600)]
Use debug_printf in windows-nat.c
While debugging a bug on Windows, I noticed that windows-nat.c is not
sending its debugging output to gdb_stdlog. This is unfortunate
because it means that "set logging debugredirect" doesn't work
properly.
This patch fixes the problem by changing windows-nat.c to use
debug_printf.
Note that get_windows_debug_event also writes one debugging message
unconditionally. It isn't clear to me if this really ought to use
DEBUG_EVENTS or not, since it seems like perhaps it is intended to
note an unexpected event occurring. So, I didn't change this.
I'm checking this in.
gdb/ChangeLog
2020-04-15 Tom Tromey <tromey@adacore.com>
* windows-nat.c (DEBUG_EXEC, DEBUG_EVENTS, DEBUG_MEM)
(DEBUG_EXCEPT): Use debug_printf.
Andrew Burgess [Sat, 4 Apr 2020 13:54:15 +0000 (14:54 +0100)]
gdb: Don't corrupt completions hash when expanding the hash table
Commit:
commit
724fd9ba432a20ef2e3f2c0d6060bff131226816
Date: Mon Jan 27 17:37:20 2020 +0000
gdb: Restructure the completion_tracker class
caused the completion hash table to become corrupted if the table ever
needed to grow beyond its original size of 200 elements.
The hash table stores completion_tracker::completion_hash_entry
objects, but hashes them based on their name, which is only one field
of the object.
When possibly inserting a new element we compute the hash with
htab_hash_string of the new elements name, and then lookup matching
elements using htab_find_slot_with_hash. If there's not matching
element we create a completion_hash_entry object within the hash
table.
However, when we allocate the hash we pass htab_hash_string to
htab_create_alloc as the hash function, and this is not OK. This
means that when the hash table needs to grow, existing elements within
the hash are re-hashed by passing the completion_hash_entry pointer to
htab_hash_string, which obviously does not do what we expect.
The solution is to create a new hash function that takes a pointer to
a completion_hash_entry, and then calls htab_hash_string on the name
of the entry only.
This regression was spotted when running the gdb.base/completion.exp
test on the aarch64 target.
gdb/ChangeLog:
* completer.c (class completion_tracker::completion_hash_entry)
<hash_name>: New member function.
(completion_tracker::discard_completions): New callback to hash a
completion_hash_entry, pass this to htab_create_alloc.
gdb/testsuite/ChangeLog:
* gdb.base/many-completions.exp: New file.
Jon Turney [Wed, 13 Jan 2016 18:27:48 +0000 (18:27 +0000)]
Better handling of realpath() failure in windows_make_so() on Cygwin
It seems Cygwin's realpath() can fail on certain DLLs (apparently some
AV software prevent it working on it's DLLs; See [1], [2]). Warn rather
than stopping with an error if that occurs.
Based on an original patch from Tim Chick.
[1] https://cygwin.com/ml/cygwin/2014-08/msg00401.html
[2] https://cygwin.com/ml/cygwin/2015-11/msg00353.html
gdb/ChangeLog:
2016-01-20 Jon Turney <jon.turney@dronecode.org.uk>
* windows-nat.c (windows_make_so): Warn rather than stopping with
an error if realpath() fails.
Fangrui Song [Wed, 15 Apr 2020 13:25:08 +0000 (14:25 +0100)]
Unify the behaviour of ld.bfd and ld.gold with respect to warning about unresolved symbol references. (PR 24613)
PR binutils/24613
include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and
RM_GENERATE_ERROR. Add RM_DIAGNOSE.
(struct bfd_link_info): Add warn_unresolved_syms.
ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and
RM_GENERATE_ERROR to RM_DIAGNOSE.
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change
RM_GENERATE_ERROR to RM_DIAGNOSE.
* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise.
bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR
to RM_DIAGNOSE plus a check of warn_unresolved_syms.
* coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise.
* elf-bfd.h (_bfd_elf_large_com_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-spu.c (spu_elf_relocate_section): Likewise.
* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
* elflink.c (elf_link_output_extsym): Likewise.
* elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
Alan Modra [Wed, 15 Apr 2020 09:56:55 +0000 (19:26 +0930)]
objdump --no-addresses
I find this useful when needing to compare compiler output, where the
address of the instruction and the value of symbols results in
unwanted differences.
* objdump.c (no_addresses): New static var.
(usage): Print help for --no-addresses.
(long_options): Add --no-addresses entry.
(objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address.
(disassemble_bytes): Don't print current line address, or reloc
address.
* doc/binutils.texi: Document objdump --no-addresses.
Alan Modra [Wed, 15 Apr 2020 09:28:11 +0000 (18:58 +0930)]
PR25823, Use after free in bfd_hash_lookup
PR 25823
* peXXigen.c (_bfd_XXi_swap_sym_in <C_SECTION>): Don't use a
pointer into strings that may be freed for section name, always
allocate a new string.
Artur Shepilko [Wed, 15 Apr 2020 07:44:12 +0000 (09:44 +0200)]
Fix makeinfo warnings in gdb.texinfo and python.texi docs
Building gdb-9.1 on a system that has an older version of makeinfo
(4.8) shows the following warnings:
-----------------
make[4]: Entering directory '/home/tester/gdb-9.1/build/gdb/doc'
makeinfo --split-size=
5000000 --split-size=
5000000 -I
../../../gdb/doc/../../readline/readline/doc -I ../../../gdb/doc/../mi
-I ../../../gdb/doc \
-o gdb.info ../../../gdb/doc/gdb.texinfo
../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character ] in @var.
../../../gdb/doc//python.texi:3297: warning: `.' or `,' must follow
@xref, not `A'.
make[4]: Leaving directory '/home/tester/gdb-9.1/build/gdb/doc'
-----------------
These are thrown by expressions like `@var{[host]}`, intended to
produce `[HOST]`.
In that context this should instead be changed to `[@var{host}]`, which
has the same effect but without the warnings.
As for the warning in `python.texi`, there's period missing at the end
of one `@xref{}` clause. Added.
gdb/doc/ChangeLog:
2020-04-15 Artur Shepilko <nomadbyte@gmail.com>
* gdb.texinfo: Transform @var{[host]} to [@var{host}]; this
clears makeinfo warnings.
* python.texi: Add a missing period trailing an @xref{} clause;
this clears a makeinfo warning.
Alan Modra [Wed, 15 Apr 2020 07:08:01 +0000 (16:38 +0930)]
PR25822, Invalid read in process_symbol_table
PR 25822
* readelf.c (get_num_dynamic_syms): Don't set num_of_syms when
reading buckets or chains fails.
Alan Modra [Wed, 15 Apr 2020 07:10:54 +0000 (16:40 +0930)]
readelf: zero static vars after freeing
When readelf is processing more than one file, static bss vars won't
start out as zero for the second file unless they are cleared.
* readelf.c (process_symbol_table): Zero gnubuckets, gnuchains
etc. after freeing.
Alan Modra [Wed, 15 Apr 2020 05:23:32 +0000 (14:53 +0930)]
readelf: increase size of static buffers
Translated strings might be larger than the original.
* readelf.c (get_group_flags): Translate text.
(get_file_type, get_symbol_binding, get_symbol_type),
(get_ppc64_symbol_other, get_symbol_other): Increase size of buffer.
Alan Modra [Wed, 15 Apr 2020 03:09:54 +0000 (12:39 +0930)]
Re: readelf: Consolidate --syms --use-dynamic with --dyn-syms
PR 25821
* readelf.c (get_num_dynamic_syms): Typo fix.
GDB Administrator [Wed, 15 Apr 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Juan Manuel Guerrero [Tue, 14 Apr 2020 16:30:01 +0000 (17:30 +0100)]
[PATCH v2 2/2] coff-go32: support extended relocations
This patch extends the relocation and line number counters for
coff-go32 and coff-go32-exe to 32 bits. As I understand it works the
same as for PE-COFF:
If the number of relocations in an object file exceeds 65534, the
NRELOC field is set to 65535 and the actual number of relocations is
stored in the VADDR field of the first relocation entry.
Executable files have no relocations, and thus the NRELOC field is
repurposed to extend NLNNO to 32-bits.
bfd * coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out)
(_bfd_go32_mkobject): New functions.
* coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(go32exe_mkobject): Call _bfd_go32_mkobject.
* coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define.
(coff_set_alignment_hook): Define function for COFF_GO32_EXE
and COFF_GO32.
(coff_write_relocs): Enable extended reloc counter code if
COFF_WITH_EXTENDED_RELOC_COUNTER is defined. Test for obj_go32.
(coff_write_object_contents): Likewise. Pad section headers
for COFF_GO32 and COFF_GO32EXE. Use bfd_coff_swap_scnhdr_out
instead of coff_swap_scnhdr_out.
* cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to
enable extended reloc counter.
* coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out):
Declare with ATTRIBUTE_UNUSED.
* libcoff-in.h: (struct coff_tdata): New field go32.
(obj_go32): Define.
* libcoff.h: Regenerate.
Kamil Rytarowski [Mon, 13 Apr 2020 11:05:59 +0000 (13:05 +0200)]
Implement IP_STAT+IP_STATUS (aliases of the same format) on NetBSD
Output based on FreeBSD with the following changes:
- "utime+stime, children" merged from "utime, children" and
"stime, children".
- "Minor faults, children", "Major faults, children",
"Virtual memory size" removed as not available in a direct
equivalent.
No new values missing or skipped in FreeBSD are printed, although
there is a long list of potential candiates.
gdb/ChangeLog:
* nbsd-nat.c (nbsd_pid_to_kinfo_proc2): New.
(nbsd_nat_target::info_proc): Add do_status.
Fangrui Song [Tue, 14 Apr 2020 14:21:50 +0000 (15:21 +0100)]
The assembler only supports 32-bit stabs. So set sh_entsize unconditionally to 12.
PR gas/25768
* elf.c (assign_section_numbers): Always set .stab sh_entsize to
12.
Alan Modra [Tue, 14 Apr 2020 00:21:44 +0000 (09:51 +0930)]
readelf memory leaks processing mips
* readelf.c (process_mips_specific): Free eopt and iopt. Avoid
possibility of overflow when checking number of conflicts.
Stephen Casner [Tue, 14 Apr 2020 13:41:27 +0000 (14:41 +0100)]
Fixes for the magic number used in PDP11 AOUT binaries.
PR ld/25677
include * aout/aout64.h (N_DATADDR): Add IMAGIC case.
bfd * pdp11.c: Add implementation of --imagic option.
(adjust_o_magic): Fix objcopy --extract-symbol test.
* libaout.h (enum aout_magic): Add i_magic.
ld * emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11.
(EXTRA_EM_FILE): New, add emulation file pdp11.
* scripttempl/pdp11.sc: New, derived from aout.sc without
irrelevant input sections.
* emultempl/pdp11.em (_add_options, _handle_option)
(_list_options): New. Add options -z, --imagic for pdp11-aout.
(_before_parse): Make --omagic be default instead of --nmagic.
(_get_script): Modify special-case linker script for --imagic.
* lexsup.c (parse_args): Explictly set config.text_read_only for -n.
* ld.texi (Options): Add documentation of PDP11-specific options.
(Options): Fix unrelated typo to --no-compact-branches.
* gen-doc.texi: @set PDP11.
* testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing.
* testsuite/ld-pdp11/sections.s: New, source for options tests.
* testsuite/ld-pdp11/imagic.d: New, test --imagic format.
* testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format.
* testsuite/ld-pdp11/nmagic.d: New, test --nmagic format.
* testsuite/ld-pdp11/omagic.d: New, test --omagic format.
Tom de Vries [Tue, 14 Apr 2020 13:30:50 +0000 (15:30 +0200)]
[gdb] Fix missing symtab includes
[ The test-case requires commit
c1a66c0629 "[gdb] Expand symbolless symtabs
using maint expand-symtabs". ]
Consider the debug info for the test-case included in this patch. It consists
of a PU:
...
<0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit)
<1><d3>: Abbrev Number: 0
...
imported by a CU:
...
<0><df>: Abbrev Number: 2 (DW_TAG_compile_unit)
<e0> DW_AT_language : 2 (non-ANSI C)
<e1> DW_AT_stmt_list : 0xe9
<1><e5>: Abbrev Number: 3 (DW_TAG_imported_unit)
<e6> DW_AT_import : <0xd2> [Abbrev Number: 2]
<1><ea>: Abbrev Number: 0
...
and the CU has a dw2-symtab-includes.h file in the .debug_line file name
table:
...
The Directory Table (offset 0x101):
1 /data/gdb_versions/devel/src/gdb/testsuite/gdb.dwarf2
The File Name Table (offset 0x138):
Entry Dir Time Size Name
1 1 0 0 dw2-symtab-includes.h
...
After expanding all symtabs, we can see the CU listed in the user field of the
PU, and vice-versa the PU listed in the includes of the CU:
...
$ gdb.sh -batch \
-iex "set language c" \
outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \
-ex "maint expand-symtabs" \
-ex "maint info symtabs"
...
{ ((struct compunit_symtab *) 0x394dd60)
debugformat DWARF 2
producer (null)
dirname (null)
blockvector ((struct blockvector *) 0x394dea0)
user ((struct compunit_symtab *) 0x394dba0)
}
{ ((struct compunit_symtab *) 0x394dba0)
debugformat DWARF 2
producer (null)
dirname (null)
blockvector ((struct blockvector *) 0x394dd10)
user ((struct compunit_symtab *) (null))
( includes
((struct compunit_symtab *) 0x394dd60)
)
}
...
But if we instead only expand the symtab for the dw2-symtab-includes.h file,
the includes and user links are gone:
...
$ gdb -batch \
-iex "set language c" \
outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \
-ex "maint expand-symtabs dw2-symtab-includes.h" \
-ex "maint info symtabs"
...
{ ((struct compunit_symtab *) 0x2728210)
debugformat DWARF 2
producer (null)
dirname (null)
blockvector ((struct blockvector *) 0x2728350)
user ((struct compunit_symtab *) (null))
}
{ ((struct compunit_symtab *) 0x2728050)
debugformat DWARF 2
producer (null)
dirname (null)
blockvector ((struct blockvector *) 0x27281c0)
user ((struct compunit_symtab *) (null))
}
...
The includes are calculated by process_cu_includes in gdb/dwarf2/read.c.
In the case of expanding all symtabs:
- the CU partial symtab is expanded using psymtab_to_symtab
- psymtab_to_symtab calls dwarf2_psymtab::read_symtab
- dwarf2_psymtab::read_symtab calls dwarf2_psymtab::expand_psymtab
- dwarf2_psymtab::read_symtab calls process_cu_includes, and we have the
includes
In the case of expanding the symtab for dw2-symtab-includes.h:
- the dw2-symtab-includes.h partial symtab is expanded using psymtab_to_symtab
- psymtab_to_symtab calls dwarf2_include_psymtab::read_symtab
- dwarf2_include_psymtab::read_symtab calls
dwarf2_include_psymtab::expand_psymtab
- dwarf2_include_psymtab::expand_psymtab calls
partial_symtab::expand_dependencies
- partial_symtab::expand_dependencies calls dwarf2_psymtab::expand_psymtab
for the CU partial symtab
- the CU partial symtab is expanded using dwarf2_psymtab::expand_psymtab
- process_cu_includes is never called
Fix this by making sure in dwarf2_include_psymtab::read_symtab that
read_symtab is called for the CU partial symtab.
Tested on x86_64-linux, with native, and target board cc-with-dwz and
cc-with-dwz-m.
In addition, tested test-case with target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.
gdb/ChangeLog:
2020-04-14 Simon Marchi <simon.marchi@polymtl.ca>
Tom de Vries <tdevries@suse.de>
PR symtab/25718
* psympriv.h (struct partial_symtab::read_symtab)
(struct partial_symtab::expand_psymtab)
(struct partial_symtab::read_dependencies): Update comments.
* dwarf2/read.c (struct dwarf2_include_psymtab::read_symtab): Call
read_symtab for includer.
(struct dwarf2_include_psymtab::expand_psymtab): Assert false.
(struct dwarf2_include_psymtab::readin_p): Call readin_p () for includer.
(struct dwarf2_include_psymtab::m_readin): Remove.
(struct dwarf2_include_psymtab::includer): New member function.
(dwarf2_psymtab::expand_psymtab): Assert !readin.
gdb/testsuite/ChangeLog:
2020-04-14 Tom de Vries <tdevries@suse.de>
PR symtab/25718
* gdb.dwarf2/dw2-symtab-includes.exp: New file.
Tom de Vries [Tue, 14 Apr 2020 13:08:42 +0000 (15:08 +0200)]
[gdb] Expand symbolless symtabs using maint expand-symtabs
Consider this test-case, consisting of header file hello.h:
...
inline static const char*
foo (void)
{
return "foo";
}
...
and source file hello.c:
...
int
main (void)
{
printf ("hello: %s\n", foo ());
return 0;
}
...
compiled with -g:
...
$ gcc hello.c -g
...
When trying to expand the partial symtab for hello.h:
...
$ gdb -batch \
-iex "set language c" \
a.out \
-ex "maint expand-symtabs hello.h" \
-ex "maint info psymtabs"
...
we in fact find that the partial symtab for hello.h (and corresponding
includer partial symtab hello.c) have not been expanded:
...
{ psymtab hello.h ((struct partial_symtab *) 0x27cf070)
readin no
...
{ psymtab hello.c ((struct partial_symtab *) 0x2cf09e0)
readin no
...
This is due to the recursively_search_psymtabs call in
psym_expand_symtabs_matching:
...
if (recursively_search_psymtabs (ps, objfile, domain,
lookup_name, symbol_matcher))
...
which always returns false for symbolless partial symtabs.
The same problem occurs with CUs where the dwarf is generated by gas
--gdwarf-2 for a foo.S: if we read such a test-case with -readnow, we'll have
a symbolless symtab for foo.S. But if we read the test-case with partial
symtabs, and expand those using "maint expand-symtabs", the foo.S psymtab
remains unexpanded.
Fix this by passing a NULL symbol_matcher and lookup_name to
expand_symtabs_matching in maintenance_expand_symtabs, and skipping the call
to recursively_search_psymtabs if symbol_matcher == NULL and
lookup_name == NULL.
Build and tested on x86_64-linux, with native.
In addition, tested test-case with target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.
gdb/ChangeLog:
2020-04-14 Tom de Vries <tdevries@suse.de>
PR symtab/25720
* symmisc.c (maintenance_expand_symtabs): Call expand_symtabs_matching
with NULL symbol_matcher and lookup_name.
* psymtab.c (psym_expand_symtabs_matching): Handle NULL symbol_matcher
and lookup_name.
* dwarf2/read.c (dw2_expand_symtabs_matching)
(dw2_debug_names_expand_symtabs_matching): Same.
* symfile.h (struct quick_symbol_functions::expand_symtabs_matching):
Make lookup_name a pointer. Update comment.
* symtab.c (global_symbol_searcher::expand_symtabs): Handle
lookup_name being a pointer.
* symfile.c (expand_symtabs_matching): Same.
* symfile-debug.c (debug_qf_expand_symtabs_matching): Same.
* linespec.c (iterate_over_all_matching_symtabs): Same.
gdb/testsuite/ChangeLog:
2020-04-14 Tom de Vries <tdevries@suse.de>
PR symtab/25720
* gdb.base/maint-expand-symbols-header-file.c: New test.
* gdb.base/maint-expand-symbols-header-file.exp: New file.
* gdb.base/maint-expand-symbols-header-file.h: New test.
H.J. Lu [Tue, 14 Apr 2020 12:00:22 +0000 (05:00 -0700)]
readelf: Consolidate --syms --use-dynamic with --dyn-syms
When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
compute dynamic symbol table size from hash table. For DT_HASH, the
number of dynamic symbol table entries equals the number of chains.
For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
indings are in hash table. Since DT_GNU_HASH/DT_MIPS_XHASH place all
symbols with STB_LOCAL binding before symbols with other bindings and
all undefined symbols defined ones in dynamic symbol table, the highest
symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
table index.
Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms
and --syms --use-dynamic.
binutils/
PR binutils/25707
* readelf.c (nbuckets): New.
(nchains): Likewise.
(buckets): Likewise.
(chains): Likewise.
(ngnubuckets): Likewise.
(gnubuckets): Likewise.
(gnuchains): Likewise.
(mipsxlat): Likewise.
(ngnuchains): Likewise.
(gnusymidx): Likewise.
(VALID_SYMBOL_NAME): Likewise.
(VALID_DYNAMIC_NAME): Use it.
(get_dynamic_data): Moved before process_dynamic_section.
(get_num_dynamic_syms): New function.
(process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH,
DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol
table. Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string
table.
(get_symbol_index_type): Don't print "bad section index" when
there is no section header.
(print_dynamic_symbol): Rewrite.
(process_symbol_table): Call print_dynamic_symbol to dump dynamic
symbol table.
ld/
PR binutils/25707
* testsuite/ld-arm/armthumb-lib.sym: Updated.
* testsuite/ld-arm/farcall-mixed-app.sym: Likewise.
* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.
* testsuite/ld-arm/fdpic-main-m.sym: Likewise.
* testsuite/ld-arm/fdpic-main.sym: Likewise.
* testsuite/ld-arm/fdpic-shared-m.sym: Likewise.
* testsuite/ld-arm/fdpic-shared.sym: Likewise.
* testsuite/ld-arm/mixed-app.sym: Likewise.
* testsuite/ld-arm/mixed-lib.sym: Likewise.
* testsuite/ld-arm/preempt-app.sym: Likewise.
* testsuite/ld-elf/hash.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elfvsb/hidden2.d: Likewise.
* testsuite/ld-mips-elf/hash2.d: Likewise.
Andrew Burgess [Fri, 3 Apr 2020 19:41:00 +0000 (20:41 +0100)]
gdb/testsuite: Move helper function into lib/dwarf.exp
Every time I write a test making use of the DWARF assembler I end up
copying in the function get_func_info. Duplicating code is bad, so
lets put this function into lib/dwarf.exp and remove all of the
duplicates.
There should be no changes in the testsuite behaviour after this
commit.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-inline-small-func.exp: Pass options to
get_func_info.
(get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete.
* lib/dwarf.exp (get_func_info): New function.
GDB Administrator [Tue, 14 Apr 2020 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Remove gdb_fildes_t
gdb_fildes_t and pfildes are no longer used, so remove them.
gdbserver/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* server.h (gdb_fildes_t): Remove typedef.
* remote-utils.c (remote_desc, list_desc): Now int.
(INVALID_DESCRIPTOR): Remove.
(gdb_connected, remote_close)
(check_remote_input_interrupt_request): Update.
* utils.h (pfildes): Don't declare.
* utils.c (pfildes): Remove.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Move gdb_notifier comment
This moves the gdb_notifier comment a bit lower in event-loop.c, to
where it belongs; and removes an obsolete comment that Pedro pointed
out.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.c: Move comment. Remove obsolete comment.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Switch gdbserver to gdbsupport event loop
This changes gdbserver to use the gdbserver event loop, removing the
ancient fork.
gdbserver/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* server.h (handle_serial_event, handle_target_event): Update.
* server.c: Don't call initialize_event_loop.
(keep_processing_events): New global.
(handle_serial_event): Return void. Set keep_processing_events.
(handle_target_event): Return void.
(start_event_loop): Move from event-loop.c. Rewrite.
* remote-utils.c (handle_accept_event): Return void.
(reset_readchar): Use delete_timer.
(process_remaining): Return void.
(reschedule): Use create_timer.
* event-loop.h: Remove.
* event-loop.cc: Remove.
* Makefile.in (OBS): Use gdbsupport/event-loop.o, not event-loop.o.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Implement event-loop glue for gdbserver
event-loop.c requires the client to provide some functions. This
patch implements these functions for gdbserver.
gdbserver/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* server.c (invoke_async_signal_handlers)
(check_async_event_handlers, flush_streams, gdb_select): New
functions.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Move event-loop.[ch] to gdbsupport/
This moves event-loop.[ch] to gdbsupport/ and updates the uses in gdb.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* run-on-main-thread.c: Update include.
* unittests/main-thread-selftests.c: Update include.
* tui/tui-win.c: Update include.
* tui/tui-io.c: Update include.
* tui/tui-interp.c: Update include.
* tui/tui-hooks.c: Update include.
* top.h: Update include.
* top.c: Update include.
* ser-base.c: Update include.
* remote.c: Update include.
* remote-notif.c: Update include.
* remote-fileio.c: Update include.
* record-full.c: Update include.
* record-btrace.c: Update include.
* python/python.c: Update include.
* posix-hdep.c: Update include.
* mingw-hdep.c: Update include.
* mi/mi-main.c: Update include.
* mi/mi-interp.c: Update include.
* main.c: Update include.
* linux-nat.c: Update include.
* interps.c: Update include.
* infrun.c: Update include.
* inf-loop.c: Update include.
* event-top.c: Update include.
* event-loop.c: Move to ../gdbsupport/.
* event-loop.h: Move to ../gdbsupport/.
* async-event.h: Update include.
* Makefile.in (COMMON_SFILES, HFILES_NO_SRCDIR): Update.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.h: Move from ../gdb/.
* event-loop.cc: Move from ../gdb/.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Introduce async-event.[ch]
This patch splits out some gdb-specific code from event-loop, into new
files async-event.[ch]. Strictly speaking this code could perhaps be
put into gdbsupport/, but because gdbserver does not currently use it,
it seemed better, for size reasons, to split it out.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* tui/tui-win.c: Include async-event.h.
* remote.c: Include async-event.h.
* remote-notif.c: Include async-event.h.
* record-full.c: Include async-event.h.
* record-btrace.c: Include async-event.h.
* infrun.c: Include async-event.h.
* event-top.c: Include async-event.h.
* event-loop.h: Move some declarations to async-event.h.
* event-loop.c: Don't include ser-event.h or top.h. Move some
code to async-event.c.
* async-event.h: New file.
* async-event.c: New file.
* Makefile.in (COMMON_SFILES): Add async-event.c.
(HFILES_NO_SRCDIR): Add async-event.h.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Introduce and use flush_streams
Code in gdbsupport can't call gdb_flush, so this introduces a new
"flush_streams" function that must be supplied by the client.
Note that the similar gdb_flush_out_err exists, but it isn't defined
in quite the same way, so it wasn't clear to me whether the two could
be merged.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* utils.c (flush_streams): New function.
* event-loop.c (gdb_wait_for_event): Call flush_streams.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* errors.h (flush_streams): Declare.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Use warning in event-loop
Change event-loop.c to avoid printf_unfiltered in favor of warning.
warning is aleady available to code in gdbsupport/.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.c (handle_file_event): Use warning, not
printf_unfiltered.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Include <chrono> in event-loop.c
Include <chrono> in event-loop.c, because it is used there. Currently
it is included indirectly, but after the subsequent patches this will
no longer be the case.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.c: Include <chrono>.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Move gdb_select.h to gdbsupport/
This moves gdb_select.h to gdbsupport/, so it can be used by other
code there.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* gdb_select.h: Move to ../gdbsupport/.
* event-loop.c: Update include path.
* top.c: Update include path.
* ser-base.c: Update include path.
* ui-file.c: Update include path.
* ser-tcp.c: Update include path.
* guile/scm-ports.c: Update include path.
* posix-hdep.c: Update include path.
* ser-unix.c: Update include path.
* gdb_usleep.c: Update include path.
* mingw-hdep.c: Update include path.
* inflow.c: Update include path.
* infrun.c: Update include path.
* event-top.c: Update include path.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* gdb_select.h: Move from ../gdb/.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Move event-loop configury to common.m4
gdb_select.h and the event loop require some configure checks, so this
moves the needed checks to common.m4 and updates the configure
scripts.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac: Remove checks that are now in GDB_AC_COMMON.
gdbserver/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* config.in: Rebuild.
gdbsupport/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* config.in, configure: Rebuild.
* common.m4 (GDB_AC_COMMON): Check for poll.h, sys/poll.h,
sys/select.h, and poll.
Tom Tromey [Mon, 13 Apr 2020 18:42:59 +0000 (12:42 -0600)]
Move start_event_loop out of event-loop.c
A subsequent patch is going to move event-loop.c to gdbsupport. In a
review of an earlier version of this series, Pedro pointed out that
the resulting code would be cleaner if start_event_loop were not
shared -- because gdb and gdbserver have some different needs here --
and so this moves start_event_loop to main.c. Because the only caller
is there, it is also now static.
gdb/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* event-loop.h (start_event_loop): Don't declare.
* event-loop.c (start_event_loop): Move...
* main.c (start_event_loop): ...here. Now static.
Sergio Durigan Junior [Mon, 13 Apr 2020 19:53:28 +0000 (15:53 -0400)]
Update my email address on MAINTAINERS
Commit pushed under the obvious/trivial rule.
gdb/ChangeLog:
2020-04-13 Sergio Durigan Junior <sergiodj@sergiodj.net>
* MAINTAINERS: Update my email address.
Tom de Vries [Mon, 13 Apr 2020 16:53:14 +0000 (18:53 +0200)]
[gdb/testsuite] Fix gdb.ada/catch_ex_std.exp gnatlink FAIL
When running test-case gdb.ada/catch_ex.exp using system gnatmake, gnatmake is
invoked like this:
...
Executing on host: \
gnatmake foo.adb -gnata -f -Isrc/gdb/testsuite/gdb.ada/catch_ex -g -lm \
-o outputs/gdb.ada/catch_ex/foo
...
When I try to use a more recent gnatmake, by mocking up a combined build:
...
$ ls -la build/gcc/
lrwxrwxrwx gfortran -> /usr/bin/gfortran-10
lrwxrwxrwx gnatbind -> /usr/bin/gnatbind-10
lrwxrwxrwx gnatlink -> /usr/bin/gnatlink-10
lrwxrwxrwx gnatmake -> /usr/bin/gnatmake-10
lrwxrwxrwx xg++ -> /usr/bin/g++-10
lrwxrwxrwx xgcc -> /usr/bin/gcc-10
...
gnatmake is invoked like this:
...
Executing on host: \
/data/gdb_versions/devel/build/gcc/gnatmake \
-I/data/gdb_versions/devel/build/gcc/ada/rts \
--GCC=/data/gdb_versions/devel/build/gcc/xgcc \
--GNATBIND=/data/gdb_versions/devel/build/gcc/gnatbind \
--GNATLINK=/data/gdb_versions/devel/build/gcc/gnatlink \
-cargs -B/data/gdb_versions/devel/build/gcc \
-largs --GCC=/data/gdb_versions/devel/build/gcc/xgcc \
-B/data/gdb_versions/devel/build/gcc \
-margs foo.adb -gnata -f -Isrc/gdb/testsuite/gdb.ada/catch_ex -g -lm \
-o outputs/gdb.ada/catch_ex/foo
...
This is set up by this bit in find_gnatmake in
/usr/share/dejagnu/libgloss.exp:
...
if {![is_remote host]} {
set file [lookfor_file $tool_root_dir gnatmake]
if { $file == "" } {
set file [lookfor_file $tool_root_dir gcc/gnatmake]
}
if { $file != "" } {
set root [file dirname $file]
set CC "$file -I$root/ada/rts --GCC=$root/xgcc \
--GNATBIND=$root/gnatbind --GNATLINK=$root/gnatlink \
-cargs -B$root \
-largs --GCC=$root/xgcc -B$root -margs"
} else {
...
However, when running test-case gdb.ada/catch_ex_std.exp using the mockup
combined build, we get:
...
Executing on host: \
/data/gdb_versions/devel/build/gcc/gnatlink foo \
-Wl,-rpath,\$ORIGIN -Wl,-lsome_package
b~foo.adb:26:79: "SS_Stack" not declared in "Secondary_Stack"^M
b~foo.adb:26:89: incorrect constraint for this kind of type^M
b~foo.adb:121:56: "Runtime_Default_Sec_Stack_Size" not declared in "Parameters"^M
FAIL: gdb.ada/catch_ex_std.exp: gnatlink foo
...
The problem is caused by the fact that the test uses gnatlink directly
rather than using gnatmake. The invoked gnatlink (which is gnatlink-10) calls
gcc-7, which are incompatible (see gcc PR86211). This problem doesn't occur
with gnatmake because there the gcc to use is passed as an argument to
gnatlink.
Fix this by adding the -largs bit from find_gnatmake in find_ada_tool, for the
case that $tool == gnatlink.
Tested on x86_64-linux, with system gcc, and gcc-10.
gdb/testsuite/ChangeLog:
2020-04-13 Tom de Vries <tdevries@suse.de>
* lib/ada.exp (find_ada_tool): Pass --GCC and -B to gnatlink, similar
to what find_gnatmake does.
Kamil Rytarowski [Sun, 12 Apr 2020 21:47:06 +0000 (23:47 +0200)]
Implement IP_MINIMAL and IP_ALL on NetBSD
gdb/ChangeLog:
* nbsd-nat.c (nbsd_nat_target::info_proc): Add IP_MINIMAL and
IP_ALL.
GDB Administrator [Mon, 13 Apr 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Kamil Rytarowski [Sun, 12 Apr 2020 19:09:48 +0000 (21:09 +0200)]
Implement "info proc cmdline" for NetBSD
Add nbsd_pid_to_cmdline() to query the program command line.
gdb/ChangeLog:
* nbsd-nat.c (nbsd_pid_to_cmdline): Add.
(nbsd_nat_target::info_proc): Add do_cmdline.
Kamil Rytarowski [Sun, 12 Apr 2020 17:24:01 +0000 (19:24 +0200)]
Implement "info proc cwd" for NetBSD
Add nbsd_pid_to_cwd() to query the program current directory.
gdb/ChangeLog:
* nbsd-nat.c (nbsd_pid_to_cwd): Add.
(nbsd_nat_target::info_proc): Add do_cwd.
Kamil Rytarowski [Sun, 12 Apr 2020 15:04:34 +0000 (17:04 +0200)]
Implement "info proc exe" for NetBSD
Use pid_to_exec_file() to query the program.
gdb/ChangeLog:
* nbsd-nat.c (nbsd_nat_target::info_proc): Add do_exe.
Kamil Rytarowski [Sun, 12 Apr 2020 00:00:14 +0000 (02:00 +0200)]
Implement "info proc mappings" for NetBSD
Define nbsd_nat_target::find_memory_regions and
nbsd_nat_target::info_proc. info_proc handles as of now only
the "mappings" command.
Define a local static function kinfo_get_vmmap() that reads
the process memory layout of a specified process.
kinfo_get_vmmap() wraps the sysctl(3) call.
nbsd-tdep.c defines now utility functions for printing the
process memory layout:
* nbsd_info_proc_mappings_header()
* nbsd_vm_map_entry_flags()
* nbsd_info_proc_mappings_entry()
gdb/ChangeLog:
* nbsd-nat.c; Include "nbsd-tdep.h" and "gdbarch.h".
* nbsd-nat.c (nbsd_nat_target::find_memory_regions)
(nbsd_nat_target::info_proc): New functions.
* nbsd-nat.c (kinfo_get_vmmap): New function.
* nbsd-nat.c (nbsd_nat_target::info_proc) Use
nbsd_info_proc_mappings_header and nbsd_info_proc_mappings_entry.
* nbsd-tdep.c (nbsd_info_proc_mappings_header)
(nbsd_info_proc_mappings_entry, nbsd_vm_map_entry_flags): New
functions.
* nbsd-tdep.c (KINFO_VME_PROT_READ, KINFO_VME_PROT_WRITE)
(KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_PAGEABLE, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN): New.
GDB Administrator [Sun, 12 Apr 2020 00:00:05 +0000 (00:00 +0000)]
Automatic date update in version.in
Artur Shepilko [Fri, 10 Apr 2020 14:56:43 +0000 (10:56 -0400)]
gdb: fix undefined behavior reported in copy_bitwise
gdb version 9.1, built with clang 8.0.0 on Ubuntu 18.04 (x86_64);
--enable-ubsan (for clang's undefined behavior sanitizer)
Executing command; `maint selftest copy_bitwise` bombs in runtime error:
../../gdb/utils.c:3432:28: runtime error: left shift of negative value -1
Closer look reveals the offending shift: `(~0 << nbits)`, apparently 0
is treated as signed int, resulting in negative complement. Explicitly
stating it unsigned 0U fixes it and the `copy_bitwise` test passes
ok.
GDB Administrator [Sat, 11 Apr 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 10 Apr 2020 13:18:49 +0000 (07:18 -0600)]
Avoid infinite recursion in get_msymbol_address
Sometimes, get_msymbol_address can cause infinite recursion, leading
to a crash. This was reported previously here:
https://sourceware.org/pipermail/gdb-patches/2019-November/162154.html
A user on irc reported this as well, and with his help and the help of
a friend of his, we found that the problem occurred because, when
reloading a separate debug objfile, the objfile would lose the
OBJF_MAINLINE flag. This would cause some symbols from this separate
debug objfile to be marked "maybe_copied" -- but then
get_msymbol_address could find the same symbol and fail as reported.
This patch fixes the bug by preserving OBJF_MAINLINE.
No test case, unfortunately, because I could not successfully make
one.
gdb/ChangeLog
2020-04-10 Tom Tromey <tromey@adacore.com>
* symfile.c (symbol_file_add_separate): Preserve OBJF_MAINLINE.
Tom Tromey [Fri, 10 Apr 2020 13:18:49 +0000 (07:18 -0600)]
Skip separate debug files when handling copy relocations
get_symbol_address and get_msymbol_address call
lookup_minimal_symbol_linkage, which iterates over the separate debug
files of the objfile that is passed in.
This means that if these functions pass in a separate debug objfile,
then they are doing unnecessary work.
This patch avoids the extra work by skipping separate debug objfiles
in the loops.
gdb/ChangeLog
2020-04-10 Tom Tromey <tromey@adacore.com>
* symtab.c (get_symbol_address, get_msymbol_address): Skip
separate debug files.
Hannes Domani [Thu, 9 Apr 2020 14:33:20 +0000 (16:33 +0200)]
Fix debugging of WOW64 processes
The new code regarding pending stops only checks for EXCEPTION_BREAKPOINT,
but for WOW64 processes STATUS_WX86_BREAKPOINT is necessary as well.
Also, ignore_first_breakpoint is used now in nat/windows-nat.c as well,
but was not available there.
gdb/ChangeLog:
2020-04-10 Hannes Domani <ssbssa@yahoo.de>
* nat/windows-nat.c (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
Move to...
* nat/windows-nat.h (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
... here.
* windows-nat.c (windows_nat_target::get_windows_debug_event):
Check for STATUS_WX86_BREAKPOINT.
(windows_nat_target::wait): Same.
Rainer Orth [Fri, 10 Apr 2020 09:18:10 +0000 (11:18 +0200)]
ld: xfail several shared (non PIC) tests on Solaris
Three ld tests currently FAIL on Solaris/SPARC:
FAIL: shared (non PIC)
FAIL: shared (non PIC, load offset)
FAIL: shared (PIC main, non PIC so)
all of them in the same way:
/var/gcc/binutils/sparcv7/obj/binutils/ld/tmpdir/ld/collect-ld: read-only
segment has dynamic relocations
Given that Solaris defaults to -z text, this is to be expected, thus
this patch xfail's them.
Tested on sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11.
* testsuite/ld-shared/shared.exp: Remove dangling comments.
xfail shared non PIC tests on Solaris.
Tom de Vries [Fri, 10 Apr 2020 07:50:11 +0000 (09:50 +0200)]
[gdb/testsuite] Fix -readnow FAIL in gdb.base/style.exp
When running test-case gdb.base/style.exp with target board readnow, we run
into:
...
FAIL: gdb.base/style.exp: filename is styled when loading symbol file
...
The problem is that with -readnow, an extra "Expanding full symbols" message
is generated:
...
(gdb) file $file^M
Reading symbols from $file...^M
Expanding full symbols from $file...^M
(gdb) FAIL: gdb.base/style.exp: filename is styled when loading symbol file
...
and the test does not expect this message.
Fix this by expecting the additional message for -readnow.
gdb/testsuite/ChangeLog:
2020-04-10 Tom de Vries <tdevries@suse.de>
* gdb.base/style.exp: Expect "Expanding full symbols" message for
-readnow.
Tom de Vries [Fri, 10 Apr 2020 07:29:52 +0000 (09:29 +0200)]
[gdb/cli] Don't let python colorize strip leading newlines
Consider the test-case gdb.base/async.exp. Using the executable, I run to
main, and land on a line advertised as line 26:
...
$ gdb outputs/gdb.base/async/async -ex start
Reading symbols from outputs/gdb.base/async/async...
Temporary breakpoint 1 at 0x4004e4: file gdb.base/async.c, line 26.
Starting program: outputs/gdb.base/async/async
Temporary breakpoint 1, main () at gdb.base/async.c:26
26 y = foo ();
...
But actually, the line turns out to be line 28:
...
$ cat -n gdb.base/async.c
...
26 y = 2;
27 z = 9;
28 y = foo ();
...
This is caused by the following: the python colorizer initializes the lexer
with default options (no second argument to get_lexer_for_filename):
...
def colorize(filename, contents):
# Don't want any errors.
try:
lexer = lexers.get_lexer_for_filename(filename)
formatter = formatters.TerminalFormatter()
return highlight(contents, lexer, formatter)
...
which include option stripnl=True, which strips leading and trailing newlines.
This causes the python colorizer to strip the two leading newlines of async.c.
Fix this by initializing the lexer with stripnl=False.
Build and reg-tested on x86_64-linux.
gdb/ChangeLog:
2020-04-10 Tom de Vries <tdevries@suse.de>
PR cli/25808
* python/lib/gdb/__init__.py: Initialize lexer with stripnl=False.
gdb/testsuite/ChangeLog:
2020-04-10 Tom de Vries <tdevries@suse.de>
PR cli/25808
* gdb.base/style.c: Add leading newlines.
* gdb.base/style.exp: Use gdb_get_line_number to get specific lines.
Check listing of main's one-line body.
GDB Administrator [Fri, 10 Apr 2020 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 9 Apr 2020 23:00:39 +0000 (19:00 -0400)]
gdb: move Tom de Vries to Global Maintainers
gdb/ChangeLog:
* MAINTAINERS (Global Maintainers): Add Tom de Vries.
(Write After Approval): Remove Tom de Vries.
Bernd Edlinger [Thu, 9 Apr 2020 01:18:23 +0000 (03:18 +0200)]
Partially revert my UB fix in record_line
This reverts the following commit partially:
commit
64dc2d4bd24ff7119c913fff91184414f09b8042
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date: Thu Mar 12 11:52:34 2020 +0100
Fix an undefined behavior in record_line
Additionally do not completely remove symbols
at the same PC than the end marker, instead
make them non-is-stmt breakpoints.
We keep the undefined behavoir fix,
but have to restore the original behavior
regarding deletion of the line entries.
2020-04-09 Bernd Edlinger <bernd.edlinger@hotmail.de>
revert partially:
2020-04-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
* buildsym.c (record_line): Fix undefined behavior and preserve
lines at eof.
Kamil Rytarowski [Wed, 8 Apr 2020 02:01:10 +0000 (04:01 +0200)]
Add SVR4 psABI specific parser for AUXV entries
NetBSD and OpenBSD always use an int to store the type as
defined in the SVR4 psABI specifications rather than long
as assumed by the default parser.
Define svr4_auxv_parse() that shares code with default_auxv_parse().
Remove obsd_auxv_parse() and switch OpenBSD to svr4_auxv_parse().
Remove not fully accurate comment from obsd-tdep.c.
Use svr4_auxv_parse() on NetBSD.
gdb/ChangeLog:
* auxv.h (svr4_auxv_parse): New.
* auxv.c (default_auxv_parse): Split into default_auxv_parse
and generic_auxv_parse.
(svr4_auxv_parse): Add.
* obsd-tdep.c: Include "auxv.h".
(obsd_auxv_parse): Remove.
(obsd_init_abi): Remove comment.
(obsd_init_abi): Change set_gdbarch_auxv_parse passed argument
from `obsd_auxv_parse' to `svr4_auxv_parse'.
* nbsd-tdep.c: Include "auxv.h".
(nbsd_init_abi): Call set_gdbarch_auxv_parse.
Rainer Orth [Thu, 9 Apr 2020 11:10:40 +0000 (13:10 +0200)]
ld: Fix pr22269-1 on 32-bit Solaris/SPARC
pr22269-1.s currently FAILs to assemble on 32-bit Solaris/SPARC:
ERROR: -K PIC tmpdir/pr22269-1.s: assembly failed
UNRESOLVED: pr22269-1 (static pie undefined weak)
tmpdir/pr22269-1.s: Assembler messages:
tmpdir/pr22269-1.s:27: Error: Architecture mismatch on "be,pn %icc,.LL4 ,pn %icc,.LL4".
tmpdir/pr22269-1.s:27: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
tmpdir/pr22269-1.s:32: Error: Architecture mismatch on "return %i7+8".
tmpdir/pr22269-1.s:32: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
tmpdir/pr22269-1.s:36: Error: Architecture mismatch on "return %i7+8".
tmpdir/pr22269-1.s:36: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
I could trace this to the fact that gcc on sparc-sun-solaris2.* defaults
to --with-cpu=v9. So the gcc -S step of compiling the testcase is run
with -mcpu=v9, while the manual invocation of as-new lacks the
corresponding -Av9, creating a mismatch.
Solaris seems to be the only affected target, otherwise only
64-bit-default configurations default to --with-cpu=v9 or
--with-cpu=ultrasparc: sparcv9-*-*, sparc64-*-*,
sparc64-*-freebsd*, ultrasparc-*-freebsd*, and sparc64-*-openbsd*.
This patch just adds -Av9 to AFLAGS_PIC in ld-elf/shared.exp. It has a
precedent in ld-elfvers/vers.exp where -Av9a is added to as_options on
sparc-*-*. It lets the test pass and causes no other changes in
sparc-sun-solaris2.11 test results.
* testsuite/ld-elf/shared.exp: Add -Av9 to AFLAGS_PIC on sparc*-*-*.
H.J. Lu [Thu, 9 Apr 2020 02:31:45 +0000 (19:31 -0700)]
x86: Correct -mlfence-before-indirect-branch= documentation
Replace "after indirect near branch" with "before indirect near branch".
* doc/c-i386.texi: Correct -mlfence-before-indirect-branch=
documentation.
GDB Administrator [Thu, 9 Apr 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Add pending stop support to gdbserver's Windows port
This changes gdbserver to also handle pending stops, the same way that
gdb does. This is PR gdb/22992.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
PR gdb/22992
* win32-low.c (child_continue): Call matching_pending_stop.
(get_child_debug_event): Call fetch_pending_stop. Push pending
stop when needed.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Implement stopped_by_sw_breakpoint for Windows gdbserver
This changes the Windows gdbserver port to implement the
stopped_by_sw_breakpoint target method. This is needed to support
pending stops.
This is a separate patch now, because Pedro suggested splitting it out
for simpler bisecting, in the case that it introduces a bug.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (win32_process_target::stopped_by_sw_breakpoint)
(win32_process_target::supports_stopped_by_sw_breakpoint):
Declare.
* win32-low.c (win32_supports_z_point_type): Always handle
Z_PACKET_SW_BP.
(win32_insert_point): Call insert_memory_breakpoint when needed.
(win32_remove_point): Call remove_memory_breakpoint when needed.
(win32_process_target::stopped_by_sw_breakpoint)
(win32_process_target::supports_stopped_by_sw_breakpoint): New
methods.
(win32_target_ops): Update.
(maybe_adjust_pc): New function.
(win32_wait): Call maybe_adjust_pc.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Introduce win32_target_ops::decr_pc_after_break
This adds a decr_pc_after_break member to win32_target_ops and updates
the two Windows targets to set it.
Note that I can't test the win32-arm-low.c change.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (struct win32_target_ops) <decr_pc_after_break>: New
field.
* win32-i386-low.c (the_low_target): Update.
* win32-arm-low.c (the_low_target): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Add read_pc / write_pc support to win32-low
This changes win32-low.c to implement the read_pc and write_pc
methods. A subsequent patch will need these.
Note that I have no way to test, or even compile, the win32-arm-low.c
change.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (win32_process_target::read_pc)
(win32_process_target::write_pc): Declare.
* win32-low.c (win32_process_target::read_pc)
(win32_process_target::write_pc): New methods.
* win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New
functions.
(the_low_target): Update.
* win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New
functions.
(the_low_target): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Make last_wait_event static
Now that last_wait_event is entirely handled in nat/windows-nat.c, it
can be made static.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* nat/windows-nat.h (last_wait_event): Don't declare.
(wait_for_debug_event): Update comment.
* nat/windows-nat.c (last_wait_event): Now static.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Move wait_for_debug_event to nat/windows-nat.c
This moves the wait_for_debug_event helper function to
nat/windows-nat.c, and changes gdbserver to use it.
wait_for_debug_event is a wrapper for WaitForDebugEvent that also sets
last_wait_event when appropriate. This is needed to properly handle
queued stops.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (wait_for_debug_event): Move to
nat/windows-nat.c.
* nat/windows-nat.h (wait_for_debug_event): Declare.
* nat/windows-nat.c (wait_for_debug_event): Move from
windows-nat.c. No longer static.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (win32_kill, get_child_debug_event): Use
wait_for_debug_event.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Introduce fetch_pending_stop
This introduces a new "fetch_pending_stop" function and changes gdb to
use it. This function removes the first matching pending stop from
the list of such stops.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (get_windows_debug_event): Use
fetch_pending_stop.
* nat/windows-nat.h (fetch_pending_stop): Declare.
* nat/windows-nat.c (fetch_pending_stop): New function.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share some inferior-related Windows code
This adds a couple of functions to nat/windows-nat.c and changes gdb
and gdbserver to use them. One function checks the list of pending
stops for a match (not yet used by gdbserver, but will be in a
subsequent patch); and the other is a wrapper for ContinueDebugEvent
that always uses the last "real" stop event.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_continue): Use matching_pending_stop and
continue_last_debug_event.
* nat/windows-nat.h (matching_pending_stop)
(continue_last_debug_event): Declare.
* nat/windows-nat.c (DEBUG_EVENTS): New define.
(matching_pending_stop, continue_last_debug_event): New
functions.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (child_continue): Call continue_last_debug_event.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share handle_exception
Both gdb and gdbserver have a "handle_exception" function, the bulk of
which is shared between the two implementations. This patch arranges
for the entire thing to be moved into nat/windows-nat.c, with the
differences handled by callbacks. This patch introduces one more
callback to make this possible.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (MS_VC_EXCEPTION): Move to nat/windows-nat.c.
(handle_exception_result): Move to nat/windows-nat.h.
(DEBUG_EXCEPTION_SIMPLE): Remove.
(windows_nat::handle_ms_vc_exception): New function.
(handle_exception): Move to nat/windows-nat.c.
(get_windows_debug_event): Update.
(STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP): Move to
nat/windows-nat.c.
* nat/windows-nat.h (handle_ms_vc_exception): Declare.
(handle_exception_result): Move from windows-nat.c.
(handle_exception): Declare.
* nat/windows-nat.c (MS_VC_EXCEPTION, handle_exception)
(STATUS_WX86_SINGLE_STEP, STATUS_WX86_BREAKPOINT): Move from
windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (handle_exception): Remove.
(windows_nat::handle_ms_vc_exception): New function.
(get_child_debug_event): Add "continue_status" parameter.
Update.
(win32_wait): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Remove some globals from windows-nat.c
windows-nat.c has a few "count" globals that don't seem to be used.
Possibly they were used for debugging at some point, but they no
longer seem useful to me. Because they get in the way of some code
sharing, this patch removes them.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (exception_count, event_count): Remove.
(handle_exception, get_windows_debug_event)
(do_initial_windows_stuff): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share handle_load_dll and handle_unload_dll declarations
This changes nat/windows-nat.h to declare handle_load_dll and
handle_unload_dll. The embedding application is required to implement
these -- while the actual code was difficult to share due to some
other differences between the two programs, sharing the declaration
lets a subsequent patch share more code that uses these as callbacks.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_nat::handle_load_dll)
(windows_nat::handle_unload_dll): Rename. No longer static.
* nat/windows-nat.h (handle_load_dll, handle_unload_dll):
Declare.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (windows_nat::handle_load_dll): Rename from
handle_load_dll. No longer static.
(windows_nat::handle_unload_dll): Rename from handle_unload_dll.
No longer static.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Fix up complaints.h for namespace use
If 'complaint' is used in a namespace context, it will fail because
'stop_whining' is only declared at the top level. This patch fixes
this problem in a simple way, by moving the declaration of
'stop_whining' out of the macro and to the top-level.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* complaints.h (stop_whining): Declare at top-level.
(complaint): Don't declare stop_whining.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Normalize handle_output_debug_string API
This changes gdbserver's implementation of handle_output_debug_string
to have the same calling convention as that of gdb. This allows for
sharing some more code in a subsequent patch.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_nat::handle_output_debug_string):
Rename. No longer static.
* nat/windows-nat.h (handle_output_debug_string): Declare.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (handle_output_debug_string): Add parameter. Change
return type.
(win32_kill, get_child_debug_event): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop, siginfo_er): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(siginfo_er): New globals. Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, siginfo_er): Move to
nat/windows-nat.c.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share get_image_name between gdb and gdbserver
This moves get_image_name to nat/windows-nat.c so that it can be
shared between gdb and gdbserver.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (get_image_name): Move to nat/windows-nat.c.
(handle_load_dll): Update.
* nat/windows-nat.c (get_image_name): Move from windows-nat.c.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (get_image_name): Remove.
(handle_load_dll): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share thread_rec between gdb and gdbserver
This changes gdb and gdbserver to use the same calling convention for
the "thread_rec" helper function. Fully merging these is difficult
due to differences in how threads are managed by the enclosing
applications; but sharing a declaration makes it possible for future
shared code to call this method.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (enum thread_disposition_type): Move to
nat/windows-nat.h.
(windows_nat::thread_rec): Rename from thread_rec. No longer
static.
(windows_add_thread, windows_nat_target::fetch_registers)
(windows_nat_target::store_registers, handle_exception)
(windows_nat_target::resume, get_windows_debug_event)
(windows_nat_target::get_tib_address)
(windows_nat_target::thread_name)
(windows_nat_target::thread_alive): Update.
* nat/windows-nat.h (enum thread_disposition_type): Move from
windows-nat.c.
(thread_rec): Declare.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (windows_nat::thread_rec): Rename from thread_rec.
No longer static. Change parameters.
(child_add_thread, child_fetch_inferior_registers)
(child_store_inferior_registers, win32_resume)
(win32_get_tib_address): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Wrap shared windows-nat code in windows_nat namespace
This wraps the shared windows-nat code in a windows_nat namespace.
This helps avoid name clashes.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c: Add "using namespace".
* nat/windows-nat.h: Wrap contents in windows_nat namespace.
* nat/windows-nat.c: Wrap contents in windows_nat namespace.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (struct win32_target_ops): Use qualified names where
needed.
* win32-i386-low.c: Add "using namespace".
* win32-low.c: Add "using namespace".
* win32-arm-low.c: Add "using namespace".
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Call CloseHandle from ~windows_thread_info
Add a destructor to windows_thread_info that calls CloseHandle.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* nat/windows-nat.h (struct windows_thread_info): Declare
destructor.
* nat/windows-nat.c (~windows_thread_info): New.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (delete_thread_info): Don't call CloseHandle.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Handle pending stops from the Windows kernel
PR gdb/22992 concerns an assertion failure in gdb when debugging a
certain inferior:
int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
Initially the investigation centered on the discovery that gdb was not
suspending other threads when attempting to single-step. This
oversight is corrected in this patch: now, when stepping a thread, gdb
will call SuspendThread on all other threads.
However, the bug persisted even after this change. In particular,
WaitForDebugEvent could see a stop for a thread that was ostensibly
suspended. Our theory of what is happening here is that there are
actually simultaneous breakpoint hits, and the Windows kernel queues
the events, causing the second stop to be reported on a suspended
thread.
In Windows 10 or later gdb could use the DBG_REPLY_LATER flag to
ContinueDebugEvent to request that such events be re-reported later.
However, relying on that did not seem advisable, so this patch instead
arranges to queue such "pending" stops, and then to report them later,
once the step has completed.
In the PR, Pedro pointed out that it's best in this scenario to
implement the stopped_by_sw_breakpoint method, so this patch does this
as well.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
PR gdb/22992
* windows-nat.c (current_event): Update comment.
(last_wait_event, desired_stop_thread_id): New globals.
(struct pending_stop): New.
(pending_stops): New global.
(windows_nat_target) <stopped_by_sw_breakpoint>
<supports_stopped_by_sw_breakpoint>: New methods.
(windows_fetch_one_register): Add assertions. Adjust PC.
(windows_continue): Handle pending stops. Suspend other threads
when stepping. Use last_wait_event
(wait_for_debug_event): New function.
(get_windows_debug_event): Use wait_for_debug_event. Handle
pending stops. Queue spurious stops.
(windows_nat_target::wait): Set stopped_at_software_breakpoint.
(windows_nat_target::kill): Use wait_for_debug_event.
* nat/windows-nat.h (struct windows_thread_info)
<stopped_at_software_breakpoint>: New field.
* nat/windows-nat.c (windows_thread_info::resume): Clear
stopped_at_software_breakpoint.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Change type of argument to windows-nat.c:thread_rec
windows-nat.c:thread_rec accepts an integer parameter whose
interpretation depends on whether it is less than, equal to, or
greater than zero. I found this confusing at times, so this patch
replaces it with an enum instead.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (enum thread_disposition_type): New.
(thread_rec): Replace "get_context" parameter with "disposition";
change type.
(windows_add_thread, windows_nat_target::fetch_registers)
(windows_nat_target::store_registers, handle_exception)
(windows_nat_target::resume, get_windows_debug_event)
(windows_nat_target::get_tib_address)
(windows_nat_target::thread_name)
(windows_nat_target::thread_alive): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share Windows thread-suspend and -resume code
This adds "suspend" and "resume" methods to windows_thread_info, and
changes gdb and gdbserver to share this code.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (thread_rec): Use windows_thread_info::suspend.
(windows_continue): Use windows_continue::resume.
* nat/windows-nat.h (struct windows_thread_info) <suspend,
resume>: Declare new methods.
* nat/windows-nat.c: New file.
* configure.nat (NATDEPFILES): Add nat/windows-nat.o when needed.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (win32_require_context, suspend_one_thread): Use
windows_thread_info::suspend.
(continue_one_thread): Use windows_thread_info::resume.
* configure.srv (srv_tgtobj): Add windows-nat.o when needed.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Use lwp, not tid, for Windows thread id
This changes windows-nat.c to put the Windows thread id into the "lwp"
field of ptid_t, not the "tid" field. This is done for two reasons.
First, ptid.h has this to say:
process_stratum targets that handle threading themselves should
prefer using the ptid.lwp field, leaving the ptid.tid field for any
thread_stratum target that might want to sit on top.
Second, this change brings gdb and gdbserver into sync here, which
makes sharing code simpler.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_add_thread, windows_delete_thread)
(windows_nat_target::fetch_registers)
(windows_nat_target::store_registers, fake_create_process)
(windows_nat_target::resume, windows_nat_target::resume)
(get_windows_debug_event, windows_nat_target::wait)
(windows_nat_target::pid_to_str)
(windows_nat_target::get_tib_address)
(windows_nat_target::get_ada_task_ptid)
(windows_nat_target::thread_name)
(windows_nat_target::thread_alive): Use lwp, not tid.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Make windows_thread_info::name a unique_xmalloc_ptr
This changes windows_thread_info::name to be a unique_xmalloc_ptr,
removing some manual memory management.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (handle_exception)
(windows_nat_target::thread_name): Update.
* nat/windows-nat.h (windows_thread_info): Remove destructor.
<name>: Now unique_xmalloc_ptr.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Change two windows_thread_info members to "bool"
This changes a couple of fields of windows_thread_info to have type
"bool". It also updates the comment of another field, to clarify the
possible values it can hold.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (thread_rec)
(windows_nat_target::fetch_registers): Update.
* nat/windows-nat.h (struct windows_thread_info) <suspended>:
Update comment.
<debug_registers_changed, reload_context>: Now bool.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-i386-low.c (update_debug_registers)
(i386_prepare_to_resume, i386_thread_added): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Use new and delete for windows_thread_info
This adds a constructor, destructor, and member initializers to
windows_thread_info, and changes gdb and gdbserver to use new and
delete.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_add_thread): Use new.
(windows_init_thread_list, windows_delete_thread): Use delete.
(get_windows_debug_event): Update.
* nat/windows-nat.h (struct windows_thread_info): Add constructor,
destructor, and initializers.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.c (child_add_thread): Use new.
(delete_thread_info): Use delete.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Share windows_thread_info between gdb and gdbserver
This introduces a new file, nat/windows-nat.h, which holds the
definition of windows_thread_info. This is now shared between gdb and
gdbserver.
Note that the two implementations different slightly. gdb had a
couple of fields ("name" and "reload_context") that gdbserver did not;
while gdbserver had one field ("base_context") that gdb did not, plus
better comments. The new file preserves all the fields, and the
comments.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (struct windows_thread_info): Remove.
* nat/windows-nat.h: New file.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (struct windows_thread_info): Remove.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Rename windows_thread_info::id to "tid"
This changes the name of a field in windows_thread_info, bringing gdb
and gdbserver closer into sync.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (struct windows_thread_info) <tid>: Rename from "id".
(thread_rec, windows_add_thread, windows_delete_thread)
(windows_continue): Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Rename win32_thread_info to windows_thread_info
This renames win32_thread_info to windows_thread_info in gdbserver.
This renaming helps make it possible to share some code between gdb
and gdbserver.
gdbserver/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (struct windows_thread_info): Rename from
win32_thread_info. Remove typedef.
(struct win32_target_ops, win32_require_context): Update.
* win32-low.c (win32_get_thread_context)
(win32_set_thread_context, win32_prepare_to_resume)
(win32_require_context, thread_rec, child_add_thread)
(delete_thread_info, continue_one_thread)
(child_fetch_inferior_registers, child_store_inferior_registers)
(win32_resume, suspend_one_thread, win32_get_tib_address):
Update.
* win32-i386-low.c (update_debug_registers)
(win32_get_current_dr, i386_get_thread_context)
(i386_prepare_to_resume, i386_thread_added, i386_single_step)
(i386_fetch_inferior_register, i386_store_inferior_register):
Update.
* win32-arm-low.c (arm_get_thread_context)
(arm_fetch_inferior_register, arm_store_inferior_register):
Update.
Tom Tromey [Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)]
Remove the "next" field from windows_thread_info
This changes windows_thread_info to remove the "next" field, replacing
the linked list of threads with a vector. This is a prerequisite to
sharing this structure with gdbserver, which manages threads
differently.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (struct windows_thread_info): Remove typedef.
(thread_head): Remove.
(thread_list): New global.
(thread_rec, windows_add_thread, windows_init_thread_list)
(windows_delete_thread, windows_continue): Update.
Simon Marchi [Wed, 8 Apr 2020 18:05:54 +0000 (14:05 -0400)]
gdb: stop using host-dependent signal numbers in windows-tdep.c
The signal enumeration in windows-tdep.c is defined differently whether
it is compiled on Cygwin or not. This is problematic, since the code in
tdep files is not supposed to be influenced by the host platform (the
platform GDB itself runs on).
This makes a difference in windows_gdb_signal_to_target. An obvious
example of clash is SIGABRT. Let's pretend we are cross-debugging a
Cygwin process from a MinGW (non-Cygwin Windows) GDB. If GDB needs to
translate the gdb signal number GDB_SIGNAL_ABRT into a target
equivalent, it would obtain the MinGW number (22), despite the target
being a Cygwin process. Conversely, if debugging a MinGW process from a
Cygwin-hosted GDB, GDB_SIGNAL_ABRT would be converted to a Cygwin signal
number (6) despite the target being a MinGW process. This is wrong,
since we want the result to depend on the target's platform, not GDB's
platform.
This known flaw was accepted because at the time we had a single OS ABI
(called Cygwin) for all Windows binaries (Cygwin ones and non-Cygwin
ones). This limitation is now lifted, as we now have separate Windows
and Cygwin OS ABIs. This means we are able to detect at runtime whether
the binary we are debugging is a Cygwin one or non-Cygwin one.
This patch splits the signal enum in two, one for the MinGW flavors and
one for Cygwin, removing all the ifdefs that made it depend on the host
platform. It then makes two separate gdb_signal_to_target gdbarch
methods, that are used according to the OS ABI selected at runtime.
There is a bit of re-shuffling needed in how the gdbarch'es are
initialized, but nothing major.
gdb/ChangeLog:
* windows-tdep.h (windows_init_abi): Add comment.
(cygwin_init_abi): New declaration.
* windows-tdep.c: Split signal enumeration in two, one for
Windows and one for Cygwin.
(windows_gdb_signal_to_target): Only deal with signal of the
Windows OS ABI.
(cygwin_gdb_signal_to_target): New function.
(windows_init_abi): Rename to windows_init_abi_common, don't set
gdb_signal_to_target gdbarch method. Add new new function with
this name.
(cygwin_init_abi): New function.
* amd64-windows-tdep.c (amd64_windows_init_abi_common): Add
comment. Don't call windows_init_abi.
(amd64_windows_init_abi): Add comment, call windows_init_abi.
(amd64_cygwin_init_abi): Add comment, call cygwin_init_abi.
* i386-windows-tdep.c (i386_windows_init_abi): Rename to
i386_windows_init_abi_common, don't call windows_init_abi. Add
a new function of this name.
(i386_cygwin_init_abi): New function.
(_initialize_i386_windows_tdep): Bind i386_cygwin_init_abi to
OS ABI Cygwin.
Simon Marchi [Wed, 8 Apr 2020 12:07:33 +0000 (08:07 -0400)]
Remove objfile parameter from read_gdb_index_from_buffer
I noticed this was unused, so remove it.
gdb/ChangeLog:
* dwarf2/read.c (read_gdb_index_from_buffer): Remove objfile
parameter.c.
(dwarf2_read_gdb_index): Update.
Gunther Nikl [Wed, 8 Apr 2020 11:33:16 +0000 (12:33 +0100)]
[PATCH 1/4]: microblaze: remove duplicate prototypes
The microblaze target header duplicates prototypes already provided by tc.h.
* config/tc-microblaze.h (md_begin, md_assemble, md_undefined_symbol,
md_show_usage, md_convert_frag, md_operand, md_number_to_chars,
md_estimate_size_before_relax, md_section_align, tc_gen_reloc,
md_apply_fix3): Delete prototypes.
Gunther Nikl [Wed, 8 Apr 2020 11:28:10 +0000 (12:28 +0100)]
[PATCH 4/4]: Add generic prototype for md_pcrel_from_section
This patch removes the need for target headers to provide a custom prototype
for md_pcrel_from_section.
* tc.h (md_pcrel_from_section): Add prototype.
* config/tc-aarch64.h (md_pcrel_from_section): Remove prototype.
* config/tc-arc.h (md_pcrel_from_section): Likewise.
* config/tc-arm.h (md_pcrel_from_section): Likewise.
* config/tc-avr.h (md_pcrel_from_section): Likewise.
* config/tc-bfin.h (md_pcrel_from_section): Likewise.
* config/tc-bpf.h (md_pcrel_from_section): Likewise.
* config/tc-csky.h (md_pcrel_from_section): Likewise.
* config/tc-d10v.h (md_pcrel_from_section): Likewise.
* config/tc-d30v.h (md_pcrel_from_section): Likewise.
* config/tc-epiphany.h (md_pcrel_from_section): Likewise.
* config/tc-fr30.h (md_pcrel_from_section): Likewise.
* config/tc-frv.h (md_pcrel_from_section): Likewise.
* config/tc-iq2000.h (md_pcrel_from_section): Likewise.
* config/tc-lm32.h (md_pcrel_from_section): Likewise.
* config/tc-m32c.h (md_pcrel_from_section): Likewise.
* config/tc-m32r.h (md_pcrel_from_section): Likewise.
* config/tc-mcore.h (md_pcrel_from_section): Likewise.
* config/tc-mep.h (md_pcrel_from_section): Likewise.
* config/tc-metag.h (md_pcrel_from_section): Likewise.
* config/tc-microblaze.h (md_pcrel_from_section): Likewise.
* config/tc-mmix.h (md_pcrel_from_section): Likewise.
* config/tc-moxie.h (md_pcrel_from_section): Likewise.
* config/tc-msp430.h (md_pcrel_from_section): Likewise.
* config/tc-mt.h (md_pcrel_from_section): Likewise.
* config/tc-or1k.h (md_pcrel_from_section): Likewise.
* config/tc-ppc.h (md_pcrel_from_section): Likewise.
* config/tc-rl78.h (md_pcrel_from_section): Likewise.
* config/tc-rx.h (md_pcrel_from_section): Likewise.
* config/tc-s390.h (md_pcrel_from_section): Likewise.
* config/tc-sh.h (md_pcrel_from_section): Likewise.
* config/tc-xc16x.h (md_pcrel_from_section): Likewise.
* config/tc-xstormy16.h (md_pcrel_from_section): Likewise.
Gunther Nikl [Wed, 8 Apr 2020 10:15:28 +0000 (11:15 +0100)]
[PATCH 3/4]: m32c: remove duplicate define and prototype
The m32c target header has a duplicate entry for MD_PCREL_FROM_SECTION.
The duplication was present since the initial commit of the port.
* config/tc-m32c.h (MD_PCREL_FROM_SECTION): Delete duplicate define.
(md_pcrel_from_section): Remove duplicate prototype.
Gunther Nikl [Wed, 8 Apr 2020 10:11:43 +0000 (11:11 +0100)]
[PATCH 2/4]: moxie: use generic pcrel support
The moxie target header uses md_pcrel_from, thus the local prototype and
the macro definition for MD_PCREL_FROM_SECTION are not needed.
* config/tc-moxie.h (MD_PCREL_FROM_SECTION): Delete define.
(md_pcrel_from): Remove prototytpe.
Tom de Vries [Wed, 8 Apr 2020 10:05:34 +0000 (12:05 +0200)]
[gdb/testsuite] Fix imported-unit.exp FAIL without psymtabs
The test-case gdb.dwarf2/imported-unit.exp contains a test testing partial
symbols, so when we run the test-case using either target board readnow,
cc-with-gdb-index or cc-with-debug-names, we run into:
...
FAIL: gdb.dwarf2/imported-unit.exp: no static partial symbols in importing unit
...
Fix this by marking the test unsupported if there are no partial symbols.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-04-08 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (psymtabs_p): New proc.
* gdb.dwarf2/imported-unit.exp: Mark "no static partial symbols in
importing unit" unsupported if there are no partial symbols.
Tom de Vries [Wed, 8 Apr 2020 04:57:56 +0000 (06:57 +0200)]
[gdb/testsuite] Add gcc/94469 xfails to gdb.ada/call_pn.exp
When running test-case gdb.ada/call_pn.exp with target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects, we run into:
...
(gdb) print last_node_id^M
Multiple matches for last_node_id^M
[0] cancel^M
[1] pck.last_node_id at gdb/testsuite/gdb.ada/call_pn/pck.adb:17^M
[2] pck.last_node_id at gdb/testsuite/gdb.ada/call_pn/foo.adb:17^M
> FAIL: gdb.ada/call_pn.exp: print last_node_id after calling pn (timeout)
...
This failure is due to a gcc bug that declares two instead of one symbols,
filed as PR gcc/94469.
Add an xfail at this test. Also add a similar xfail at an earlier test, that
only triggers with -readnow. Stabilize test results by making sure the
earlier xfail is always triggered, using "maint expand-symtabs".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-04-08 Tom de Vries <tdevries@suse.de>
PR testsuite/25760
* gdb.ada/call_pn.exp: Call "maint expand-symtabs". Add xfails.