aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-03-28PR24390, Don't decode mtfsb field as a cr fieldAlan Modra8-15/+43
"mtfsb0 4*cr7+lt" doesn't make all that much sense, but unfortunately glibc uses just that instead of "mtfsb0 28" to clear the fpscr xe bit. So for backwards compatibility accept cr field expressions when assembling mtfsb operands, but disassemble to a plain number. PR 24390 include/ * opcode/ppc.h (PPC_OPERAND_CR_REG): Comment. opcodes/ * ppc-opc.c (BTF): Define. (powerpc_opcodes): Use for mtfsb*. * ppc-dis.c (print_insn_powerpc): Print fields with both PPC_OPERAND_CR_REG and PPC_OPERAND_CR_BIT as a plain number. gas/ * testsuite/gas/ppc/476.d: Update mtfsb*. * testsuite/gas/ppc/a2.d: Likewise.
2019-03-28Automatic date update in version.inGDB Administrator1-1/+1
2019-03-28sim/common: Fix warnings: "warning: implicit declaration of function..."Stafford Horne7-0/+28
During building of several cgen simulator's I notices the below warnings. Adding includes fixes these. Including config.h allows stdio.h to properly configure itself to expose asprintf(). The other warnings for abort, free, memset, strlen are trivial. Warnings: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c: In function ‘sim_watchpoint_install’: ../../../binutils-gdb/sim/or1k/../common/sim-watch.c:415:10: warning: implicit declaration of function ‘asprintf’; did you mean ‘vasprintf’? [-Wimplicit-function-declaration] if (asprintf (&name, "watch-%s-%s", ^~~~~~~~ vasprintf ../../../binutils-gdb/sim/lm32/../common/hw-device.c: In function ‘hw_strdup’: ../../../binutils-gdb/sim/lm32/../common/hw-device.c:59:34: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration] char *dup = hw_zalloc (me, strlen (str) + 1); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-events.c: In function ‘hw_event_queue_schedule’: ../../../binutils-gdb/sim/lm32/../common/hw-events.c:92:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] memset (&dummy, 0, sizeof dummy); ^~~~~~ ../../../binutils-gdb/sim/lm32/../common/hw-handles.c: In function ‘hw_handle_remove_ihandle’: ../../../binutils-gdb/sim/lm32/../common/hw-handles.c:211:4: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration] free (delete); ^~~~ ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c: In function ‘pack_fpu’: ../../../binutils-gdb/sim/lm32/../common/sim-fpu.c:292:7: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration] abort (); ^~~~~ sim/common/ChangeLog: * sim-options.c: Include "config.h". Include <stdio.h>. * sim-watch.c: Include "config.h". Include <stdio.h>. * hw-device.c: Include <string.h>. * hw-events.c: Include <string.h>. * hw-handles.c: Include <stdlib.h>. * sim-fpu.c: Include <stdlib.h>.
2019-03-28sim/common: convert sim-arange to use sim-inlineStafford Horne8-36/+83
This fixes a TODO item and also fixes an error which we get when building with no optimizations (-O0) in at least gcc 8.2.1. Tested with sims that use cgen code lm32, or1k, cris, m32r and inlining is working corretly. Reference Error: gcc -DHAVE_CONFIG_H -DWITH_DEFAULT_MODEL='"or1200"' -DWITH_ALIGNMENT=STRICT_ALIGNMENT \ -DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31 -DWITH_TARGET_ADDRESS_BITSIZE=32 \ -DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG -DDEFAULT_INLINE=0 -DWITH_SCACHE=16384 \ -I. -I../../../binutils-gdb/sim/or1k -I../common -I../../../binutils-gdb/sim/or1k/../common \ -I../../include -I../../../binutils-gdb/sim/or1k/../../include -I../../bfd \ -I../../../binutils-gdb/sim/or1k/../../bfd -I../../opcodes -I../../../binutils-gdb/sim/or1k/../../opcodes \ -g -o run nrun.o libsim.a ../../bfd/libbfd.a ../../opcodes/libopcodes.a ../../libiberty/libiberty.a \ -ldl -lz -lm /usr/bin/ld: libsim.a(mloop.o): in function `extract': /home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:82: undefined reference to `sim_addr_range_hit_p' /usr/bin/ld: /home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:83: undefined reference to `sim_addr_range_hit_p' collect2: error: ld returned 1 exit status make[3]: *** [Makefile:305: run] Error 1 sim/common/ChangeLog: * Make-common.in (sim-arange_h): Remove sim-arange.c * sim-arange.c: Remove SIM_ARANGE_C. Add ifdef for _SIM_ARANGE_C_. Include "sim-arange.h". Remove include for unused "sim-assert.h". Remove DEFINE_INLINE_P. Remove DEFINE_NON_INLINE_P. (sim_addr_range_add): Declare as INLINE_SIM_ARANGE. (sim_addr_range_delete): Declare as INLINE_SIM_ARANGE. (sim_addr_range_hit_p): Change from SIM_ARANGE_INLINE to INLINE_SIM_ARANGE. * sim-arange.h (sim_addr_range_add): Declare as INLINE_SIM_ARANGE. (sim_addr_range_delete): Declare as INLINE_SIM_ARANGE. (sim_addr_range_hit_p) Declare as INLINE_SIM_ARANGE. Remove definition of SIM_ARANGE_INLINE. Remove [HAVE_INLINE]. Wrap include "sim-arange.c" in H_REVEALS_MODULE_P. * sim-base.h: Include "sim-arange.h" * sim-basics.h: Remove include of "sim-arange.h" * sim-inline.c: Include "sim-arange.c" * sim-inline.h: Define INLINE_SIM_ARANGE. Define SIM_ARANGE_INLINE. Define EXTERN_SIM_ARANGE_P. Define STATIC_INLINE_SIM_ARANGE. Define STATIC_SIM_ARANGE.
2019-03-27Fix buffer overflow regression due to minsym malloc-ed instead of obstack-ed.Philippe Waroquiers2-8/+15
Valgrind detects the following error in a bunch of tests, e.g. in gdb.base/foll-fork.exp. ==15155== VALGRIND_GDB_ERROR_BEGIN ==15155== Invalid read of size 8 ==15155== at 0x55BE04: minimal_symbol_upper_bound(bound_minimal_symbol) (minsyms.c:1504) ==15155== by 0x3B2E9C: find_pc_partial_function(unsigned long, char const**, unsigned long*, unsigned long*, block const**) (blockframe.c:340) ==15155== by 0x3B3135: find_function_entry_range_from_pc(unsigned long, char const**, unsigned long*, unsigned long*) (blockframe.c:385) ==15155== by 0x4F5597: fill_in_stop_func(gdbarch*, execution_control_state*) [clone .part.16] (infrun.c:4124) ==15155== by 0x4FBE01: fill_in_stop_func (infrun.c:7636) ==15155== by 0x4FBE01: process_event_stop_test(execution_control_state*) (infrun.c:6279) ... ==15155== Address 0x715bec8 is 0 bytes after a block of size 2,952 alloc'd ==15155== at 0x4C2E2B3: realloc (vg_replace_malloc.c:836) ==15155== by 0x405F2C: xrealloc (common-utils.c:62) ==15155== by 0x55BA4E: xresizevec<minimal_symbol> (poison.h:170) ==15155== by 0x55BA4E: minimal_symbol_reader::install() (minsyms.c:1399) ==15155== by 0x4981C7: elf_read_minimal_symbols (elfread.c:1165) ... This seems to be a regression created by: commit 042d75e42c5572f333e0e06dabd3c5c4afab486c Author: Tom Tromey <tom@tromey.com> AuthorDate: Sat Mar 2 12:29:48 2019 -0700 Commit: Tom Tromey <tom@tromey.com> CommitDate: Fri Mar 15 16:02:10 2019 -0600 Allocate minimal symbols with malloc Before this commit, the array of 'struct minimal_symbol' contained a last element that was a "null symbol". The comment in minimal_symbol_reader::install was: /* We also terminate the minimal symbol table with a "null symbol", which is *not* included in the size of the table. This makes it easier to find the end of the table when we are handed a pointer to some symbol in the middle of it. Zero out the fields in the "null symbol" allocated at the end of the array. Note that the symbol count does *not* include this null symbol, which is why it is indexed by mcount and not mcount-1. */ memset (&msymbols[mcount], 0, sizeof (struct minimal_symbol)); However, minimal_symbol_upper_bound was still based on the assumption that the array of minsym is terminated by a minsym with a null symbol: it is looping with: for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++) Replace this NULL comparison by a logic that calculates how many msymbol are following the msymbols from which we are starting from. (Re-)tested on debian/amd64, natively and under valgrind. gdb/ChangeLog 2019-03-24 Philippe Waroquiers <philippe.waroquiers@skynet.be> Tom Tromey <tromey@adacore.com> * minsyms.c (minimal_symbol_upper_bound): Fix buffer overflow.
2019-03-27Testsuite: Ensure interrupt-daemon-attach doesn't run foreverAlan Hayward2-2/+14
Looking at the AArch64 buildbot, I noticed about two dozen old instances of interrupt-daemon-attach taking up a full 100% cpu each. If the test fails then the test binary relies on an alarm to ensure it dies after 60 seconds. As per the Linux man page for alarm: Alarms created by alarm() ... are not inherited by children created via fork. Update the test to add an alarm in the child and also put a sleep in the child loop so it does not constantly consume cpu. Note I haven't managed to re-create why the test failed. This fix will just stop it hanging and consuming cpu when it does. gdb/testsuite/ChangeLog: * gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep in child.
2019-03-27Automatic date update in version.inGDB Administrator1-1/+1
2019-03-26gdb-gdb.py.in: Fix error when printing range typeJoel Brobecker2-7/+28
I noticed that trying to print the contents of a struct main_type would fail when the type was a TYPE_CODE_RANGE: (gdb) p *type.main_type $1 = Python Exception <class 'gdb.error'> There is no member named low_undefined.: And indeed, Python is right, fields "low_undefined" has been removed from struct range_bounds back in ... 2014! It was done when we introduced dynamic bounds handling. This patch fixes gdb-gdb.py.in according to the new structure. gdb/ChangeLog: * gdb-gdb.py.in (StructMainTypePrettyPrinter.bound_img): New method. (StructMainTypePrettyPrinter.bounds_img): Use new "bound_img" method to compute the bounds of range types. Also print "[evaluated]" if the bounds' values come from a dynamic evaluation.
2019-03-26gdb: Make python display_hint None handling defined behaviourAndrew Burgess6-2/+40
The documentation say that the display_hint method must return a string to serve as a display hint, and then goes on to list some acceptable strings. However, if we don't supply the display_hint method then we get a default display style behaviour and there's currently no way (in the python api) to force this default behaviour. The guile api allows #f to be used in order to force the default display style behaviour, and this is documented. Currently, using None in the python api also forces the default display behaviour. This commit extends the documentation to make returning None from the display_hint method an official mechanism by which the user can get the default display style. I've extended one of the existing tests to cover this case. gdb/doc/ChangeLog: * python.texi (Pretty Printing API): Document use of None for the display_hint. gdb/testsuite/ChangeLog: * gdb.python/py-prettyprint.c (struct container) <is_map_p>: New field. (make_container): Initialise new field. * gdb.python/py-prettyprint.exp: Add new tests. * gdb.python/py-prettyprint.py (class ContainerPrinter) <display_hint>: New method.
2019-03-26gdb/testsuite: Make test names unique in gdb.python/py-prettyprint.expAndrew Burgess2-12/+21
This makes the test names unique in gdb.python/py-prettyprint.exp, it also switches to use gdb_breakpoint and gdb_continue_to_breakpoint more so that we avoid test names with the source line number in - this is bad if the test source ever changes as the test names will then change. One final change is to switch from using gdb_py_test_silent_cmd to use gdb_test_no_output, the former should be used for running python commands and can catch any thrown exception. However, in this case the command being run is not a python command, its just a normal GDB CLI command that produces no output, so lets use the appropriate wrapper function. gdb/testsuite/ChangeLog: * gdb.python/py-prettyprint.exp: Use gdb_breakpoint and gdb_continue_to_breakpoint more throughout this test. (run_lang_tests) Supply unique test names, and use gdb_test_no_output.
2019-03-26gdb: Avoid trailing whitespace when pretty printingAndrew Burgess6-3/+129
While writing a new test for 'set print pretty on' I spotted that GDB will sometimes add a trailing whitespace character when pretty printing. This commit removes the trailing whitespace and updates the expected results in one tests where this was an issue. I've added an extra test for 'set print pretty on' as it doesn't seem to have much testing. gdb/ChangeLog: * cp-valprint.c (cp_print_value_fields): Don't print trailing whitespace when pretty printing is on. gdb/testsuite/ChangeLog: * gdb.base/finish-pretty.exp: Update expected results. * gdb.base/pretty-print.c: New file. * gdb.base/pretty-print.exp: New file.
2019-03-26Fix Powerpc buildAlan Hayward2-0/+5
gdb/ChangeLog: * ppc-linux-nat.c: Add include.
2019-03-26Add AArch64 Pointer Authentication to the NEWS fileAlan Hayward2-0/+6
gdb/ChangeLog: * NEWS: Mention AArch64 Pointer Authentication.
2019-03-26AArch64/Arm: Update testcases fixing endiannes and linux targetsTamar Christina11-146/+145
This fixes the testcases that are failing due to my recent patch. It turns out that the start address across baremetal and linux builds isn't entirely predictable without a linker script. Since the address themselves are not the important thing I am ignoring them now. Secondly I was encoding data using .word using non 0 values, however because .word is subjected to endiannes these non-zero values under big-endian happen to fall into the encoding space of instructions which changes the disassembly. Using 0 fixes this problem and the purpose of the test still holds, though objdump will dump ... for data only sections, which is ok as the data/insn mixed sections will test the patch. The ARM Attributes sections is not important and is ignored. binutils/ChangeLog: * testsuite/binutils-all/aarch64/in-order.d: Likewise. * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise. * testsuite/binutils-all/aarch64/out-of-order.d: Likewise. * testsuite/binutils-all/aarch64/out-of-order.s: Likewise. * testsuite/binutils-all/arm/in-order-all.d: Likewise. * testsuite/binutils-all/arm/in-order.d: Likewise. * testsuite/binutils-all/arm/out-of-order-all.d: Likewise. * testsuite/binutils-all/arm/out-of-order.d: Likewise. * testsuite/binutils-all/arm/out-of-order.s: Likewise.
2019-03-26gdbserver: Add linux_get_hwcapAlan Hayward7-122/+79
In gdbserver, Tidy up calls to read HWCAP (and HWCAP2) by adding common functions, removing the Arm, AArch64, PPC and S390 specific versions. No functionality differences. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_get_hwcap): Remove function. (aarch64_arch_setup): Call linux_get_hwcap. * linux-arm-low.c (arm_get_hwcap): Remove function. (arm_read_description): Call linux_get_hwcap. * linux-low.c (linux_get_auxv): New function. (linux_get_hwcap): Likewise. (linux_get_hwcap2): Likewise. * linux-low.h (linux_get_hwcap): New declaration. (linux_get_hwcap2): Likewise. * linux-ppc-low.c (ppc_get_auxv): Remove function. (ppc_arch_setup): Call linux_get_hwcap. * linux-s390-low.c (s390_get_hwcap): Remove function. (s390_arch_setup): Call linux_get_hwcap.
2019-03-26Provide string description of definition, visibility and resolution in LTO ↵marxin3-6/+81
plug-in. ld/ChangeLog: 2019-02-26 Martin Liska <mliska@suse.cz> * plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str, lto_visibility_str and use then to inform about plugin-symbols. * testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
2019-03-26Take over Dave Brolley's maintainerships for FR30, FRV and MEP.Nick Clifton2-3/+8
* MAINTAINERS: Take over Dave Brolley's maintainerships for FR30, FRV and MEP.
2019-03-26Fix Arm buildAlan Hayward2-0/+5
Add missing include. 2019-03-26 Alan Hayward <alan.hayward@arm.com> * arm-linux-nat.c: Add include.
2019-03-25Fix use-after-free in source_cache::get_source_linesSimon Marchi2-0/+11
Commit ab42892fb7d2 ("Fix vertical scrolling of TUI source window") introduced a use-after-free in source_cache::get_source_lines. At the beginning of the method, we get the fullname of the symtab: const char *fullname = symtab_to_fullname (s); fullname points to the string owned by the symtab (s.fullname). When we later do scoped_fd desc = open_source_file (s); s.fullname gets reallocated (even though the string contents may not change). The fullname local variable now points to freed memory. To avoid it, refresh the value of fullname after calling open_source_file. Here is the ASan report: $ ./gdb -nx --data-directory=data-directory ./a.out (gdb) start Temporary breakpoint 1 at 0x1130: file test.cpp, line 12. Starting program: /home/simark/build/binutils-gdb/gdb/a.out Temporary breakpoint 1, main () at test.cpp:12 ================================================================= ==26068==ERROR: AddressSanitizer: heap-use-after-free on address 0x6210003d4100 at pc 0x7fed89a34681 bp 0x7ffd8d185d80 sp 0x7ffd8d185528 READ of size 2 at 0x6210003d4100 thread T0 #0 0x7fed89a34680 in __interceptor_strlen /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:301 #1 0x55b6edf6c2f7 in std::char_traits<char>::length(char const*) /usr/include/c++/8.2.1/bits/char_traits.h:320 #2 0x55b6edf6c9b2 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) /usr/include/c++/8.2.1/bits/basic_string.h:516 #3 0x55b6ef09121b in source_cache::get_source_lines(symtab*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) /home/simark/src/binutils-gdb/gdb/source-cache.c:214 #4 0x55b6ef0a15cb in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1340 #5 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415 #6 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914 #7 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180 #8 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853 #9 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870 #10 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98 #11 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297 #12 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687 #13 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106 #14 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142 #15 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782 #16 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43 #17 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358 #18 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733 #19 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859 #20 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322 #21 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371 #22 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331 #23 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174 #24 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190 #25 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #26 0x7fed88ad8222 in __libc_start_main (/usr/lib/libc.so.6+0x24222) #27 0x55b6edf4f86d in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x197186d) 0x6210003d4100 is located 0 bytes inside of 4096-byte region [0x6210003d4100,0x6210003d5100) freed by thread T0 here: #0 0x7fed89a8ac19 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66 #1 0x55b6edfe12df in xfree<char> /home/simark/src/binutils-gdb/gdb/common/common-utils.h:60 #2 0x55b6edfea675 in gdb::xfree_deleter<char>::operator()(char*) const /home/simark/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:34 #3 0x55b6edfe532c in std::unique_ptr<char, gdb::xfree_deleter<char> >::reset(char*) /usr/include/c++/8.2.1/bits/unique_ptr.h:382 #4 0x55b6edfe7329 in std::unique_ptr<char, gdb::xfree_deleter<char> >::operator=(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /usr/include/c++/8.2.1/bits/unique_ptr.h:289 #5 0x55b6ef09ec2b in find_and_open_source(char const*, char const*, std::unique_ptr<char, gdb::xfree_deleter<char> >*) /home/simark/src/binutils-gdb/gdb/source.c:990 #6 0x55b6ef09f56a in open_source_file(symtab*) /home/simark/src/binutils-gdb/gdb/source.c:1069 #7 0x55b6ef090f78 in source_cache::get_source_lines(symtab*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) /home/simark/src/binutils-gdb/gdb/source-cache.c:205 #8 0x55b6ef0a15cb in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1340 #9 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415 #10 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914 #11 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180 #12 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853 #13 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870 #14 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98 #15 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297 #16 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687 #17 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106 #18 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142 #19 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782 #20 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43 #21 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358 #22 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733 #23 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859 #24 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322 #25 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371 #26 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331 #27 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174 #28 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190 #29 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 previously allocated by thread T0 here: #0 0x7fed89a8b019 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86 #1 0x7fed88af983f in realpath@@GLIBC_2.3 (/usr/lib/libc.so.6+0x4583f) #2 0x7fed899dbbbc in __interceptor_canonicalize_file_name /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3297 #3 0x55b6ee376a03 in gdb_realpath(char const*) /home/simark/src/binutils-gdb/gdb/common/pathstuff.c:72 #4 0x55b6ef09ec12 in find_and_open_source(char const*, char const*, std::unique_ptr<char, gdb::xfree_deleter<char> >*) /home/simark/src/binutils-gdb/gdb/source.c:990 #5 0x55b6ef09f56a in open_source_file(symtab*) /home/simark/src/binutils-gdb/gdb/source.c:1069 #6 0x55b6ef0a0f12 in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1270 #7 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415 #8 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914 #9 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180 #10 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853 #11 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870 #12 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98 #13 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297 #14 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687 #15 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106 #16 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142 #17 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782 #18 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43 #19 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358 #20 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733 #21 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859 #22 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322 #23 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371 #24 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331 #25 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174 #26 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190 #27 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #28 0x7fed88ad8222 in __libc_start_main (/usr/lib/libc.so.6+0x24222) gdb/ChangeLog: * source-cache.c (source_cache::get_source_lines): Re-read fullname after calling open_source_file.
2019-03-26Automatic date update in version.inGDB Administrator1-1/+1
2019-03-26Fix relpp may be used uninitializedAlan Modra2-1/+5
* objdump.c (dump_relocs_in_section): Warning fix.
2019-03-25Note support for TLS variables on FreeBSD.John Baldwin2-0/+9
gdb/ChangeLog: * NEWS: Mention TLS support for FreeBSD.
2019-03-25Clean up some comments in minsyms.cTom Tromey2-42/+15
Philippe pointed out that some comments in minsyms.c still referred to obstack allocation. This patch fixes these up. In most cases here, my view is that the comments were more misleading than helpful. So, I've generally removed text. gdb/ChangeLog 2019-03-25 Tom Tromey <tromey@adacore.com> * minsyms.c (BUNCH_SIZE): Update comment. (~minimal_symbol_reader): Remove old comment. (compact_minimal_symbols): Update comment. (minimal_symbol_reader::install): Remove old comment. Update other comments.
2019-03-25Fix s390 buildAlan Hayward2-0/+5
Add missing include. 2019-03-25 Alan Hayward <alan.hayward@arm.com> * s390-linux-nat.c: Add include.
2019-03-25Add linux_get_hwcapAlan Hayward12-71/+75
Tidy up calls to read HWCAP (and HWCAP2) by adding common functions, removing the PPC and AArch64 specific versions. The only function difference is in aarch64_linux_core_read_description - if the hwcap read fails it now return a valid description instead of nullptr. gdb/ChangeLog: 2019-03-25 Alan Hayward <alan.hayward@arm.com> * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Call linux_get_hwcap. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. (aarch64_linux_get_hwcap): Remove function. * aarch64-linux-tdep.h (aarch64_linux_get_hwcap): Remove declaration. * arm-linux-nat.c (arm_linux_nat_target::read_description):Call linux_get_hwcap. * arm-linux-tdep.c (arm_linux_core_read_description): Likewise. * linux-tdep.c (linux_get_hwcap): Add function. (linux_get_hwcap2): Likewise. * linux-tdep.h (linux_get_hwcap): Add declaration. (linux_get_hwcap2): Likewise. * ppc-linux-nat.c (ppc_linux_get_hwcap): Remove function. (ppc_linux_get_hwcap2): Likewise. (ppc_linux_nat_target::region_ok_for_hw_watchpoint): Call linux_get_hwcap. (ppc_linux_nat_target::insert_watchpoint): Likewise. (ppc_linux_nat_target::watchpoint_addr_within_range): Likewise. (ppc_linux_nat_target::read_description): Likewise. * ppc-linux-tdep.c (ppc_linux_core_read_description): Likewise. * s390-linux-nat.c: Likewise. * s390-linux-tdep.c (s390_core_read_description): Likewise.
2019-03-25Arm: Fix Arm disassembler mapping symbol search.Tamar Christina13-151/+339
Similar to the AArch64 patches the Arm disassembler has the same issues with out of order sections but also a few short comings. For one thing there are multiple code blocks to determine mapping symbols, and they all work slightly different, and neither fully correct. The first thing this patch does is centralise the mapping symbols search into one function mapping_symbol_for_insn. This function is then updated to perform a search in a similar way as AArch64. Their used to be a value has_mapping_symbols which was used to determine the default disassembly for objects that have no mapping symbols. The problem with the approach was that it was determining this value in the same loop that needed it, which is why this field could take on the states -1, 0, 1 where -1 means "don't know". However this means that until you actually find a mapping symbol or reach the end of the disassembly glob, you don't know if you did the right action or not, and if you didn't you can't correct it anymore. This is why the two jump-reloc-veneers-* testcases end up disassembling some insn as data when they shouldn't. Out of order here refers to an object file where sections are not listed in a monotonic increasing VMA order. The ELF ABI for Arm [1] specifies the following for mapping symbols: 1) A text section must always have a corresponding mapping symbol at it's start. 2) Data sections do not require any mapping symbols. 3) The range of a mapping symbol extends from the address it starts on up to the next mapping symbol (exclusive) or section end (inclusive). However there is no defined order between a symbol and it's corresponding mapping symbol in the symbol table. This means that while in general we look up for a corresponding mapping symbol, we have to make at least one check of the symbol below the address being disassembled. When disassembling different PCs within the same section, the search for mapping symbol can be cached somewhat. We know that the mapping symbol corresponding to the current PC is either the previous one used, or one at the same address as the current PC. However this optimization and mapping symbol search must stop as soon as we reach the end or start of the section. Furthermore if we're only disassembling a part of a section, the search is a allowed to search further than the current chunk, but is not allowed to search past it (The mapping symbol if there, must be at the same address, so in practice we usually stop at PC+4). lastly, since only data sections don't require a mapping symbol the default mapping type should be DATA and not INSN as previously defined, however if the binary has had all its symbols stripped than this isn't very useful. To fix this we determine the default based on the section flags. This will allow the disassembler to be more useful on stripped binaries. If there is no section than we assume you to be disassembling INSN. [1] https://developer.arm.com/docs/ihi0044/latest/elf-for-the-arm-architecture-abi-2018q4-documentation#aaelf32-table4-7 binutils/ChangeLog: * testsuite/binutils-all/arm/in-order-all.d: New test. * testsuite/binutils-all/arm/in-order.d: New test. * testsuite/binutils-all/arm/objdump.exp: Support .d tests. * testsuite/binutils-all/arm/out-of-order-all.d: New test. * testsuite/binutils-all/arm/out-of-order.T: New test. * testsuite/binutils-all/arm/out-of-order.d: New test. * testsuite/binutils-all/arm/out-of-order.s: New test. ld/ChangeLog: * testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly. * testsuite/ld-arm/jump-reloc-veneers-long.d: Update disassembly. opcodes/ChangeLog: * arm-dis.c (struct arm_private_data): Remove has_mapping_symbols. (mapping_symbol_for_insn): Implement new algorithm. (print_insn): Remove duplicate code.
2019-03-25AArch64: Have -D override mapping symbol as documented.Tamar Christina6-17/+100
The documentation for -D says that on Arm platforms -D should disassemble data as instructions. "If the target is an ARM architecture this switch also has the effect of forcing the disassembler to decode pieces of data found in code sections as if they were instructions. " This makes it do as it says on the tincan so it's more consistent with aarch32. The usecase here is for baremetal developers who have created their instructions using .word directives instead if .insn. Though for Linux users I do find this behavior somewhat non-optimal. Perhaps there should be a new flag that just disassembles the values following the actual mapping symbol? binutils/ChangeLog: * testsuite/binutils-all/aarch64/in-order-all.d: New test. * testsuite/binutils-all/aarch64/out-of-order-all.d: New test. * testsuite/binutils-all/aarch64/out-of-order.d: opcodes/ChangeLog: * aarch64-dis.c (print_insn_aarch64): Implement override.
2019-03-25AArch64: Fix AArch64 disassembler mapping symbol searchTamar Christina5-7/+93
My previous patch for AArch64 was not enough to catch all the cases where disassembling an out-of-order section could go wrong. It had missed the case DATA sections could be incorrectly disassembled as TEXT. Out of order here refers to an object file where sections are not listed in a monotonic increasing VMA order. The ELF ABI for AArch64 [1] specifies the following for mapping symbols: 1) A text section must always have a corresponding mapping symbol at it's start. 2) Data sections do not require any mapping symbols. 3) The range of a mapping symbol extends from the address it starts on up to the next mapping symbol (exclusive) or section end (inclusive). However there is no defined order between a symbol and it's corresponding mapping symbol in the symbol table. This means that while in general we look up for a corresponding mapping symbol, we have to make at least one check of the symbol below the address being disassembled. When disassembling different PCs within the same section, the search for mapping symbol can be cached somewhat. We know that the mapping symbol corresponding to the current PC is either the previous one used, or one at the same address as the current PC. However this optimization and mapping symbol search must stop as soon as we reach the end or start of the section. Furthermore if we're only disassembling a part of a section, the search is a allowed to search further than the current chunk, but is not allowed to search past it (The mapping symbol if there, must be at the same address, so in practice we usually stop at PC+4). lastly, since only data sections don't require a mapping symbol the default mapping type should be DATA and not INSN as previously defined, however if the binary has had all its symbols stripped than this isn't very useful. To fix this we determine the default based on the section flags. This will allow the disassembler to be more useful on stripped binaries. If there is no section than we assume you to be disassembling INSN. [1] https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4#aaelf64-section4-5-4 binutils/ChangeLog: * testsuite/binutils-all/aarch64/in-order.d: New test. * testsuite/binutils-all/aarch64/out-of-order.d: Disassemble data as well. opcodes/ChangeLog: * aarch64-dis.c (print_insn_aarch64): Update the mapping symbol search order.
2019-03-25AArch64: Fix disassembler bug with out-of-order sectionsTamar Christina9-1/+98
The AArch64 disassembler has an optimization that it uses to reduce the amount it has to search for mapping symbols during disassembly. This optimization assumes that sections are listed in the section header in monotonic increasing VMAs. However this is not a requirement for the ELF specification. Because of this when such "out of order" sections occur the disassembler would pick the wrong mapping symbol to disassemble the section with. This fixes it by explicitly passing along the stop offset for the current disassembly glob and when this changes compared to the previous one we've seen the optimization won't be performed. In effect this restarts the search from a well defined starting point. Usually the symbol's address. The existing stop_vma can't be used for this as it is allowed to be unset and setting this unconditionally would change the semantics of this field. binutils/ChangeLog: * objdump.c (disassemble_bytes): Pass stop_offset. * testsuite/binutils-all/aarch64/out-of-order.T: New test. * testsuite/binutils-all/aarch64/out-of-order.d: New test. * testsuite/binutils-all/aarch64/out-of-order.s: New test. include/ChangeLog: * dis-asm.h (struct disassemble_info): Add stop_offset. opcodes/ChangeLog: * aarch64-dis.c (last_stop_offset): New. (print_insn_aarch64): Use stop_offset.
2019-03-25Fix testsuite hangs when gdb_test_multiple body errors outPedro Alves2-2/+26
This commit fixes a regression in the testsuite itself, triggered by errors being raised from within gdb_test_multiple, originally reported by Pedro Franco de Carvalho's at <https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts of the commit message are based on his report. This started happening due to a commit that was introduced recently, and it can cause the testsuite to hang. The commit that triggers this is: fe1a5cad302b5535030cdf62895e79512713d738 [gdb/testsuite] Log wait status on process no longer exists error That commit introduces a new "eof" block in gdb_test_multiple. That is not incorrect itself, but dejagnu's remote_expect is picking that block as the "default" action when an error is raised from within the commands inside a call to gdb_test_multiple: # remote_expect works basically the same as standard expect, but it # also takes care of getting the file descriptor from the specified # host and also calling the timeout/eof/default section if there is an # error on the expect call. # proc remote_expect { board timeout args } { I find that "feature" surprising, and I don't really know why it exists, but this means that the eof section that remote_expect picks as the error block can be executed even when there was no actual eof and the GDB process is still running, so the wait introduced in the commit that tries to get the exit status of GDB hangs forever, while GDB itself waits for input. This only happens when there are internal testsuite errors (not testcase failures). This can be reproduced easily with a testcase such as: gdb_start gdb_test_multiple "show version" "show version" { -re ".*" { error "forced error" } } I think that working around this in GDB is useful so that the testsuite doesn't hang in these cases. Adding an empty "default" block at the end of the expect body in gdb_test_multiple doesn't work, because dejagnu gives preference to "eof" blocks: if { $x eq "eof" } { set save_next 1 } elseif { $x eq "default" || $x eq "timeout" } { if { $error_sect eq "" } { set save_next 1 } } And we do have "eof" blocks. So we need to make sure that the last "eof" block is safe to use as the default error block. It's also pedantically incorrect to print "ERROR: Process no longer exists" which is what we'd get if the last eof block we have was selected (more below on this). So this commit solves this by appending an "eof" with an empty spawn_id list, so that it won't ever match. Now, why is the first "eof" block selected today as the error block, instead of the last one? The reason is that remote_expect, while parsing the body to select the default block to execute after an error, is affected by the comments in the body (since they are also parsed). If this comment in gdb_test_multiple # patterns below apply to any spawn id specified. is changed to # The patterns below apply to any spawn id specified. then the second eof block is selected and there is no hang. Any comment at that same place with an even number of tokens also works. This is IMO a coincidence caused by how comments work in TCL. Comments should only appear in places where a command can appear. And here, remote_expect is parsing a list of options, not commands, so it's not unreasonable to not parse comments, similarly to how this: set a_list { an_element # another_element } results in a list with three elements, not one element. The fact that comments with an even number of tokens work is just a coincidence of how remote_expect's little state machine is implemented. I thought we could solve this by stripping out comment lines in gdb_expect, but I didn't find an easy way to do that. Particularly, a couple naive approaches I tried run into complications. For example, we have gdb_test calls with regular expressions that include sequences like "\r\n#", and by the time we get to gdb_expect, the \r\n have already been expanded to a real newline, so just splitting the whole body at newline boundaries, looking for lines that start with # results in incorrectly stripping out half of the gdb_text regexp. I think it's better (at least in this commit), to move the comments out of the list, because it's much simpler and risk free. gdb/testsuite/ChangeLog: 2019-03-25 Pedro Alves <palves@redhat.com> * lib/gdb.exp (gdb_test_multiple): Split appends to $code and move comments outside list. Append '-i "" eof' section.
2019-03-24Remove null_block_symbolTom Tromey11-55/+71
This removes null_block_symbol. It seemed simpler to me to change initializations and returns to use value initialization rather than null_block_symbol. This also fixes up a few spots where initialization was done piecemeal. gdb/ChangeLog 2019-03-24 Tom Tromey <tom@tromey.com> * ada-lang.c (standard_lookup): Simplify initialization. (ada_lookup_symbol_nonlocal): Simplify return. * solib-spu.c (spu_lookup_lib_symbol): Simplify return. * solib-darwin.c (darwin_lookup_lib_symbol): Simplify return. * solib-svr4.c (elf_lookup_lib_symbol): Simplify return. * rust-lang.c (rust_lookup_symbol_nonlocal): Simplify initialization. * solib.c (solib_global_lookup): Simplify. * symtab.c (null_block_symbol): Remove. (symbol_cache_lookup): Simplify returns. (lookup_language_this): Simplify returns. (lookup_symbol_aux): Simplify return. (lookup_local_symbol): Simplify returns. (lookup_global_symbol_from_objfile): Simplify return. (lookup_symbol_in_objfile_symtabs) (lookup_symbol_in_objfile_from_linkage_name): Simplify return. (lookup_symbol_via_quick_fns, lookup_symbol_in_static_block) (lookup_static_symbol, lookup_global_symbol): Simplify return. * cp-namespace.c (cp_lookup_bare_symbol) (cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports) (cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1) (cp_lookup_nested_symbol): Don't use null_block_symbol. (cp_lookup_symbol_via_imports): Simplify initialization. (find_symbol_in_baseclass): Likewise. * symtab.h (null_block_symbol): Remove. * d-namespace.c (d_lookup_symbol): Don't use null_block_symbol. (d_lookup_nested_symbol, d_lookup_symbol_imports) (d_lookup_symbol_module): Likewise. (find_symbol_in_baseclass): Simplify initialization.
2019-03-24Don't include symtab.h from expression.hTom Tromey2-3/+5
expression.h includes symtab.h, but apparently only for the declaration of struct block. This patch changes it to foward-declare the structure, and remove the include. gdb/ChangeLog 2019-03-24 Tom Tromey <tom@tromey.com> * expression.h: Don't include symtab.h. (struct block): Forward declare.
2019-03-24More block constificationTom Tromey26-53/+99
I noticed that there are still many places referring to non-const blocks. This constifies all the remaining ones that I found that could be constified. In a few spots, this search found unused variables or fields. I removed these. I've also removed some unnecessary casts to "struct block *". gdb/ChangeLog 2019-03-24 Tom Tromey <tom@tromey.com> * c-exp.y (typebase): Remove casts. * gdbtypes.c (lookup_unsigned_typename, ) (lookup_signed_typename): Remove cast. * eval.c (parse_to_comma_and_eval): Remove cast. * parse.c (write_dollar_variable): Remove cast. * block.h (struct block) <superblock>: Now const. * symfile-debug.c (debug_qf_map_matching_symbols): Update. * psymtab.c (psym_map_matching_symbols): Make "block" const. (map_block): Make "block" const. * symfile.h (struct quick_symbol_functions) <map_matching_symbols>: Constify block argument to "callback". * symtab.c (basic_lookup_transparent_type_quick): Make "block" const. (find_pc_sect_compunit_symtab): Make "b" const. (find_symbol_at_address): Likewise. (search_symbols): Likewise. * dwarf2read.c (dw2_lookup_symbol): Make "block" const. (dw2_debug_names_lookup_symbol): Likewise. (dw2_map_matching_symbols): Update. * p-valprint.c (pascal_val_print): Remove "block". * ada-lang.c (ada_add_global_exceptions): Make "b" const. (aux_add_nonlocal_symbols): Make "block" const. (resolve_subexp): Remove cast. * linespec.c (iterate_over_all_matching_symtabs): Make "block" const. (iterate_over_file_blocks): Likewise. * f-exp.y (%union) <bval>: Remove. * coffread.c (patch_opaque_types): Make "b" const. * spu-tdep.c (spu_catch_start): Make "block" const. * c-valprint.c (print_unpacked_pointer): Remove "block". * symmisc.c (dump_symtab_1): Make "b" const. (block_depth): Make "block" const. * d-exp.y (%union) <bval>: Remove. * cp-support.h (cp_lookup_rtti_type): Update. * cp-support.c (cp_lookup_rtti_type): Make "block" const. * psymtab.c (psym_lookup_symbol): Make "block" const. (maintenance_check_psymtabs): Make "b" const. * python/py-framefilter.c (extract_sym): Make "sym_block" const. (enumerate_locals, enumerate_args): Update. * python/py-symtab.c (stpy_global_block): Make "block" const. (stpy_static_block): Likewise. * inline-frame.c (block_starting_point_at): Make "new_block" const. * block.c (find_block_in_blockvector): Make return type const. (blockvector_for_pc_sect): Make "b" const. (find_block_in_blockvector): Make "b" const.
2019-03-25Automatic date update in version.inGDB Administrator1-1/+1
2019-03-24(re-)fix the regcache leaks when detaching from an executable.Philippe Waroquiers1-6/+8
Commit 799efbe8e01ab8292c01f46ac59a6fb2349d4535 was supposed to fix the below leak. However, for this fix to work, it is critical to save the ptid before detach. This commit (pushed as OBVIOUS, as the change was already reviewed/approved) saves the ptid before the detach, as in the original reviewed patch (see https://sourceware.org/ml/gdb-patches/2019-02/msg00263.html). Re-tested on debian/amd64, natively and under valgrind. ==7426== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,872 of 3,020 ==7426== at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344) ==7426== by 0x5BD1E1: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330) ==7426== by 0x5BD39A: get_thread_regcache (regcache.c:366) ==7426== by 0x5BD39A: get_current_regcache() (regcache.c:372) ==7426== by 0x4B1EB4: get_current_frame() (frame.c:1588) ...
2019-03-24Automatic date update in version.inGDB Administrator1-1/+1
2019-03-23Have parser reset the innermost block trackerTom Tromey9-60/+60
I ran across a comment in symfile.c today: /* Clear globals which might have pointed into a removed objfile. FIXME: It's not clear which of these are supposed to persist between expressions and which ought to be reset each time. */ It seems to me that this can be clarified: the parser entry points ought to reset the innermost block tracker (and the expression context block), and these should not be considered valid for code to use at arbitrary times -- only immediately after an expression has been parsed. This patch implements this idea. This could be further improved by removing the parser globals and changing the parser functions to return this information, but I have not done this. Tested by the buildbot. gdb/ChangeLog 2019-03-23 Tom Tromey <tom@tromey.com> * varobj.c (varobj_create): Update. * symfile.c (clear_symtab_users): Don't reset innermost_block. * printcmd.c (display_command, do_one_display): Don't reset innermost_block. * parser-defs.h (enum innermost_block_tracker_type): Move to expression.h. (innermost_block): Update comment. * parse.c (parse_exp_1): Add tracker_types parameter. (parse_exp_in_context): Rename from parse_exp_in_context_1. Add tracker_types parameter. Reset innermost_block. (parse_exp_in_context): Remove. (parse_expression_for_completion): Update. * objfiles.c (~objfile): Don't reset expression_context_block or innermost_block. * expression.h (enum innermost_block_tracker_type): Move from parser-defs.h. (parse_exp_1): Add tracker_types parameter. * breakpoint.c (set_breakpoint_condition, watch_command_1): Don't reset innermost_block.
2019-03-23Include bcache.h from objfiles.hTom Tromey2-1/+5
objfiles.h needs "struct bcache" to be complete, so it should include bcache.h. This patch implements this. Tested by rebuilding. gdb/ChangeLog 2019-03-23 Tom Tromey <tom@tromey.com> * objfiles.h: Include bcache.h.
2019-03-23Use scoped_restore_current_language in two placesTom Tromey3-14/+10
I found a couple of spots that manually saved and restored the current language. This patch changes them to use scoped_restore_current_language. Tested by the buildbot. gdb/ChangeLog 2019-03-23 Tom Tromey <tom@tromey.com> * linespec.c (get_current_search_block): Use scoped_restore_current_language. * symmisc.c (dump_symtab): Use scoped_restore_current_language.
2019-03-23Automatic date update in version.inGDB Administrator1-1/+1
2019-03-22AArch64: Read pauth section from core filesAlan Hayward3-0/+31
gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Check for pauth section. * aarch64-linux-tdep.h (AARCH64_LINUX_SIZEOF_PAUTH): New define.
2019-03-22AArch64: Prologue scan unwinder support for signed return addressesAlan Hayward2-6/+91
Pauth address signing is enabled at binary compile time. When enabled the return addresses for functions may be mangled. This patch adds functionality to restore the original address for use in the prologue scan unwinder. In the prologue analyzer, check for PACIASP/PACIBSP (enable address mangling) and AUTIASP/AUTIBSP (disable address mangling). When unwinding the PC from the prologue, unmask the register if required. Add a test case to the prologue tests. gdb/ChangeLog: * aarch64-tdep.c (aarch64_analyze_prologue): Check for pauth instructions. (aarch64_analyze_prologue_test): Add PACIASP test. (aarch64_prologue_prev_register): Unmask PC value.
2019-03-22AArch64: DWARF unwinder support for signed return addressesAlan Hayward2-2/+95
Pauth address signing is enabled at binary compile time. When enabled the return addresses for functions may be mangled. This patch adds functionality to restore the original address for use in the DWARF unwinder. DW_CFA_AARCH64_negate_ra_state in a binary indicates the toggling of address signing between enabled and disabled. Ensure the state is stored in the DWARF register ra_state. Ensure the pauth DWARF registers are initialised. gdb/ChangeLog: * aarch64-tdep.c (aarch64_frame_unmask_address): New function. (aarch64_dwarf2_prev_register): Unmask PC value. (aarch64_dwarf2_frame_init_reg): Init pauth registers. (aarch64_execute_dwarf_cfa_vendor_op): Check for DW_CFA_AARCH64_negate_ra_state. (aarch64_gdbarch_init): Add aarch64_execute_dwarf_cfa_vendor_op.
2019-03-22AArch64: Add pauth DWARF registersAlan Hayward3-33/+79
Map the pauth registers to DWARF. Add a new pseudo register ra_state and also map this to DWARF. This register is hidden from the user - prevent it from being read or written to. It will be used for the unmangling of addresses. gdb/ChangeLog: * aarch64-tdep.c (aarch64_dwarf_reg_to_regnum): Check for pauth registers. (aarch64_pseudo_register_name): Likewise. (aarch64_pseudo_register_type): Likewise. (aarch64_pseudo_register_reggroup_p): Likewise. (aarch64_gdbarch_init): Add pauth registers. * aarch64-tdep.h (AARCH64_DWARF_PAUTH_RA_STATE): New define. (AARCH64_DWARF_PAUTH_DMASK): Likewise. (AARCH64_DWARF_PAUTH_CMASK): Likewise. (struct gdbarch_tdep): Add regnum for ra_state.
2019-03-22AArch64: gdbserver: read pauth registersAlan Hayward6-6/+46
Add the pauth registers to the regset lists. Add a new regset type OPTIONAL_REGS which allows for the regset read to fail. Once the read fails, it will not be checked again. This allows targets with optional features to keep a single static regset_info structure. gdb/ChangeLog: * arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_store_pauthregset): New function. * linux-low.c (regsets_store_inferior_registers): Allow optional reads to fail. * linux-low.h (enum regset_type): Add OPTIONAL_REGS.
2019-03-22AArch64: Read pauth registersAlan Hayward5-0/+101
Initialise the pauth registers when creating a target description, and store the regnum of the first pauth register. Use ptrace to read the registers in the pauth feature. Do not allow the registers to be written. gdb/ChangeLog: * aarch64-linux-nat.c (fetch_pauth_masks_from_thread): New function. (aarch64_linux_nat_target::fetch_registers): Read pauth registers. * aarch64-tdep.c (aarch64_cannot_store_register): New function. (aarch64_gdbarch_init): Add puth registers. * aarch64-tdep.h (struct gdbarch_tdep): Add pauth features. * arch/aarch64.h (AARCH64_PAUTH_DMASK_REGNUM): New define. (AARCH64_PAUTH_CMASK_REGNUM): Likewise.
2019-03-22AArch64: Use HWCAP to detect pauth featureAlan Hayward6-8/+72
Add aarch64_get_hwcap functions for reading the HWCAP. From this extract the PACA value and use this to enable pauth. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Read PACA hwcap. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. (aarch64_linux_get_hwcap): New function. * aarch64-linux-tdep.h (AARCH64_HWCAP_PACA): New define. (aarch64_linux_get_hwcap): New declaration. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (AARCH64_HWCAP_PACA): New define. (aarch64_get_hwcap): New function. (aarch64_arch_setup): Read APIA hwcap.
2019-03-22AArch64: Add pointer authentication featureAlan Hayward18-26/+101
Pointer Authentication is a new feature in AArch64 v8.3-a. When enabled in the compiler, function return addresses will be mangled by the kernel. Add register description xml and wire up to aarch64_linux_read_description. This description includes the two pauth user registers. Nothing yet uses the feature - that is added in later patches. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Add pauth param. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. * aarch64-tdep.c (struct target_desc): Add in pauth. (aarch64_read_description): Add pauth param. (aarch64_gdbarch_init): Likewise. * aarch64-tdep.h (aarch64_read_description): Likewise. * arch/aarch64.c (aarch64_create_target_description): Likewise. * arch/aarch64.h (aarch64_create_target_description): Likewise. * features/Makefile: Add new files. * features/aarch64-pauth.c: New file. * features/aarch64-pauth.xml: New file. gdb/doc/ChangeLog: * gdb.texinfo: Describe pauth feature. gdb/gdbserver/ChangeLog: * linux-aarch64-ipa.c (get_ipa_tdesc): Add pauth param. (initialize_low_tracepoint): Likewise. * linux-aarch64-low.c (aarch64_arch_setup): Likewise. * linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Likewise. * linux-aarch64-tdesc.c (struct target_desc): Likewise. (aarch64_linux_read_description): Likewise. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Likewise.
2019-03-22Testsuite: Ensure pie is disabled on some testsAlan Hayward5-4/+53
Recent versions of Ubuntu and Debian default GCC to enable pie. In dump.exp, pie will causes addresses to be out of range for IHEX. In break-interp.exp, pie is explicitly set for some tests and assumed to be disabled for the remainder. Ensure pie is disabled for these tests when required. In addition, add a pie option to gdb_compile to match the nopie option and simplify use. gdb/testsuite/ChangeLog: * README: Add pie options. * gdb.base/break-interp.exp: Ensure pie is disabled. * gdb.base/dump.exp: Likewise. * lib/gdb.exp (gdb_compile): Add pie option.
2019-03-22Automatic date update in version.inGDB Administrator1-1/+1