aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2019-06-11Remove trailing newlines from help textTom Tromey18-68/+102
I noticed recently that some command had a trailing newline in its "help" output. So, I temporarily hacked cli-decode.c to print something when a new command was installed that had a trailing newline in its help message, and wrote this patch, which removes all the ones I could find this way. (There could still be a few more in *-nat files.) Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-11 Tom Tromey <tromey@adacore.com> * infcall.c (_initialize_infcall): Remove trailing newline from help. * user-regs.c (_initialize_user_regs): Remove trailing newline from help. * typeprint.c (_initialize_typeprint): Remove trailing newline from help. * reverse.c (_initialize_reverse): Remove trailing newlines from help. * tracepoint.c (_initialize_tracepoint): Remove trailing newlines from help. * language.c (add_set_language_command): Remove trailing newline from help. * infcmd.c (_initialize_infcmd): Remove trailing newlines from help. * disasm.c (_initialize_disasm): Remove trailing newline from help. * top.c (init_main): Remove trailing newline from help. * interps.c (_initialize_interpreter): Remove trailing newline from help. * btrace.c (_initialize_btrace): Remove trailing newlines from help. * breakpoint.c (_initialize_breakpoint): Remove trailing newline from help. * python/python.c (_initialize_python): Remove trailing newline from help. * spu-tdep.c (_initialize_spu_tdep): Remove trailing newlines from help. * tui/tui-win.c (_initialize_tui_win): Remove trailing newlines from help. Reformat some text. * tui/tui-stack.c (_initialize_tui_stack): Remove trailing newline from help. * tui/tui-layout.c (_initialize_tui_layout): Remove trailing newline from help.
2019-06-11[gdb/testsuite] Fix remove-inferiors.exp FAIL with readnow boardTom de Vries2-2/+9
We see this failure with the readnow board: ... FAIL: gdb.multi/remove-inferiors.exp: load binary ... When running with board readnow, an extra message "Expanding full symbols" is emitted after the "Reading symbols" message, and the regexp corresponding to the FAIL only allows the first message. Fix this by allowing the extra message in the regexp. gdb/testsuite/ChangeLog: 2019-06-11 Tom de Vries <tdevries@suse.de> PR testsuite/24521 * gdb.multi/remove-inferiors.exp: Allow "Expanding full symbols" message.
2019-06-11Remove shadowing from darwin-nat.cTom Tromey2-7/+10
Building on Darwin with gcc showed that darwin-nat.c had some shadowing variable declarations. This removes them. gdb/ChangeLog 2019-06-11 Tom Tromey <tromey@adacore.com> * darwin-nat.c (darwin_decode_exception_message) (darwin_decode_message, darwin_nat_target::kill): Fix shadowing.
2019-06-11[gdb/testsuite] Fix main high_pc in nonvar-access.expTom de Vries2-1/+12
When running gdb.dwarf2/nonvar-access.exp with board readnow, we have: ... FAIL: gdb.dwarf2/nonvar-access.exp: print/x def_implicit_s ... and 12 more similar failures. I've tracked this down to the range of main being hardcoded to [_main, _main+0x10000) in the dwarf assembly: ... DW_TAG_subprogram { {name main} {DW_AT_external 1 flag} {low_pc [gdb_target_symbol main] DW_FORM_addr} {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr} } { ... which overlaps with the .debug_info for the elf-init.c CU (containing __libc_csu_init and __libc_csu_fini). Fix this by using function_range to find the actual range of main. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-11 Tom de Vries <tdevries@suse.de> PR testsuite/24521 * gdb.dwarf2/nonvar-access.exp: Fix main high_pc.
2019-06-11[gdb/testsuite] Add readnow.expTom de Vries2-0/+31
Add a target board to test -readnow. gdb/testsuite/ChangeLog: 2019-06-11 Tom de Vries <tdevries@suse.de> * boards/readnow.exp: New file.
2019-06-10gdb: Check for not allocated/associated values during array slicingAndrew Burgess4-2/+16
When extracting an array slice we should give up if the array is not-allocated or not-associated. For Fortran, at least in gfortran compiled code, the upper and lower bounds are undefined if the array is not allocated or not associated, in which case performing checks against these bounds will result in undefined behaviour. Better then to throw an error if we try to slice such an array. This changes the error message that the user will receive in these cases (if they got an error message before). Previously they may have gotten "slice out of range" now they'll get "array not allocated" or "array not associated". gdb/ChangeLog: * valops.c (value_slice): Check for not allocated or not associated values. gdb/testsuite/ChangeLog: * gdb.fortran/vla-sizeof.exp: Update expected results.
2019-06-10[gdb] Fix heap-buffer-overflow in cp_find_first_component_auxTom de Vries2-1/+8
When compiling gdb with '-lasan -fsanitizer=address' and running tests with: - export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0", - target board cc-with-gdb-index, - the "[gdb/testsuite] Fix gdb.base/break-probes.exp with native-gdbserver" commit reverted to avoid running into PR24617, we get with gdb.arch/amd64-init-x87-values.exp: ... ==31229==ERROR: AddressSanitizer: heap-buffer-overflow on address \ 0x62500098c93c at pc 0x000000bcc748 bp 0x7ffe39487660 sp 0x7ffe39487658 READ of size 1 at 0x62500098c93c thread T0 #0 0xbcc747 in cp_find_first_component_aux src/gdb/cp-support.c:999 #1 0xbcc6e9 in cp_find_first_component(char const*) \ src/gdb/cp-support.c:977 #2 0xcc2cf3 in mapped_index_base::build_name_components() \ src/gdb/dwarf2read.c:4499 #3 0xcc3322 in dw2_expand_symtabs_matching_symbol src/gdb/dwarf2read.c:4552 #4 0xcc817f in dw2_expand_symtabs_matching src/gdb/dwarf2read.c:5228 #5 0xfe8f48 in iterate_over_all_matching_symtabs src/gdb/linespec.c:1147 #6 0x1003506 in add_matching_symbols_to_info src/gdb/linespec.c:4413 #7 0xffe21b in find_function_symbols src/gdb/linespec.c:3886 #8 0xffe4a2 in find_linespec_symbols src/gdb/linespec.c:3914 #9 0xfee3ad in linespec_parse_basic src/gdb/linespec.c:1865 #10 0xff5128 in parse_linespec src/gdb/linespec.c:2655 #11 0xff8872 in event_location_to_sals src/gdb/linespec.c:3150 #12 0xff90a8 in decode_line_full(event_location const*, int, \ program_space*, symtab*, int, linespec_result*, \ char const*, char const*) src/gdb/linespec.c:3230 #13 0x9ce449 in parse_breakpoint_sals src/gdb/breakpoint.c:9057 #14 0x9ea022 in create_sals_from_location_default src/gdb/breakpoint.c:13708 #15 0x9e2c1f in bkpt_create_sals_from_location src/gdb/breakpoint.c:12514 #16 0x9cff06 in create_breakpoint(gdbarch*, event_location const*, \ char const*, int, char const*, int, int, bptype, int, \ auto_boolean, breakpoint_ops const*, int, int, int, \ unsigned int) src/gdb/breakpoint.c:9238 #17 0x9d114a in break_command_1 src/gdb/breakpoint.c:9402 #18 0x9d1b60 in break_command(char const*, int) src/gdb/breakpoint.c:9473 #19 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106 #20 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \ src/gdb/cli/cli-decode.c:1892 #21 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630 #22 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586 #23 0xdde7c1 in command_line_handler(std::unique_ptr<char, \ gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773 #24 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217 #25 0x16f2198 in rl_callback_read_char src/readline/callback.c:220 #26 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \ src/gdb/event-top.c:175 #27 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192 #28 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514 #29 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731 #30 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857 #31 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321 #32 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370 #33 0x10a7715 in captured_command_loop src/gdb/main.c:331 #34 0x10aa548 in captured_main src/gdb/main.c:1173 #35 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188 #36 0x87bd35 in main src/gdb/gdb.c:32 #37 0x7f16e1434f89 in __libc_start_main (/lib64/libc.so.6+0x20f89) #38 0x87bb49 in _start (build/gdb/gdb+0x87bb49) 0x62500098c93c is located 0 bytes to the right of 8252-byte region \ [0x62500098a900,0x62500098c93c) allocated by thread T0 here: #0 0x7f16e359a600 in malloc (/usr/lib64/libasan.so.5+0xeb600) #1 0x1742ddf in bfd_malloc src/bfd/libbfd.c:275 #2 0x1738824 in bfd_get_full_section_contents src/bfd/compress.c:253 #3 0xe30044 in gdb_bfd_map_section(bfd_section*, unsigned long*) \ src/gdb/gdb_bfd.c:704 #4 0xcb56bf in dwarf2_read_section(objfile*, dwarf2_section_info*) \ src/gdb/dwarf2read.c:2539 #5 0xd5bcd0 in get_gdb_index_contents_from_section<dwarf2_per_objfile> \ src/gdb/dwarf2read.c:6217 #6 0xd7fc7d in gdb::function_view<gdb::array_view<unsigned char const> \ (...) const src/gdb/common/function-view.h:284 #7 0xd7fddd in gdb::function_view<gdb::array_view<unsigned char const> \ (...) src/gdb/common/function-view.h:278 #8 0xd730cf in gdb::function_view<gdb::array_view<unsigned char const> \ (...) const src/gdb/common/function-view.h:247 #9 0xcbc7ee in dwarf2_read_gdb_index src/gdb/dwarf2read.c:3582 #10 0xcce731 in dwarf2_initialize_objfile(objfile*, dw_index_kind*) \ src/gdb/dwarf2read.c:6297 #11 0xdb88c4 in elf_symfile_read src/gdb/elfread.c:1256 #12 0x141262a in read_symbols src/gdb/symfile.c:798 #13 0x14140a7 in syms_from_objfile_1 src/gdb/symfile.c:1000 #14 0x1414393 in syms_from_objfile src/gdb/symfile.c:1017 #15 0x1414fb7 in symbol_file_add_with_addrs src/gdb/symfile.c:1124 #16 0x14159b7 in symbol_file_add_from_bfd(bfd*, char const*, \ enum_flags<symfile_add_flag>, std::vector<other_sections, \ std::allocator<other_sections> >*, \ enum_flags<objfile_flag>, objfile*) src/gdb/symfile.c:1203 #17 0x1415b6c in symbol_file_add(char const*, enum_flags<symfile_add_flag>, std::vector<other_sections, \ std::allocator<other_sections> >*, \ enum_flags<objfile_flag>) src/gdb/symfile.c:1216 #18 0x1415f2f in symbol_file_add_main_1 src/gdb/symfile.c:1240 #19 0x1418599 in symbol_file_command(char const*, int) \ src/gdb/symfile.c:1675 #20 0xde2fa6 in file_command src/gdb/exec.c:433 #21 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106 #22 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \ src/gdb/cli/cli-decode.c:1892 #23 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630 #24 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586 #25 0xdde7c1 in command_line_handler(std::unique_ptr<char, \ gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773 #26 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217 #27 0x16f2198 in rl_callback_read_char src/readline/callback.c:220 #28 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \ src/gdb/event-top.c:175 #29 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192 SUMMARY: AddressSanitizer: heap-buffer-overflow src/gdb/cp-support.c:999 in \ cp_find_first_component_aux Shadow bytes around the buggy address: 0x0c4a801298d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c4a801298e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c4a801298f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c4a80129900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c4a80129910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c4a80129920: 00 00 00 00 00 00 00[04]fa fa fa fa fa fa fa fa 0x0c4a80129930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c4a80129940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c4a80129950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c4a80129960: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c4a80129970: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==31229==ABORTING ... The problem happens as follows. The executable amd64-init-x87-values gets an index (due to target board cc-with-gdb-index), which looks as follows: ... Hex dump of section '.gdb_index': 0x00000000 08000000 18000000 28000000 28000000 ........(...(... 0x00000010 3c000000 3c200000 00000000 00000000 <...< .......... 0x00000020 2e000000 00000000 d4004000 00000000 ..........@..... 0x00000030 db004000 00000000 00000000 00000000 ..@............. 0x00000040 00000000 00000000 00000000 00000000 ................ 0x00000050 00000000 00000000 00000000 00000000 ................ ... more zeroes ... 0x00002010 00000000 00000000 00000000 00000000 ................ 0x00002020 00000000 00000000 00000000 00000000 ................ 0x00002030 00000000 00000000 00000000 ............ ... The structure of this index is: ... header : [0x0, 0x18) : size 0x18 culist : [0x18 ,0x28) : size 0x10 typesculist : [0x28, 0x28) : size 0x0 adress area : [0x28, 0x3c) : size 0x14 symbol table : [0x3c, 0x203c) : size 0x2000 constant pool: [0x203c, 0x203c): size 0x0 EOF : 0x203c ... Note that the symbol table consists entirely of empty slots (where an empty slot is a pair of 32-bit zeroes), and that the constant pool is empty. The problem happens here in mapped_index_base::build_name_components: ... auto count = this->symbol_name_count (); for (offset_type idx = 0; idx < count; idx++) { if (this->symbol_name_slot_invalid (idx)) continue; const char *name = this->symbol_name_at (idx); ... when accessing the slot at idx == 0 in the symbol table, symbol_name_slot_invalid returns false so we calculate name, which is calculated using 'constant_pool + symbol_table[idx].name', which means we get name == constant_pool. And given that the constant pool is empty, name now points past the memory allocated for the index, and when we access name[0] for the first time in cp_find_first_component_aux, we run into the heap-buffer-overflow. Fix this by fixing the definition of symbol_name_slot_invalid: ... - return bucket.name == 0 && bucket.vec; + return bucket.name == 0 && bucket.vec == 0; ... Tested on x86_64-linux. gdb/ChangeLog: 2019-06-10 Tom de Vries <tdevries@suse.de> PR gdb/24618 * dwarf2read.c (struct mapped_index::symbol_name_slot_invalid): Make sure an empty slot (defined by a 32-bit zero pair) is recognized as invalid.
2019-06-10[gdb] Fix dynamic-stack-buffer-overflow in linespec_lexer_lex_stringTom de Vries2-1/+10
When compiling gdb with '-lasan -fsanitizer=address' and running tests with 'export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0"', I run into: ... ERROR: GDB process no longer exists UNRESOLVED: gdb.linespec/cpls-abi-tag.exp: \ test_abi_tag: completion: at tag: tab complete "b test_abi_tag_function[abi:" ... In more detail: ... ==3637==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address \ 0x7fff5952bbdd at pc 0x000000fe5c57 bp 0x7fff5952af30 sp 0x7fff5952af28 READ of size 1 at 0x7fff5952bbdd thread T0 #0 0xfe5c56 in linespec_lexer_lex_string src/gdb/linespec.c:727 #1 0xfe7473 in linespec_lexer_lex_one src/gdb/linespec.c:946 #2 0xfe799d in linespec_lexer_consume_token src/gdb/linespec.c:982 #3 0xff446d in parse_linespec src/gdb/linespec.c:2564 #4 0xff78be in linespec_complete(completion_tracker&, char const*, \ symbol_name_match_type) src/gdb/linespec.c:2961 #5 0xb9299c in complete_address_and_linespec_locations \ src/gdb/completer.c:573 #6 0xb93e90 in location_completer(cmd_list_element*, completion_tracker&, \ char const*, char const*) src/gdb/completer.c:919 #7 0xb940c5 in location_completer_handle_brkchars src/gdb/completer.c:956 #8 0xb957ec in complete_line_internal_normal_command \ src/gdb/completer.c:1208 #9 0xb96507 in complete_line_internal_1 src/gdb/completer.c:1430 #10 0xb965c2 in complete_line_internal src/gdb/completer.c:1449 #11 0xb98630 in gdb_completion_word_break_characters_throw \ src/gdb/completer.c:1862 #12 0xb98838 in gdb_completion_word_break_characters() \ src/gdb/completer.c:1897 #13 0x16c6362 in _rl_find_completion_word src/readline/complete.c:943 #14 0x16ca8d0 in rl_complete_internal src/readline/complete.c:1843 #15 0x16c460c in rl_complete src/readline/complete.c:408 #16 0x16b3368 in _rl_dispatch_subseq src/readline/readline.c:774 #17 0x16b3092 in _rl_dispatch src/readline/readline.c:724 #18 0x16b2939 in readline_internal_char src/readline/readline.c:552 #19 0x16f1fb0 in rl_callback_read_char src/readline/callback.c:201 #20 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \ src/gdb/event-top.c:175 #21 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192 #22 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514 #23 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731 #24 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857 #25 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321 #26 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370 #27 0x10a7715 in captured_command_loop src/gdb/main.c:331 #28 0x10aa548 in captured_main src/gdb/main.c:1173 #29 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188 #30 0x87bd35 in main src/gdb/gdb.c:32 #31 0x7fb0364c6f89 in __libc_start_main (/lib64/libc.so.6+0x20f89) #32 0x87bb49 in _start (build/gdb/gdb+0x87bb49) Address 0x7fff5952bbdd is located in stack of thread T0 at offset 557 in frame #0 0xb93702 in location_completer(cmd_list_element*, completion_tracker&, \ char const*, char const*) src/gdb/completer.c:831 This frame has 4 object(s): [32, 40) 'copy' [96, 104) 'location' [160, 168) 'text' [224, 256) 'completion_info' <== Memory access at offset 557 overflows \ this variable HINT: this may be a false positive if your program uses some custom stack \ unwind mechanism or swapcontext (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: dynamic-stack-buffer-overflow \ src/gdb/linespec.c:727 in linespec_lexer_lex_string Shadow bytes around the buggy address: 0x10006b29d720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006b29d730: 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2 f2 f2 0x10006b29d740: f2 f2 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f2 f2 0x10006b29d750: f2 f2 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00 0x10006b29d760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x10006b29d770: 00 00 00 00 ca ca ca ca 00 00 00[05]cb cb cb cb 0x10006b29d780: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 0x10006b29d790: 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f3 f3 f3 f3 0x10006b29d7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006b29d7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006b29d7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==3637==ABORTING ... The problem happens in linespec_lexer_lex_string when lexing "b test_abi_tag_function[abi:\0" (using a notation where we make the implicit terminating \0 explicit). We arrrive here with (PARSER_STREAM (parser)) == ":\0": ... /* Do not tokenize ABI tags such as "[abi:cxx11]". */ else if (PARSER_STREAM (parser) - start > 4 && startswith (PARSER_STREAM (parser) - 4, "[abi")) ++(PARSER_STREAM (parser)); ... and consume ':', after which we end up here and consume '\0': ... /* Advance the stream. */ ++(PARSER_STREAM (parser)); ... after which (PARSER_STREAM (parser)) points past the end of the string. Fix this by removing the first "++(PARSER_STREAM (parser))", and add an assert to the second one to detect moving past the end-of-string. Build and tested on x86_64-linux. gdb/ChangeLog: 2019-06-10 Tom de Vries <tdevries@suse.de> PR gdb/24611 * linespec.c (linespec_lexer_lex_string): Remove incorrect "++(PARSER_STREAM (parser))" for "[abi"-prefixed colon. Add assert.
2019-06-10[gdb/symtab] Fix symbol loading performance regressionTom de Vries2-6/+16
The commit "[gdb/symtab] Fix language of duplicate static minimal symbol" introduces a performance regression, when loading a cc1 executable build with -O0 -g and gcc 7.4.0. The performance regression, measured in 'real' time is about 175%. The slower execution comes from the fact that the fix in symbol_set_names makes the call to symbol_find_demangled_name unconditional. Fix this by reverting the commit, and redoing the fix as follows. Recapturing the original problem, the first time symbol_set_names is called with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is not present in the per_bfd->demangled_names_hash hash table, so symbol_find_demangled_name is called to demangle the name, after which the mangled/demangled pair is added to the hashtable. The call to symbol_find_demangled_name also sets gsymbol.language to lang_cplus. The second time symbol_set_names is called with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is present in the hash table, so the demangled name from the hash table is used. However, the language of the symbol remains lang_auto. Fix this by adding a field language in struct demangled_name_entry, and using the field in symbol_set_names to set the language of gsymbol, if necessary. Tested on x86_64-linux. gdb/ChangeLog: 2019-06-10 Tom de Vries <tdevries@suse.de> PR symtab/24545 * symtab.c (struct demangled_name_entry): Add language field. (symbol_set_names): Revert "[gdb/symtab] Fix language of duplicate static minimal symbol". Set and use language field.
2019-06-10Update help text in ada-lang.cTom Tromey2-5/+17
I noticed that the "catch assert" help text erroneously claimed to accept an argument, and while fixing this I went ahead and added "Usage" text and made other minor updates to the commands in ada-lang.c. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * ada-lang.c (_initialize_ada_language): Update help text.
2019-06-10Remove newlines from warningsTom Tromey15-19/+52
ARI pointed out that a recent patch introduced a call to "warning" with a string that ended in a newline: https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html This is generally forbidden, I believe, because warning adds its own newline. This patch removes all of the trailing newlines I was able to find. I searched for 'warning (.*\\n"' and then fixed the ones where the newline appeared at the end of the string (some had internal newlines). Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning with a newline. * guile/guile.c (handle_boot_error): Don't end warning with a newline. * cli/cli-cmds.c (exit_status_set_internal_vars): Don't end warning with a newline. * s12z-tdep.c (s12z_skip_prologue): Don't end warning with a newline. (s12z_frame_cache): Likewise. * dwarf-index-cache.c (index_cache::store): Don't end warning with a newline. * solib-svr4.c (disable_probes_interface): Don't end warning with a newline. * nat/fork-inferior.c (fork_inferior): Don't end warning with a newline. * python/python.c (do_finish_initialization): Don't end warning with a newline. gdb/gdbserver/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * remote-utils.c (look_up_one_symbol, relocate_instruction): Don't end warning with a newline. * linux-s390-low.c (s390_get_wordsize): Don't end warning with a newline. * thread-db.c (attach_thread): Don't end warning with a newline. (thread_db_notice_clone): Likewise. * tracepoint.c (gdb_agent_helper_thread): Don't end warning with a newline. * linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't end warning with a newline.
2019-06-10Use gdbpy_enter in py-breakpoint.cTom Tromey2-10/+14
A few spots in py-breakpoint.c acquire the GIL manually. However, because these spots generate events, and because events are expected to be arbitrary gdb-flavored Python code, it's important to use gdbpy_enter instead, in order to ensure that the other gdb-related Python globals are set correctly. This patch makes this change. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tom@tromey.com> * python/py-breakpoint.c (gdbpy_breakpoint_created) (gdbpy_breakpoint_deleted, gdbpy_breakpoint_modified): Use gdbpy_enter.
2019-06-10Delay allocation of dbx_symfile_infoTom Tromey4-18/+20
I noticed that elfread.c always allocates a dbx_symfile_info, even though this is only ever needed in the unusual case of reading stabs in ELF. This patch moves the allocation into dbxread.c, and applies the same treatment to similar code in coffread.c. Regression tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile data. (elf_new_init): Don't call stabsread_new_init. * dbxread.c (coffstab_build_psymtabs): Set dbx objfile data. (elfstab_build_psymtabs): Likewise. Call stabsread_new_init. * coffread.c (coff_symfile_init): Don't set the dbx objfile data.
2019-06-10[gdb/symtab] Support DW_AT_main_subprogram with -readnow.Tom de Vries2-0/+10
DW_AT_main_subprogram is supported in normal mode in read_partial_die, but not in -readnow mode. Fix this by adding support for DW_AT_main_subprogram in read_func_scope. Tested on x86_64-linux with native and RFC target board readnow ( https://sourceware.org/ml/gdb-patches/2019-05/msg00073.html ). gdb/ChangeLog: 2019-06-10 Tom de Vries <tdevries@suse.de> PR symtab/16264 PR symtab/24517 * dwarf2read.c (read_func_scope): Handle DW_AT_main_subprogram.
2019-06-06Apply substitute-path to relative filenames as wellРуслан Ижбулатов2-9/+9
When source file path is relative to the build directory (which is considered a good practice and is enforced in certain buildsystems, such as meson), gdb only applies substitute-path to the build directory path. Then gdb appends the source file path to the rewritten build directory path, and tries to access that. This fails if either two of the following conditions are true: a) The user didn't specify substitute-path for the build directory. This is highly likely, since path substitution for build directories is not documented anywhere, and since gdb does not tell[0] the user the path to the build directory, just the source file path. b) The source file path changed. This can also easily happen, since a source path that is relative to the build directory can include any number of directory names that are not part of the program source tree (starting with the name of the root directory of the source tree). Gdb will not apply substitute-path to that relative path, thus there is no way for the user to tell gdb about these changes. This commit changes the code to apply substitute-path to all filenames, both relative and absolute. This way it is possible to do things like: set substitute-path ../foobar-1.0 /src/my/foobar-1.0 which is completely in line with the user expectations. This might break unusual cases where build directory path is also relative (is that even possible?) and happens to match the path to the source directory (i.e. happens to match a substitution rule). [0]: There's a "maintenance info symtabs" command that does show the names of the build directories, but normal users are not required to know or use that. gdb/ChangeLog 2019-06-06 Руслан Ижбулатов <lrn1986@gmail.com> * source.c (find_and_open_source): Also rewrite relative file names.
2019-06-06Add thread-exit annotation.Amos Bird9-7/+70
gdb/ChangeLog 2019-04-26 Amos Bird <amosbird@gmail.com> * annotate.c (annotate_thread_exited): Add "thread-exited" annotation. gdb/doc/ChangeLog 2019-06-06 Amos Bird <amosbird@gmail.com> * annotate.texinfo (Multi-threaded Apps): Add entry for thread-exited annotation. gdb/testsuite/ChangeLog 2019-06-06 Amos Bird <amosbird@gmail.com> * gdb.base/annota1.exp (thread_switch): Add test for thread-exited annotation.
2019-06-06Add timestamps to "maint time" outputTom Tromey5-5/+47
Currently "maint time" will print the amount of time a command took. Sometimes, though, it's useful to have a timestamp as well -- for example if one is correlating a gdb log with some other log. This patch adds a timestamp to the start and end of each command when this setting is in effect. This also removes a "//" comment and changes scoped_command_stats to use DISABLE_COPY_AND_ASSIGN; two minor things I noticed while working on the patch. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-06 Tom Tromey <tromey@adacore.com> * maint.h (class scoped_command_stats): Use DISABLE_COPY_AND_ASSIGN. <print_time>: New method. * maint.c (scoped_command_stats, ~scoped_command_stats): Call print_time. (scoped_command_stats::print_time): New method. gdb/testsuite/ChangeLog 2019-06-06 Tom Tromey <tromey@adacore.com> * gdb.base/maint.exp: Expect command started/finished output.
2019-06-05gdb/testsuite: Improve comments in recently added testAndrew Burgess3-2/+8
Remove the use of 'I' within some comments in a recently added test. gdb/testsuite/ChangeLog: * gdb.arch/riscv-unwind-long-insn-6.s: Remove use of 'I' in comment. * gdb.arch/riscv-unwind-long-insn-8.s: Likewise.
2019-06-05gdb/riscv: Don't error when decoding a 6 or 8 byte instructionAndrew Burgess7-4/+194
If the RISC-V prologue scanner finds a 6 or 8 byte instruction we currently throw an internal error, which is not great for the user. A mechanism already exists in the prologue scanner to leave instructions marked as unknown so that we can stop the prologue scan without raising an error, this is used for all 2 and 4 byte instructions that are not part of the small set the prologue scanner actually understands. This commit changes GDB so that all 6 and 8 byte instructions are marked as unknown, rather than causing an error. gdb/ChangeLog: * riscv-tdep.c (riscv_insn::decode): Gracefully ignore instructions of lengths 6 or 8 bytes. gdb/testsuite/ChangeLog: * gdb.arch/riscv-unwind-long-insn-6.s: New file. * gdb.arch/riscv-unwind-long-insn-8.s: New file. * gdb.arch/riscv-unwind-long-insn.c: New file. * gdb.arch/riscv-unwind-long-insn.exp: New file.
2019-06-04Introduce and use make_unique_xstrdupPedro Alves23-45/+65
Adds an utility function to make it shorter to write the common case of wrapping an xstrdup with a unique_xmalloc_ptr, and uses it throughout. Note: I tried to put this in common/common-utils.h near skip_spaces, etc. but that is included in common/common-defs.h before common/gdb_unique_ptr.h is included, so it would fail to compile because gdb::unique_xmalloc_ptr isn't defined at that point yet. I tried moving the gdb_unique_ptr.h inclusion before common-utils.h, but that doesn't work because gdb_unique_ptr.h depends on common-utils.h for xfree. gdb/ChangeLog: 2019-06-04 Pedro Alves <palves@redhat.com> * common/gdb_unique_ptr.h (make_unique_xstrdup): New. * ada-lang.c (catch_ada_completer): Use make_unique_xstrdup. * breakpoint.c (condition_completer): Likewise. * cli/cli-dump.c (scan_expression): Likewise. * common/filestuff.c (mkdir_recursive): Likewise. * common/gdb_tilde_expand.c (gdb_tilde_expand_up) * common/pathstuff.c (gdb_realpath, gdb_realpath_keepfile) (gdb_abspath): Likewise. * compile/compile-cplus-types.c (compile_cplus_instance::decl_name): Likewise. * completer.c (complete_explicit_location): (signal_completer, reg_or_group_completer_1): Likewise. * cp-support.c (cp_remove_params_if_any): Likewise. * fbsd-tdep.c (fbsd_core_vnode_path): Likewise. * guile/scm-safe-call.c (gdbscm_safe_eval_string): Likewise. * infcmd.c (strip_bg_char): Likewise. * linespec.c (copy_token_string): Likewise. * mi/mi-main.c (output_cores): Likewise. * psymtab.c (psymtab_search_name): * symfile.c (test_set_ext_lang_command): Likewise. * target.c (target_fileio_read_stralloc): Likewise. * tui/tui-regs.c (tui_reggroup_completer): Likewise. * value.c (complete_internalvar): Likewise. gdb/gdbserver/ChangeLog: 2019-06-04 Pedro Alves <palves@redhat.com> * server.c (captured_main): Use make_unique_xstrdup.
2019-06-04Fix paths to ChangeLog filesPedro Alves3-5/+4
2019-06-04Add an objfile getter to gdb.TypeChristian Biesinger via gdb-patches7-0/+41
This allows users of the Python API to find the objfile where a type was defined. gdb/ChangeLog: gdb/ChangeLog 2019-06-04 Christian Biesinger <cbiesinger@google.com> Add objfile property to gdb.Type. * gdb/NEWS: Mention Python API addition. * gdb/python/py-type.c (typy_get_objfile): New method. gdb/doc/ChangeLog 2019-06-04 Christian Biesinger <cbiesinger@google.com> * gdb/doc/python.texi: Document new gdb.Type.objfile property. gdb/testsuite/ChangeLog 2019-06-04 Christian Biesinger <cbiesinger@google.com> * gdb/testsuite/gdb.python/py-type.exp: Test for new gdb.Type.objfile property.
2019-06-03Document in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes.Philippe Waroquiers4-4/+95
2019-06-03Update tests following changes to "help" and "apropos"Philippe Waroquiers8-29/+102
Factorizes the testing of the help output, by having a single place that defines the common help trailer and/or prefix messages.
2019-06-03Improve usability and/or readibility of help and apropos output.Philippe Waroquiers4-22/+69
The "help" command can output long list of command names or classes. Use the title style to style the command names or classes to make the output more readable. Similarly, change "apropos" command to also style the command names. It is sometimes unclear why "apropos REGEXP" lists some commands, and then the user has to manually do 'help command' for all commands listed by "apropos" to see more details about the matching commands. => Add an optional flag -v so that "apropos -v REGEXP": * outputs the full documentation of matching commands. * highlights the documentation parts matching REGEXP.
2019-06-03Add highlight style, title style, fputs_highlighted. Improve 'show style'Philippe Waroquiers5-34/+161
Have 'show style' and its subcommands using a style to style its output. This allows the GDB user or developer to use 'show style' to visually see with one command how all the current styles look like. Add 2 new styles highlight style, title style and fputs_highlighted function. Highlight style is used by fputs_highlighted to highlight the parts of its char *STR argument that match a HIGHLIGHT regexp. This (and the title style) will be used in a following patch.
2019-06-02Remove fromhex implementation from gdbreplayTom Tromey3-20/+7
gdbreplay had its own implementation of fromhex. This patch changes it to use the one in common/. gdb/gdbserver/ChangeLog 2019-06-02 Tom Tromey <tom@tromey.com> * gdbreplay.c (fromhex): Remove. * Makefile.in (GDBREPLAY_OBS): Add rsp-low.o.
2019-05-31NEWS and documentation for | (pipe) command.Philippe Waroquiers4-0/+102
gdb/ChangeLog * NEWS: Mention new pipe command and new convenience variables. gdb/doc/ChangeLog * gdb.texinfo (Shell Commands): Document pipe command. (Logging Output): Add a reference to pipe command. (Convenience Variables): Document $_shell_exitcode and $_shell_exitstatus.
2019-05-31Test the | (pipe) command.Philippe Waroquiers3-1/+97
gdb/testsuite/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/shell.exp: Test pipe command, $_shell_exitcode, $_shell_exitsignal. * gdb.base/default.exp: Update for new convenience variables.
2019-05-31Implement | (pipe) command.Philippe Waroquiers3-2/+116
The pipe command allows to run a GDB command, and pipe its output to a shell command: (gdb) help pipe Send the output of a gdb command to a shell command. Usage: | [COMMAND] | SHELL_COMMAND Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND Usage: pipe [COMMAND] | SHELL_COMMAND Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND Executes COMMAND and sends its output to SHELL_COMMAND. The -d option indicates to use the string DELIM to separate COMMAND from SHELL_COMMAND, in alternative to |. This is useful in case COMMAND contains a | character. With no COMMAND, repeat the last executed command and send its output to SHELL_COMMAND. (gdb) For example: (gdb) pipe print some_data_structure | grep -B3 -A3 something The pipe character is defined as an alias for pipe command, so that the above can be typed as: (gdb) | print some_data_structure | grep -B3 -A3 something If no GDB COMMAND is given, then the previous command is relaunched, and its output is sent to the given SHELL_COMMAND. This also defines convenience vars $_shell_exitcode and $_shell_exitsignal to record the exit code and exit signal of the last shell command launched by GDB e.g. by "shell", "pipe", ... gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (pipe_command): New function. (_initialize_cli_cmds): Call add_com for pipe_command. Define | as an alias for pipe. (exit_status_set_internal_vars): New function. (shell_escape): Call exit_status_set_internal_vars. cli/cli-decode.c (find_command_name_length): Recognize | as a single character command.
2019-05-31Add function execute_command_to_ui_filePhilippe Waroquiers3-13/+32
2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdbcmd.h (execute_command_to_ui_file): New declaration. top.c (execute_command_to_ui_file): New function, mostly a copy of execute_command_to_string. (execute_command_to_string): Implement by calling execute_command_to_ui_file.
2019-05-31Add previous_saved_command_line to allow a command to repeat a previous command.Philippe Waroquiers6-24/+125
Currently, a previous command can be repeated when the user types an empty line. This is implemented in handle_line_of_input by returning saved_command_line in case an empty line has been input. If we want a command to repeat the previous command, we need to save the previous saved_command_line, as when a command runs, the saved_command_line already contains the current command line of the command being executed. As suggested by Tom, the previous_saved_command_line is made static. At the same time, saved_command_line is also made static. The support functions/variables for the repeat command logic are now all located inside top.c. gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.h (saved_command_line): Remove declaration. * top.c (previous_saved_command_line, previous_repeat_arguments): New variables. (saved_command_line): Make static, define together with other 'repeat variables'. (dont_repeat): Clear repeat_arguments. (repeat_previous, get_saved_command_line, save_command_line): New functions. (gdb_init): Initialize saved_command_line and previous_saved_command_line. * main.c (captured_main_1): Remove saved_command_line initialization. * event-top.c (handle_line_of_input): Update to use the new 'repeat' related functions instead of direct access to saved_command_line. * command.h (repeat_previous, get_saved_command_line, save_command_line): New declarations. (dont_repeat): Add comment.
2019-05-30Two comment fixes in gdbtypes.hTom Tromey2-2/+9
This fixes a couple of comments in gdbtypes.h. One comment had a typo; and another comment referred to "Moto", which is presumably some long-gone Motorola-related project. Tested by rebuilding. gdb/ChangeLog 2019-05-30 Tom Tromey <tromey@adacore.com> * gdbtypes.h (struct range_bounds) <flag_upper_bound_is_count>: Fix comment. (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): Rewrite comment.
2019-05-30Initialize variable word in completeJan Vrany2-0/+12
The complete function should set parameter word to the end of the word to complete. However, completion_find_completion_word may fail, leaving word uninitialized. To make sure word is always set, initialize it to the completion point which is the end of the line parameter. gdb/Changelog PR cli/24587 * completer.c (complete): Initialize variable word.
2019-05-29Don't crash is dwarf_decode_macro_bytes's 'body' is NULL, even when '!is_define'Sergio Durigan Junior2-17/+22
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008 On commit 7bede82892a06e6c26989803e70f53697392dcf9 ("Don't crash if dwarf_decode_macro_bytes's 'body' is NULL"), I was too strict when checking if 'body' is NULL: the check only comprised the case when 'is_define' is true. However, the corruption of .debug_macro by rpmbuild's "debugedit" also affects the case when 'is_define' is false, i.e., when the macro is being undefined. This commit improves the check and covers both cases now. This has been tested on Fedora 30 with a problematic debuginfo, and I don't see a segfault anymore. OK to push? gdb/ChangeLog: 2019-05-29 Sergio Durigan Junior <sergiodj@redhat.com> Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192 Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008 * dwarf2read.c (dwarf_decode_macro_bytes): Move check to see if 'body' is NULL to the outter 'if', protecting the '!is_define' situation as well.
2019-05-29Fix failure in gdb.ada/complete.expTom Tromey2-2/+8
I noticed a failure in gdb.ada/complete.exp when testing locally: FAIL: gdb.ada/complete.exp: complete break ada This failed due to this output: [...] break ada/generated/gnatvsn.ads break ada/libgnat/s-excmac.ads break ada/sdefault.adb break ada/snames.adb break ada/snames.ads This patch updates the regexp to allow "/" and "-" to appear. gdb/testsuite/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * gdb.ada/complete.exp (test_gdb_no_completion): Add "/" and "-" to "break complete ada" test case's regexp.
2019-05-29Make some DWARF complaints clearerTom Tromey2-6/+26
I noticed that the complaint in partial_die_parent_scope was not using dwarf_tag_name, so I changed that. Then I noticed that dwarf_tag_name does not show the numeric value for an unrecognized tag, so I changed that function and all the related functions to do so. gdb/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * dwarf2read.c (partial_die_parent_scope): Call dwarf_tag_name. (dwarf_unknown): New function. (dwarf_tag_name, dwarf_attr_name, dwarf_form_name) (dwarf_type_encoding_name): Use dwarf_unknown.
2019-05-29Fix crash in cp_print_value_fieldsTom Tromey5-7/+90
PR c++/20020 concerns a crash in cp_print_value_fields. The immediate cause is that cp_print_value_fields does not handle the case where value_static_field fails. This is fixed in this patch by calling cp_print_static_field from the "try" block. Digging a bit deeper, the error occurs because GCC does not emit a DW_AT_const_value for a static constexpr member appearing in a template class. I've filed a GCC bug for this. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> PR c++/20020: * cp-valprint.c (cp_print_value_fields): Call cp_print_static_field inside "try". gdb/testsuite/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> PR c++/20020: * gdb.cp/constexpr-field.exp: New file. * gdb.cp/constexpr-field.cc: New file.
2019-05-29Add new GCC 9 warnings to warnings.m4Tom Tromey6-3/+25
GCC 9 has a few new warnings that aren't enabled in the gdb build by default: -Wdeprecated-copy, -Wdeprecated-copy-dtor, and -Wredundant-move. This patch enables them all. Tested by rebuilding with a new GCC (git master) on x86-64 Fedora 29. gdb/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * inflow.c (struct terminal_info): Add default operator=. * configure: Rebuild. * warning.m4 (AM_GDB_WARNINGS): Add -Wdeprecated-copy, -Wdeprecated-copy-dtor, -Wredundant-move. gdb/gdbserver/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * configure: Rebuild.
2019-05-29Add "set print finish"Tom Tromey9-5/+87
A user wanted to be able to disable the display of the value when using "finish" -- but still have the value entered into the value history in case it was useful later on. Part of the rationale here is that sometimes the value might be quite large, or expensive to display (in their case this was compounded by a rogue pretty-printer). This patch implements this idea. gdb/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * NEWS: Add entry. * infcmd.c (print_return_value_1): Handle finish_print option. (show_print_finish): New function. (_initialize_infcmd): Add "set/show print finish" commands. * valprint.c (user_print_options): Initialize new member. * valprint.h (struct value_print_options) <finish_print>: New member. gdb/doc/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Continuing and Stepping): Document new commands. gdb/testsuite/ChangeLog 2019-05-29 Tom Tromey <tromey@adacore.com> * gdb.base/finish.exp (finish_no_print): New proc. (finish_tests): Call it.
2019-05-28Remove find_old_style_renaming_symbolTom Tromey4-187/+22
We found a case where a "bt" was very slow with Ada code. Profiling with callgrind showed this to be primarily due to calls to find_old_style_renaming_symbol. Because new-style renaming symbols were implemented in 2007, it seems safe enough to remove this old code. A "-batch -ex bt" test on a large Ada program improves from: 13.23user 0.57system 0:13.82elapsed 99%CPU (0avgtext+0avgdata 571408maxresident)k to 4.25user 0.48system 0:04.74elapsed 99%CPU (0avgtext+0avgdata 559844maxresident)k with this patch. Tested on x86-64 Fedora 29. Joel reviewed this internally; and as it is Ada-specific, I am checking it in. gdb/ChangeLog 2019-05-28 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_remove_Xbn_suffix) (find_old_style_renaming_symbol) (parse_old_style_renaming): Remove. (ada_find_renaming_symbol): Don't call find_old_style_renaming_symbol. (ada_is_renaming_symbol): Rename from ada_find_renaming_symbol. Remove "block" parameter. Return bool. Now static. (ada_read_var_value): Update and simplify. * ada-exp.y (write_var_or_type): Remove old code.
2019-05-28Suppress SIGTTOU when handling errorsAlan Hayward6-31/+45
Calls to error () can cause SIGTTOU to send gdb to the background. For example, on an Arm build: (gdb) b main Breakpoint 1 at 0x10774: file /build/gdb/testsuite/../../../src/binutils-gdb/gdb/testsuite/gdb.base/watchpoint.c, line 174. (gdb) r Starting program: /build/gdb/testsuite/outputs/gdb.base/watchpoint/watchpoint [1]+ Stopped ../gdb ./outputs/gdb.base/watchpoint/watchpoint localhost$ fg ../gdb ./outputs/gdb.base/watchpoint/watchpoint Cannot parse expression `.L1199 4@r4'. warning: Probes-based dynamic linker interface failed. Reverting to original interface. The SIGTTOU is raised whilst inside a syscall during the call to tcdrain. Fix is to use scoped_ignore_sigttou to ensure SIGTTOU is blocked. In addition fix include comments - job_control is not included via terminal.h gdb/ChangeLog: * event-top.c: Remove include comment. * inflow.c (class scoped_ignore_sigttou): Move from here... * inflow.h (class scoped_ignore_sigttou): ...to here. * ser-unix.c (hardwire_drain_output): Block SIGTTOU during drain. * top.c: Remove include comment.
2019-05-27Fix typo in gdb/NEWSTom Tromey2-1/+5
I noticed a typo in gdb/NEWS. This fixes it. gdb/ChangeLog 2019-05-27 Tom Tromey <tom@tromey.com> * NEWS: Fix typo.
2019-05-24[gdb/testsuite] Add test-case for gdb-add-index.shTom de Vries2-0/+78
Add a test-case gdb.dwarf2/gdb-add-index.exp to test gdb/contrib/gdb-add-index.sh. Tested with x86_64-linux. gdb/testsuite/ChangeLog: 2019-05-24 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/gdb-add-index.exp: New file.
2019-05-22Constify target_ops::follow_execTom Tromey6-12/+21
I noticed that target_ops::follow_exec took a "char *" parameter, where "const char *" would be more correct. This patch changes this (and related functions) to be constified. Tested by rebuilding. gdb/ChangeLog 2019-05-22 Tom Tromey <tromey@adacore.com> * target.c (target_follow_exec): Constify parameter. * target-delegates.c: Rebuild. * remote.c (remote_target::follow_exec): Constify parameter. * infrun.c (follow_exec): Constify parameter. * target.h (struct target_ops) <follow_exec>: Constify parameter. (target_follow_exec): Likewise.
2019-05-22Add "style" proc to the test suiteTom Tromey4-8/+35
This adds a "style" helper proc to the test suite, and updates existing style tests to use it. Thanks to Sergio for the idea. Tested on x86-64 Fedora 29. gdb/testsuite/ChangeLog 2019-05-22 Tom Tromey <tromey@adacore.com> * gdb.base/info-shared.exp (check_info_shared): Use "style". * gdb.base/style.exp: Use "style". * lib/gdb-utils.exp (style): New proc.
2019-05-22[gdb/testsuite] Require c++11 for gdb.base/align.expTom de Vries2-1/+9
When building gdb on ubuntu 16.04 with gcc 5.4.0, and running the gdb testsuite we run into a failure due align.exp requiring at least c++11. Fix this by adding -std=c++11. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-05-22 Tom de Vries <tdevries@suse.de> * gdb.base/align.exp: Require c++11.
2019-05-22[gdb/testsuite] Add missing mi_skip_python_tests to ↵Tom de Vries2-0/+9
py-mi-var-info-path-expression.exp Fix gdb.python/py-mi-var-info-path-expression.exp for a gdb build without python support. gdb/testsuite/ChangeLog: 2019-05-22 Tom de Vries <tdevries@suse.de> PR testsuite/24586 * gdb.python/py-mi-var-info-path-expression.exp: Call mi_skip_python_tests to check if python is supported.
2019-05-22AArch64: Treat pauth ops as nops on non-pauth systemsAlan Hayward5-1/+94
Running an address signed binary through GDB on a non pauth system gives the following error: Call Frame Instruction op 45 in vendor extension space is not handled on this architecture. Instead GDB should ignore the op, treating it as a nop. Add test case for pauth binaries, regardless of whether the target supports it. gdb/ChangeLog: * aarch64-tdep.c (aarch64_execute_dwarf_cfa_vendor_op): Treat DW_CFA_AARCH64_negate_ra_state as nop on non pauth targets. gdb/testsuite/ChangeLog: * gdb.arch/aarch64-pauth.c: New test. * gdb.arch/aarch64-pauth.exp: New file.
2019-05-22Document gdb.in/gdb.cmd files and debugredirect cli commandAlan Hayward6-0/+47
Add missing documentation for the debugredirect setting. Add description and uses of gdb.in/gdb.cmd to the testsuite README. Mention this in the NEWS file. gdb/ChangeLog: * NEWS: Add debugredirect and testsuite sections. gdb/doc/ChangeLog: * gdb.texinfo (Shell Commands): Add debugredirect. gdb/testsuite/ChangeLog: * README (Re-running Tests Outside The Testsuite): New section.