Commit Graph

107379 Commits

Author SHA1 Message Date
John Baldwin
ad15549d51 Use gdbfmt for vprintf_filtered.
gdbfmt was already used for printf_filtered, so using it for
vprintf_filtered is more consistent.

As a result, all callers of vfprintf_maybe_filtered now use gdbfmt, so
the function can be simplified to assume the gdbfmt case and remove
the associated bool argument.  Similary, vprintf_filtered is now a
simple wrapper around vfprintf_filtered.
2021-08-30 17:23:15 -07:00
GDB Administrator
c0e5bb42c6 Automatic date update in version.in 2021-08-31 00:00:07 +00:00
John Baldwin
6fc590e1f5 fbsd-nat: Don't use '%jd' and '%ju' with printf_filtered.
The handler for 'info proc status' for native processes on FreeBSD
uses the 'j' size modifier along with uintmax_t / intmax_t casts to
output integer values for types such as off_t that are not aliases of
a basic C type such as 'int' or 'long'.  printf_filtered does not
support the 'j' modifer, so this resulted in runtime errors in
practice:

(gdb) info proc stat
process 8674
Name: ls
State: T (stopped)
Parent process: 8673
Process group: 8674
Session id: 2779
Unrecognized format specifier 'j' in printf

Instead, use plongest and pulongest to generate the output strings of
these integer values.
2021-08-30 11:08:38 -07:00
Simon Marchi
00894ecf46 gdb: fix build error in unittests/parallel-for-selftests.c
We get this error when building GDB on some platforms.  I get it using
g++-10 on Ubuntu 20.04 (installed using the distro package).  It was
also reported by John Baldwin, using a clang that uses libc++.

      CXX    unittests/parallel-for-selftests.o
    cc1plus: warning: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
    /home/smarchi/src/binutils-gdb/gdb/unittests/parallel-for-selftests.c: In function 'void selftests::parallel_for::test(int)':
    /home/smarchi/src/binutils-gdb/gdb/unittests/parallel-for-selftests.c:53:30: error: use of deleted function 'std::atomic<int>::atomic(const std::atomic<int>&)'
       53 |   std::atomic<int> counter = 0;
          |                              ^
    In file included from /usr/include/c++/9/future:42,
                     from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/thread-pool.h:29,
                     from /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/parallel-for.h:26,
                     from /home/smarchi/src/binutils-gdb/gdb/unittests/parallel-for-selftests.c:22:
    /usr/include/c++/9/atomic:755:7: note: declared here
      755 |       atomic(const atomic&) = delete;
          |       ^~~~~~
    /usr/include/c++/9/atomic:759:17: note:   after user-defined conversion: 'constexpr std::atomic<int>::atomic(std::atomic<int>::__integral_type)'
      759 |       constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
          |                 ^~~~~~

I haven't dug to know why it does not happen everywhere, but this patch
fixes it by using the constructor to initialize the variable, rather
than the assignment operator.

Change-Id: I6b27958171bf6187f6a875657395fd10441db7e6
2021-08-30 13:58:20 -04:00
Nelson Chu
685bb4e84b RISC-V: PR28291, Fix the gdb fails that PR27916 caused.
* According to PR28291, we get the following unexpected gdb behavior,

(gdb) disassemble 0x0,+4
Dump of assembler code from 0x0 to 0x4:
   0x0000000000000000:
   0x0000000000000001:
   0x0000000000000002:
   0x0000000000000003:
End of assembler dump.

* This patch should fix it to the right behavior,

(gdb) disassemble 0x0,+4
Dump of assembler code from 0x0 to 0x4:
   0x0000000000000000:  Cannot access memory at address 0x0

opcodes/
    pr 28291
    * riscv-dis.c (print_insn_riscv): Return STATUS if it is not zero.
2021-08-30 23:30:11 +08:00
Tom Tromey
282aa4f7d2 Add some parallel_for_each tests
Tom de Vries noticed that a patch in the DWARF scanner rewrite series
caused a regression in parallel_for_each -- it started crashing in the
case where the number of threads is 0 (there was an unchecked use of
"n-1" that was used to size an array).

