aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Allow re-assigning to convenience variablesTom Tromey2019-11-142-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A customer reported somewhat odd gdb behavior, where re-assigning an array or string to a convenience variable would yield "Too many array elements". A test case is: (gdb) p $x = "x" (gdb) p $x = "xyz" This patch fixes the problem by making a special case in the evaluator for assignment to convenience variables, which seems like the correct behavior. Note that a previous patch implemented this for Ada, see commit f411722cb ("Allow re-assigning to convenience variables"). gdb/ChangeLog 2019-11-14 Tom Tromey <tromey@adacore.com> * eval.c (evaluate_subexp_standard) <BINOP_ASSIGN>: Do not pass an expected type for the RHS if the LHS is a convenience variable. gdb/testsuite/ChangeLog 2019-11-14 Tom Tromey <tromey@adacore.com> * gdb.base/gdbvars.exp (test_convenience_variables): Add regression tests. Change-Id: I5e66a2d243931a5c43c7af4bc9f6717464c2477e
* Make TUI resizing tests more robustTom Tromey2019-11-123-46/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As Sergio pointed out, the TUI resizing tests are flaky. Debugging this showed three main problems. 1. expect's "stty" command processes its arguments one-by-one. So, rather than requesting a single resize, it sends two separate resize requests (one for rows and one for columns). This means gdb sees two SIGWINCH signals and resizes the terminal twice. I consider this a bug in expect, but I couldn't readily see how to report a bug; and anyway the fix wouldn't propagate very quickly. This patch works around this problem by explicitly doing two separate resizes (so it will be robust if expect ever does change); and then by waiting for each resize to complete before continuing. 2. gdb uses curses to drive the console rendering. Currently the test suite looks for terminal text insertion sequences to decide when a command has completed. However, it turns out that, sometimes, curses can output things in non-obvious ways. I didn't debug into curses but I guess this can happen due to output optimizations. No matter the reason, sometimes the current approach of only tracking text insertions is not enough to detect that gdb has finished rendering. This patch fixes this problem by arranging to detect the termination output after any curses command, not just insertion. 3. Detecting when a resize has completed is tricky. In fact, I could not find a way to reliably do this. This patch fixes this problem by adding a special maint "tui-resize-message" setting to gdb. When this is enabled, gdb will print a message after each SIGWINCH has been fully processed. The test suite enables this mode and then waits for the message in order to know when control can be returned to the calling test. This patch also adds a timeout, to avoid the situation where the terminal code fails to notice a change for some reason. This lets the test at least try to continue. gdb/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * tui/tui-win.c (resize_message): New global. (show_tui_resize_message): New function. (tui_async_resize_screen): Print message if requested. (_initialize_tui_win): Add tui-resize-message setting. * NEWS: Add entry for new commands. gdb/doc/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * gdb.texinfo (Maintenance Commands): Document new command. gdb/testsuite/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * lib/tuiterm.exp (_accept): Add wait_for parameter. Check output after any command. Expect prompt after WAIT_FOR is seen. (enter_tui): Enable resize messages. (command): Expect command in output. (get_line): Avoid error when cursor appears to be off-screen. (dump_screen): Include screen size in title. (_do_resize): New proc, from "resize". (resize): Rewrite. Do resize in two steps. * gdb.tui/empty.exp (layouts): Fix entries. (check_boxes): Remove xfail. (check_text): Dump screen on failure. Change-Id: I420e0259cb99b21adcd28f671b99161eefa7a51d
* gdb/python: Introduce gdb.lookup_static_symbolsAndrew Burgess2019-11-102-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If gdb.lookup_static_symbol is going to return a single symbol then it makes sense (I think) for it to return a context sensitive choice of symbol, that is the global static symbol that would be visible to the program at that point. However, if the user of the python API wants to instead get a consistent set of global static symbols, no matter where they stop, then they have to instead consider all global static symbols with a given name - there could be many. That is what this new API function offers, it returns a list (possibly empty) of all global static symbols matching a given name (and optionally a given symbol domain). gdb/ChangeLog: * python/py-symbol.c (gdbpy_lookup_static_symbols): New function. * python/python-internal.h (gdbpy_lookup_static_symbols): Declare new function. * python/python.c (python_GdbMethods): Add gdb.lookup_static_symbols method. * NEWS: Mention gdb.lookup_static_symbols. gdb/testsuite/ChangeLog: * gdb.python/py-symbol.exp: Add test for gdb.lookup_static_symbols. gdb/doc/ChangeLog: * python.texi (Symbols In Python): Add documentation for gdb.lookup_static_symbols. Change-Id: I1153b0ae5bcbc43b3dcf139043c7a48bf791e1a3
* gdb/python: smarter symbol lookup for gdb.lookup_static_symbolAndrew Burgess2019-11-104-12/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using gdb.lookup_static_symbol I think that GDB should find static symbols (global symbol with static linkage) from the current object file ahead of static symbols from other object files. This means that if we have two source files f1.c and f2.c, and both files contains 'static int foo;', then when we are stopped in f1.c a call to 'gdb.lookup_static_symbol ("foo")' will find f1.c::foo, and if we are stopped in f2.c we would find 'f2.c::foo'. Given that gdb.lookup_static_symbol always returns a single symbol, but there can be multiple static symbols with the same name GDB is always making a choice about which symbols to return. I think that it makes sense for the choice GDB makes in this case to match what a user would get on the command line if they asked to 'print foo'. gdb/testsuite/ChangeLog: * gdb.python/py-symbol.c: Declare and call function from new py-symbol-2.c file. * gdb.python/py-symbol.exp: Compile both source files, and add new tests for gdb.lookup_static_symbol. * gdb.python/py-symbol-2.c: New file. gdb/doc/ChangeLog: * python.texi (Symbols In Python): Extend documentation for gdb.lookup_static_symbol. gdb/ChangeLog: * python/py-symbol.c (gdbpy_lookup_static_symbol): Lookup in static block of current object file first. Also fix typo in header comment. Change-Id: Ie55dbeb8806f35577b46015deecde27a0ca2ab64
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (4)Tom de Vries2019-11-0243-397/+359
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in the testsuite/gdb.base subdir. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-11-02 Tom de Vries <tdevries@suse.de> * gdb.base/advance.exp: Drop superfluous 3rd argument to gdb_test. * gdb.base/anon.exp: Same. * gdb.base/auto-connect-native-target.exp: Same. * gdb.base/call-ar-st.exp: Same. * gdb.base/catch-syscall.exp: Same. * gdb.base/commands.exp: Same. * gdb.base/default.exp: Same. * gdb.base/display.exp: Same. * gdb.base/float.exp: Same. * gdb.base/foll-fork.exp: Same. * gdb.base/help.exp: Same. * gdb.base/info-macros.exp: Same. * gdb.base/info-proc.exp: Same. * gdb.base/info-target.exp: Same. * gdb.base/long_long.exp: Same. * gdb.base/macscp.exp: Same. * gdb.base/memattr.exp: Same. * gdb.base/nofield.exp: Same. * gdb.base/pointers.exp: Same. * gdb.base/printcmds.exp: Same. * gdb.base/ptype.exp: Same. * gdb.base/restore.exp: Same. * gdb.base/return.exp: Same. * gdb.base/scope.exp: Same. * gdb.base/set-noassign.exp: Same. * gdb.base/setshow.exp: Same. * gdb.base/shlib-call.exp: Same. * gdb.base/signals.exp: Same. * gdb.base/sigstep.exp: Same. * gdb.base/skip.exp: Same. * gdb.base/solib-symbol.exp: Same. * gdb.base/stap-probe.exp: Same. * gdb.base/step-line.exp: Same. * gdb.base/step-test.exp: Same. * gdb.base/style.exp: Same. * gdb.base/varargs.exp: Same. * gdb.base/vla-datatypes.exp: Same. * gdb.base/vla-ptr.exp: Same. * gdb.base/vla-sideeffect.exp: Same. * gdb.base/volatile.exp: Same. * gdb.base/watch-cond-infcall.exp: Same. * gdb.base/watchpoint.exp: Same. Change-Id: Ifd24dc13d552e7dd03f9049db419b08c6adc4112
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (3)Tom de Vries2019-11-0217-69/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in the testsuite/gdb.cp subdir. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-11-02 Tom de Vries <tdevries@suse.de> * gdb.cp/anon-union.exp: Drop superfluous 3rd argument to gdb_test. * gdb.cp/cpexprs.exp: Same. * gdb.cp/except-multi-location.exp: Same. * gdb.cp/exceptprint.exp: Same. * gdb.cp/gdb2384.exp: Same. * gdb.cp/inherit.exp: Same. * gdb.cp/m-static.exp: Same. * gdb.cp/meth-typedefs.exp: Same. * gdb.cp/misc.exp: Same. * gdb.cp/namespace.exp: Same. * gdb.cp/non-trivial-retval.exp: Same. * gdb.cp/overload.exp: Same. * gdb.cp/pr17132.exp: Same. * gdb.cp/re-set-overloaded.exp: Same. * gdb.cp/rvalue-ref-types.exp: Same. * gdb.cp/templates.exp: Same. Change-Id: I0254d0cea71e7376aedb078166188a8010eeaebe
* [ARM, thumb] Fix disassembling bug after reloading a symbol fileLuis Machado2019-11-013-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The speed optimization from commit 5f6cac4085c95c5339b9549dc06d4f9184184fa6 made GDB skip reloading all symbols when the same symbol file is reloaded. As a result, ARM targets only read the mapping symbols the first time we load a symbol file. When reloaded, the speed optimization above will cause an early return and gdbarch_record_special_symbol won't be called to save mapping symbol data, which in turn affects disassembling of thumb instructions. First load and correct disassemble output: Dump of assembler code for function main: 0x0000821c <+0>: bx pc 0x0000821e <+2>: nop 0x00008220 <+4>: mov r0, #0 0x00008224 <+8>: bx lr Second load and incorrect disassemble output: Dump of assembler code for function main: 0x0000821c <+0>: bx pc 0x0000821e <+2>: nop 0x00008220 <+4>: movs r0, r0 0x00008222 <+6>: b.n 0x8966 0x00008224 <+8>: vrhadd.u16 d14, d14, d31 This happens because the mapping symbol data is stored in an objfile_key-based container, and that data isn't preserved across the two symbol loading operations. The following patch fixes this by storing the mapping symbol data in a bfd_key-based container, which doesn't change as long as the bfd is the same. I've also added a new test to verify the correct disassemble output. gdb/ChangeLog: 2019-11-01 Luis Machado <luis.machado@linaro.org> PR gdb/25124 * arm-tdep.c (arm_per_objfile): Rename to ... (arm_per_bfd): ... this. (arm_objfile_data_key): Rename to ... (arm_bfd_data_key): ... this. (arm_find_mapping_symbol): Adjust access to new bfd_key-based data. (arm_record_special_symbol): Likewise. gdb/testsuite/ChangeLog: 2019-11-01 Luis Machado <luis.machado@linaro.org> PR gdb/25124 * gdb.arch/pr25124.S: New file. * gdb.arch/pr25124.exp: New file. Change-Id: I22c3e6ebe9bfedad66d56fe9656994fa1761c485
* gdb: Add new commands to list module variables and functionsAndrew Burgess2019-10-315-3/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds two new commands "info module functions" and "info module variables". These commands list all of the functions and variables grouped by module and then by file. For example: (gdb) info module functions All functions in all modules: Module "mod1": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 35: void mod1::__copy_mod1_M1t1(Type m1t1, Type m1t1); 25: void mod1::sub_m1_a(integer(kind=4)); 31: integer(kind=4) mod1::sub_m1_b(void); Module "mod2": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 41: void mod2::sub_m2_a(integer(kind=4), logical(kind=4)); 49: logical(kind=4) mod2::sub_m2_b(real(kind=4)); The new commands take set of flags that allow the output to be filtered, the user can filter by variable/function name, type, or containing module. As GDB doesn't currently track the relationship between a module and the variables or functions within it in the symbol table, so I filter based on the module prefix in order to find the functions or variables in each module. What this makes clear is that a user could get this same information using "info variables" and simply provide the prefix themselves, for example: (gdb) info module functions -m mod1 _a All functions matching regular expression "_a", in all modules matching regular expression "mod1": Module "mod1": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 25: void mod1::sub_m1_a(integer(kind=4)); Is similar to: (gdb) info functions mod1::.*_a.* All functions matching regular expression "mod1::.*_a": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 25: void mod1::sub_m1_a(integer(kind=4)); The benefits I see for a separate command are that the user doesn't have to think (or know) about the module prefix format, nor worry about building a proper regexp. The user can also easily scan across modules without having to build complex regexps. The new function search_module_symbols is extern in this patch despite only being used within symtab.c, this is because a later patch in this series will also be using this function from outside symtab.c. This patch is a new implementation of an idea originally worked on by Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM. gdb/ChangeLog: * symtab.c (info_module_cmdlist): New variable. (info_module_command): New function. (search_module_symbols): New function. (info_module_subcommand): New function. (struct info_modules_var_func_options): New struct. (info_modules_var_func_options_defs): New variable. (make_info_modules_var_func_options_def_group): New function. (info_module_functions_command): New function. (info_module_variables_command): New function. (info_module_var_func_command_completer): New function. (_initialize_symtab): Register new 'info module functions' and 'info module variables' commands. * symtab.h (typedef symbol_search_in_module): New typedef. (search_module_symbols): Declare new function. * NEWS: Mention new commands. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'info module variables' and 'info module functions' commands. gdb/testsuite/ChangeLog: * gdb.fortran/info-modules.exp: Update expected results, and add additional tests for 'info module functinos', and 'info module variables'. * gdb.fortran/info-types.exp: Update expected results. * gdb.fortran/info-types.f90: Extend testcase with additional module variables and functions. Change-Id: I8c2960640e2e101b77eff54027d687e21ec22e2b
* gdb/fortran: Add new 'info modules' commandAndrew Burgess2019-10-315-3/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new command 'info modules' that lists all of the modules GDB knows about from the debug information. A module is a debugging entity in the DWARF defined with DW_TAG_module, currently Fortran is known to use this tag for its modules. I'm not aware of any other language that currently makes use of DW_TAG_module. The output style is similar to the 'info type' output: (gdb) info modules All defined modules: File info-types.f90: 16: mod1 24: mod2 (gdb) Where the user is told the file the module is defined in and, on the left hand side, the line number at which the module is defined along with the name of the module. This patch is a new implementation of an idea originally worked on by Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM. gdb/ChangeLog: * dwarf2read.c (dw2_symtab_iter_next): Handle MODULE_DOMAIN. (dw2_expand_marked_cus): Handle MODULES_DOMAIN. (dw2_debug_names_iterator::next): Handle MODULE_DOMAIN and MODULES_DOMAIN. (scan_partial_symbols): Only create partial module symbols for non declarations. * psymtab.c (recursively_search_psymtabs): Handle MODULE_DOMAIN and MODULES_DOMAIN. * symtab.c (search_domain_name): Likewise. (search_symbols): Likewise. (print_symbol_info): Likewise. (symtab_symbol_info): Likewise. (info_modules_command): New function. (_initialize_symtab): Register 'info modules' command. * symtab.h (enum search_domain): Add MODULES_DOMAIN. * NEWS: Mention new 'info modules' command. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'info modules' command. gdb/testsuite/ChangeLog: * gdb.fortran/info-modules.exp: New file. * gdb.fortran/info-types.exp: Build with new file. * gdb.fortran/info-types.f90: Include and use new module. * gdb.fortran/info-types-2.f90: New file. Change-Id: I2b781dd5a06bcad04620ccdc45f01a0f711adfad
* Test the convenience functions $_gdb_setting and $_gdb_setting_str.Philippe Waroquiers2019-10-314-10/+179
| | | | | | | | | | | | | gdb/testsuite/ChangeLog 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/setshow.exp: Test $_gdb_setting and $_gdb_setting_str. * gdb.base/settings.exp: Test all settings types using $_gdb_maint_setting and $_gdb_maint_setting_str in proc_show_setting, that now verifies that the value of "maint show" is the same as returned by the settings functions. Test the type of the maintenance settings. * gdb.base/default.exp: Update show_conv_list.
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (2)Tom de Vries2019-10-3133-183/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in some gdb testsuite subdirs. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-31 Tom de Vries <tdevries@suse.de> * gdb.arch/amd64-disp-step-avx.exp: Drop superfluous 3rd argument to gdb_test. * gdb.arch/amd64-disp-step.exp: Same. * gdb.asm/asm-source.exp: Same. * gdb.btrace/buffer-size.exp: Same. * gdb.btrace/cpu.exp: Same. * gdb.btrace/enable.exp: Same. * gdb.dwarf2/count.exp: Same. * gdb.dwarf2/dw2-ranges-func.exp: Same. * gdb.dwarf2/dw2-ranges-psym.exp: Same. * gdb.fortran/vla-datatypes.exp: Same. * gdb.fortran/vla-history.exp: Same. * gdb.fortran/vla-ptype.exp: Same. * gdb.fortran/vla-value.exp: Same. * gdb.fortran/whatis_type.exp: Same. * gdb.guile/guile.exp: Same. * gdb.multi/tids.exp: Same. * gdb.python/py-finish-breakpoint.exp: Same. * gdb.python/py-framefilter.exp: Same. * gdb.python/py-pp-registration.exp: Same. * gdb.python/py-xmethods.exp: Same. * gdb.python/python.exp: Same. * gdb.server/connect-with-no-symbol-file.exp: Same. * gdb.server/no-thread-db.exp: Same. * gdb.server/run-without-local-binary.exp: Same. * gdb.stabs/weird.exp: Same. * gdb.threads/attach-many-short-lived-threads.exp: Same. * gdb.threads/thread-find.exp: Same. * gdb.threads/tls-shared.exp: Same. * gdb.threads/tls.exp: Same. * gdb.threads/wp-replication.exp: Same. * gdb.trace/ax.exp: Same. * lib/gdb.exp (gdb_test_exact, help_test_raw): Same. Change-Id: I2fa544c68f8c0099a77e03ff04ddc010eb2b6c7c
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test callTom de Vries2019-10-3129-144/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurences in gdb.ada. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-31 Tom de Vries <tdevries@suse.de> * gdb.ada/array_bounds.exp: Drop superfluous 3rd argument to gdb_test. * gdb.ada/array_subscript_addr.exp: Same. * gdb.ada/arrayidx.exp: Same. * gdb.ada/arrayparam.exp: Same. * gdb.ada/arrayptr.exp: Same. * gdb.ada/boolean_expr.exp: Same. * gdb.ada/call_pn.exp: Same. * gdb.ada/complete.exp: Same. * gdb.ada/fixed_cmp.exp: Same. * gdb.ada/fun_addr.exp: Same. * gdb.ada/funcall_param.exp: Same. * gdb.ada/interface.exp: Same. * gdb.ada/mod_from_name.exp: Same. * gdb.ada/null_array.exp: Same. * gdb.ada/packed_array.exp: Same. * gdb.ada/packed_tagged.exp: Same. * gdb.ada/print_chars.exp: Same. * gdb.ada/print_pc.exp: Same. * gdb.ada/ptype_arith_binop.exp: Same. * gdb.ada/ptype_field.exp: Same. * gdb.ada/ptype_tagged_param.exp: Same. * gdb.ada/rec_return.exp: Same. * gdb.ada/ref_tick_size.exp: Same. * gdb.ada/str_ref_cmp.exp: Same. * gdb.ada/taft_type.exp: Same. * gdb.ada/tagged.exp: Same. * gdb.ada/type_coercion.exp: Same. * gdb.ada/uninitialized_vars.exp: Same. Change-Id: Ibb84a41573c7f21295f3fd42da9b96534205c5c4
* [gdb/testsuite] Add -early pattern flag for gdb_test_multipleTom de Vries2019-10-302-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Proc gdb_test_multiple builds up and executes a gdb_expect expression with pattern/action clauses. The clauses are either implicit (added by gdb_test_multiple) or explicit (passed via the gdb_test_multiple parameter user_code). However, there are a few implicit clauses which are inserted before the explicit ones, making sure those take precedence. Add an -early pattern flag for a gdb_test_multiple user_code clause to specify that the clause needs to be inserted before any implicit clause. Using this pattern flag, we can f.i. setup a kfail for an assertion failure <assert> during gdb_continue_to_breakpoint by the rewrite: ... gdb_continue_to_breakpoint <msg> <pattern> ... into: ... set breakpoint_pattern "(?:Breakpoint|Temporary breakpoint) .* (at|in)" gdb_test_multiple "continue" "continue to breakpoint: <msg>" { -early -re "internal-error: <assert>" { setup_kfail gdb/nnnnn "*-*-*" exp_continue } -re "$breakpoint_pattern <pattern>\r\n$gdb_prompt $" { pass $gdb_test_name } } Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-30 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_test_multiple): Handle -early pattern flag. Change-Id: I376c636b0812be52e7137634b1a4f50bf2b999b6
* [gdb] Fix more typos in comments (2)Tom de Vries2019-10-2610-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * aarch64-linux-tdep.c: Fix typos in comments. * aarch64-tdep.c: Same. * ada-lang.c: Same. * amd64-nat.c: Same. * arc-tdep.c: Same. * arch/aarch64-insn.c: Same. * block.c: Same. * breakpoint.h: Same. * btrace.h: Same. * c-varobj.c: Same. * cli/cli-decode.c: Same. * cli/cli-script.c: Same. * cli/cli-utils.h: Same. * coff-pe-read.c: Same. * coffread.c: Same. * compile/compile-cplus-symbols.c: Same. * compile/compile-object-run.c: Same. * completer.c: Same. * corelow.c: Same. * cp-support.c: Same. * demangle.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame.c: Same. * dwarf2-frame.h: Same. * eval.c: Same. * frame-base.h: Same. * frame.h: Same. * gdbcmd.h: Same. * gdbtypes.h: Same. * gnu-nat.c: Same. * guile/scm-objfile.c: Same. * i386-tdep.c: Same. * i386-tdep.h: Same. * infcall.c: Same. * infcall.h: Same. * linux-nat.c: Same. * m68k-tdep.c: Same. * macroexp.c: Same. * memattr.c: Same. * mi/mi-cmd-disas.c: Same. * mi/mi-getopt.h: Same. * mi/mi-main.c: Same. * minsyms.c: Same. * nat/aarch64-sve-linux-sigcontext.h: Same. * objfiles.h: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-tdep.h: Same. * progspace.h: Same. * prologue-value.h: Same. * python/py-evtregistry.c: Same. * python/py-instruction.h: Same. * record-btrace.c: Same. * record-full.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * ser-tcp.c: Same. * sol-thread.c: Same. * sparc-sol2-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * symfile.c: Same. * symtab.h: Same. * target.c: Same. * tracepoint.c: Same. * tui/tui-data.h: Same. * tui/tui-io.c: Same. * tui/tui-win.c: Same. * tui/tui.c: Same. * unittests/rsp-low-selftests.c: Same. * user-regs.h: Same. * utils.c: Same. * utils.h: Same. * valarith.c: Same. * valops.c: Same. * valprint.c: Same. * valprint.h: Same. * value.c: Same. * value.h: Same. * varobj.c: Same. * x86-nat.h: Same. * xtensa-tdep.c: Same. gdb/gdbserver/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * linux-aarch64-low.c: Fix typos in comments. * linux-arm-low.c: Same. * linux-low.c: Same. * linux-ppc-low.c: Same. * proc-service.c: Same. * regcache.h: Same. * server.c: Same. * tracepoint.c: Same. * win32-low.c: Same. gdb/stubs/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * ia64vms-stub.c: Fix typos in comments. * m32r-stub.c: Same. * m68k-stub.c: Same. * sh-stub.c: Same. gdb/testsuite/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * gdb.base/bigcore.c: Fix typos in comments. * gdb.base/ctf-ptype.c: Same. * gdb.base/long_long.c: Same. * gdb.dwarf2/dw2-op-out-param.S: Same. * gdb.python/py-evthreads.c: Same. * gdb.reverse/i387-stack-reverse.c: Same. * gdb.trace/tfile.c: Same. * lib/compiler.c: Same. * lib/compiler.cc: Same. Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
* [gdb/testsuite] Use -wrap and $gdb_test_name in gdb_test_multiple calls (2)Tom de Vries2019-10-257-51/+47
| | | | | | | | | | | | | | | | | | | | | Make gdb_test_multiple calls shorter by using new gdb_test_multiple variable $gdb_test_name and new gdb_test_multiple pattern flag -wrap. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-25 Tom de Vries <tdevries@suse.de> * gdb.reverse/sigall-precsave.exp: Use -wrap and $gdb_test_name in gdb_test_multiple calls. * gdb.reverse/sigall-reverse.exp: Same. * gdb.reverse/solib-precsave.exp: Same. * gdb.reverse/solib-reverse.exp: Same. * gdb.reverse/until-precsave.exp: Same. * gdb.reverse/until-reverse.exp: Same. Change-Id: I67bb327d069dbc439410996bcfe6c7f905b2ca52
* [gdb/testsuite] Add -wrap pattern flag to gdb_test_multipleTom de Vries2019-10-243-12/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, in order to rewrite: ... gdb_test <command> <pattern> <message> ... using gdb_test_multiple, we get: ... gdb_test_multiple <command> <message> { -re "\[\r\n\]*(?:<pattern>)\[\r\n\]+$gdb_prompt $" { pass $gdb_test_name } } ... Add a '-wrap pattern flag to gdb_test_multiple, that wraps the regexp pattern as gdb_test wraps its message argument. This allows us to rewrite into the more compact: ... gdb_test_multiple <command> <message> { -re -wrap <pattern> { pass $gdb_test_name } } ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-24 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_test_multiple): Add -wrap pattern flag. * gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing kfail using -wrap pattern flag and convenience variable gdb_test_name. Change-Id: Ie42c97d5ab7acf6db351299ccd23a83540fe6e1a
* gdb/python: Return None from Progspace.block_for_pc on errorAndrew Burgess2019-10-242-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation for Progspace.block_for_pc says: Return the innermost gdb.Block containing the given pc value. If the block cannot be found for the pc value specified, the function will return None. However, the implementation actually throws an error for invalid addresses, like this: (gdb) python print gdb.current_progspace ().block_for_pc (1) Traceback (most recent call last): File "<string>", line 1, in <module> RuntimeError: Cannot locate object file for block. Error while executing Python code. (gdb) This has been the behaviour since the command was first added (when the documentation was still as above) in this commit: commit f3e9a8177c41893858fce2bdf339dbe90b3a4ef5 Date: Wed Feb 24 21:18:28 2010 +0000 Since that commit the code in question has moved around, but the important parts are largely unchanged. The function in question is now in py-progspace.c:pspy_block_for_pc. Examining the code shows that the real state is more complex than just the function throws an error instead of returning None, instead the real situation is: 1. If we can't find a compilation unit for the $pc value then we throw an error, but 2. If we can find a compilation unit, but can't find a block within the compilation unit for the $pc then return None. I suspect for most users of the Python API this distinction is irrelevant, and I propose that we standardise on one single failure mechanism. Given the function can currently return None in some cases, and is documented to return None on error, I propose we make that the case for all error paths, which is what this patch does. As the Progspace.block_for_pc method is currently untested, I've added some basic tests including for a call with an invalid $pc. This is potentially an API breaking change, though an undocumented part of the API. Also, users should have been checking and handling a None return value anyway, so my hope is that this shouldn't be too disruptive. gdb/ChangeLog: * python/py-progspace.c (pspy_block_for_pc): Return None for all error paths. gdb/testsuite/ChangeLog: * gdb.python/py-progspace.exp: Add tests for the Progspace.block_for_pc method. Change-Id: I9cea8d2132902bcad0013d1fd39080dd5423cc57
* Use m4_include, not sinclude in .m4 filesTom Tromey2019-10-232-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Pedro pointed out that sinclude does not error if a file is missing. This patch changes gdb to only use m4_include, which seems more correct. gdb/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * configure: Rebuild. * acinclude.m4: Use m4_include, not sinclude. gdb/gdbserver/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * configure: Rebuild. * acinclude.m4: Use m4_include, not sinclude. gdb/testsuite/ChangeLog 2019-10-23 Tom Tromey <tom@tromey.com> * configure: Rebuild. * aclocal.m4: Use m4_include, not sinclude. Change-Id: I970362e0af7875f9f72796401126acf0ff6dba11
* [gdb/testsuite] Compile infcall-nested-structs.exp with -O2Tom de Vries2019-10-213-35/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As mentioned in commit 745ff14e6e1 "[gdb/tdep] Fix 'Unexpected register class' assert in amd64_push_arguments", of the 12 KFAILs added there, 3 are KPASSing with g++ 4.8.5. The KPASSes are due to: - gdb incorrectly expecting the second half of the result of function rtn_str_struct_02_01 in register %rdx. - rtn_str_struct_02_01 using %rdx as a temporary, thereby accidentally setting it to the expected value. Reduce the chance of hiding errors due accidental register settings by compiling the test-case with -O2. This fixes the KPASSes when applied on top of commit 745ff14e6e1. Tested on x86_64-linux. Tested with g++ 4.8.5, 7.4.1, 8.3.1, 9.2.1. gdb/testsuite/ChangeLog: 2019-10-21 Tom de Vries <tdevries@suse.de> * gdb.base/infcall-nested-structs.c: Add __attribute__((noinline,noclone)) to all functions. (call_all): Add missing variable initialization. Simplify return value. (breakpt): Increment volatile variable, to prevent call from being optimized out. * gdb.base/infcall-nested-structs.exp: Compile with -O2. Change-Id: Ic027e1c957fecd6686345639db99f5eaee3cdf05
* [gdb/testsuite] Fix gdb.fortran/module.exp for debug info from other filesTom de Vries2019-10-172-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | On openSUSE Leap 15.1, I get: ... FAIL: gdb.fortran/module.exp: info variables -n ... because the info variables command prints info also for init.c: ... File init.c:^M 24: const int _IO_stdin_used;^M ... while the regexps in the test-case only expect info for module.f90. Fix this by extending the regexps. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-17 Tom de Vries <tdevries@suse.de> * gdb.fortran/module.exp: Allow info variables to print info for files other than module.f90. Change-Id: I401d8018b121fc7343f6bc8b671900349462457f
* gdb/fortran: Add test for module variables in 'info variables' outputAndrew Burgess2019-10-162-0/+28
| | | | | | | | | | | | | | | Recent work from Tom Tromey to better handle variables with associated copy relocations has fixed a Fortran issue where module variables wouldn't show up in the output of 'info variables'. This commit adds a test for this functionality to ensure it doesn't get broken in the future. gdb/testsuite/ChangeLog: * gdb.fortran/module.exp: Extend with 'info variables' test. Change-Id: I7306b1d0a9a72947fd48ad7a03f49df774d6573b
* gdb/testsuite: Allow cc-with-tweaks board file to be used with FortranAndrew Burgess2019-10-162-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The board file cc-with-tweaks is used as the core for lots of other board files, for example cc-with-gdb-index and cc-with-debug-names. This commit extends cc-with-tweaks so that it will wrap the Fortran compiler, allowing for more test coverage. I tested all of the board files that make use of cc-with-tweaks running the gdb.fortran/*.exp test set, and in some cases I did see extra failures. The "standard" results are: === gdb Summary === # of expected passes 953 # of known failures 2 With board file 'cc-with-dwz-m': === gdb Summary === # of expected passes 903 # of unexpected failures 1 # of known failures 2 # of untested testcases 4 With board file 'dwarf4-gdb-index': === gdb Summary === # of expected passes 950 # of unexpected failures 3 # of known failures 2 With board file 'fission-dwp': === gdb Summary === # of expected passes 949 # of unexpected failures 4 # of known failures 2 Despite these extra failure I don't think this should prevent this change going in as these failures presumably already exist in GDB. gdb/testsuite/ChangeLog: * boards/cc-with-tweaks.exp: Setup F90_FOR_TARGET and F77_FOR_TARGET. Change-Id: I06d412f94d0e119ad652dd6c20829f6705a54622
* [gdb/tdep] Fix inferior call arg passing for amd64Tom de Vries2019-10-162-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have 12 KFAILS in gdb.base/infcall-nested-structs.exp for PR tdep/25096. A minimal version of the failure looks like this. Consider test.c: ... struct s { int c; struct { int a; float b; } s1; }; struct s ref = { 0, { 'a', 'b' } }; int __attribute__((noinline,noclone)) check (struct s arg) { return arg.s1.a == 'a' && arg.s1.b == 'b' && arg.c == 0; } int main (void) { return check (ref); } ... When calling 'check (ref)' from main, we have '1' as expected: ... $ g++ test.c -g ; ./a.out ; echo $? 1 ... But when calling 'check (ref)' from the gdb prompt, we get '0': ... $ gdb a.out -batch -ex start -ex "p check (ref)" Temporary breakpoint 1 at 0x400518: file test.c, line 8. Temporary breakpoint 1, main () at test.c:8 8 { return check (ref); } $1 = 0 ... The layout of struct s is this: - the field c occupies 4 bytes at offset 0, - the s1.a field occupies 4 bytes at offset 4, and - the s1.b field occupies 4 bytes at offset 8. When compiling at -O2, we can see from the disassembly of main: ... 4003f0: 48 8b 3d 31 0c 20 00 mov 0x200c31(%rip),%rdi \ # 601028 <ref> 4003f7: f3 0f 10 05 31 0c 20 movss 0x200c31(%rip),%xmm0 \ # 601030 <ref+0x8> 4003fe: 00 4003ff: e9 ec 00 00 00 jmpq 4004f0 <_Z5check1s> ... that check is called with fields c and s1.a passed in %rdi, and s1.b passed in %xmm0. However, the classification in theclass (a variable representing the first and second eightbytes, to put it in SYSV X86_64 psABI terms) in amd64_push_arguments is incorrect: ... (gdb) p theclass $1 = {AMD64_INTEGER, AMD64_INTEGER} ... and therefore the struct is passed using %rdi and %rsi instead of using %rdi and %xmm0, which explains the failure. The reason that we're misclassifying the argument in amd64_classify_aggregate has to do with how nested struct are handled. Rather than using fields c and s1.a for the first eightbyte, and using field s1.b for the second eightbyte, instead field c is used for the first eightbyte, and fields s1.a and s1.b are classified together in an intermediate eightbyte, which is then used to merge with both the first and second eightbyte. Fix this by factoring out a new function amd64_classify_aggregate_field, and letting it recursively handle fields of nested structs. Tested on x86_64-linux. Tested with g++ 4.8.5, 7.4.1, 8.3.1, 9.2.1. Tested with clang++ 5.0.2 (which requires removing additional_flags=-Wno-psabi and adding additional_flags=-Wno-deprecated). gdb/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> PR tdep/25096 * amd64-tdep.c (amd64_classify_aggregate_field): Factor out of ... (amd64_classify_aggregate): ... here. (amd64_classify_aggregate_field): Handled fiels of nested structs recursively. gdb/testsuite/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> PR tdep/25096 * gdb.base/infcall-nested-structs.exp: Remove PR25096 KFAILs. Change-Id: Id55c74755f0a431ce31223acc86865718ae0c123
* [gdb/tdep] Fix 'Unexpected register class' assert in amd64_push_argumentsTom de Vries2019-10-162-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Atm, when executing gdb.base/infcall-nested-structs.exp on x86_64-linux, we get: ... FAIL: gdb.base/infcall-nested-structs.exp: l=c++: types-tc-tf: \ p/d check_arg_struct_02_01 (ref_val_struct_02_01) FAIL: gdb.base/infcall-nested-structs.exp: l=c++: types-ts-tf: \ p/d check_arg_struct_02_01 (ref_val_struct_02_01) FAIL: gdb.base/infcall-nested-structs.exp: l=c++: types-ti-tf: \ p/d check_arg_struct_02_01 (ref_val_struct_02_01) === gdb Summary === nr of expected passes 9255 nr of unexpected failures 3 nr of expected failures 142 ... The 3 FAILs are reported as PR tdep/25096. The 142 XFAILs are for a gdb assertion failure, reported in PR tdep/24104, which should have been KFAILs since there's a problem in gdb rather than in the environment. A minimal version of the assertion failure looks like this. Consider test.c: ... struct s { struct { } es1; long f; }; struct s ref = { {}, 'f' }; int __attribute__((noinline,noclone)) check (struct s arg) { return arg.f == 'f'; } int main (void) { return check (ref); } ... When calling 'check (ref)' from main, we have '1' as expected: ... $ g++ test3.c -g && ( ./a.out; echo $? ) 1 ... But when calling 'check (ref)' from the gdb prompt, we get: ... $ gdb a.out -batch -ex start -ex "p check (ref)" Temporary breakpoint 1 at 0x4004f7: file test.c, line 8. Temporary breakpoint 1, main () at test.c:8 8 { return check (ref); } src/gdb/amd64-tdep.c:982: internal-error: \ CORE_ADDR amd64_push_arguments(regcache*, int, value**, CORE_ADDR, \ function_call_return_method): \ Assertion `!"Unexpected register class."' failed. ... The assert happens in this loop in amd64_push_arguments: ... for (j = 0; len > 0; j++, len -= 8) { int regnum = -1; int offset = 0; switch (theclass[j]) { case AMD64_INTEGER: regnum = integer_regnum[integer_reg++]; break; case AMD64_SSE: regnum = sse_regnum[sse_reg++]; break; case AMD64_SSEUP: gdb_assert (sse_reg > 0); regnum = sse_regnum[sse_reg - 1]; offset = 8; break; default: gdb_assert (!"Unexpected register class."); } ... } ... when processing theclass[0], which is AMD64_NO_CLASS: ... (gdb) p theclass $1 = {AMD64_NO_CLASS, AMD64_INTEGER} ... The layout of struct s is that the empty field es1 occupies one byte (due to c++) at offset 0, and the long field f occupies 8 bytes at offset 8. When compiling at -O2, we can see from the disassembly of main: ... 4003f0: 48 8b 3d 41 0c 20 00 mov 0x200c41(%rip),%rdi \ # 601038 <ref+0x8> 4003f7: e9 e4 00 00 00 jmpq 4004e0 <_Z5check1s> 4003fc: 0f 1f 40 00 nopl 0x0(%rax) ... that check is called with field f passed in %rdi, meaning that the classification in theclass is correct, it's just not supported in the loop in amd64_push_arguments mentioned above. Fix the assert by implementing support for 'AMD64_NO_CLASS' in that loop. This exposes 9 more FAILs of the PR tdep/25096 type, so mark all 12 of them as KFAIL. Tested on x86_64-linux. Tested with g++ 4.8.5, 7.4.1, 8.3.1, 9.2.1. With 4.8.5, 3 of the 12 KFAILs are KPASSing. Tested with clang++ 5.0.2 (which requires removing additional_flags=-Wno-psabi and adding additional_flags=-Wno-deprecated). gdb/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> PR tdep/24104 * amd64-tdep.c (amd64_push_arguments): Handle AMD64_NO_CLASS in loop that handles 'theclass'. gdb/testsuite/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> PR tdep/24104 * gdb.base/infcall-nested-structs.exp: Remove XFAIL for PR tdep/24104. Add KFAIL for PR tdep/25096. Change-Id: I8b66345bbf5c00209ca75b1209fd4d60b36e9ede
* [gdb/testsuite] Fix local-static.exp with g++-4.8Tom de Vries2019-10-162-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With g++-4.8, I see: ... (gdb) PASS: gdb.cp/local-static.exp: c++: print free_inline_func(void) print 'S::method()'::S_M_s_var_int^M No symbol "S_M_s_var_int" in specified context.^M (gdb) FAIL: gdb.cp/local-static.exp: c++: print 'S::method()'::S_M_s_var_int ... The variable is declared like this (showing pruned .ii): ... void S::method () { static int S_M_s_var_int = 4; } ... But the DWARF generated for the variable is encapsulated in an unnamed lexical block: ... <1><121>: Abbrev Number: 5 (DW_TAG_structure_type) <122> DW_AT_name : S ... <2><14f>: Abbrev Number: 6 (DW_TAG_subprogram) ... <150> DW_AT_name : (indirect string, offset: 0x599): method <156> DW_AT_linkage_name: (indirect string, offset: 0x517): \ _ZN1S6methodEv /* demangled: dS::method() */ ... <1><3f8>: Abbrev Number: 21 (DW_TAG_subprogram) <3f9> DW_AT_specification: <0x14f> ... <3fe> DW_AT_low_pc : 0x4004fc <406> DW_AT_high_pc : 0x2c /* 0x400528 */ ... <2><418>: Abbrev Number: 17 (DW_TAG_formal_parameter) <419> DW_AT_name : (indirect string, offset: 0x68a): this ... <2><424>: Abbrev Number: 18 (DW_TAG_lexical_block) <425> DW_AT_low_pc : 0x400508 <42d> DW_AT_high_pc : 0x1e /* 0x400526 */ <3><435>: Abbrev Number: 22 (DW_TAG_variable) <436> DW_AT_name : (indirect string, offset: 0x29d): S_M_s_var_int ... which has the effect that the variable is not addressable unless the program counter is in the range of the lexical block. This is caused by gcc PR debug/55541, which was fixed in gcc 5. Mark in total 225 FAILs as XFAIL. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> PR testsuite/25059 * gdb.cp/local-static.exp (do_test): Add xfails for gcc PR debug/55541. Change-Id: Ibe86707eecffc79f1bb474d7928ea7d0c39a00a2
* [gdb/testsuite] Fix regexp for reg value in jit-reader.expTom de Vries2019-10-162-20/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | On openSUSE Leap 15.1 (as well as on Fedora-x86_64-m64 buildbot) I see: ... FAIL: gdb.base/jit-reader.exp: with jit-reader: after mangling: current frame: info registers ... The problem is that r10 is printed signed: ... r10 0xffffffffffffffb0 -80^M ... but the regexp expects a signed value: ... "r10 $hex +$decimal" \ ... Fix this by allowing signed values. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-16 Tom de Vries <tdevries@suse.de> * gdb.base/jit-reader.exp: Allow non-pointer registers to be printed as signed. Change-Id: Ie494d24fad7a9af7ac6bfaf731c4aa04f1333830
* [gdb/testsuite] Fix gdb.ada/mi_task_arg.expTom de Vries2019-10-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | On openSUSE Leap 15.1, we have: ... FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output) ... The problem is that the stack-list-arguments command prints a frame argument 'self_id' for function system.tasking.stages.task_wrapper: ... frame={level="2",args=[{name="self_id",value="0x12345678"}] ... where none (args=[]) is expected. The frame argument is in fact correct. The FAIL does not show for say, fedora 30, because there the executable uses the system.tasking.stages.task_wrapper from /lib64/libgnarl-9.so. Adding "additional_flags=-bargs additional_flags=-shared additional_flags=-largs" to the flags argument of gdb_compile_ada gives us the same PASS, but installing libada7-debuginfo gets us the same FAIL again. Fix the FAIL by allowing the 'self_id' argument. Tested on x86_64-linux. Change-Id: I5aee5856fa6aeb0cc78aa4fe69deecba5b00b77a
* gdb.mi/list-thread-groups-available.exp: read entries one by one instead of ↵Simon Marchi2019-10-142-9/+23
| | | | | | | | | | | | | | | | | | | increasing timeout Commit 580f1034 ("Increase timeout in gdb.mi/list-thread-groups-available.exp") changed gdb.mi/list-thread-groups-available.exp to significantly increase the timeout, which was necessary for when running with make check-read1. Pedro suggested a better alternative, which is to use gdb_test_multiple and consume one entry at a time. This patch does that. gdb/testsuite/ChangeLog: * gdb.mi/list-thread-groups-available.exp: Read entries one by one instead of increasing timeout. Change-Id: I51b689458503240f24e401f054e6583d9172ebdf
* Mention PR c++/20020 in ChangeLog entryTom de Vries2019-10-131-0/+1
| | | | | [ Port of gdb-8.3-branch commit 59047affb0a "Update ChangeLog entry of commit 98c90f8028 and mention PR c++/20020". ]
* Mention PR testsuite/25016 in ChangeLog entryTom de Vries2019-10-131-0/+1
| | | | | [ Port of gdb-8.3-branch commit 3d80b2e754f "Update ChangeLog entry of commit 3b752ac2e6 and mention PR testsuite/25016". ]
* Mention PR breakpoints/25011 in ChangeLog entryTom de Vries2019-10-131-0/+1
| | | | | [ Port of gdb-8.3-branch commit 88f07f28d5b "Update ChangeLog entry of commit 7e38ddcb2e and mention PR breakpoints/25011". ]
* [gdb/testsuite] Add KFAIL for missing support of reverse-debugging xsaveTom de Vries2019-10-139-8/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Normally the gdb.reverse/*.exp test-cases pass on my system (apart from the record/23188 KFAIL for gdb.reverse/step-precsave.exp). But when specifying GLIBC_TUNABLES=glibc.tune.hwcaps=-XSAVEC_Usable to force glibc to use _dl_runtime_resolve_xsave instead of _dl_runtime_resolve_xsavec, we run into 1054 FAILs like this: ... (gdb) PASS: gdb.reverse/sigall-reverse.exp: b gen_HUP continue^M Continuing.^M Process record does not support instruction 0xfae64 at address \ 0x7ffff7ded958.^M Process record: failed to record execution log.^M ^M Program stopped.^M 0x00007ffff7ded958 in _dl_runtime_resolve_xsave () from \ /lib64/ld-linux-x86-64.so.2^M (gdb) FAIL: gdb.reverse/sigall-reverse.exp: get signal ABRT ... The problem is that the xsave instruction is not supported in reverse-debugging (PR record/25038). Add KFAILs for this PR. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-13 Tom de Vries <tdevries@suse.de> PR record/25038 * gdb.reverse/sigall-precsave.exp: Add PR record/25038 KFAIL. * gdb.reverse/sigall-reverse.exp: Same. * gdb.reverse/solib-precsave.exp: Same. * gdb.reverse/solib-reverse.exp: Same. * gdb.reverse/step-precsave.exp: Same. * gdb.reverse/until-precsave.exp: Same. * gdb.reverse/until-reverse.exp: Same. * lib/gdb.exp (gdb_continue_to_breakpoint): Same.
* gdb/testsuite: Fix typos in infcall-nested-structs.cAndreas Arnez2019-10-102-10/+18
| | | | | | | | | | | | | | | | | | Some of the comparison functions in infcall-nested-structs.c contain redundant comparisons like a.<some_field> == a.<some_field> instead of a.<some_field> == b.<some_field>. They were introduced with this commit: 36eb4c5f9bbe6 - "infcall-nested-structs: Test up to five fields" Fix the redundant comparisons. gdb/testsuite/ChangeLog: * gdb.base/infcall-nested-structs.c (cmp_struct_02_01) (cmp_struct_02_02, cmp_struct_04_01, cmp_struct_04_02) (cmp_struct_05_01, cmp_struct_static_02_01) (cmp_struct_static_04_01, cmp_struct_static_06_01): Fix redundant comparisons.
* [gdb/testsuite] Fix ada tests with -fPIE/-pieTom de Vries2019-10-102-0/+31
| | | | | | | | | | | | | | | | | | | When running the gdb testsuite with target board unix/-fPIE/-pie, the resulting ada executables are not PIE executables, because gnatmake doesn't recognize -pie, and consequently doesn't pass it to gnatlink. Fix this by replacing "-pie" with "-largs -pie -margs" in target_compile_ada_from_dir, and doing the same for -no-pie. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-10 Tom de Vries <tdevries@suse.de> PR testsuite/24888 * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to gnatlink.
* [gdb/testsuite] Add XFAILs in gdb.rust/simple.exp for incorrect DWARFTom de Vries2019-10-092-5/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On openSUSE Leap 15.1 using rustc version 1.36.0 (using llvm 7), I get: ... (gdb) PASS: gdb.rust/simple.exp: print e2.0 print k^M $54 = simple::SpaceSaver::Thebox(40, 0x0)^M (gdb) FAIL: gdb.rust/simple.exp: print k ... while we're expecting: ... gdb_test "print k" " = simple::SpaceSaver::Nothing" ... When using a relatively recent version of Rust with a somewhat older version of LLVM, the Rust compiler will emit a legacy encoding of enums (see also quirk_rust_enum in dwarf2read.c). So, the variable k: ... <17><3d58>: Abbrev Number: 15 (DW_TAG_variable) <3d59> DW_AT_location : 3 byte block: 91 b8 4 (DW_OP_fbreg: 568) <3d5d> DW_AT_name : (indirect string, offset: 0xf9a): k <3d61> DW_AT_alignment : 1 <3d62> DW_AT_decl_file : 1 <3d63> DW_AT_decl_line : 129 <3d64> DW_AT_type : <0x4232> ... has type: ... <2><4232>: Abbrev Number: 11 (DW_TAG_union_type) <4233> DW_AT_name : (indirect string, offset: 0x3037): SpaceSaver <4237> DW_AT_byte_size : 16 <4238> DW_AT_alignment : 8 <3><4239>: Abbrev Number: 9 (DW_TAG_member) <423a> DW_AT_name : (indirect string, offset: 0x29f5): RUST$ENCODED$ENUM$0$Nothing <423e> DW_AT_type : <0x4245> <4242> DW_AT_alignment : 8 <4243> DW_AT_data_member_location: 0 ... The "RUST$ENCODED$ENUM$0$Nothing" means that field 0 is both a pointer and a discriminant, and if the value is 0, then the enum is just a data-less variant named "Nothing". However, the corresponding type has two fields, where not field 0 but field 1 is a pointer, and field 0 is a byte: ... <2><4245>: Abbrev Number: 8 (DW_TAG_structure_type) <4246> DW_AT_name : (indirect string, offset: 0x2a11): Thebox <424a> DW_AT_byte_size : 16 <424b> DW_AT_alignment : 8 <3><424c>: Abbrev Number: 9 (DW_TAG_member) <424d> DW_AT_name : (indirect string, offset: 0x670): __0 <4251> DW_AT_type : <0x436b> <4255> DW_AT_alignment : 1 <4256> DW_AT_data_member_location: 8 <3><4257>: Abbrev Number: 9 (DW_TAG_member) <4258> DW_AT_name : (indirect string, offset: 0x1662): __1 <425c> DW_AT_type : <0x45da> <4260> DW_AT_alignment : 8 <4261> DW_AT_data_member_location: 0 ... Mark this as xfail. gdb/testsuite/ChangeLog: 2019-10-09 Tom de Vries <tdevries@suse.de> PR testsuite/25048 * gdb.rust/simple.exp: Add xfails for incorrect DWARF.
* gdb/testsuite/ada: Handle missing debug info caseAndrew Burgess2019-10-072-7/+23
| | | | | | | | | | | | | | | | Update a test script to handle the case where missing Ada debug information means we can't catch exceptions. This was discussed on the list here: https://sourceware.org/ml/gdb-patches/2019-08/msg00607.html And is similar to code that already exists in the test scripts gdb.ada/catch_ex.exp and gdb.ada/mi_catch_ex.exp. gdb/testsuite/ChangeLog: * gdb.ada/catch_ex_std.exp: Handle being unabled to catch Ada exceptions due to missing debug information.
* [gdb/testsuite] Update expected _gdb_major/_gdb_minor in default.expTom de Vries2019-10-072-2/+6
| | | | | | | | | | | | | | | | | | Now that commit "225f296a023 Change gdb/version.in to 9.0.50.DATE-git (new version numbering scheme)" has changed the gdb version number, we see: ... FAIL: gdb.base/default.exp: show convenience ($_gdb_major = 8 not found) ... Fix this by updating the expected _gdb_major/_gdb_minor to 9.1. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-07 Tom de Vries <tdevries@suse.de> * gdb.base/default.exp: Expect _gdb_major/_gdb_minor to be 9.1.
* gdb/testsuite: Add gdb_test_name variableAndrew Burgess2019-10-073-32/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new feature to gdb_test_multiple, an automatically created variable gdb_test_name. The idea is to make it easier to write tests using gdb_test_multiple, and avoid places where the string passed to pass/fail within an action element is different to the message passed to the top level gdb_test_multiple. As an example, previously you might write this: gdb_test_multiple "print foo" "test foo" { -re "expected output 1" { pass "test foo" } -re "expected output 2" { fail "test foo" } } This is OK, but it's easy for the pass/fail strings to come out of sync, or contain a typo. A better version would look like this: set testname "test foo" gdb_test_multiple "print foo" $testname { -re "expected output 1" { pass $testname } -re "expected output 2" { fail $testname } } This is better, but its a bit of a drag having to create a new variable each time. After this patch you can now write this: gdb_test_multiple "print foo" "test foo" { -re "expected output 1" { pass $gdb_test_name } -re "expected output 2" { fail $gdb_test_name } } The $gdb_test_name is setup by gdb_test_multiple, and cleaned up once the test has completed. Nested calls to gdb_test_multiple are supported, though $gdb_test_name will only ever contain the inner most test message (which is probably what you want). My only regret is that '$gdb_test_name' is so long, but I wanted something that was unlikely to clash with any existing variable name, or anything that a user is likely to want to use. I've tested this on x86-64/GNU Linux and see no test regressions, and I've converted one test script over to make use of this new technique both as an example, and to ensure that the new facility doesn't get broken. I have no plans to convert all tests over to this technique, but I hope others will find this useful for writing tests in the future. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_test_multiple): Add gdb_test_name mechanism. * gdb.base/annota1.exp: Update to use gdb_test_name.
* gdb: CTF supportWeimin Pan2019-10-078-0/+2023
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the CTF (Compact Ansi-C Type Format) support in gdb. Two submissions on which this gdb work depends were posted earlier in May: * On the binutils mailing list - adding libctf which creates, updates, reads, and manipulates the CTF data. * On the gcc mailing list - expanding gcc to directly emit the CFT data with a new command line option -gt. CTF is a reduced form of debugging information whose main purpose is to describe the type of C entities such as structures, unions, typedefs and function arguments at the global scope only. It does not contain debug information about source lines, location expressions, or local variables. For more information on CTF, see the documentation in the libdtrace-ctf source tree, available here: <https://raw.githubusercontent.com/oracle/libdtrace-ctf/master/doc/ctf-format>. This patch expands struct elfinfo by adding the .ctf section, which contains CTF debugging info, and modifies elf_symfile_read() to read it. If both DWARF and CTF exist in a program, only DWARF will be read. CTF data will be read only when there is no DWARF. The two-stage symbolic reading and setting strategy, partial and full, was used. File ctfread.c contains functions to transform CTF data into gdb's internal symbol table structures by iterately reading entries from CTF sections of "data objects", "function info", "variable info", and "data types" when setting up either partial or full symbol table. If the ELF symbol table is available, e.g. not stripped, the CTF reader will associate the found type information with these symbol entries. Due to the proximity between DWARF and CTF (CTF being a much simplified subset of DWARF), some DWARF implementation was reused to support CTF. Test cases ctf-constvars.exp, ctf-cvexpr.exp, ctf-ptype.exp, and ctf-whatis.exp have been added to verify the correctness of this support. This patch has missing features and limitations which we will add and address in the future patches. gdb/ChangeLog +2019-10-07 Weimin Pan <weimin.pan@oracle.com> + + * gdb/ctfread.c: New file. + * gdb/ctfread.h: New file. + * gdb/elfread.c: Include ctfread.h. + (struct elfinfo text_p): New member ctfsect. + (elf_locate_sections): Mark CTF section. + (elf_symfile_read): Call elfctf_build_psymtabs. + * gdb/Makefile.in (LIBCTF): Add. + (CLIBS): Use it. + (CDEPS): Likewise. + (DIST): Add ctfread.c. + * Makefile.def (dependencies): Add all-libctf to all-gdb + * Makefile.in: Add "all-gdb: maybe-all-libctf" + gdb/testsuite/ChangeLog +2019-10-07 Weimin Pan <weimin.pan@oracle.com> + + * gdb.base/ctf-whatis.exp: New file. + * gdb.base/ctf-whatis.c: New file. + * gdb.base/ctf-ptype.exp: New file. + * gdb.base/ctf-ptype.c: New file. + * gdb.base/ctf-constvars.exp: New file. + * gdb.base/ctf-constvars.c: New file. + * gdb.base/ctf-cvexpr.exp: New file. +
* [gdb/testsuite] Fix local-static.exp with gcc-4.8Tom de Vries2019-10-042-1/+8
| | | | | | | | | | | | | | | | | | | | | | | With gdb.cp/local-static.exp and gcc 4.8, I see: ... gdb compile failed, src/gdb/testsuite/gdb.cp/local-static.c: In function 'main': src/gdb/testsuite/gdb.cp/local-static.c:148:3: error: 'for' loop initial \ declarations are only allowed in C99 mode for (int i = 0; i < 1000; i++) ^ src/gdb/testsuite/gdb.cp/local-static.c:148:3: note: use option -std=c99 or \ -std=gnu99 to compile your code UNTESTED: gdb.cp/local-static.exp: c: failed to prepare ... Fix this by moving the declaration of int i out of the for loop. gdb/testsuite/ChangeLog: 2019-10-04 Tom de Vries <tdevries@suse.de> * gdb.cp/local-static.c (main): Move declaration of int i out of the for loop.
* Avoid crash on single-field union in RustTom Tromey2019-10-033-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR rust/24976 points out a crash in gdb when a single-field union is used in Rust. The immediate problem was a NULL pointer dereference in quirk_rust_enum. However, that code is also erroneously treating a single-field union as if it were a univariant enum. Looking at the output of an older Rust compiler, it turns out that univariant enums are distinguished by having a single *anonymous* field. This patch changes quirk_rust_enum to limit its fixup to this case. Tested with a new-enough version of the Rust compiler to cause the crash; plus by using an older executable that uses the old univariant encoding. gdb/ChangeLog 2019-10-03 Tom Tromey <tom@tromey.com> PR rust/24976: * dwarf2read.c (quirk_rust_enum): Handle single-element unions. gdb/testsuite/ChangeLog 2019-10-03 Tom Tromey <tom@tromey.com> PR rust/24976: * gdb.rust/simple.rs (Union2): New type. (main): Use Union2. * gdb.rust/simple.exp: Add test.
* gdb/fortran: Allow for matching symbols with missing scopeAndrew Burgess2019-10-032-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit allows symbol matching within Fortran code without having to specify all of the symbol's scope. For example, given this Fortran code: module aaa contains subroutine foo print *, "hello." end subroutine foo end module aaa subroutine foo print *, "hello." end subroutine foo program test call foo contains subroutine foo print *, "hello." end subroutine foo subroutine bar use aaa call foo end subroutine bar end program test The user can now do this: (gdb) b foo Breakpoint 1 at 0x4006c2: foo. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x00000000004006c2 in aaa::foo at nest.f90:4 1.2 y 0x0000000000400730 in foo at nest.f90:9 1.3 y 0x00000000004007c3 in test::foo at nest.f90:16 The user asks for a breakpoint on 'foo' and is given a breakpoint on all three possible 'foo' locations. The user is, of course, still able to specify the scope in order to place a single breakpoint on just one of the foo functions (or use 'break -qualified foo' to break on just the global foo). gdb/ChangeLog: * f-lang.c (f_language_defn): Use cp_get_symbol_name_matcher and cp_search_name_hash. * NEWS: Add entry about nested function support. gdb/testsuite/ChangeLog: * gdb.fortran/nested-funcs-2.exp: Run tests with and without the nested function prefix.
* gdb/fortran: Nested subroutine supportAndrew Burgess2019-10-035-3/+319
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is a rebase and update of the following three patches: https://sourceware.org/ml/gdb-patches/2018-11/msg00298.html https://sourceware.org/ml/gdb-patches/2018-11/msg00302.html https://sourceware.org/ml/gdb-patches/2018-11/msg00301.html I have merged these together into a single commit as the second patch, adding scope support to nested subroutines, means that some of the changes in the first patch are now no longer useful and would have to be backed out. The third patch is tightly coupled to the changes in the second of these patches and I think deserves to live together with it. There is an extra change in cp-namespace.c that is new, this resolves an issue with symbol lookup when placing breakpoints from within nested subroutines. There is also an extra test added to this commit 'nested-funcs-2.exp' that was written by Richard Bunt from ARM, this offers some additional testing of breakpoints on nested functions. After this commit it is possible to place breakpoints on nested Fortran subroutines and functions by using a fully scoped name, for example, given this simple Fortran program: program greeting call message contains subroutine message print *, "Hello World" end subroutine message end program greeting It is possible to place a breakpoint in 'message' with: (gdb) break greeting::message Breakpoint 1 at 0x4006c9: file basic.f90, line 5. What doesn't work with this commit is placing a breakpoint like this: (gdb) break message Function "message" not defined. Making this work will come in a later commit. gdb/ChangeLog: * cp-namespace.c (cp_search_static_and_baseclasses): Only search for nested static variables when searchin VAR_DOMAIN. * dwarf2read.c (add_partial_symbol): Add nested subroutines to the global scope, update comment. (add_partial_subprogram): Call add_partial_subprogram recursively for nested subroutines when processinng Fortran. (load_partial_dies): Process the child entities of a subprogram when processing Fortran. (partial_die_parent_scope): Handle building scope for Fortran nested functions. (process_die): Record that nested functions have a scope. (new_symbol): Always record Fortran subprograms on the global symbol list. (determine_prefix): How to build the prefix for Fortran subprograms. gdb/testsuite/ChangeLog: * gdb.fortran/nested-funcs.exp: Tests for placing breakpoints on nested functions. * gdb.fortran/nested-funcs.f90: Update expected results. * gdb.fortran/nested-funcs-2.exp: New file. * gdb.fortran/nested-funcs-2.f90: New file. gdb/doc/ChangeLog: * doc/gdb.texinfo (Fortran Operators): Describe scope operator.
* gdb/testsuite: Reduce test name duplication in gdb.python testsAndrew Burgess2019-10-034-158/+231
| | | | | | | | | | | | | | This commit removes some, but not all, of the test name duplication within the gdb.python tests. On my local machine this takes the number of duplicate test names in this set of tests from 174 to 85. It is possible that different setups might encounter more duplicate tests. gdb/testsuite/ChangeLog: * gdb.python/py-parameter.exp: Make test names unique. * gdb.python/py-template.exp: Likewise. * gdb.python/py-value.exp: Likewise.
* gdb/testsuite: Reduce test name duplication in gdb.base testsAndrew Burgess2019-10-0310-174/+251
| | | | | | | | | | | | | | | | | | | This commit removes some, but not all, of the test name duplication within the gdb.base tests. On my local machine this takes the number of duplicate test names in this set of tests from 454 to 145. It is possible that different setups might encounter more duplicate tests. gdb/testsuite/ChangeLog: * gdb.base/break-interp.exp: Reduce test name duplication. * gdb.base/call-sc.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/charset.exp: Likewise. * gdb.base/dump.exp: Likewise. * gdb.base/ena-dis-br.exp: Likewise. * gdb.base/relational.exp: Likewise. * gdb.base/step-over-syscall.exp: Likewise. * gdb.base/structs.exp: Likewise.
* gdb/testsuite: Make test names unique in gdb.linespec testsAndrew Burgess2019-10-033-4/+12
| | | | | | | | | | | Make test names unique in the gdb.linespec tests. On my local machine this removed 43 duplicate test names. It is possible that different setups might still encounter some duplicates. gdb/testsuite/ChangeLog: * gdb.linespec/explicit.exp: Make test names unique. * gdb.linespec/ls-errs.exp: Likewise.
* gdb/testsuite: Make test names unique in gdb.reverse testsAndrew Burgess2019-10-0314-47/+102
| | | | | | | | | | | | | | | | | | | | | | Make test names unique in the gdb.reverse tests. On my local machine this removed 825 duplicate test names. It is possible that different setups might still encounter some duplicates. gdb/testsuite/ChangeLog: * gdb.reverse/break-precsave.exp: Make test names unique. * gdb.reverse/break-reverse.exp: Likewise. * gdb.reverse/finish-precsave.exp: Likewise. * gdb.reverse/finish-reverse.exp: Likewise. * gdb.reverse/machinestate-precsave.exp: Likewise. * gdb.reverse/machinestate.exp: Likewise. * gdb.reverse/readv-reverse.exp: Likewise. * gdb.reverse/recvmsg-reverse.exp: Likewise. * gdb.reverse/sigall-precsave.exp: Likewise. * gdb.reverse/sigall-reverse.exp: Likewise. * gdb.reverse/step-indirect-call-thunk.exp: Likewise. * gdb.reverse/watch-precsave.exp: Likewise. * gdb.reverse/watch-reverse.exp: Likewise.
* gdb: Don't ignore all SIGSTOP when the signal handler is set to passAndrew Burgess2019-10-033-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was observed that in a multi-threaded application on GNU/Linux, that if the user has set the SIGSTOP to be pass (using GDB's handle command) then the inferior would hang upon hitting a breakpoint. What happens is that when a thread hits the breakpoint GDB tries to stop all of the other threads by sending them a SIGSTOP and setting the stop_requested flag in the target_ops structure - this can be seen in infrun.c:stop_all_threads. GDB then waits for all of the other threads to stop. When the SIGSTOP event arrives we eventually end up in linux-nat.c:linux_nat_filter_event, which has the job of deciding if the event we're looking at (the SIGSTOP arriving in this case) is something that should be reported back to the core of GDB. One of the final actions of this function is to check if we stopped due to a signal, and if we did, and the signal has been set to 'pass' by the user then we ignore the event and resume the thread. This code already has some conditions in place that mean the event is reported to GDB even if the signal is in the set of signals to be passed to the inferior. In this commit I extend this condition such that: If the signal is a SIGSTOP, and the thread's stop_requested flag is set (indicating we're waiting for the thread to stop with a SIGSTOP) then we should report this SIGSTOP to GDB and not pass it to the inferior. With this change in place the test now passes. Regression tested on x86-64 GNU/Linux with no regressions. gdb/ChangeLog: * linux-nat.c (linux_nat_filter_event): Don't ignore SIGSTOP if we have just sent the thread a SIGSTOP and are waiting for it to arrive. gdb/testsuite/ChangeLog: * gdb.threads/stop-with-handle.c: New file. * gdb.threads/stop-with-handle.exp: New file.
* [gdb/testsuite] Fix list-missing-source.exp with gcc 4.8Tom de Vries2019-10-032-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With gcc 4.8.1, we see this FAIL: ... (gdb) PASS: gdb.base/list-missing-source.exp: list info source^M Current source file is outputs/gdb.base/list-missing-source/main.c^M Source language is c.^M Producer is GNU C 4.8.5 -mtune=generic -march=x86-64 -g -fno-stack-protector.^M Compiled with DWARF 2 debugging format.^M Does not include preprocessor macro info.^M (gdb) FAIL: gdb.base/list-missing-source.exp: info source ... The problem is that a "Compilation directory is <dir>" line is expected, but this is missing due to the fact the the compilation unit for main.c doesn't contain a DW_AT_comp_dir in the DW_TAG_compile_unit DIE. Fix this by allowing the "Compilation directory" line to be missing. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-03 Tom de Vries <tdevries@suse.de> PR testsuite/25059 * gdb.base/list-missing-source.exp: Allowing the "Compilation directory" line to be missing.
* [gdb/testsuite] Fix info-types.exp with gcc/g++ 4.8Tom de Vries2019-10-032-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gdb.base/info-types.exp test-case FAILs with gcc/g++ 4.8 because the DWARF record for the 'unsigned int' type is missing in the executables, while it is present for gcc/g++ 7.4.1. For a minimal example using gcc 7.4.1: ... $ echo "enum enum_t { AA, BB, CC }; enum enum_t var;" > enum.c $ gcc enum.c -c -g ... we find that the enum type has DW_AT_encoding 'unsigned': <1><1d>: Abbrev Number: 2 (DW_TAG_enumeration_type) <1e> DW_AT_name : (indirect string, offset: 0x1f): enum_t <22> DW_AT_encoding : 7 (unsigned) <23> DW_AT_byte_size : 4 <24> DW_AT_type : <0x3e> <28> DW_AT_decl_file : 1 <29> DW_AT_decl_line : 1 <2a> DW_AT_sibling : <0x3e> ... and a DW_AT_type reference to the type 'unsigned int': ... <1><3e>: Abbrev Number: 4 (DW_TAG_base_type) <3f> DW_AT_byte_size : 4 <40> DW_AT_encoding : 7 (unsigned) <41> DW_AT_name : (indirect string, offset: 0x26): unsigned int ... With gcc 4.8.5 however, we have no 'unsigned' encoding, and no DW_AT_type: ... <1><1d>: Abbrev Number: 2 (DW_TAG_enumeration_type) <1e> DW_AT_name : (indirect string, offset: 0x1f): enum_t <22> DW_AT_byte_size : 4 <23> DW_AT_decl_file : 1 <24> DW_AT_decl_line : 1 <25> DW_AT_sibling : <0x39> ... as well as no record for 'unsigned int'. Make the test-case pass with gcc/g++ 4.8 by making the presence of the 'unsigned int' type optional. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-03 Tom de Vries <tdevries@suse.de> PR testsuite/25059 * gdb.base/info-types.exp: Make the presence of the 'unsigned int' type optional.