sparc can fail at inline prologue skipping. Andrew Burgess tracked
this down to sparc32_skip_prologue, which should use
skip_prologue_using_sal rather than its hand-rolled variant.
I don't have a good way to test this with the gdb test suite (is there
a board file for using qemu? That would help), but it fixes a
regression in the internal AdaCore test suite. We've had this patch
internally at AdaCore for a while, but I just now finally got around
to making sure that backing it out reintroduces the problem.
gdb/ChangeLog
2020-09-21 Tom Tromey <tromey@adacore.com>
* sparc-tdep.c (sparc32_skip_prologue): Use
skip_prologue_using_sal.
This patch corrects "size" and "bitsize" in R_RISCV_RVC_* reloc howtos
so that elfnn-riscv.c:perform_relocation doesn't access past the end
of a section. I've also corrected "size" in the R_RISCV_CALL* reloc
howtos since these relocs apply to two consecutive instructions. That
caused fallout in the assembler with complaints about "fixup not
contained within frag" due to tc-riscv.c:append_insn finishing off a
frag after the auipc insn making up a "call" macro. Which is a little
rude since the CALL reloc also relocates the following jalr. Fixed by
changing the frag handling a little.
I've also changed R_RISCV_ALIGN and R_RISCV_TPREL_ADD marker reloc
howtos to look like R_RISCV_NONE, and corrected dst_mask for numerous
relocs, not that it matters very much.
bfd/
PR 26569
* elfxx-riscv.c (howto_table): Correct size and bitsize of
R_RISCV_RVC_BRANCH, R_RISCV_RVC_JUMP, and R_RISCV_RVC_LUI.
Correct size for R_RISCV_TLS_DTPMOD32, R_RISCV_TLS_DTPREL32,
R_RISCV_CALL, and R_RISCV_CALL_PLT. Make R_RISCV_TPREL_ADD and
R_RISCV_ALIGN like R_RISCV_NONE. Correct dst_mask many relocs.
gas/
* config/tc-riscv.c (append_insn): Don't tie off frags at CALL
relocs.
(riscv_call): Tie them off after the jalr.
(md_apply_fix): Zero fx_size of RELAX fixup.
Tests that use a secondary MI channel (i.e., either tests that call
mi_gdb_start with separate-mi-tty, or all tests when
FORCE_SEPARATE_MI_TTY=1 is specified on the make check command line),
don't close GDB correctly.
E.g., if you run gdb.mi/mi-exec-run.exp in a loop:
while true; do make check TESTS="gdb.mi/mi-exec-run.exp"; done
you can see more than one gdb running at the same time:
$ ps -ef | grep -v grep | grep "gdb/gdb"
pedro 40507 1 7 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
pedro 40562 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
pedro 40727 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
pedro 40786 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
This commit fixes it.
gdb/testsuite/ChangeLog:
* lib/mi-support.exp (mi_uncatched_gdb_exit) Switch to the main
spawn_id before calling remote_close. Close secondary MI channel.
This changes generic_load to avoid bfd_map_over_sections, in favor of
iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* symfile.c (add_section_size_callback): Remove.
(load_one_section): Rename from load_section_callback. Change
parameters.
(generic_load): Use foreach.
This changes build_section_table to avoid bfd_map_over_sections, in
favor of iteration. In this situation it seemed simple to just remove
the helper function entirely.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* exec.c (add_to_section_table): Remove.
(build_section_table): Use foreach.
This changes elf_symfile_read to avoid bfd_map_over_sections, in favor
of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* elfread.c (elf_locate_sections): Change parameters.
(elf_symfile_read): Use foreach.
This changes restore_command to avoid bfd_map_over_sections, in favor
of iteration. A helper data structure can also be removed by this
patch.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* cli/cli-dump.c (struct callback_data): Remove.
(restore_one_section): Rename from restore_section_callback.
Change parameters.
(restore_binary_file): Change parameters.
(restore_command): Use foreach.
This changes gcore_memory_sections to avoid bfd_map_over_sections, in
favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* gcore.c (make_output_phdrs): Remove 'ignored' parameter.
(gcore_copy_callback): Likewise.
(gcore_memory_sections): Use foreach.
This changes some ELF osabi tag-sniffing functions to avoid
bfd_map_over_sections, in favor of iteration. I could only readily
test the generic one.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* osabi.h (generic_elf_osabi_sniff_abi_tag_sections): Update.
* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Change
parameters.
(generic_elf_osabi_sniffer): Use foreach.
* mips-sde-tdep.c (mips_sde_elf_osabi_sniffer): Use foreach.
* arm-tdep.c (arm_elf_osabi_sniffer): Use foreach.
This changes some functions in dwarf2/read.c to avoid
bfd_map_over_sections, in favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (locate_dwz_sections): Change parameters.
(dwarf2_get_dwz_file): Use foreach.
(dwarf2_locate_dwo_sections): Change parameters.
(open_and_init_dwo_file): Use foreach.
(dwarf2_locate_common_dwp_sections): Change parameters.
(open_and_init_dwp_file): Use foreach.
This changes some functions in symfile.c to avoid
bfd_map_over_sections, in favor of iteration. Some helper types can
also be removed due to this change.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* symfile.h: (find_lowest_section): Don't declare.
* symfile.c (find_lowest_section): Now static. Change
parameters.
(struct place_section_arg): Remove.
(place_section): Change parameters.
(addr_info_make_relative): Use foreach.
(symfile_dummy_outputs): Remove.
(default_symfile_relocate): Use foreach.
This changes build_objfile_section_table to avoid
bfd_map_over_sections, in favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* objfiles.c (add_to_objfile_sections): Rename from
add_to_objfile_sections_full.
(add_to_objfile_sections): Remove.
(build_objfile_section_table): Use foreach.
This changes get_stap_base_address to avoid bfd_map_over_sections, in
favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* stap-probe.c (get_stap_base_address_1): Remove.
(get_stap_base_address): Use foreach.
This changes gdb_bfd_close_or_warn to avoid bfd_map_over_sections, in
favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* gdb_bfd.c (free_one_bfd_section): Remove 'abfd' and 'ignore'
parameters.
(gdb_bfd_close_or_warn): Use foreach.
This changes core_target_open to avoid bfd_map_over_sections, in favor
of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* corelow.c (add_to_thread_list): Change parameters.
(core_target_open): Use foreach.
This adds a new overload of gdb_bfd_sections, that accepts a
gdb_bfd_ref_ptr. This also fixes the formatting of the existing
function, since I happened to notice it was mildly off.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* gdb_bfd.h (gdb_bfd_sections): New overload. Fix formatting of
existing function.
This commit makes the whitespace usage when printing Fortran arrays
more consistent, and more inline with how we print C arrays.
Currently a 2 dimensional Fotran array is printed like this, I find
the marked whitespace unpleasant:
(( 1, 2, 3) ( 4, 5, 6) )
^ ^ ^
After this commit the same array is printed like this:
((1, 2, 3) (4, 5, 6))
Which seems more inline with how we print C arrays, in the case of C
arrays we don't add extra whitespace before the first element.
gdb/ChangeLog:
* f-valprint.c (f77_print_array_1): Adjust printing of whitespace
for arrays.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Update expected results.
* gdb.fortran/class-allocatable-array.exp: Likewise.
* gdb.fortran/multi-dim.exp: Likewise.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.mi/mi-vla-fortran.exp: Likewise.
The Fortran specific OP_F77_UNDETERMINED_ARGLIST is currently handled
in the generic expression handling code. There's no reason why this
should be the case, so this commit moves handling of this into Fortran
specific files.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* eval.c: Remove 'f-lang.h' include.
(value_f90_subarray): Moved to f-lang.c.
(eval_call): Renamed to...
(evaluate_subexp_do_call): ...this, is no longer static, header
comment moved into header file.
(evaluate_funcall): Update call to eval_call.
(skip_undetermined_arglist): Moved to f-lang.c.
(fortran_value_subarray): Likewise.
(evaluate_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to evaluate_subexp_f.
(calc_f77_array_dims): Moved to f-lang.c
* expprint.c (print_subexp_funcall): New function.
(print_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to print_subexp_f, OP_FUNCALL uses new function.
(dump_subexp_body_funcall): New function.
(dump_subexp_body_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to dump_subexp_f, OP_FUNCALL uses new function.
* expression.h (evaluate_subexp_do_call): Declare.
* f-lang.c (value_f90_subarray): Moved from eval.c.
(skip_undetermined_arglist): Likewise.
(calc_f77_array_dims): Likewise.
(fortran_value_subarray): Likewise.
(evaluate_subexp_f): Add OP_F77_UNDETERMINED_ARGLIST support.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
* fortran-operator.def (OP_F77_UNDETERMINED_ARGLIST): Move
declaration of this operation to here.
* parse.c (operator_length_standard): OP_F77_UNDETERMINED_ARGLIST
support moved to operator_length_f.
* parser-defs.h (dump_subexp_body_funcall): Declare.
(print_subexp_funcall): Declare.
* std-operator.def (OP_F77_UNDETERMINED_ARGLIST): Moved to
fortran-operator.def.
This commit is a refactor of part of the Fortran array and string
handling code.
The current code is split into two blocks, linked, weirdly, with a
goto. After this commit all the code is moved to its own function,
and arrays and strings are now handled using the same code; this will
be useful later when I want to add array stride support where strings
will want to be treated just like arrays, but is a good clean up even
without the array stride work, which is why I'm merging it now.
For now the new function is added as a static within eval.c, even
though the function is Fortran only. A following commit will remove
some of the Fortran specific code from eval.c into one of the Fortran
specific files, including this new function.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* eval.c (fortran_value_subarray): New function, content is taken
from...
(evaluate_subexp_standard): ...here, in two places. Now arrays
and strings both call the new function.
(calc_f77_array_dims): Add header comment, handle strings.
With -m32 -fcf-protection, GCC generates an `endbr32` instruction at the
function entry:
[hjl@gnu-cfl-2 gdb]$ cat /tmp/x.c
int
main(void)
{
return 0;
}
[hjl@gnu-cfl-2 gdb]$ gcc -g -fcf-protection /tmp/x.c -m32
(gdb) b main
Breakpoint 1 at 0x8049176: file /tmp/x.c, line 3.
(gdb) r
Breakpoint 1, main () at /tmp/x.c:3
3 {
(gdb) disass
Dump of assembler code for function main:
=> 0x08049176 <+0>: endbr32
0x0804917a <+4>: push %ebp
0x0804917b <+5>: mov %esp,%ebp
0x0804917d <+7>: mov $0x0,%eax
0x08049182 <+12>: pop %ebp
0x08049183 <+13>: ret
End of assembler dump.
(gdb)
Update i386_analyze_prologue to skip `endbr32`:
(gdb) b main
Breakpoint 1 at 0x804917d: file /tmp/x.c, line 4.
(gdb) r
Breakpoint 1, main () at /tmp/x.c:4
4 return 0;
(gdb) disass
Dump of assembler code for function main:
0x08049176 <+0>: endbr32
0x0804917a <+4>: push %ebp
0x0804917b <+5>: mov %esp,%ebp
=> 0x0804917d <+7>: mov $0x0,%eax
0x08049182 <+12>: pop %ebp
0x08049183 <+13>: ret
End of assembler dump.
(gdb)
Tested with
$ make check RUNTESTFLAGS="--target_board='unix{-m32,}' i386-prologue-skip-cf-protection.exp"
on Fedora 32/x86-64.
2020-0X-YY Victor Collod <vcollod@nvidia.com>
gdb/ChangeLog:
PR gdb/26635
* i386-tdep.c (i386_skip_endbr): Add a helper function to skip endbr.
(i386_analyze_prologue): Call i386_skip_endbr.
gdb/testsuite/ChangeLog:
PR gdb/26635
* gdb.arch/amd64-prologue-skip-cf-protection.exp: Make the test
compatible with i386, and move it to...
* gdb.arch/i386-prologue-skip-cf-protection.exp: ... here.
* gdb.arch/amd64-prologue-skip-cf-protection.c: Move to...
* gdb.arch/i386-prologue-skip-cf-protection.c: ... here.
In this commit:
commit 6108fd1823
Date: Thu Sep 17 11:47:50 2020 -0600
Use htab_up in type copying
A use after free bug was introduced. In compile-object-run.c, in the
function compile_object_run, the code used to look like this:
htab_t copied_types;
/* .... snip .... */
/* OBJFILE may disappear while FUNC_TYPE still will be in use. */
copied_types = create_copied_types_hash (objfile);
func_type = copy_type_recursive (objfile, func_type, copied_types);
htab_delete (copied_types);
/* .... snip .... */
call_function_by_hand_dummy (func_val, NULL, args,
do_module_cleanup, data);
The copied_types table exists on the obstack of objfile, but is
deleted once the call to copy_type_recursive has been completed.
After the change the code now looks like this:
/* OBJFILE may disappear while FUNC_TYPE still will be in use. */
htab_up copied_types = create_copied_types_hash (objfile);
func_type = copy_type_recursive (objfile, func_type, copied_types.get ());
/* .... snip .... */
call_function_by_hand_dummy (func_val, NULL, args,
do_module_cleanup, data);
The copied_types is now a unique_ptr and deleted automatically when it
goes out of scope.
The problem however is that objfile, and its included obstack, may be
deleted by the call to do_module_cleanup, which is called by
call_function_by_hand_dummy.
This means that in the new code the objfile, and its obstack, are
deleted before copied_types is deleted, and as copied_types is on the
objfiles obstack, we are now reading undefined memory.
The solution in this commit is to wrap the call to
create_copied_types_hash and copy_type_recursive into a new static
helper function. The htab_up will then be deleted within the new
function's scope, before objfile is deleted.
This resolves some non-deterministic test failures I was seeing in
gdb.compile/*.exp tests.
gdb/ChangeLog:
* compile/compile-object-run.c (create_copied_type_recursive): New
function.
(compile_object_run): Use new function.
Add gas and opcodes support for two xBPF-exclusive ALU operations:
SDIV (signed division) and SMOD (signed modulo), and add tests for
them in gas.
cpu/
* bpf.cpu (insn-op-code-alu): Add SDIV and SMOD.
(define-alu-insn-bin, daib): Take ISAs as an argument.
(define-alu-instructions): Update calls to daib pmacro with
ISAs; add sdiv and smod.
gas/
* testsuite/gas/bpf/alu-xbpf.d: New file.
* testsuite/gas/bpf/alu-xbpf.s: Likewise.
* testsuite/gas/bpf/alu32-xbpf.d: Likewise.
* testsuite/gas/bpf/alu32-xbpf.d: Likewise.
* testuiste/gas/bpf/bpf.exp: Run new tests.
opcodes/
* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-opc.h: Likewise.
The m32r simulator currently always returns -1 for the register size
after both a fetch and a store. In the fetch case GDB is forgiving of
this, but in the store case GDB treats a return value of -1 as an
error.
This commit updates the m32r simulator to return a valid register size
when fetching or storing a register. This fixes any GDB test that
writes to a register, which will include any GDB test that makes an
inferior call, for example gdb.base/break.exp.
sim/m32r/ChangeLog:
* m32r.c (m32rbf_register_size): New function.
(m32rbf_fetch_register): Use new function.
(m32rbf_store_register): Likewise.
Move windows_core_xfer_shared_libraries() and windows_core_pid_to_str()
to windows-tdep, and use in amd64-windows-tdep.c to handle Cygwin x86_64
core dumps.
v2:
Keep _initialize function at the bottom of the file.
gdb/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* windows-tdep.h: Add prototypes.
* i386-windows-tdep.c(windows_core_xfer_shared_libraries): Move.
(i386_windows_core_pid_to_str): Move and rename ...
* windows-tdep.c (windows_core_xfer_shared_libraries): ... to here
(windows_core_pid_to_str): ... and here.
* amd64-windows-tdep.c (amd64_windows_init_abi_common): Register here.
Register a gregset_reg_offset array for Cygwin x86_64 core dump parsing
(this causes the generic i386_iterate_over_regset_sections() '.reg'
section iterator to get installed by i386_gdbarch_init()).
gdb/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* amd64-windows-tdep.c(amd64_windows_gregset_reg_offset): Add.
(amd64_windows_init_abi_common): ... and register.
"thread find" with multiple inferiors got broken with the multi-target
work:
Thread 1 "gdb" hit Breakpoint 1, internal_error (...) at ../../src/gdbsupport/errors.cc:51
51 {
(top-gdb) bt
#0 internal_error (file=0xffffd4d0 <error: Cannot access memory at address 0xffffd4d0>, line=0, fmt=0x555556330320 "en_US.UTF-8") at ../../src/gdbsupport/errors.cc:51
#1 0x0000555555bca4c7 in target_thread_name (info=0x555556801290) at ../../src/gdb/target.c:2035
#2 0x0000555555beb07a in thread_find_command (arg=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/thread.c:1959
#3 0x000055555572ec49 in do_const_cfunc (c=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:95
#4 0x0000555555732abd in cmd_func (cmd=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:2181
#5 0x0000555555bf1245 in execute_command (p=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/top.c:664
#6 0x00005555559cad10 in catch_command_errors (command=0x555555bf0c31 <execute_command(char const*, int)>, arg=0x7fffffffe082 "thread find 1", from_tty=0) at ../../src/gdb/main.c:457
#7 0x00005555559cc33d in captured_main_1 (context=0x7fffffffdb60) at ../../src/gdb/main.c:1218
#8 0x00005555559cc571 in captured_main (data=0x7fffffffdb60) at ../../src/gdb/main.c:1243
#9 0x00005555559cc5e8 in gdb_main (args=0x7fffffffdb60) at ../../src/gdb/main.c:1268
#10 0x0000555555623816 in main (argc=17, argv=0x7fffffffdc78) at ../../src/gdb/gdb.c:32
The problem is that we're not switching to the inferior/target before
calling target methods, which trips on an assertion put in place
exactly to catch this sort of problem.
gdb/testsuite/ChangeLog:
PR gdb/26631
* gdb.multi/multi-target-thread-find.exp: New file.
gdb/ChangeLog:
PR gdb/26631
* thread.c (thread_find_command): Switch inferior before calling
target methods.
gdb.multi/multi-target.exp sets up a debug environment with multiple
gdbservers, multiple native processes, and multiple cores, which has
proved useful for exercising a number of multi-target scenarios.
But, as we add more tests to gdb.base/multi-target.exp, it is growing
a bit too large (making a bit cumbersome to debug) and too slow to run
(if you have glibc debug info).
This commit thus splits the multi-target.exp into several testcases,
one per use case. The common setup code is moved to a new
multi-target.exp.tcl file that is included by all the resulting
multi-target testcases.
gdb/testsuite/ChangeLog:
* gdb.multi/multi-target-continue.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-info-inferiors.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-interrupt.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-no-resumed.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-ping-pong-next.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target.exp.tcl: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target.exp: Delete.
The tests in this script are driven from two lists of expected
results, one of the lists is missing some data so DejaGNU ends up
passing the empty string to gdb_test, which means the test always
passes.
This commit adds the missing expected results into the script. The
tests still pass so there's no change in the results, but we are now
actually checking GDB's behaviour.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Add missing message data.
Make the testcase work when built with a C++ compiler.
gdb/testsuite/ChangeLog:
* gdb.python/py-frame-inline.exp: Adjust to optionally expect a
full prototype.
Fixes:
src/gdb/testsuite/gdb.base/sizeof.c:54:9: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
... when the testcase is built with a C++ compiler.
gdb/testsuite/ChangeLog:
* gdb.base/sizeof.c (fill): Add cast.
Make these testcases work when compiled as C++ programs.
These testcases use the alias attribute, which requires passing in the
target function's mangled name in C++. To avoid having to figure out
how the functions are mangled, explicitly specify a linkage name.
This is preferred over 'extern "C"' because that doesn't work with
static functions.
gdb/testsuite/ChangeLog:
* gdb.base/prologue.c [__cplusplus] (marker): Explicitly specify
linkage name.
* gdb.base/prologue.exp: Use print /d.
* gdb.base/symbol-alias.exp: Handle C++ output.
* gdb.base/symbol-alias2.c: Handle C++ output.
[__cplusplus] (func): Explicitly specify linkage name.
This adjusts gdb.python/py-nested-maps.c to make it buildable as C++ program.
key_t is renamed because of:
src/gdb/testsuite/gdb.python/py-nested-maps.c:23:8: error: definition of type 'key_t' conflicts with typedef of the same name
struct key_t
^
/usr/include/x86_64-linux-gnu/sys/types.h:121:17: note: 'key_t' declared here
typedef __key_t key_t;
^
gdb/testsuite/ChangeLog:
* gdb.python/py-nested-maps.c (struct key_t): Rename to...
(struct my_key_t): ... this. Adjust all references.
(struct value_t): Rename to ...
(struct my_value_t): ... this. Adjust all references.
(create_map, add_map_element, create_map_map)
(add_map_map_element): Add casts.