He also pointed out that there were no tests of parallel_for_each.
This adds a few tests of parallel_for_each, primarily testing that
different settings for the number of threads will work.  This test
catches the bug that he found in that series.
2021-08-30 07:44:33 -06:00
Tom Tromey
ee8b88452c Add a show function for "maint show worker-threads"
I wanted to see how many threads gdb thought it was using, but
"maint show worker-threads" only reported "unlimited".  This patch
adds a show function so that it will now report the number of threads
gdb has started.

Regression tested on x86-64 Fedora 34.
2021-08-30 07:37:46 -06:00
Tom de Vries
f947f96797 [gdb/cli] Don't assert on empty string for core-file
With current gdb we run into:
...
$ gdb -batch '' ''
: No such file or directory.
pathstuff.cc:132: internal-error: \
  gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): \
  Assertion `path != NULL && path[0] != '\0'' failed.
...

Fix this by skipping the call to gdb_abspath in core_target_open in the
empty-string case, such that we have instead:
...
$ gdb -batch '' ''
: No such file or directory.
: No such file or directory.
$
...

Tested on x86_64-linux.

gdb/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

	PR cli/28290
	* gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the
	empty-string case.

gdb/testsuite/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

	PR cli/28290
	* gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
2021-08-30 14:34:03 +02:00
Nelson Chu
9b9b1092f0 RISC-V: PR27916, Support mapping symbols.
Similar to ARM/AARCH64, we add mapping symbols in the symbol table,
to mark the start addresses of data and instructions.  The $d means
data, and the $x means instruction.  Then the disassembler uses these
symbols to decide whether we should dump data or instruction.

Consider the mapping-04 test case,
$ cat tmp.s
  .text
  .option norelax
  .option norvc
  .fill 2, 4, 0x1001
  .byte 1
  .word 0
  .balign 8
  add a0, a0, a0
  .fill 5, 2, 0x2002
  add a1, a1, a1
  .data
  .word 0x1             # No need to add mapping symbols.
  .word 0x2

$ riscv64-unknown-elf-as tmp.s -o tmp.o
$ riscv64-unknown-elf-objdump -d tmp.o

Disassembly of section .text:

0000000000000000 <.text>:
   0:   00001001         .word   0x00001001  # Marked $d, .fill directive.
   4:   00001001         .word   0x00001001
   8:   00000001         .word   0x00000001  # .byte + part of .word.
   c:   00               .byte   0x00        # remaining .word.
   d:   00               .byte   0x00        # Marked $d, odd byte of alignment.
   e:   0001             nop                 # Marked $x, nops for alignment.
  10:   00a50533         add     a0,a0,a0
  14:   20022002         .word   0x20022002  # Marked $d, .fill directive.
  18:   20022002         .word   0x20022002
  1c:   2002             .short  0x2002
  1e:   00b585b3         add     a1,a1,a1    # Marked $x.
  22:   0001             nop                 # Section tail alignment.
  24:   00000013         nop

* Use $d and $x to mark the distribution of data and instructions.
  Alignments of code are recognized as instructions, since we usually
  fill nops for them.

* If the alignment have odd bytes, then we cannot just fill the nops
  into the spaces.  We always fill an odd byte 0x00 at the start of
  the spaces.  Therefore, add a $d mapping symbol for the odd byte,
  to tell disassembler that it isn't an instruction.  The behavior
  is same as Arm and Aarch64.

The elf/linux toolchain regressions all passed.  Besides, I also
disable the mapping symbols internally, but use the new objudmp, the
regressions passed, too.  Therefore, the new objudmp should dump
the objects corretly, even if they don't have any mapping symbols.

bfd/
	pr 27916
	* cpu-riscv.c (riscv_elf_is_mapping_symbols): Define mapping symbols.
	* cpu-riscv.h: extern riscv_elf_is_mapping_symbols.
	* elfnn-riscv.c (riscv_maybe_function_sym): Do not choose mapping
	symbols as a function name.
	(riscv_elf_is_target_special_symbol): Add mapping symbols.
binutils/
	pr 27916
	* testsuite/binutils-all/readelf.s: Updated.
	* testsuite/binutils-all/readelf.s-64: Likewise.
	* testsuite/binutils-all/readelf.s-64-unused: Likewise.
	* testsuite/binutils-all/readelf.ss: Likewise.
	* testsuite/binutils-all/readelf.ss-64: Likewise.
	* testsuite/binutils-all/readelf.ss-64-unused: Likewise.
gas/
	pr 27916
	* config/tc-riscv.c (make_mapping_symbol): Create a new mapping symbol.
	(riscv_mapping_state): Decide whether to create mapping symbol for
	frag_now.  Only add the mapping symbols to text sections.
	(riscv_add_odd_padding_symbol): Add the mapping symbols for the
	riscv_handle_align, which have odd bytes spaces.
	(riscv_check_mapping_symbols): Remove any excess mapping symbols.
	(md_assemble): Marked as MAP_INSN.
	(riscv_frag_align_code): Marked as MAP_INSN.
	(riscv_init_frag): Add mapping symbols for frag, it usually called
	by frag_var.  Marked as MAP_DATA for rs_align and rs_fill, and
	marked as MAP_INSN for rs_align_code.
	(s_riscv_insn): Marked as MAP_INSN.
	(riscv_adjust_symtab): Call riscv_check_mapping_symbols.
	* config/tc-riscv.h (md_cons_align): Defined to riscv_mapping_state
	with MAP_DATA.
	(TC_SEGMENT_INFO_TYPE): Record mapping state for each segment.
	(TC_FRAG_TYPE): Record the first and last mapping symbols for the
	fragments.  The first mapping symbol must be placed at the start
	of the fragment.
	(TC_FRAG_INIT): Defined to riscv_init_frag.
	* testsuite/gas/riscv/mapping-01.s: New testcase.
	* testsuite/gas/riscv/mapping-01a.d: Likewise.
	* testsuite/gas/riscv/mapping-01b.d: Likewise.
	* testsuite/gas/riscv/mapping-02.s: Likewise.
	* testsuite/gas/riscv/mapping-02a.d: Likewise.
	* testsuite/gas/riscv/mapping-02b.d: Likewise.
	* testsuite/gas/riscv/mapping-03.s: Likewise.
	* testsuite/gas/riscv/mapping-03a.d: Likewise.
	* testsuite/gas/riscv/mapping-03b.d: Likewise.
	* testsuite/gas/riscv/mapping-04.s: Likewise.
	* testsuite/gas/riscv/mapping-04a.d: Likewise.
	* testsuite/gas/riscv/mapping-04b.d: Likewise.
	* testsuite/gas/riscv/mapping-norelax-04a.d: Likewise.
	* testsuite/gas/riscv/mapping-norelax-04b.d: Likewise.
	* testsuite/gas/riscv/no-relax-align.d: Updated.
	* testsuite/gas/riscv/no-relax-align-2.d: Likewise.
include/
	pr 27916
	* opcode/riscv.h (enum riscv_seg_mstate): Added.

opcodes/
	pr 27916
	* riscv-dis.c (last_map_symbol, last_stop_offset, last_map_state):
	Added to dump sections with mapping symbols.
	(riscv_get_map_state): Get the mapping state from the symbol.
	(riscv_search_mapping_symbol): Check the sorted symbol table, and
	then find the suitable mapping symbol.
	(riscv_data_length): Decide which data size we should print.
	(riscv_disassemble_data): Dump the data contents.
	(print_insn_riscv): Handle the mapping symbols.
	(riscv_symbol_is_valid): Marked mapping symbols as invalid.
2021-08-30 17:36:11 +08:00
Tom de Vries
590d3faada [gdb/testsuite] Improve argument syntax of proc arange
The current syntax of proc arange is:
...
  proc arange { arange_start arange_length {comment ""} {seg_sel ""} } {
...
and a typical call looks like:
...
  arange $start $len
...

This style is somewhat annoying because if you want to specify the last
parameter, you need to give the default values of all the other optional ones
before as well:
...
  arange $start $len "" $seg_sel
...

Update the syntax to:
...
    proc arange { options arange_start arange_length } {
       parse_options {
           { comment "" }
           { seg_sel "" }
       }
...
such that a typical call looks like:
...
  arange {} $start $len
...
and a call using seg_sel looks like:
...
  arange {
    seg_sel $seg_sel
  } $start $len
...

Also update proc aranges, which already has an options argument, to use the
new proc parse_options.

Tested on x86_64-linux.

Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
2021-08-30 10:30:26 +02:00
GDB Administrator
cb03dd22b3 Automatic date update in version.in 2021-08-30 00:00:06 +00:00
GDB Administrator
6481316162 Automatic date update in version.in 2021-08-29 00:00:08 +00:00
H.J. Lu
7de7786bb7 ld: Change indirect symbol from IR to undefined
bfd/

	PR ld/28264
	* elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from
	IR to undefined.

ld/

	PR ld/28264
	* testsuite/ld-plugin/lto.exp: Run PR ld/28264 test.
	* testsuite/ld-plugin/pr28264-1.d: New file.
	* testsuite/ld-plugin/pr28264-2.d: Likewise.
	* testsuite/ld-plugin/pr28264-3.d: Likewise.
	* testsuite/ld-plugin/pr28264-4.d: Likewise.
	* testsuite/ld-plugin/pr28264.c: Likewise.
	* testsuite/ld-plugin/pr28264.ver: Likewise.
2021-08-27 19:44:57 -07:00
Alan Modra
b05929a20e PR28264, ld.bfd crash on linking efivar with LTO
PR 28264
	PR 26978
	* linker.c (_bfd_generic_link_add_one_symbol <MIND>): Check
	that string is non-NULL.
2021-08-28 10:19:09 +09:30
GDB Administrator
bfc25dcdad Automatic date update in version.in 2021-08-28 00:00:07 +00:00
Tom de Vries
34daac4b16 [gdb/symtab] Don't write .gdb_index symbol table with empty entries
When comparing the sizes of the index files generated for shlib
outputs/gdb.dwarf2/dw2-zero-range/shr1.sl, I noticed a large difference
between .debug_names:
...
$ gdb -q -batch $shlib -ex "save gdb-index -dwarf-5 ."
$ du -b -h shr1.sl.debug_names shr1.sl.debug_str
61      shr1.sl.debug_names
0       shr1.sl.debug_str
...
and .gdb_index:
...
$ gdb -q -batch $shlib -ex "save gdb-index ."
$ du -b -h shr1.sl.gdb-index
8.2K    shr1.sl.gdb-index
...

The problem is that the .gdb_index contains a non-empty symbol table with only
empty entries.

Fix this by making the symbol table empty, such that we have instead:
...
$ du -b -h shr1.sl.gdb-index
184     shr1.sl.gdb-index
...

Tested on x86_64-linux.
2021-08-27 17:14:49 +02:00
Tom de Vries
426f7bbfd4 [gdb/testsuite] Generate .debug_aranges in gdb.dlang/watch-loc.exp
Before commit 5ef670d81f "[gdb/testsuite] Add dummy start and end CUs in
dwarf assembly" we had in exec outputs/gdb.dlang/watch-loc/watch-loc a D
compilation unit at offset 0xc7:
...
  Compilation Unit @ offset 0xc7:
   Length:        0x4c (32-bit)
   Version:       4
   Abbrev Offset: 0x64
   Pointer Size:  8
 <0><d2>: Abbrev Number: 2 (DW_TAG_compile_unit)
    <d3>   DW_AT_language    : 19       (D)
...
with a corresponding .debug_aranges entry:
...
Offset into .debug_info:  0xc7
  Pointer Size:             4
  Segment Size:             0

    Address    Length
    004004a7 0000000b
    00000000 00000000
...

After that commit we have a dummy CU at offset 0xc7 and the D compilation unit
at offset 0xd2:
...
  Compilation Unit @ offset 0xc7:
   Length:        0x7 (32-bit)
   Version:       4
   Abbrev Offset: 0x64
   Pointer Size:  8
  Compilation Unit @ offset 0xd2:
   Length:        0x4c (32-bit)
   Version:       4
   Abbrev Offset: 0x65
   Pointer Size:  8
 <0><dd>: Abbrev Number: 2 (DW_TAG_compile_unit)
    <de>   DW_AT_language    : 19       (D)
...
while the .debug_aranges entry still points to 0xc7.

The problem is that the test-case uses a hack (quoting from
commit 75f06e9dc5):
...
[ Note: this is a non-trivial test-case.  The file watch-loc-dw.S contains a
.debug_info section, but not an .debug_aranges section or any actual code.
The file watch-loc.c contains code and a .debug_aranges section, but no other
debug section.  So, the intent for the .debug_aranges section in watch-loc.c
is to refer to a compilation unit in the .debug_info section in
watch-loc-dw.S. ]
...
and adding the dummy CU caused that hack to stop working.

Fix this by moving the generation of .debug_aranges from watch-loc.c to
watch-loc.exp, such that we have:
...
  Offset into .debug_info:  0xd2
  Pointer Size:             4
  Segment Size:             0

    Address    Length
    004004a7 0000000b
    00000000 00000000
...

Tested on x86_64-linux.
2021-08-27 17:10:23 +02:00
Tom de Vries
6a6429e19b [gdb/testsuite] Generate .debug_aranges entry for dummy CU
A best practise for DWARF [1] is to generate .debug_aranges entries for CUs
even if they have no address range.

Generate .debug_arange entries for the dummy CUs added by the DWARF assembler.

Tested on x86_64-linux.

[1] http://wiki.dwarfstd.org/index.php?title=Best_Practices
2021-08-27 16:52:44 +02:00
Tom de Vries
1d4a20b576 [gdb/testsuite] Add .debug_aranges in more test-cases
A couple of test-cases fail when run with target board cc-with-debug-names due
to missing .debug_aranges entries for the CUs added by the dwarf assembler.

Add a .debug_aranges entry for those CUs.

Tested on x86_64-linux.
2021-08-27 16:38:53 +02:00
Tom de Vries
9f63756509 [gdb/testsuite] Support .debug_aranges in dwarf assembly
Add a proc aranges such that we can generate .debug_aranges sections in dwarf
assembly using:
...
  cu { label cu_label } {
  ...
  }

  aranges {} cu_label {
    arange $addr $len [<comment>] [$segment_selector]
  }
...

Tested on x86_64-linux.
2021-08-27 16:38:53 +02:00
Tom de Vries
698c974ffc [gdb/testsuite] Add label option to proc cu
We can use current dwarf assembly infrastructure to declare a label that marks
the start of the CU header:
...
  declare_labels header_start_cu_a
  _section ".debug_info"
  header_start_cu_a : cu {} {
  }
  _section ".debug_info"
  header_start_cu_b : cu {} {
  }
...
on the condition that we switch to the .debug_info section before, which makes
this style of use fragile.

Another way to achieve the same is to use the label as generated by the cu
proc itself:
...
  variable _cu_label
  cu {} {
  }
  set header_start_cu_a $_cu_label
  cu {} {
  }
  set header_start_cu_b $_cu_label
...
but again that seems fragile given that adding a new CU inbetween will
silently result in the wrong value for the label.

Add a label option to proc cu such that we can simply do:
...
  cu { label header_start_cu_a } {
  }
  cu { label header_start_cu_b } {
  }
...

Tested on x86_64-linux.
2021-08-27 16:38:53 +02:00
GDB Administrator
77d63f99d6 Automatic date update in version.in 2021-08-27 00:00:08 +00:00
Andrew Burgess
89662f6901 gdb: remove some stray newlines in debug output
I spotted a couple of stray newlines that were left at the end of
debug message during conversion to the new debug output scheme.  These
messages are part of the 'set debug lin-lwp 1' output.
2021-08-26 11:29:11 +01:00
GDB Administrator
0b98060864 Automatic date update in version.in 2021-08-26 00:00:14 +00:00
GDB Administrator
f120bef247 Automatic date update in version.in 2021-08-25 00:00:08 +00:00
Tom Tromey
d58e54bd27 Fix two regressions caused by CU / TU merging
PR symtab/28160 and PR symtab/27893 concern GDB crashes in the test
suite when using the "fission" target board.  They are both caused by
the patches that merge the list of CUs with the list of TUs (and to a
lesser degree by the patches to share DWARF data across objfiles), and
the underlying issue is the same: it turns out that reading a DWO can
cause new type units to be created.  This means that the list of
dwarf2_per_cu_data objects depends on precisely which CUs have been
expanded.  However, because the type units can be created while
expanding a CU means that the vector of CUs can expand while it is
being iterated over -- a classic mistake.  Also, because a TU can be
added later, it means the resize_symtabs approach is incorrect.

This patch fixes resize_symtabs by removing it, and having set_symtab
resize the vector on demand.  It fixes the iteration problem by
introducing a safe (index-based) iterator and changing the relevant
spots to use it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28160
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27893
2021-08-24 07:51:46 -06:00
Alan Modra
5c133c1095 Real programmers don't configure gcc using --with-ld
* testsuite/lib/ld-lib.exp (run_host_cmd): Give a clue as to why
	gcc -B doesn't pick up the ld under test.
2021-08-24 20:39:29 +09:30
Alan Modra
d4f5b5e214 objdump -S test fail on mingw
FAIL: objdump -S
FAIL: objdump --source-comment
is seen on mingw for the simple reason that gcc adds a .exe suffix on
the output file if not already present.  Fix that, and tidy some objcopy
tests.

	* testsuite/lib/binutils-common.exp (exeext): New proc.
	* testsuite/binutils-all/objcopy.exp (exe, test_prog): Use it here.
	(objcopy_remove_relocations_from_executable): Catch objcopy errors.
	Only run on ELF targets.
	* testsuite/binutils-all/objdump.exp (exe): Set variable.
	(test_build_id_debuglink, test_objdump_S): Use exe file suffix.
2021-08-24 20:39:29 +09:30
James Bowman (FTDI-UK)
ee077885e5 FT32: Remove recursion in ft32_opcode
The function ft32_opcode used recursion.  This could cause a stack
overflow.  Replaced with a pair of non-recursive functions.

	PR 28169
        * ft32-dis.c: Formatting.
	(ft32_opcode1): Split out from..
	(ft32_opcode): ..here.
2021-08-24 20:39:29 +09:30
GDB Administrator
ba67587722 Automatic date update in version.in 2021-08-24 00:00:08 +00:00
Tom Tromey
d30c6bef12 Fix a latent bug in dw2-ranges-overlap.exp
dw2-ranges-overlap.exp creates a program where a psymtab has two
address ranges, and a function without debug info whose address is
between these two ranges.  Then it sets a breakpoint on this function
and runs to it, expecting that the language should remain "auto; c"
when stopped.

However, this test case also has a "main" function described (briefly)
in the DWARF, and this function is given language C++.  Also, a
breakpoint stop sets the current language to the language that was
used when setting the breakpoint.

My new DWARF scanner decides that this "main" is the main program and
sets the current language to C++ at startup, causing this test to
fail.

This patch fixes the test in a simple way, by introducing a new
function that takes the place of "main" in the DWARF.  I think this
still exercises the original problem, but also avoids problems with my
branch.

It seemed safe to me to submit this separately.
2021-08-23 14:14:20 -06:00
Tom de Vries
a9680e0e54 [gdb] Fix 'not in executable format' error message
With trying to load a non-executable file into gdb, we run into PR26880:
...
$ gdb -q -batch test.c
"0x7ffc87bfc8d0s": not in executable format: \
  file format not recognized
...

The problem is caused by using %ps in combination with the error function
(note that confusingly, it does work in combination with the warning
function).

Fix this by using plain "%s" instead.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-08-22  Tom de Vries  <tdevries@suse.de>

	PR gdb/26880
	* gdb/exec.c (exec_file_attach): Use %s instead of %ps in call to
	error function.

gdb/testsuite/ChangeLog:

2021-08-22  Tom de Vries  <tdevries@suse.de>

	PR gdb/26880
	* gdb.base/non-executable.exp: New file.
2021-08-23 12:08:25 +02:00
Tom de Vries
74cdc3e088 [gdb/testsuite] Use compiler-generated instead of gas-generated stabs
The test-case gdb.dwarf2/dw2-ranges.exp is the only one in the gdb testsuite
that uses gas-generated stabs.

While the use seems natural alongside the use of gas-generated dwarf in the
same test-case, there are a few known issues, filed on the gdb side as:
- PR symtab/12497 - "stabs: PIE relocation does not work"
- PR symtab/28221 - "[readnow, stabs] FAIL: gdb.dwarf2/dw2-ranges.exp: \
  info line func"
and on the gas side as:
- PR gas/28233 - "[gas, --gstabs] Generate stabs more similar to gcc"

The test-case contains a KFAIL for PR12497, but it's outdated and fails to
trigger.

The intention of the test-case is to test gas-generated dwarf, and using
gcc-generated stabs instead of gas-generated stabs works fine.

Supporting compiler-generated stabs is already a corner-case for gdb, and
there's no current commitment/incentive to support/workaround gas-generated
stabs, which can be considered a corner-case of a corner-case.

Work around these problem by using compiler-generated stabs in the test-case.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-08-22  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/dw2-ranges.exp: Use compiler-generated stabs.
2021-08-23 12:08:25 +02:00
Tom de Vries
5ef670d81f [gdb/testsuite] Add dummy start and end CUs in dwarf assembly
Say one compiles a hello.c:
...
$ gcc -g hello.c
...

On openSUSE Leap 15.2 and Tumbleweed, the CU for hello.c is typically not the
first in .debug_info, nor the last, due to presence of debug information in
objects for sources like:
- ../sysdeps/x86_64/start.S
- init.c
- ../sysdeps/x86_64/crti.S
- elf-init.c
- ../sysdeps/x86_64/crtn.S.

On other systems, say ubuntu 18.04.5, the CU for hello.c is typically the
first and the last in .debug_info.

This difference has caused me to find some errors in the dwarf assembly
using openSUSE, that didn't show up on other platforms.

Force the same situation on other platforms by adding a dummy start
and end CU.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-08-22  Tom de Vries  <tdevries@suse.de>

	PR testsuite/28235
	* lib/dwarf.exp (Dwarf::dummy_cu): New proc.
	(Dwarf::assemble): Add dummy start and end CU.
2021-08-23 12:08:25 +02:00
Tom de Vries
d53f8a8472 [gdb/testsuite] Fix dw2-ranges-psym.exp with -readnow
When running test-case gdb.dwarf2/dw2-ranges-psym.exp with target board
-readnow, I run into:
...
(gdb) file dw2-ranges-psym^M
Reading symbols from dw2-ranges-psym...^M
Expanding full symbols from dw2-ranges-psym...^M
(gdb) set complaints 0^M
(gdb) FAIL: gdb.dwarf2/dw2-ranges-psym.exp: No complaints
...

The problem is that the regexp expects a gdb prompt immediately after the
"Reading symbols" line.

Fix this by updating the regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-08-22  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_load_no_complaints): Update regexp to allow
	"Expanding full symbols" Line.
2021-08-23 12:08:25 +02:00
GDB Administrator
a12ea97b9d Automatic date update in version.in 2021-08-23 00:00:07 +00:00
Mike Frysinger
fe7f0b0135 sim: m32r: add __linux__ hack for non-Linux hosts
The m32r Linux syscall emulation logic assumes the host environment
directly matches -- it's being run on 32-bit little endian Linux.
This breaks building for non-Linux systems, so put all the code in
__linux__ ifdef checks.  This code needs a lot of love to make it
work everywhere, but let's at least unbreak it for non-Linux hosts.
2021-08-22 03:11:16 -04:00
GDB Administrator
ca4f6fe4fb Automatic date update in version.in 2021-08-22 00:00:07 +00:00
GDB Administrator
49e96aa482 Automatic date update in version.in 2021-08-21 00:00:07 +00:00
Mike Frysinger
082cf6944a sim: nltvals: switch output mode to a directory
In preparation for this script generating more files, change the output
argument to specify a directory.  This drops the stdout behavior, but
since no one really runs this tool directly, it's not a big deal.
2021-08-19 21:05:28 -04:00
GDB Administrator
f28b723787 Automatic date update in version.in 2021-08-20 00:00:08 +00:00
Simon Marchi
9413ea1609 gdb: use bool in notify_command_param_changed_p and do_set_command
Trivial patch to use bool instead of int.

Change-Id: I9e5f8ee4305272a6671cbaaaf2f0484eff0d1ea5
2021-08-19 14:29:30 -04:00
H.J. Lu
ca22cf5ed5 x86: Put back 3 aborts in OP_E_memory
Put back 3 aborts where invalid lengths should have been filtered out.

gas/

	PR binutils/28247
	* testsuite/gas/i386/bad-bcast.s: Add a comment.

opcodes/

	PR binutils/28247
	* * i386-dis.c (OP_E_memory): Put back 3 aborts.
2021-08-19 07:39:10 -07:00
H.J. Lu
7e40d574be x86: Avoid abort on invalid broadcast
Print "{bad}" on invalid broadcast instead of abort.

gas/

	PR binutils/28247
	* testsuite/gas/i386/bad-bcast.d: New file.
	* testsuite/gas/i386/bad-bcast.s: Likewise.
	* testsuite/gas/i386/i386.exp: Run bad-bcast.

opcodes/

	PR binutils/28247
	* i386-dis.c (OP_E_memory): Print "{bad}" on invalid broadcast
	instead of abort.
2021-08-19 07:01:20 -07:00
Aaron Merey
8ddf46454a gdb/solib: Refactor scan_dyntag
scan_dyntag is unnecessarily duplicated in solib-svr4.c and solib-dsbt.c.

Move this function to solib.c and rename it to gdb_bfd_scan_elf_dyntag.
Also add it to solib.h so it is included in both solib-svr4 and solib-dsbt.
2021-08-18 22:24:18 -04:00
GDB Administrator
76bed1fdbd Automatic date update in version.in 2021-08-19 00:00:35 +00:00
Will Schmidt
533f04079c [gdb] [rs6000] Add ppc64_linux_gcc_target_options method.
Add a method to set the gcc target options for the ppc64 targets.
This change sets an empty value, which allows the gcc
default values (-mcmodel=medium) be used, instead of -mcmodel=large
which is set by the default_gcc_target_options hook.
2021-08-18 11:45:49 -05:00
Will Schmidt
bc0df0fa47 [gdb] [rs6000] Add ppc64*_gnu_triplet_regexp methods.
Add methods to set the target triplet so we can
find the proper gcc when our gcc is named of
the form powerpc64{le}-<foo>-gcc or ppc64{le}-<foo>-gcc.
2021-08-18 11:43:45 -05:00
Alan Modra
a86733d63d Re: as: Replace the removed symbol with the versioned symbol
Some targets, typically embedded without shared libraries, replace the
relocation symbol with a section symbol (see tc_fix_adjustable).
Allow the test to pass for such targets.  Fixes the following.

avr-elf  +FAIL: symver symver16
d10v-elf  +FAIL: symver symver16
dlx-elf  +FAIL: symver symver16
ip2k-elf  +FAIL: symver symver16
m68k-elf  +FAIL: symver symver16
mcore-elf  +FAIL: symver symver16
pj-elf  +FAIL: symver symver16
s12z-elf  +FAIL: symver symver16
visium-elf  +FAIL: symver symver16
z80-elf  +FAIL: symver symver16

	PR gas/28157
	* testsuite/gas/symver/symver16.d: Relax reloc match.
2021-08-18 13:36:57 +09:30
Alan Modra
89c905a342 [GOLD] PowerPC64 relocation overflow for -Os register save/restore funcs
Fixes a silly mistake in calculating the address of -Os out-of-line
register save/restore function copies.  Copies of these linker defined
functions are added to stub sections when the original (in
target->savres_section) can't be reached.

	* powerpc.cc (Target_powerpc::Relocate::relocate): Correct address
	calculation of out-of-line save/restore function copies.
2021-08-18 13:36:57 +09:30