aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2019-07-14[gdb/testsuite] Fix unterminated string in gdb.objc/basicclass.expTom de Vries2-1/+6
The test-case gdb.objc/basicclass.exp contains an unterminated string, introduced in refactoring commit fa43b1d7ca "after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test". Fix the unterminated string. gdb/testsuite/ChangeLog: 2019-07-14 Tom de Vries <tdevries@suse.de> PR testsuite/24760 * gdb.objc/basicclass.exp: Fix unterminated string.
2019-07-12gdb: Better support for dynamic properties with negative valuesAndrew Burgess5-0/+75
When the type of a property is smaller than the CORE_ADDR in which the property value has been placed, and if the property is signed, then sign extend the property value from its actual type up to the size of CORE_ADDR. gdb/ChangeLog: * dwarf2loc.c (dwarf2_evaluate_property): Sign extend property value if its desired type is smaller than a CORE_ADDR and signed. gdb/testsuite/ChangeLog: * gdb.fortran/vla-ptype.exp: Print array with negative bounds. * gdb.fortran/vla-sizeof.exp: Print the size of an array with negative bounds. * gdb.fortran/vla-value.exp: Print elements of an array with negative bounds. * gdb.fortran/vla.f90: Setup an array with negative bounds for testing.
2019-07-11gdb: Allow quoting around string options in the gdb::option frameworkAndrew Burgess2-17/+45
Currently string options must be a single string with no whitespace, this limitation prevents the gdb::option framework being used in some places. After this commit, string options can be quoted in single or double quotes, and quote characters can be escaped with a backslash if needed to either place them within quotes, or to avoid starting a quoted argument. This test adds a new function extract_string_maybe_quoted which is basically a copy of extract_arg_maybe_quoted from cli/cli-utils.c, however, the cli-utils.c function will be deleted in the next commit. There are tests to exercise the new quoting mechanism. gdb/ChangeLog: * cli/cli-option.c (parse_option): Use extract_string_maybe_quoted to extract string arguments. * common/common-utils.c (extract_string_maybe_quoted): New function. * common/common-utils.h (extract_string_maybe_quoted): Declare. gdb/testsuite/ChangeLog: * gdb.base/options.exp (expect_string): Dequote strings in results. (test-string): Test strings with different quoting and reindent.
2019-07-10Change Ada catchpoints to be bp_catchpointTom Tromey7-13/+24
Like Pedro's earlier patches to change catchpoint to be of type bp_catchpoint, this changes the Ada catchpoints to follow. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-07-10 Tom Tromey <tromey@adacore.com> * ada-lang.h (is_ada_exception_catchpoint): Declare. * breakpoint.c (init_ada_exception_breakpoint): Register as bp_catchpoint. (print_one_breakpoint_location, print_one_breakpoint): Use is_ada_exception_catchpoint. * ada-lang.c (class ada_catchpoint_location): Pass bp_loc_software_breakpoint to bp_location constructor. (is_ada_exception_catchpoint): New function. gdb/testsuite/ChangeLog 2019-07-10 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_ex_cond.exp: Update expected results. * gdb.ada/mi_catch_ex_hand.exp: Update expected results. * gdb.ada/mi_catch_ex.exp: Update expected results. * gdb.ada/mi_catch_assert.exp: Update expected results. * gdb.ada/catch_ex.exp (catch_exception_info) (catch_exception_entry, catch_assert_entry) (catch_unhandled_entry): Update. * gdb.ada/catch_assert_if.exp: Update expected results.
2019-07-10Restore original GDB prompt in define.expRichard Bunt2-1/+15
define.exp will fail on a GDB which has set a custom prompt to identify itself. This is because the test resets the prompt to a hard coded "(gdb)" but then verifies the success of this against the value in $gdb_prompt, which is set to the custom prompt. The original approach to fix this involved resetting the prompt to $gdb_prompt rather than a hard coded "(gdb)". However it was noted during review that $gdb_prompt is a regular expression rather than a string. This is problematic because in general the prompt would be reset to a regular expression rather than an instance of a string accepted by said regular expression. The fix used in this commit avoids the above issue by capturing the literal prompt from running "show prompt" and uses this literal to restore the previous prompt. Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64. gdb/testsuite/ChangeLog: 2019-07-10 Richard Bunt <richard.bunt@arm.com> Stephen Roberts <stephen.roberts@arm.com> * gdb.base/define.exp: Restore original prompt.
2019-07-09"catch catch/throw/rethrow", breakpoint -> catchpointPedro Alves5-21/+20
Currently, with: (gdb) catch catch Catchpoint 1 (catch) (gdb) catch throw Catchpoint 2 (throw) (gdb) catch rethrow Catchpoint 3 (rethrow) You get: (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x0000000000b122af exception catch 2 breakpoint keep y 0x0000000000b1288d exception throw 3 breakpoint keep y 0x0000000000b12931 exception rethrow I think it doesn't make much sense usability-wise, to show a catchpoint as a breakpoint. The fact that GDB sets a breakpoint at some magic address in the C++ run time is an implementation detail, IMO. And as seen in the previous patch, such a catchpoint can end up with more than one location/address even, so showing a single address isn't entirely accurate. This commit hides the addresses from view, and makes GDB show "catchpoint" for type as well: (gdb) info breakpoints Num Type Disp Enb Address What 1 catchpoint keep y exception catch 2 catchpoint keep y exception throw 3 catchpoint keep y exception rethrow This comment in the code seems telling: /* We need to reset 'type' in order for code in breakpoint.c to do the right thing. */ cp->type = bp_breakpoint; It kind of suggests that the reason catchpoints end up shown as breakpoints was that it was easier to implement them that way, rather than a desired property. This commit fixes things up to make it possible to have bp_catch breakpoints have software/hardware breakpoint locations, thus eliminating the need for that hack: - redo breakpoint_address_is_meaningful in terms of the location's type rather than breakpoint type. - teach bpstat_what about stepping over the catchpoint locations. - install a allocate_location method for "catch catch/throw/rethrow", one that forces the location type. Note that this also reverts the gdb hunk from: commit 2a8be20359dba9cc684fd3ffa222d985399f3b18 Commit: Tom Tromey <tom@tromey.com> CommitDate: Sat Oct 6 22:17:45 2018 -0600 Fix Python gdb.Breakpoint.location crash because now "catch throw" catchpoints hit the if (obj->bp->type != bp_breakpoint) Py_RETURN_NONE; check above, and, adjusts the testcase to no longer expect to see the catchpoint in the gdb.breakpoints() list. (Note: might make sense to do the same to Ada exception catchpoints.) gdb/ChangeLog: 2019-07-09 Pedro Alves <palves@redhat.com> * break-catch-throw.c (print_one_exception_catchpoint): Skip the "addr" field. (allocate_location_exception_catchpoint): New. (handle_gnu_v3_exceptions): Don't reset 'type' to bp_breakpoint. (initialize_throw_catchpoint_ops): Install allocate_location_exception_catchpoint as allocate_location method. * breakpoint.c (bpstat_what) <bp_catch>: Set action to BPSTAT_WHAT_SINGLE if not stopping and the location's type is not bp_loc_other. (breakpoint_address_is_meaningful): Delete. (bl_address_is_meaningful): New. (breakpoint_locations_match): Adjust comment. (bp_location_from_bp_type): New, factored out of... (bp_location::bp_location(breakpoint *)): ... this. (bp_location::bp_location(breakpoint *, bp_loc_type)): New, factored out of... (bp_location::bp_location(breakpoint *)): ... this. Reimplement. (bp_loc_is_permanent): Use bl_address_is_meaningful instead of breakpoint_address_is_meaningful. (bp_locations_compare): Adjust comment. (update_global_location_list): Use bl_address_is_meaningful instead of breakpoint_address_is_meaningful. * breakpoint.h (bp_location::bp_location(breakpoint *)): New explicit. (bp_location::bp_location(breakpoint *, bp_loc_type)): Declare. * python/py-breakpoint.c (bppy_get_location): No longer check whether location is null. gdb/doc/ChangeLog: 2019-07-09 Pedro Alves <palves@redhat.com> * gdb.texinfo (C++ Exception GDB/MI Catchpoint Commands): Adjust examples to show type=catchpoint instead of type=breakpoint and an address. gdb/testsuite/ChangeLog: 2019-07-09 Pedro Alves <palves@redhat.com> * gdb.cp/catch-multi-stdlib.exp: Adjust expected "info breakpoints" output. * gdb.cp/exception.exp: Adjust expected "info breakpoints" output. * gdb.python/py-breakpoint.exp: No longer expect that "catch throw" creates breakpoint. * gdb.mi/mi-catch-cpp-exceptions.exp (setup_catchpoint): Expect 'type="catchpoint"'.
2019-07-09Fix "info break" + "catch catch" + -static-{libstdc++,libgcc}Pedro Alves4-0/+155
If you debug current GDB, set a "catch catch/throw/rethrow" catchpoint, and then do "info breakpoints", the top GDB hits an internal error: (top-gdb) catch catch Catchpoint 1 (catch) (top-gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y src/gdb/breakpoint.c:6040: internal-error: void print_one_breakpoint_location(breakpoint*, bp_location*, int, bp_location**, int): Assertion `b->loc == NULL || b->loc->next == NULL' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) The assertion in question is asserting that a breakpoint with a print_one method only has one location, and it fails because this catchpoint ends up with two locations. Internally, "catch catch" sets a breakpoint at __cxa_begin_catch. If we do that manually, we see the locations: (top-gdb) b -qualified __cxa_begin_catch Breakpoint 2 at 0xb122b0 (2 locations) (top-gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y <MULTIPLE> 2.1 y 0x0000000000b122b0 <__cxa_begin_catch> 2.2 y 0x00007ffff2f4ddb0 in __cxxabiv1::__cxa_begin_catch(void*) at ../../../../libstdc++-v3/libsupc++/eh_catch.cc:41 Note that I had used -qualified. It seems strange that we get a location for a namespaced symbol, but that happens because the minimal symbol for that address is indeed called __cxa_begin_catch. The real issue is that gdb is linked with -static-libgcc/-static-libstdc++. And then, it _also_ ends up with shared libstc++ loaded: (top-gdb) info sharedlibrary stdc++ From To Syms Read Shared Object Library 0x00007ffff2f4b380 0x00007ffff2ffc018 Yes /lib64/libstdc++.so.6 Location 2.2 is set within libstdc++.so.6's range: (top-gdb) p 0x00007ffff2f4b380 <= 0x00007ffff2f4ddb0 && 0x00007ffff2f4ddb0 < 0x00007ffff2ffc018 $1 = true So due to -static-lib*, we end up with _two_ copies of the __cxa_begin_catch code: (top-gdb) disassemble 0x0000000000b122b0 Dump of assembler code for function __cxa_begin_catch: 0x0000000000b122b0 <+0>: push %rbx 0x0000000000b122b1 <+1>: mov %rdi,%rbx 0x0000000000b122b4 <+4>: callq 0xb11a80 <__cxa_get_globals> 0x0000000000b122b9 <+9>: movabs $0xb8b1aabcbcd4d500,%rdx ... (top-gdb) disassemble 0x00007ffff2f4ddb0 Dump of assembler code for function __cxxabiv1::__cxa_begin_catch(void*): 0x00007ffff2f4ddb0 <+0>: push %rbx 0x00007ffff2f4ddb1 <+1>: mov %rdi,%rbx 0x00007ffff2f4ddb4 <+4>: callq 0x7ffff2f4a090 <__cxa_get_globals@plt> 0x00007ffff2f4ddb9 <+9>: movabs $0xb8b1aabcbcd4d500,%rdx ... I think we end up with libstdc++.so.6 loaded because libsource-highlight.so depends on it. Irrespective of whether it's a good idea to use -static-libgcc/-static-libstdc++, GDB should not crash. Since there are two copies of the code, it seems right to have more than one location. So the fix is just to remove the assertion. A testcase is included, which mimics the scenerio described above, with binary linked with -static-lib{stdc++,gcc} and a shared library that is linked normally, along with other combinations for good measure. gdb/ChangeLog: 2019-07-09 Pedro Alves <palves@redhat.com> PR c++/15468 * breakpoint.c (print_one_breakpoint_location): Remove single-location assert. gdb/testsuite/ChangeLog: 2019-07-09 Pedro Alves <palves@redhat.com> PR c++/15468 * gdb.cp/except-multi-location-lib.cc: New. * gdb.cp/except-multi-location-main.cc: New. * gdb.cp/except-multi-location.exp: New.
2019-07-09Fix printcmds.exp failure for wide strings tests.Philippe Waroquiers2-15/+20
wchar_t type must be known to create wide strings. As this type is predefined when current GDB language is C++, switch to c++ for the wide strings tests. Problem analysis and fix by Sergio.
2019-07-09gdb: Don't skip prologue for explicit line breakpoints in assemblerAndrew Burgess3-0/+75
It was observed that in some cases, placing a breakpoint in an assembler file using filename:line-number syntax would result in the breakpoint being placed at a different line within the file. For example, consider this x86-64 assembler: test: push %rbp /* Break here. */ mov %rsp, %rbp nop /* Stops here. */ The user places the breakpoint using file:line notation targeting the line marked 'Break here', GDB actually stops at the line marked 'Stops here'. The reason is that the label 'test' is identified as the likely start of a function, and the call to symtab.c:skip_prologue_sal causes GDB to skip forward over the instructions that GDB believes to be part of the prologue. I believe however, that when debugging assembler code, where the user has instruction-by-instruction visibility, if they ask for a specific line, GDB should (as far as possible) stop on that line, and not perform any prologue skipping. I don't believe that the behaviour of higher level languages should change, in these cases skipping the prologue seems like the correct thing to do. In order to implement this change I needed to extend our current tracking of when the user has requested an explicit line number. We already tracked this in some cases, but not in others (see the changes in linespec.c). However, once I did this I started to see some additional failures (in tests gdb.base/break-include.exp gdb.base/ending-run.exp gdb.mi/mi-break.exp gdb.mi/mi-reverse.exp gdb.mi/mi-simplerun.exp) where we currently expected a breakpoint placed at one file and line number to be updated to reference a different line number, this was fixed by removing some code in symtab.c:skip_prologue_sal. My concern here is that removing this check didn't cause anything else to fail. I have a new test that covers my original case, this is written for x86-64 as most folk have access to such a target, however, any architecture that has a prologue scanner can be impacted by this change. gdb/ChangeLog: * linespec.c (decode_digits_list_mode): Set explicit_line to a bool value. (decode_digits_ordinary): Set explicit_line field in sal. * symtab.c (skip_prologue_sal): Don't skip prologue for a symtab_and_line that was set on an explicit line number in assembler code. Do always update the recorded symtab and line if we do skip the prologue. gdb/testsuite/ChangeLog: * gdb.arch/amd64-break-on-asm-line.S: New file. * gdb.arch/amd64-break-on-asm-line.exp: New file.
2019-07-08Ensure GDB printf command can print convenience var strings without a target.Philippe Waroquiers2-5/+60
Without this patch, GDB printf command calls malloc on the target, writes the convenience var content to the target, re-reads the content from the target, and then locally printf the string. This implies inferior calls, and does not work when there is no running inferior, or when the inferior is a core dump. With this patch, printf command can printf string convenience variables without inferior function calls. Ada string convenience variables can also be printed. gdb/ChangeLog 2019-07-08 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Mention that GDB printf and eval commands can now print C-style and Ada-style convenience var strings without calling the inferior. * printcmd.c (printf_c_string): Locally print GDB internal var instead of transiting via the inferior. (printf_wide_c_string): Likewise. gdb/testsuite/ChangeLog 2019-07-08 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/printcmds.exp: Test printing C string and C wide string convenience vars without transiting via the inferior. Also make test names unique.
2019-07-08Fix breakpoints on file reloads for PIE binariesAlan Hayward2-30/+40
When a binary is built using PIE, reloading the file will cause GDB to error on restart. For example: gdb ./a.out (gdb) break main (gdb) run (gdb) file ./a.out (gdb) continue Will cause GDB to error with: Continuing. Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x9e0 Command aborted. This is due to the symbol offsets not being relocated after reloading the file. Fix is to ensure solib_create_inferior_hook is called, in the same manner as infrun.c:follow_exec(). Expand the idempotent test to cover PIE scenarios. gdb/ChangeLog: * symfile.c (symbol_file_command): Call solib_create_inferior_hook. gdb/testsuite/ChangeLog: * gdb.base/break-idempotent.exp: Test both PIE and non PIE.
2019-07-04Fix foreach_with_prefix regressionPedro Alves3-1/+107
Fix a silly bug in commit a26c8de0ee93 ("Fix early return in foreach_with_prefix"). That patch made foreach_with_prefix always return after the first iteration, making ~10k tests disappear from test runs... This fixes it, and as penance, adds a testcase that exercises all kinds of different returns possible (ok, error, return, break, continue). I've written it with regular "foreach", and then switched to foreach_with_prefix and made sure we get the same results. I put the testcase in a new gdb.testsuite/ subdir, since this is exercising the testsuite harness bits. We can move this elsewhere if people prefer a different place, but I'm going ahead in order to unbreak the testsuite ASAP. gdb/testsuite/ChangeLog: 2019-07-04 Pedro Alves <palves@redhat.com> * lib/gdb.exp (foreach_with_prefix): Don't return early if body returned ok(0), break(3) or continue(4). * gdb.testsuite/foreach_with_prefix.exp: New file.
2019-07-04i386/AArch64: Remove old xml testsAlan Hayward2-1/+5
Both the i386, X86_64 and AArch64 builds of gdbserver include a bunch of legacy xml files, dat files and auto generated C files, when building for unit test. These tests exists back from when feature target descriptions were added to prove that the new target descriptions were identical to the original older versions. The old files are not used for anything other than these tests. Now that this has been proven, we are not gaining anything by keeping the original files and tests. Should new functionality be added, it would break the tests, unless the functionality was backported to the xml. There is no requirement that we must match the exact xml from N releases ago. It adds obfuscation, where as the feature target descriptions were meant to simplify the code. In addition, there are a bunch of xml and dat files which are completely unused. This patch removes the selftests and the target descriptions from gdbserver. Update the unittest to allow 0 tests (note, this failed on other targets that never had any tests). gdb/ChangeLog: * aarch64-tdep.c: Remove xml self tests. * amd64-linux-tdep.c: Likewise. * amd64-tdep.c: Likewise. * i386-linux-tdep.c: Likewise. * i386-tdep.c: Likewise. gdb/gdbserver/ChangeLog: * configure.srv: Remove legacy xml. * linux-aarch64-low.c (initialize_low_arch): Remove initialize_low_tdesc call. * linux-aarch64-tdesc-selftest.c: Remove file. * linux-aarch64-tdesc.h (initialize_low_tdesc): Remove. * linux-x86-low.c (initialize_low_arch): Remove initialize_low_tdesc call. * linux-x86-tdesc-selftest.c: Remove file. * linux-x86-tdesc.h (initialize_low_tdesc): Remove. gdb/testsuite/ChangeLog: * gdb.server/unittest.exp: Allow 0 unit tests to run.
2019-07-03Fix early return in foreach_with_prefixPedro Alves2-1/+13
I noticed that an early return in a foreach_with_prefix block does not cause the outer scope to return, like: foreach_with_prefix var {"foo" "bar"} { return } # Control continues here, but it should not. The problem is that we're missing the usual "return -code" treatment. This commit fixes it. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * lib/gdb.exp (foreach_with_prefix): Use "catch" and "return -code".
2019-07-03pipe command completerPedro Alves2-2/+51
This commit adds a completer for the "pipe" command. It can complete "pipe"'s options, and the specified GDB command. To make the completer aware of the "-d" option, this converts the option processing to use gdb::option. Tests included. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> PR cli/24732 * cli/cli-cmds.c (struct pipe_cmd_opts): New. (pipe_cmd_option_defs): New. (make_pipe_cmd_options_def_group): New. (pipe_command): Use gdb::option::process_options. (pipe_command_completer): New function. (_initialize_cli_cmds): Install completer for "pipe" command. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> PR cli/24732 * gdb.base/shell.exp: Load completion-support.exp. Adjust expected error output. Add completion tests.
2019-07-03Fix latent bug in test_gdb_complete_cmd_multiplePedro Alves2-1/+7
A following patch will add the following to a testcase: test_gdb_completion_offers_commands "| " And that tripped on a latent testsuite bug: (gdb) | PASS: gdb.base/shell.exp: tab complete "| " ^CQuit (gdb) complete | | ! | + PASS: gdb.base/shell.exp: cmd complete "| " | *** List may be truncated, max-completions reached. *** (gdb) FAIL: gdb.base/shell.exp: set max-completions 200 set max-completions 200 The issue is that "|" ends up as part of a regexp, and "|" in regexps has a special meaning... Fix this with string_to_regexp. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * lib/completion-support.exp (test_gdb_complete_cmd_multiple): Use string_to_regexp.
2019-07-03Teach gdb::option about string optionsPedro Alves2-17/+75
A following patch will make the "pipe" command use the gdb::option framework for option processing. However, "pipe"'s only option today is a string option, "-d DELIM", and gdb::option does not support string options yet. This commit adds support for string options, mapped to var_string. For now, a string is parsed up until the first whitespace. I imagine that we'll need to add support for quoting so that we could do: (gdb) cmd -option 'some -string' without gdb confusing the "-string" for an option. This doesn't seem important for pipe, so I'm leaving it for another day. One thing I'm not happy with, is that the string data is managed as a raw malloc-allocated char *, which means that we need to xfree it manually. This is because var_string settings work that way too. Although with var_string settings we're leaking the strings at gdb exit, that was never really a problem. For options though, leaking is undesirable. I think we should tackle that for both settings and options at the same time, so for now I'm just managing the malloced data manually. It's a bit ugly in option_def_and_value, but at least that's hidden from view. For testing, this adds a new "-string" option to "maint test-settings", and then tweaks gdb.base/options.exp to exercise it. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * cli/cli-option.c (union option_value) <string>: New field. (struct option_def_and_value): Add ctor, move ctor, dtor and use DISABLE_COPY_AND_ASSIGN. (option_def_and_value::clear_value): New. (parse_option, save_option_value_in_ctx, get_val_type_str) (add_setshow_cmds_for_options): Handle var_string. * cli-option.h (union option_def::var_address) <string>: New field. (struct string_option_def): New. * maint-test-options.c (struct test_options_opts): Add default ctor and use DISABLE_COPY_AND_ASSIGN. <string_opt>: New field. (test_options_opts::~test_options_opts): New. (test_options_opts::dump): Also dump "-string". (test_options_option_defs): Install "string. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (expect_none, expect_flag, expect_bool) (expect_integer): Adjust to expect "-string". (expect_string): New. (all_options): Expect "-string". (test-flag, test-boolean): Adjust to expect "-string". (test-string): New proc. (top level): Call it.
2019-07-03Make gdb::option::complete_options save processed arguments tooPedro Alves2-29/+87
Currently, gdb::option::complete_options just discards any processed option argument, because no completer needs that data. When completing "pipe -d XXX gdbcmd XXX" however, the completer needs to know about -d's argument (XXX), in order to know where input is already past the gdb command and the delimiter. In this commit, the fix for that is the factoring out of the save_option_value_in_ctx function and calling it in complete_options. For testing, this makes "maint show test-options-completion-result" show the processed options too, like what the "maint test-options" subcommands output when run. Then, of course, gdb.base/options.exp is adjusted. Doing this exposed a couple latent bugs, which is what the other gdb changes in the patch are for: - in the var_enum case, without the change, we'd end up with a null enum argument, and print: "-enum (null)" - The get_ulongest change is necessary to avoid advancing PP in a case where we end up throwing an error, e.g., when parsing "11x". Without the change the operand pointer shown by "maint show test-options-completion-result" would be left pointing at "x" instead of "11x". gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * cli/cli-option.c (parse_option) <var_enum>: Don't return an option_value with a null enumeration. (complete_options): Save the option values in the context. (save_option_value_in_ctx): New, factored out from ... (process_options): ... here. * cli/cli-utils.c (get_ulongest): Don't advance PP until the end of the function. * maint-test-options.c (test_options_opts::dump): New, factored out from ... (maintenance_test_options_command_mode): ... here. (maintenance_test_options_command_completion_result): Delete. (maintenance_test_options_command_completion_text): Update comment. (maintenance_show_test_options_completion_result): Change prototype. Just print maintenance_test_options_command_completion_text. (save_completion_result): New. (maintenance_test_options_completer_mode): Pass options context to complete_options, and then save a dump. (_initialize_maint_test_options): Use add_cmd to install "maint show test-options-completion-result". gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (test-misc, test-flag, test-boolean) (test-uinteger, test-enum): Adjust res_test_gdb_... calls to pass the expected output in the success.
2019-07-03Fix test_gdb_complete_tab_multiple racePedro Alves2-2/+11
Running 'make check-read1 TESTS="gdb.base/options.exp"' revealed a race in test_gdb_complete_tab_multiple. There's a gdb_test_multiple call that expects a prompt in the middle of the regexp. That's racy because gdb_test_multiple includes a built-in FAIL pattern for the prompt, which may match if gdb is slow enough to produce the rest of the output after the prompt. Fix this in the usual way of splitting the matching in two. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * lib/completion-support.exp (test_gdb_complete_tab_multiple): Split one gdb_test_multiple call in two to avoid a race.
2019-07-03Introduce the "with" commandPedro Alves3-0/+335
( See original discussion and prototype here: https://sourceware.org/ml/gdb-patches/2019-05/msg00570.html ) (gdb) help with Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING. Usage: with SETTING [VALUE] [-- COMMAND] Usage: w SETTING [VALUE] [-- COMMAND] With no COMMAND, repeats the last executed command. SETTING is any setting you can change with the "set" subcommands. E.g.: with language pascal -- print obj with print elements unlimited -- print obj As can be seen above, the "with" command is just like "set", but instead of setting the setting permanently, it sets the setting, runs a command and then restores the setting. (gdb) p g_s $1 = {a = 1, b = 2, c = 3} (gdb) with language ada -- print g_s $2 = (a => 1, b => 2, c => 3) Warning: the current language does not match this frame. (gdb) show language The current source language is "auto; currently c". (gdb) with print elements 100 -- with print object on -- print 1 $3 = 1 You can shorten things a bit though, as long as unambiguous. So this: (gdb) with print elements 100 -- with print object off -- print 1 is the same as: (gdb) w p el 100 -- w p o 0 -- p 1 Note that the patch adds a "w" alias for "with", as "w" is not currently taken: (gdb) w Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws. Let me know if you'd prefer to reserve "w" for one of the other commands above. IMHO, this command will end up being used frequently enough that it deserves the "w" shorthand. A nice feature is that this is fully integrated with TAB-completion: (gdb) with p[TAB] pagination print prompt python (gdb) with print [TAB] address max-depth static-members array max-symbolic-offset symbol array-indexes null-stop symbol-filename asm-demangle object symbol-loading demangle pascal_static-members thread-events elements pretty type entry-values raw union frame-arguments repeats vtbl inferior-events sevenbit-strings (gdb) with print [TAB] (gdb) with print elements unlimited -- thread apply all -[TAB] -ascending -c -q -s (gdb) with print elements unlimited -- print -[TAB] -address -max-depth -repeats -vtbl -array -null-stop -static-members -array-indexes -object -symbol -elements -pretty -union The main advantage of this new command compared to command options, like the new "print -OPT", is that this command works with any setting, and, it works nicely when you want to override a setting while running a user-defined command, like: (gdb) with print pretty -- usercmd The disadvantage is that it isn't as compact or easy to type. I think of command options and this command as complementary. I think that even with this new command, it makes sense to continue developing the command options in the direction of exposing most-oft-used settings as command options. Inspired by Philippe's "/" command proposal, if no command is specified, then the last command is re-invoked, under the overridden setting: (gdb) p g_s $1 = {a = 1, b = 2, c = 3} (gdb) with language ada $2 = (a => 1, b => 2, c => 3) Warning: the current language does not match this frame. Note: "with" requires "--" to separate the setting from the command. It might be possible to do without that, but, I haven't tried it yet, and I think that this can go in without it. We can always downgrade to making "--" optional if we manage to make it work. On to the patch itself, the implementation of the command is simpler than one might expect. A few details: - I factored out a bit from pipe_command into repeat_previous directly, because otherwise I'd need to copy&paste the same code and same error message in the with command. - The parse_cli_var_uinteger / parse_cli_var_zuinteger_unlimited / do_set_command changes are necessary since we can now pass an empty string as argument. - do_show_command was split in two, as a FIXME comment suggests, but for a different reason: we need to get a string version of a "set" command's value, and we already had code for that in do_show_command. That code is now factored out to the new get_setshow_command_value_string function. - There's a new "maint with" command added too: (gdb) help maint with Like "with", but works with "maintenance set" variables. Usage: maintenance with SETTING [VALUE] [-- COMMAND] With no COMMAND, repeats the last executed command. SETTING is any setting you can change with the "maintenance set" subcommands. "with" and "maint with" share 99% of the implementation. This might be useful on its own, but it's also useful for testing, since with this, we can use the "maint set/show test-settings" settings for exercising the "with" machinery with all the command type variants (all enum var_types). This is done in the new gdb/base/with.exp testcase. The documentation bits are originally based on Philippe's docs for the "/" command, hence the attribution in the ChangeLog. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "with" and "maint with". * cli/cli-cmds.c (with_command_1, with_command_completer_1) (with_command, with_command_completer): New. (pipe_command): Adjust to new repeat_previous interface. (_initialize_cli_cmds): Install the "with" command and its "w" alias. * cli/cli-cmds.h (with_command_1, with_command_completer_1): New declarations. * cli/cli-setshow.c (parse_cli_var_uinteger) (parse_cli_var_zuinteger_unlimited, do_set_command): Handle empty argument strings for all var_types. (get_setshow_command_value_string): New, factored out from ... (do_show_command): ... this. * cli/cli-setshow.h: Include <string>. (get_setshow_command_value_string): Declare. * command.h (repeat_previous): Now returns const char *. Adjust comment. * maint.c: Include "cli/cli-cmds.h". (maintenance_with_cmd, maintenance_with_cmd_completer): New. (_initialize_maint_cmds): Register the "maintenance with" command. * top.c (repeat_previous): Move bits from pipe_command here: Return the saved command line, if any; error out if there's no command to relaunch. gdb/doc/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Command Settings): New node documenting the general concept of settings, how to change them, and the new "with" command. (Maintenance Commands): Document "maint with". gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/with.c: New file. * gdb.base/with.exp: New file.
2019-07-03"maint test-settings set/show" -> "maint set/show test-settings"Pedro Alves2-13/+20
This commit renames "maint test-settings set/show" to "maint set/show test-settings". This helps the following patch, which introduce a "maint with" command what works with all "maint set" settings. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "maint set/show test-settings" instead of "maint test-settings". * maint-test-settings.c (maintenance_test_settings_list): Delete. (maintenance_test_settings_set_list): Rename to ... (maintenance_set_test_settings_list): ... this. (maintenance_test_settings_show_list): Rename to ... (maintenance_show_test_settings_list): ... this. (maintenance_test_settings_cmd): Delete. (maintenance_test_settings_set_cmd): ... (maintenance_set_test_settings_cmd): ... this. (maintenance_test_settings_show_cmd): ... (maintenance_show_test_settings_cmd): ... this. (maintenance_test_settings_show_value_cmd): (maintenance_show_test_settings_value_cmd): ... this. (_initialize_maint_test_settings): No longer install the "maint test-settings" prefix command. Rename "maint test-settings set" to "maint set test-settings", and "maint test-settings show" to "maint show test-settings". Adjust all subcommands. gdb/doc/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.texinfo (Maintenance Commands): Document "maint set/show test-settings" instead of "maint test-settings set/show". gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/settings.exp: Replace all references to "maint test-settings set" with references to "maint set test-settings", and all references to "maint test-settings show" with references to "maint show test-settings".
2019-07-03Fix defaults of some "maint test-settings" subcommandsPedro Alves2-3/+11
New tests added later for the incoming "with" command exposed a couple invalid-default-value bugs in the "maint test-settings" commands: - var_filename commands don't allow setting the filename to the empty string (unlike var_optional_filename commands), yet, "maint test-settings filename"'s control variable was not initialized, so on startup, "maint test-settings show filename" shows an empty string. - "maint test-settings enum"'s control variable was not initialized, so on startup, "maint test-settings show enum" shows an empty value instead of a valid enum value. Both issues are fixed by initializing the control variables. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * maint-test-settings.c (maintenance_test_settings_xxx) (maintenance_test_settings_yyy, maintenance_test_settings_zzz): New. (maintenance_test_settings_enums): Use them. (maintenance_test_settings_enum): Default to maintenance_test_settings_xxx. (_initialize_maint_test_settings): Initialize MAINTENANCE_TEST_SETTINGS_FILENAME. gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/settings.exp (test-string): Adjust expected out when testing "maint test-settings show filename"
2019-07-02Make "info threads" use the gdb::option frameworkPedro Alves2-0/+23
This makes "info threads" use the gdb::option framework to process options. There's only one option today (-gid), and it isn't used much frequently unless you're looking at matching MI output. Still, this was in the neighborhood of "thread apply" so I had converted it. The main advantage is that TAB completion now shows you the available options, and gives you a hint to what the command accepts as operand argument, including showing a metasyntactic variable: (gdb) info threads [TAB] -gid ID (gdb) help info threads Display currently known threads. Usage: info threads [OPTION]... [ID]... Options: -gid Show global thread IDs. If ID is given, it is a space-separated list of IDs of threads to display. Otherwise, all threads are displayed. (gdb) gdb/ChangeLog: 2019-07-02 Pedro Alves <palves@redhat.com> * NEWS (Completion improvements): Mention "info threads". * thread.c (struct info_threads_opts, info_threads_option_defs) (make_info_threads_options_def_group): New. (info_threads_command): Use gdb::option::process_options. (info_threads_command_completer): New. (_initialize_thread): Use gdb::option::build_help to build the help text for "info threads". gdb/testsuite/ChangeLog: 2019-07-02 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (test-info-threads): New procedure. (top level): Call it.
2019-06-28Handle either order of name and linkage nameTom Tromey3-0/+141
We discovered that the Ada support in gdb depends on the order of the DW_AT_name and DW_AT_linkage_name attributes in the DWARF. In particular, if they are emitted in the "wrong" order for some system symbols, "catch exception" will not work. This patch fixes this problem by arranging to always prefer the linkage name if both exist. This seems to be what the full symbol reader already does -- that is, this is another bug arising from having two different DWARF readers. Another possible issue here is that gdb still doesn't really preserve mangled names properly. There's a PR open about this. However, this seems to be somewhat involved to fix, which is why this patch continues to work around the bigger issue. gdb/ChangeLog 2019-06-28 Tom Tromey <tromey@adacore.com> * dwarf2read.c (partial_die_info::read): Prefer the linkage name for Ada. gdb/testsuite/ChangeLog 2019-06-28 Tom Tromey <tromey@adacore.com> * gdb.dwarf2/ada-linkage-name.c: New file. * gdb.dwarf2/ada-linkage-name.exp: New file.
2019-06-27Fix two buglets in cp_print_value_fields patchTom Tromey2-1/+6
Pedro and Tom both pointed out issues in the cp_print_value_fields patch, aka the fix for PR c++/20020. This patch addresses both issues. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-27 Tom Tromey <tromey@adacore.com> * cp-valprint.c (cp_print_value_fields): Pass opts, not options, to cp_print_static_field. gdb/testsuite/ChangeLog 2019-06-27 Tom Tromey <tromey@adacore.com> * gdb.cp/constexpr-field.exp: Use setup_xfail.
2019-06-26[gdb/testsuite] Compile varval twice, once without bad DWARFTom de Vries2-202/+225
When we run gdb.dwarf2/varval.exp with board cc-with-dwz, we run into: ... gdb compile failed, dwz: varval: Couldn't find DIE referenced by \ DW_OP_GNU_variable_value cc-with-tweaks.sh: dwz did not modify varval. UNTESTED: gdb.dwarf2/varval.exp: failed to prepare ... The problem is that varval contains some bad DWARF, which has been added intentionally to test GDB, but that bad DWARF causes dwz to error out, which has the consequence that the test-case remains untested with cc-with-dwz, while the test-case contains also correct DWARF that does not occur in any other test, and which we would really like to test with board cc-with-dwz. Fix this by compiling varval twice, once without and once with the bad DWARF, such that we have at least: ... PASS: gdb.dwarf2/varval.exp: print varval PASS: gdb.dwarf2/varval.exp: print varval2 PASS: gdb.dwarf2/varval.exp: print constval PASS: gdb.dwarf2/varval.exp: print mixedval PASS: gdb.dwarf2/varval.exp: print pointerval PASS: gdb.dwarf2/varval.exp: print *pointerval PASS: gdb.dwarf2/varval.exp: print structval PASS: gdb.dwarf2/varval.exp: print untypedval gdb compile failed, dwz: varval: Couldn't find DIE referenced by \ DW_OP_GNU_variable_value cc-with-tweaks.sh: dwz did not modify varval. UNTESTED: gdb.dwarf2/varval.exp: failed to prepare ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-26 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/varval.exp: Compile twice, once without bad DWARF.
2019-06-26[gdb/testsuite] Add back missing debug for index-cache.expTom de Vries2-1/+5
The proc prepare_for_testing has "debug" as default argument for the options parameter. In the commit c596f180a1 "[gdb/testsuite] Compile index-cache.c with -Wl,--build-id", by setting the options argument we've effectively dropped "debug". This causes index-cache.exp to not contain any debug info anymore on most systems (though not on openSUSE), which causes index-cache.exp FAILs. Fix this by adding back the missing "debug" option. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-26 Tom de Vries <tdevries@suse.de> * gdb.base/index-cache.exp: Add back missing debug option.
2019-06-25Fix alias command not detecting non matching prefix & sometimes asserting.Philippe Waroquiers2-0/+54
alias_command does not detect that the prefixes of the alias command and the aliased command are not matching: it is comparing the alias prefix with itself, instead of comparing it with the aliased command prefix. This causes either the alias command to silently do nothing, or to have GDB asserting: (gdb) alias assigne imprime limite-elements = set print elements ../../binutils-gdb/gdb/cli/cli-cmds.c:1552: internal-error: void alias_command(const char*, int): Assertion `c_command != NULL && c_command != (struct cmd_list_element *) -1' failed. A problem internal to GDB has been detected, Fix the logic, and update gdb.base/alias.exp to test these cases. gdb/ChangeLog 2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (alias_command): Compare the alias prefix with the command prefix. gdb/testsuite/ChangeLog 2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Test non matching/non existing prefixes.
2019-06-25[gdb/testsuite] Regenerate dw2-restrict.STom de Vries2-316/+198
When running gdb.dwarf2/dw2-restrict.exp with board cc-with-dwz, we run into: ... dwz: dw2-restrict: DW_AT_stmt_list not DW_FORM_sec_offset or DW_FORM_data4 ... The problem is that the DW_AT_stmt_list is encoded using DW_FORM_addr, while DW_FORM_sec_offset or DW_FORM_data4 would be appropriate. The test-case uses a dw2-restrict.S which was generated using clang 2.9, which contained a bug ( https://bugs.llvm.org/show_bug.cgi?id=9995 ) causing this problem. Fix this by regenerating using clang 5.0.1. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-25 Tom de Vries <tdevries@suse.de> PR testsuite/24727 * gdb.dwarf2/dw2-restrict.S: Regenerate using clang 5.0.1.
2019-06-24[gdb/testsuite] Fix label reference in implptr-64bit.expTom de Vries2-1/+5
When running gdb.dwarf2/implptr-64bit.exp with board cc-with-dwz-m, we run into: ... dwz: dwz.c:2363: checksum_die: \ Assertion `\ ((!op_multifile && !rd_multifile && !fi_multifile) || cu != die_cu (ref)) \ && (!op_multifile || cu->cu_chunk == die_cu (ref)->cu_chunk)' failed. cc-with-tweaks.sh: line 218: 13030 Aborted \ $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null ... In other words, PR dwz/24170. The trigger for the dwz PR is when intra-CU references are encoded using section-relative encoding DW_FORM_ref_addr, but could have been encoded using CU-relative encoding DW_FORM_ref4. Fix the intra-CU '%' label reference in implptr-64bit.exp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-24 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/implptr-64bit.exp: Fix intra-CU '%' label reference.
2019-06-24[gdb/testsuite] Fix DW_AT_decl_file in gdb.trace testsTom de Vries3-6/+12
When running gdb.trace/{entry-values.exp,unavailable-dwarf-piece.exp} with board cc-with-dwz, we run into two failures related to the DW_AT_decl_file attribute: - The encoding DW_FOR_sdata is used for DW_AT_decl_file, while the attribute is required to have a an "unsigned integer constant" value. - The DW_AT_decl_file attributes refer to a file with index one, while there's no such file. Fix this by using DW_FOR_udata and the value 0, meaning "no file specified". Tested on x86_64-linux with board native-gdbserver. gdb/testsuite/ChangeLog: 2019-06-24 Tom de Vries <tdevries@suse.de> * gdb.trace/entry-values.exp: Use DW_FORM_udata instead of DW_FOR_sdata for DW_AT_decl_file. Use 0 for DW_AT_decl_file. * gdb.trace/unavailable-dwarf-piece.exp: Same.
2019-06-24[gdb/testsuite] Fix inter-cu refs in inlined_subroutine-inheritance.expTom de Vries2-3/+7
When running gdb.dwarf2/inlined_subroutine-inheritance.exp with board cc-with-dwz, we run into: ... dwz: inlined_subroutine-inheritance: Couldn't find DIE referenced by \ DW_AT_abstract_origin ... The problem is that the DW_AT_abstract_origin attributes refer to DIEs in other CUs, while the references are encoded using the cu-relative encoding DW_FORM_ref4. Fix this by forcing the references to use DW_FORM_ref_addr. Tested on x86_64-linux. Tested with commit c24bdb023c "Introduce dwarf2_cu::get_builder" reverted, and verified that the test-case fails in the same way before and after this patch. gdb/testsuite/ChangeLog: 2019-06-24 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/inlined_subroutine-inheritance.exp:
2019-06-21[gdb/testsuite] Compile index-cache.c with -Wl,--build-idTom de Vries2-1/+6
When testing gdb.base/index-cache.exp using a gcc build without --enable-linker-build-id we get: ... FAIL: gdb.base/index-cache.exp: \ test_cache_enabled_miss: at least one file was created FAIL: gdb.base/index-cache.exp: \ test_cache_enabled_miss: couldn't get executable build id FAIL: gdb.base/index-cache.exp: \ test_cache_enabled_hit: check index-cache stats ... With "set debug index-cache on" we find: ... (gdb) file index-cache Reading symbols from index-cache... index cache: objfile index-cache has no build id ... The problem is that a build-id is required for the index-cache functionality. Fix this by compiling index-cache.c with -Wl,--build-id. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-21 Tom de Vries <tdevries@suse.de> * gdb.base/index-cache.exp: Add additional_flags=-Wl,--build-id.
2019-06-21[gdb/testsuite] Mark ptype_union.exp as unsupported for cc-with-gdb-indexTom de Vries2-0/+12
When testing gdb with board cc-with-gdb-index, we run into: ... FAIL: gdb.ada/ptype_union.exp: ptype global FAIL: gdb.ada/ptype_union.exp: print global ... The index is not supported for Ada (PR24713), and cc-with-gdb-index does not add an index for Ada test-cases. However, this test-case compiles C sources, for which cc-with-gdb-index does add an index. In gdb we load the executable containing the index and set the language to Ada, resulting in gdb trying to handle something that is not supported. Fix the fail by marking this unsupported. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-06-21 Tom de Vries <tdevries@suse.de> PR testsuite/24518 PR ada/24713 * gdb.ada/ptype_union.exp: Mark as unsupported if executable contains index.
2019-06-19Add intro comment to length_cond.expTom Tromey2-0/+7
Pedro pointed out that the new length_cond.exp test did not have an intro comment. This adds one. gdb/testsuite/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * gdb.ada/length_cond.exp: Add intro comment.
2019-06-19Fix crash when setting breakpoint conditionTom Tromey5-0/+127
gdb could crash when setting a breakpoint condition on a breakpoint when using the Ada language. The problem occurred because the ada_evaluate_subexp would try to evaluate the array to compute its attributes, but evaluating can't really be done at this time. This patch fixes the problem by arranging not to try to evaluate in EVAL_AVOID_SIDE_EFFECTS mode when computing an attribute. Tested on x86-64 Fedora 29. Because this is Ada-specific, and because Joel approved it internally, I am checking it in. gdb/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_evaluate_subexp) <case OP_ATR_FIRST>: Handle EVAL_AVOID_SIDE_EFFECTS specially. gdb/testsuite/ChangeLog 2019-06-19 Tom Tromey <tromey@adacore.com> * gdb.ada/length_cond.exp: New file. * gdb.ada/length_cond/length_cond.adb: New file. * gdb.ada/length_cond/pck.adb: New file. * gdb.ada/length_cond/pck.ads: New file.
2019-06-18[gdb/testsuite] Use -fuse-ld=gold in fission.expTom de Vries2-1/+6
The target board fission.exp requires the gold linker (because it supports --gdb-index). When running the target board on a system where the default linker is not gold, most tests will fail to compile. Fix this by adding "-fuse-ld=gold" ( supported in gcc since version 4.8). gdb/testsuite/ChangeLog: 2019-06-18 Tom de Vries <tdevries@suse.de> * boards/fission.exp (debug_flags): Add "-fuse-ld=gold".
2019-06-18Add comment to list0.hTom Tromey2-1/+5
Pedro suggested adding a comment to list0.h to explain the control character. Tested on x86-64 Fedora 29. gdb/testsuite/ChangeLog 2019-06-18 Tom Tromey <tromey@adacore.com> * gdb.base/list0.h: Add comment explaining control character.
2019-06-18[gdb/testsuite] Break up long debug_flags line in fission.expTom de Vries2-1/+10
gdb/testsuite/ChangeLog: 2019-06-18 Tom de Vries <tdevries@suse.de> * boards/fission.exp: Break up long debug_flags line.
2019-06-16Write index for dwz -m fileSimon Marchi2-0/+21
PR 24445 ("dwz multifile index not written to index cache") exposed the fact that we are not doing things right when we generate an index for an object file that has is linked to a dwz file. The same happens whether the index is generated with the intent of populating the index cache or using the save gdb-index command. The problem can be observed when running these tests with the cc-with-dwz-m board: FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats FAIL: gdb.dwarf2/gdb-index.exp: index used FAIL: gdb.dwarf2/gdb-index.exp: index used after symbol reloading When generating the index for such file and inspecting the CU list of the resulting index (with readelf --debug-dump=gdb_index), we can see something like: CU table: [ 0] 0x0 - 0xb9 [ 1] 0x0 - 0x44 This is supposed to be a sorted list of the ranges of all CUs in the file this index represents, so already having some overlap is a red flag. It turns out that we save the ranges of CUs coming from both the main file and the dwz file in the same index. After digging a little bit, it became quite obvious that the index in the main file should only list the CUs present in the main file, and a separate index should be generated for the dwz file, listing the CUs present in that file. First, that's what happens if you run dwz on a file that already has a GDB index embedded. Second, dwarf2read.c has code to read an index from a dwz file. The index in the dwz file is actually required to be present, if the main file has an index. So this patch changes write_psymtabs_to_index to generate an index for the dwz file, if present. That index only contains a CU list, just like what the dwz tool does when processing a file that already contains an index. Some notes about the implementation: - The file management (creating a temp file, make sure it's close/removed on error - in the right order) is a bit heavy in write_psymtabs_to_index, and I needed to add a third file. I factored this pattern in a separate class, index_wip_file. - It became a bit tedious to keep the call to assert_file_size in write_psymtabs_to_index, write_gdbindex would have had to return two sizes. Instead, I moved the calls to assert_file_size where the file is written. The downside is that we lose the filename at this point, but it was only used for the very improbable case of ftell failing, so I think it's not a problem. - The actual writing of the index file is factored out to write_gdbindex_1, so it can be re-used for both index files. - While the "save gdb-index" command will now write two .gdb-index files, this patch does not update the gdb-add-index.sh script, this will come in a later patch. gdb/ChangeLog: YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> PR gdb/24445 * dwarf-index-write.h (write_psymtabs_to_index): Add dwz_basename parameter. * dwarf-index-write.c (write_gdbindex): Move file writing to write_gdbindex_1. Change return type void. (assert_file_size): Move up, remove filename parameter. (write_gdbindex_1): New function. (write_debug_names): Change return type to void, call assert_file_size. (struct index_wip_file): New struct. (write_psymtabs_to_index): Add dwz_basename parameter. Move file logic to index_wip_file. Write index for dwz file if needed. (save_gdb_index_command): Pass basename of dwz file, if present. * dwarf-index-cache.c (index_cache::store): Obtain and pass build-id of dwz file, if present. * dwarf2read.c (struct dwz_file): Move to dwarf2read.h. (dwarf2_get_dwz_file): Likewise. * dwarf2read.h (struct dwz_file): Move from dwarf2read.c. (dwarf2_get_dwz_file): Likewise. gdb/testsuite/ChangeLog: YYYY-MM-DD Tom de Vries <tdevries@suse.de> PR gdb/24445 * gdb.dwarf2/gdb-index.exp (add_gdb_index): Update dwz file with generated index.
2019-06-16gdb/testsuite: Improve detection of bug gdb/24541Andrew Burgess2-0/+9
In bug gdb/24686 a testsuite failure was reported, this failure was actually just another instance of bug gdb/24541, however, due to the non-deterministic nature of bug gdb/24541 the testsuite pattern that was intended to catch this bug failed. This commit adds a second pattern to help detect gdb/24541, which should change the FAIL reported in gdb/24686 into a KFAIL. gdb/testsuite/ChangeLog: PR gdb/24686 * gdb.mi/mi-catch-cpp-exceptions.exp: Add an extra pattern to improve detection of bug gdb/24541.
2019-06-16Fix some whitespace issues in gdb ChangeLogsSimon Marchi1-11/+11
2019-06-16Make gdb.base/index-cache.exp work with readnow board (PR 24669)Simon Marchi2-20/+37
The gdb.base/index-cache.exp test fails with the readnow board: $ make check TESTS="gdb.base/index-cache.exp" RUNTESTFLAGS="--target_board=readnow" FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache stats FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats The problem is similar to what was fixed in 5a56d6a65f84 ("[gdb/testsuite] Fix index-cache.exp with cc-with-{gdb-index,debug-names}") In that commit, gdb.base/index-cache.exp was modified to account for the fact that the index cache is not used when the binary already has an embedded index. The same situation happens when GDB is started with the -readnow flag: it bypasses indices and partial symbols. So this patch updates the test to also expect the index cache not to be used if -readnow is present in $GDBFLAGS, gdb/testsuite/ChangeLog: PR gdb/24669 * gdb.base/index-cache.exp (uses_readnow, expecting_index_cache_use): Define global variable. (test_cache_enabled_miss, test_cache_enabled_hit): Use expecting_index_cache_use.
2019-06-16gdb/fortran: Show the type for non allocated / associated typesAndrew Burgess7-17/+224
Show the type of not-allocated and/or not-associated types. For array types and pointer to array types we are going to print the number of ranks. Consider this Fortran program: program test integer, allocatable :: vla (:) logical l allocate (vla(5:12)) l = allocated (vla) end program test And this GDB session with current HEAD: (gdb) start ... 2 integer, allocatable :: vla (:) (gdb) n 4 allocate (vla(5:12)) (gdb) ptype vla type = <not allocated> (gdb) p vla $1 = <not allocated> (gdb) And the same session with this patch applied: (gdb) start ... 2 integer, allocatable :: vla (:) (gdb) n 4 allocate (vla(5:12)) (gdb) ptype vla type = integer(kind=4), allocatable (:) (gdb) p vla $1 = <not allocated> (gdb) The type of 'vla' is now printed correctly, while the value itself still shows as '<not allocated>'. How GDB prints the type of associated pointers has changed in a similar way. gdb/ChangeLog: * f-typeprint.c (f_print_type): Don't return early for not associated or not allocated types. (f_type_print_varspec_suffix): Add print_rank parameter and print ranks of array types in case they dangling. (f_type_print_base): Add print_rank parameter. gdb/testsuite/ChangeLog: * gdb.fortran/pointers.f90: New file. * gdb.fortran/print_type.exp: New file. * gdb.fortran/vla-ptype.exp: Adapt expected results. * gdb.fortran/vla-type.exp: Likewise. * gdb.fortran/vla-value.exp: Likewise. * gdb.mi/mi-vla-fortran.exp: Likewise.
2019-06-15gdb/mi: New commands to catch C++ exceptionsAndrew Burgess4-3/+285
Adds some MI commands to catch C++ exceptions. The new commands are -catch-throw, -catch-rethrow, and -catch-catch, these all correspond to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'. Each MI command takes two optional arguments, '-t' has the effect of calling 'tcatch' instead of 'catch', for example: (gdb) -catch-throw -t Is the same as: (gdb) tcatch throw There is also a '-r REGEXP' argument that can supply a regexp to match against the exception type, so: (gdb) -catch-catch -r PATTERN Is the same as: (gdb) catch catch PATTERN The change in print_mention_exception_catchpoint might seem a little strange; changing the output from using ui_out::field_int and ui_out::text to using ui_out::message. The print_mention_exception_catchpoint is used as the 'print_mention' method for the exception catchpoint breakpoint object. Most of the other 'print_mention' methods (see breakpoint.c) use either printf_filtered, of ui_out::message. Using field_int was causing an unexpected field to be added to the MI output. Here's the output without the change in print_mention_exception_catchpoint: (gdb) -catch-throw ^done,bkptno="1",bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x00000000004006c0", what="exception throw",catch-type="throw", thread-groups=["i1"],times="0"} Notice the breakpoint number appears in both the 'bkptno' field, and the 'number' field within the 'bkpt' tuple. Here's the output with the change in print_mention_exception_catchpoint: (gdb) -catch-throw ^done,bkpt={number="1",type="breakpoint",disp="keep", enabled="y",addr="0x00000000004006c0", what="exception throw",catch-type="throw", thread-groups=["i1"],times="0"} gdb/ChangeLog: * NEWS: Mention new MI commands. * break-catch-throw.c (enum exception_event_kind): Move to breakpoint.h. (print_mention_exception_catchpoint): Output text as a single message. (catch_exception_command_1): Rename to... (catch_exception_event): ...this, make non-static, update header command, and change some parameter types. (catch_catch_command): Update for changes to catch_exception_command_1. (catch_throw_command): Likewise. (catch_rethrow_command): Likewise. * breakpoint.c (enum exception_event_kind): Delete. * breakpoint.h (enum exception_event_kind): Moved here from break-catch-throw.c. (catch_exception_event): Declare. * mi/mi-cmd-catch.c (mi_cmd_catch_exception_event): New function. (mi_cmd_catch_throw): New function. (mi_cmd_catch_rethrow): New function. (mi_cmd_catch_catch): New function. * mi/mi-cmds.c (mi_cmds): Add 'catch-throw', 'catch-rethrow', and 'catch-catch' entries. * mi/mi-cmds.h (mi_cmd_catch_throw): Declare. (mi_cmd_catch_rethrow): Declare. (mi_cmd_catch_catch): Declare. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new node. (C++ Exception GDB/MI Catchpoint Commands): New node to describe new MI commands. gdb/testsuite/ChangeLog: * gdb.mi/mi-catch-cpp-exceptions.cc: New file. * gdb.mi/mi-catch-cpp-exceptions.exp: New file. * lib/mi-support.exp (mi_expect_stop): Handle 'exception-caught' as a stop reason.
2019-06-15gdb: Don't allow annotations to influence what else GDB printsAndrew Burgess4-3/+10
The annotations should be additional information printed by GDB to be consumed by users (GUIs), but GDB shouldn't reduce what it prints based on whether annotations are on or not. However, this is what happens for annotate_source_line. This commit makes annotate_source_line a void function that simply outputs the annotation information, GDB will then print the contents of the source line to the terminal in the normal way. Some tests needed to be updated after this commit. gdb/ChangeLog: * annotate.c (annotate_source_line): Change return type to void, update implementation to match. * annotate.h (annotate_source_line): Change return type to void, update header comment. * stack.c (print_frame_info): Don't change what frame information is printed based on whether annotations are on or not. gdb/testsuite/ChangeLog: * gdb.base/annota1.exp: Update expected results. * gdb.cp/annota2.exp: Likewise. * gdb.cp/annota3.exp: Likewise.
2019-06-15gdb: Remove file path from test nameAndrew Burgess2-1/+6
Having paths in test names makes comparing sum files difficult, rename a test to avoid paths in test names. gdb/testsuite/ChangeLog: * gdb.base/style-logging.exp: Remove path from test name.
2019-06-14Do not emit style escape sequences to log fileTom Tromey2-0/+75
PR gdb/24502 requests that the "set logging" log file not contain style escape sequences emitted by gdb. This seemed like a reasonable request to me, so this patch implements filtering for the log file. This also updates a comment in ui-style.h that I noticed while writing the patch. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> PR gdb/24502: * ui-style.h (skip_ansi_escape): Update comment. * ui-file.h (class no_terminal_escape_file): New class. * ui-file.c (no_terminal_escape_file::write) (no_terminal_escape_file::puts): New methods. * cli/cli-logging.c (handle_redirections): Use no_terminal_escape_file. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> PR gdb/24502: * gdb.base/style-logging.exp: New file.
2019-06-14Warn if add-symbol-file does not provide any symbolsTom Tromey3-0/+53
A user suggested that add-symbol-file ought to warn if the file does not in fact provide any symbols. This seemed like a decent idea, so this patch implements this idea. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * symfile.c (add_symbol_file_command): Remove obsolete comment. Warn if symbol file does not provide any symbols. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * gdb.base/symfile-warn.exp: New file. * gdb.base/symfile-warn.c: New file.
2019-06-14Only compute realpath when basenames_may_differ is setTom Tromey2-0/+55
A user noted that, when sources are symlinked, gdb annotations will print the real path, rather than the name of the symlink. It seems to me that it is better to print the name of the file that was actually used in the build, unless there is some reason not to. This patch implements this, with the caveat that it will not work when basenames-may-differ is enabled. The way this mode is currently implemented, returning the symbolic (not real) path is not possible. While I think it would be good to redo the source file name cache and perhaps integrate it with class source_cache, I haven't done so here. Regression tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * source.c (find_and_open_source): Respect basenames_may_differ. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * gdb.base/annotate-symlink.exp: New file.