When compiled on a 32-bit host, a temp var is too small for possible
64-bit values to be calculated.
* readelf.c (print_gnu_build_attribute_name): Make "bytes"
unsigned long long.
When looking at the UB errors, I noticed that cbitb_test.d disassembly
wasn't reproducing the input assembly. That turned out to be an error
in make_argument case arg_cr. This fixes that and makes some general
tidies.
opcodes/
* cr16-dis.c: Formatting.
(parameter): Delete struct typedef. Use dwordU instead
throughout file.
(make_argument <arg_idxr>): Simplify detection of cbitb, sbitb
and tbitb.
(make_argument <arg_cr>): Extract 20-bit field not 16-bit.
gas/
* testsuite/gas/cr16/cbitb_test.d: Update expected output.
* testsuite/gas/cr16/cbitw_test.d: Likewise.
* testsuite/gas/cr16/sbitb_test.d: Likewise.
* testsuite/gas/cr16/sbitw_test.d: Likewise.
* testsuite/gas/cr16/storb_test.d: Likewise.
* testsuite/gas/cr16/storw_test.d: Likewise.
* testsuite/gas/cr16/tbitb_test.d: Likewise.
* testsuite/gas/cr16/tbitw_test.d: Likewise.
Always use unsigned constants in expressions generating masks. The
following trys mightily to avoid UB (but hits it anyway with bits=32
and 0x7fffffff << 1), and worse, for 32-bit int, 64-bit long, bits=32
doesn't generate 0xffffffff.
max = ((((1 << (bits - 1)) - 1) << 1) | 1);
results in -1, or max = 0xffffffffffffffff.
This patch fixes that problem, a possible shift exponent of -1U,
removes some dead code, and makes general tidies.
PR26437
PR26438
* config/tc-cr16.c: Include limits.h, formatting.
(CR16_PRINT): Wrap params in parentheses. Remove parens from uses
throughout file.
(getconstant): Handle zero nbits.
(print_operand): Simplify handling of index regs.
(check_range): Use int32_t variables. Correct range checks.
By inspection, I noticed that print_program_space is calling
target_pid_to_str on the wrong target stack. Most targets print a
process pid the same way, so it isn't actually visible.
gdb/ChangeLog:
* progspace.c (print_program_space): Use all_inferiors. Switch to
the inferior before calling target_pid_to_str.
The tests in gdb.base/advance-until-multiple-locations.exp that expect
the program to stop at a caller fail on some systems, depending on
compiler. E.g., with Clang 10, I see:
advance ovld_func
0x00000000004011a3 in test () at /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc:51
51 ovld_func ();
(gdb) FAIL: gdb.base/advance-until-multiple-locations.exp: advance_overload: second advance stops at caller
And Tom de Vries saw:
...
(gdb) until ovld_func^M
main () at advance-until-multiple-locations.cc:61^M
61 }^M
(gdb) FAIL: gdb.base/advance-until-multiple-locations.exp:until_overload: until ovld_func
...
Which exact line the program stops is not important. All we care
about here is that the program stopped at the caller function.
So fix it by adjusting the patterns to match the frame header/function
reported by the breakpoint hits instead of the source lines text.
Tested against:
- gcc {4.8, 4.9, 7.3.1, 9.3.0, trunk-20200828}
- clang {5.0.2, 10}
gdb/testsuite/ChangeLog:
* gdb.base/advance-until-multiple-locations.exp
(advance_overload, until_overload): Adjust to match the
frame/function header instead of the source line text.
While looking at psymtabs again, I noticed a couple of outdated
comments. These days, psymtabs can be destroyed, as they are no
longer obstack-allocated.
gdb/ChangeLog
2020-08-28 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_end_psymtab): Update comment.
* dbxread.c (dbx_end_psymtab): Update comment.
parse_args uses getopt_long_only so it can handle long options both
with double and single dash. But this means that some single dash
options like -gdwarf-1 don't generate an error (unlike --gdwarf-1).
This is especially confusing since there is also --gdwarf2, but no
--gdwarf4 (it is --gdwarf-4). When giving -gdwarf4 the option is
silently interpreted as -g (which set dwarf_version to 2). This causes
some confusion for people who don't expect this and suddenly get
DWARF2 instead of DWARF4 as they might expect.
So make it so that the -gdwarf<unknown> creates an error, just like
--gdwarf<unknown> would.
__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.
This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.
Some MSP430 linker scripts do not align the __*_array start symbols, so
this added warning will catch that problem and help the user avoid
the potential incorrect execution of the program.
ld/ChangeLog:
* emultempl/msp430.em (input_section_exists): New.
(check_array_section_alignment): New.
(gld${EMULATION_NAME}_finish): New.
* scripttempl/elf32msp430.sc: Add ALIGN directives before the
definition of __*_array_start symbols.
* testsuite/ld-msp430-elf/finiarray-warn.ld: New test.
* testsuite/ld-msp430-elf/finiarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray-nowarn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray.s: New test.
* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
* testsuite/ld-msp430-elf/preinitarray-warn.ld: New test.
* testsuite/ld-msp430-elf/preinitarray-warn.r: New test.
The %pT vfinfo format prints the linker script name with a line number,
however sometimes it may be necessary to print the linker script name
without any associated line number.
ld/ChangeLog:
* ldmisc.c (vfinfo): Support new "%pU" format specifier.
Consider test-case test.c:
...
$ cat test.c
int main (void) {
return 0;
L1:
(void)0;
}
...
Compiled with debug info:
...
$ gcc test.c -g
...
When attempting to set a breakpoint at L1, which is a label without address:
...
<1><f4>: Abbrev Number: 2 (DW_TAG_subprogram)
<f5> DW_AT_name : main
<2><115>: Abbrev Number: 3 (DW_TAG_label)
<116> DW_AT_name : L1
<119> DW_AT_decl_file : 1
<11a> DW_AT_decl_line : 5
<2><11b>: Abbrev Number: 0
...
we run into an internal-error:
...
$ gdb -batch a.out -ex "b main:L1"
linespec.c:3233: internal-error: void \
decode_line_full(const event_location*, int, program_space*, symtab*, \
int, linespec_result*, const char*, const char*): \
Assertion `result.size () == 1 || canonical->pre_expanded' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...
Fix this by detecting the error condition in decode_line_full instead, and
throwing an error, such that we have instead:
...
(gdb) b main:L1
Location main:L1 not available
(gdb)
...
Unfortunately, to call event_location_to_string, which is used to get the
location name in the error message, we need to pass a non-const struct
event_location, because the call may cache the string in the struct (See
EL_STRING). So, we change the prototype of decode_line_full accordingly, and
everywhere this propages to.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-08-28 Tom de Vries <tdevries@suse.de>
PR breakpoint/26544
* breakpoint.c (parse_breakpoint_sals): Remove const from struct
event_location.
(create_breakpoint): Same.
(base_breakpoint_decode_location): Same.
(bkpt_create_sals_from_location): Same.
(bkpt_decode_location): Same.
(bkpt_probe_create_sals_from_location): Same.
(bkpt_probe_decode_location): Same.
(tracepoint_create_sals_from_location): Same.
(tracepoint_decode_location): Same.
(tracepoint_probe_decode_location): Same.
(strace_marker_create_sals_from_location): Same.
(strace_marker_decode_location): Same.
(create_sals_from_location_default): Same.
(decode_location_default): Same.
* breakpoint.h (struct breakpoint_ops): Same.
(create_breakpoint): Same.
* linespec.h (decode_line_full): Same.
* linespec.c (decode_line_full): Same. Throw error if
result.size () == 0.
gdb/testsuite/ChangeLog:
2020-08-28 Tom de Vries <tdevries@suse.de>
* gdb.base/label-without-address.c: New test.
* gdb.base/label-without-address.exp: New file.
PR19011
bfd * cofflink.c (_bfd_coff_generic_relocate_section): Provide a value
for undefined symbols which will not generate extra warning
messages about truncated relocs.
ld * testsuite/lib/ld-lib.exp (ld_link_defsyms): For PE based targets
define the __main and ___main symbols in terms of the main symbol.
Fixes new failures due to image base change.
PR 19011
* testsuite/ld-plugin/plugin.exp: Use modified CFLAGS throughout
file. Add --image-base for pecoff.
In fact, we can treate these two relocation as the same one in the
riscv_elf_check_relocs. I have heard that RISC-V lld had made this
improvement, and so had GNU AARCH64, they only need R_AARCH64_CALL26
for calls rather than two seperate relocations.
Beside, the following PLT issue for RISC-V 32-bit glibc seems to be
fixed by applying at least this patch.
<https://sourceware.org/pipermail/libc-alpha/2020-August/117214.html>
I have ran the toolchain regression, and everything seems fine for now.
bfd/
* elfnn-riscv.c (riscv_elf_check_relocs): Treat R_RISCV_CALL
and R_RISCV_CALL_PLT as the same in the riscv_elf_check_relocs.
(riscv_elf_relocate_section): Remove the R_RISCV_CALL for the
unresolved reloc checks.
ld/
testsuite/ld-riscv-elf/lib-nopic-01a.s: Use R_RISCV_JAL rather
than R_RISCV_CALL.
testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.
If you do "advance LINESPEC", and LINESPEC expands to more than one
location, GDB just errors out:
if (sals.size () != 1)
error (_("Couldn't get information on specified line."));
For example, advancing to a line in an inlined function, inlined three
times:
(gdb) b 21
Breakpoint 1 at 0x55555555516f: advance.cc:21. (3 locations)
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x000055555555516f in inline_func at advance.cc:21
1.2 y 0x000055555555517e in inline_func at advance.cc:21
1.3 y 0x000055555555518d in inline_func at advance.cc:21
(gdb) advance 21
Couldn't get information on specified line.
(gdb)
Similar issue with the "until" command, as it shares the
implementation with "advance".
Since, as the comment in gdb.base/advance.exp says, "advance <location>"
is really just syntactic sugar for "tbreak <location>;continue",
fix this by making GDB insert a breakpoint at all the resolved
locations.
A new testcase is included, which exercises both "advance" and
"until", in two different cases expanding to multiple locations:
- inlined functions
- C++ overloads
This also exercises the inline frames issue fixed by the previous
patch.
gdb/ChangeLog:
PR gdb/26524
* breakpoint.c (until_break_fsm) <location_breakpoint,
caller_breakpoint>: Delete fields.
<breakpoints>: New field.
<until_break_fsm>: Adjust to save a breakpoint vector instead of
two individual breakpoints.
(until_break_fsm::should_stop): Loop over breakpoints in the
breakpoint vector.
(until_break_fsm::clean_up): Adjust to clear the breakpoints
vector.
(until_break_command): Handle location expanding into multiple
sals.
gdb/testsuite/ChangeLog:
PR gdb/26523
PR gdb/26524
* gdb.base/advance-until-multiple-locations.cc: New.
* gdb.base/advance-until-multiple-locations.exp: New.
If you do "tbreak LINENO; c" to advance to an inlined function, GDB
presents the stop at the inline frame instead of at the non-artificial
stack frame:
(gdb) list 21
18 static inline __attribute__ ((always_inline)) int
19 inline_func (int i)
20 {
21 return i + 1;
22 }
(gdb) tbreak 21
Temporary breakpoint 3 at 0x55555555516f: advance.cc:21.
(gdb) c
Continuing.
Temporary breakpoint 3, inline_func (i=0) at advance.cc:21
21 return i + 1;
The logic for this is in stopped_by_user_bp_inline_frame:
/* Loop over the stop chain and determine if execution stopped in an
inlined frame because of a breakpoint with a user-specified
location set at FRAME_BLOCK. */
static bool
stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)
If however, you do "advance LINENO" or "until LINENO" instead, GDB
presents the stop at the non-artificial frame:
(gdb) advance 21
main () at advance.cc:43
43 i = inline_func (i);
(gdb)
"advance" and "until" should really behave like user breakpoints here,
since their location is also user-specified. As the comment in
gdb.base/advance.exp says, "advance <location>" is really just
syntactic sugar for "tbreak <location>; continue".
Fix this by making stopped_by_user_bp_inline_frame also consider
advance/until breakpoints.
A testcase covering this will be included in the next patch.
gdb/ChangeLog:
PR gdb/26523
* inline-frame.c (stopped_by_user_bp_inline_frame): Also consider
bp_until breakpoints user-specified locations. Update intro
comment.
The "X" in "MSP430X" indicates an extension to the original MSP430 ISA, but
these functions are generically used for all MSP430 ISAs, so the names should
not use the "X" suffix.
binutils/ChangeLog:
* readelf.c (get_msp430x_section_type_name): Rename to ...
(get_msp430_section_type_name): ... this.
(get_section_type_name): Use get_msp430_section_type_name.
(display_msp430x_attribute): Rename to ...
(display_msp430_attribute): ... this.
(process_arch_specific): Use display_msp430_attribute.
Use multi_line to make the expected pattern more readable.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-reg-undefined.exp: Use multi_line.
Change-Id: Ia8e42d156c0c30265121eb890e1db17a692dbaf0
Make the test names unique in gdb.arch/*.exp by either modifying the
test names or using with_test_prefix.
I have also fixed a typo 'forth' -> 'fourth' throughout gdb.arch/*.
Finally, I replaced code like this:
gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
"Breakpoint .* at .*${srcfile}.*" \
"set first breakpoint in main"
With this:
gdb_breakpoint [gdb_get_line_number "first breakpoint here"]
In those files that I was already modifying for the other reasons
given above.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-byte.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-dword.exp: Likewise.
* gdb.arch/amd64-pseudo.c: Fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-stap-special-operands.exp: Make test names
unique.
* gdb.arch/amd64-tailcall-ret.exp: Likewise.
* gdb.arch/amd64-word.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/i386-byte.exp: Make test names unique, use
gdb_breakpoint.
* gdb.arch/i386-word.exp: Likewise.
PR 26356
* som.c (som_bfd_copy_private_section_data): Issue error when a
subspace is specified without its containing space.
* testsuite/binutils-all/objcopy.exp (objcopy --reverse-bytes): Add
"-j $PRIVATE$" to command on hppa*-*-hpux*.
* testsuite/lib/utils-lib.exp (default_binutils_run): Remove existing
dollar-sign quotes before quoting. Do this prior to generating log
output.
When the tokens MCLINE, MCENDLINE, and MCCOMMENT were created, the
line number was not increased, which led to an incorrect value in
the error output.
PR 26088
* mclex.c (skip_until_eol): if eol was found, increment line number
I wanted to make a nicer / type-safe interface for
bfd_map_over_sections, avoiding the `void *` data parameter.
My first shot was to make a wrapper for bfd_map_over_sections,
gdb_bfd_map_over_sections that took a gdb::function_view.
However, I think that a range adapter gives nicer and simpler code, as a
simple for loop is easier to read than a callback / lambda function. So
here it is, it uses next_iterator and next_adapter, so it's not much
code.
As an example, I ported maintenance_info_sections and friends to use it.
The maint_print_section_data type could probably be removed now, but I
didn't want to do too much in one patch.
gdb/ChangeLog:
* gdb_bfd.h (gdb_bfd_section_iterator, gdb_bfd_section_range,
gdb_bfd_sections): New.
* maint.c (print_bfd_section_info): Change param type to
maint_print_section_data.
(print_objfile_section_info): Likewise.
(print_bfd_section_info_maybe_relocated): Likewise.
(maintenance_info_sections): Use gdb_bfd_sections.
Change-Id: Ib496f6b0a0eb7aadb10da1dd381304014d934ea0
Yes, the target is marked obsolete due to this and other segfaults,
but this one is easy enough to fix.
* elf32-arm.c (elf32_arm_final_link_relocate): Don't segfault
on sym_sec not being output.