aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
AgeCommit message (Collapse)AuthorFilesLines
2019-01-24AArch64 AAPCS: Ignore static membersAlan Hayward2-6/+191
Static members in C++ structs are global data and therefore not part of the list of struct members considered for passing in registers. Note the corresponding code in GCC (from which the GDB AAPCS code is based) does not have any static member checks due to the static members not being part of the struct type at that point. Extend gdb.base/infcall-nested-structs.exp to test structs with static members when compiled for C++. XFAIL more cases for x86_64 (see gdb/24104). For completeness, ensure some test cases have both empty structures and static members. Also fixes gdb.dwarf2/dw2-cp-infcall-ref-static.exp. gdb/ChangeLog: * aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): Check for static members. (pass_in_v_vfp_candidate): Likewise. gdb/testsuite/ChangeLog: * gdb.base/infcall-nested-structs.c (struct struct_static_02_01): New structure. (struct struct_static_02_02): Likewise. (struct struct_static_02_03): Likewise. (struct struct_static_02_04): Likewise. (struct struct_static_04_01): Likewise. (struct struct_static_04_02): Likewise. (struct struct_static_04_03): Likewise. (struct struct_static_04_04): Likewise. (struct struct_static_06_01): Likewise. (struct struct_static_06_02): Likewise. (struct struct_static_06_03): Likewise. (struct struct_static_06_04): Likewise. (cmp_struct_static_02_01): Likewise. (cmp_struct_static_02_02): Likewise. (cmp_struct_static_02_03): Likewise. (cmp_struct_static_02_04): Likewise. (cmp_struct_static_04_01): Likewise. (cmp_struct_static_04_02): Likewise. (cmp_struct_static_04_03): Likewise. (cmp_struct_static_04_04): Likewise. (cmp_struct_static_06_01): Likewise. (cmp_struct_static_06_02): Likewise. (cmp_struct_static_06_03): Likewise. (cmp_struct_static_06_04): Likewise. (call_all): Test new structs. * gdb.base/infcall-nested-structs.exp: Likewise.
2019-01-21AArch64 AAPCS: Empty structs have non zero size in C++Alan Hayward1-13/+45
When gdb.base/infcall-nested-structs.c is complied as C++, the compiler will not pass structs containing empty structs via float arguments. This is because structs in C++ have a minimum size of 1, causing padding in the struct once compiled. The AAPCS does not allow structs with padding to be passed in float arguments. Add padding checks to AArch64 and add C++ compile variant to the test. Some of the tests fail on X86_64. This has been raised as bug gdb/24104. gdb/ChangeLog: * aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): Check for padding. gdb/testsuite/ChangeLog: * gdb.base/infcall-nested-structs.exp: Test C++ in addition to C.
2019-01-21Testsuite: Ensure stack protection is off for GCCAlan Hayward2-0/+96
Using -fstack-protector-strong will cause GDB to break on the wrong line when placing a breakpoint on a function. This is due to inadequate dwarf line numbering, and is being tracked by the GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432 GCC (and Clang) provided by Debian/Ubuntu default to stack protector being enabled. Ensure that when running the GDB testsuite, stack protector is always turned off for GCC 4.1.0 (when stack protector was added) and above. Ensure that this does not cause infinite recursion due to test_compiler_info having to compile a file itself. Add a test to explicitly test breakpoints with various levels of stack protection on both GCC and Clang, with xfail for the known errors. Restore change in ovldbreak.exp which worked around the issue. gdb/testsuite/ChangeLog: 2019-01-18 Alan Hayward <alan.hayward@arm.com> * gdb.base/stack-protector.c: New test. * gdb.base/stack-protector.exp: New file. * gdb.cp/ovldbreak.exp: Only allow a single break line. * lib/gdb.exp (get_compiler_info): Use getting_compiler_info option. (gdb_compile): Remove stack protector for GCC and prevent recursion.
2019-01-12gdb/testsuite: Don't allow paths to appear in test nameAndrew Burgess1-0/+1
Having paths in the test names makes it harder to compare results between two runs in different directories. Give the test a name so that the path doesn't appear. gdb/ChangeLog: * gdb.base/style.exp: Don't include path in testname.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker874-874/+874
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-12-28Fix a crash in jit.cTom Tromey3-0/+102
A user at Mozilla pointed out a crash in jit.c. In his situation, an inferior using the JIT API exec'd an executable that did not use it. This caused an assertion failure when jit.c:free_objfile_data called delete_breakpoint with NULL. This patch fixes the problem in the obvious way. New test case included. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * jit.c (free_objfile_data): Only delete breakpoint if non-null. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> Simon Marchi <simark@simark.ca> * gdb.base/jit-exec.exp: New file. * gdb.base/jit-exec.c: New file. * gdb.base/jit-execd.c: New file.
2018-12-28Style addressesTom Tromey1-1/+1
This changes gdb to style addresses. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind) <ADDRESS>: New constant. * ui-out.c (ui_out::field_core_addr): Add styling. * stack.c (print_frame): Add styling. * printcmd.c (print_address): Add styling. (print_address_demangle, info_address_command): Likewise. * cli/cli-style.h (address_style): Declare. * cli/cli-style.c (address_style): New global. (_initialize_cli_style): Register new commands. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Update test to check for address styling.
2018-12-28Style the "Reading symbols" messageTom Tromey1-0/+4
The "Reading symbols" message does not use ui-out (perhaps it should?), so this styles it using the low-level API. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * symfile.c (symbol_file_add_with_addrs): Style file name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for styling of "Reading symbols" message.
2018-12-28Style the gdb welcome messageTom Tromey1-0/+6
This changes gdb to style the welcome message that is shown by default. The styling is only done interactively. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * top.c (print_gdb_version): Style gdb version number. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for version number styling.
2018-12-28Style print_address_symbolicTom Tromey1-0/+2
print_address_symbolic does not use ui-out, so it did not style function names. This patch changes it to use the low-level style code directly. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * printcmd.c (print_address_symbolic): Style function name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for print_address_symbolic.
2018-12-28Style locations when setting a breakpointTom Tromey1-1/+4
say_where does not use ui-out, so function and file names printed by it were not styled. This patch changes say_where to use the low-level style code directly. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * breakpoint.c (say_where): Style file name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for breakpoint setting.
2018-12-28Style variable namesTom Tromey1-1/+2
This adds style support for variable names. For the time being, this is only done in backtraces, not in ptype or print; those places do not use ui-out and so would need ad hoc changes. This also adds styling to the names printed for local variables in "backtrace full". This code does not use ui-out, so the styling is done using the low-level API. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind) <VARIABLE>: New global. * stack.c (print_frame_arg): Style name. * printcmd.c (print_variable_and_value): Style variable name. * cli/cli-style.h (variable_name_style): Declare. * cli/cli-style.c (variable_name_style): New global. (_initialize_cli_style): Update. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for variable names.
2018-12-28Add output styles to gdbTom Tromey2-0/+61
This adds some output styling to the CLI. A style is currently a foreground color, a background color, and an intensity (dim or bold). (This list could be expanded depending on terminal capabilities.) A style can be applied while printing. For ui-out, this is done by passing the style constant as an argument. For low-level cases, fprintf_styled and fputs_styled are provided. Users can control the style via a number of new set/show commands. In the interest of not typing many nearly-identical documentation strings, I automated this. On the down side, this is not very i18n-friendly. I've chose some default colors to use. I think it would be good to enable this by default, so that when users start the new gdb, they will see the new feature. Stylizing is done if TERM is set and is not "dumb". This could be improved when the TUI is available by using the curses has_colors call. That is, the lowest layer could call this without committing to using curses everywhere; see my other patch for TUI colorizing. I considered adding a new "set_style" method to ui_file. However, because the implementation had to interact with the pager code, I didn't take this approach. But, one idea might be to put the isatty check there and then have it defer to the lower layers. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * utils.h (set_output_style, fprintf_styled) (fputs_styled): Declare. * utils.c (applied_style, desired_style): New globals. (emit_style_escape, set_output_style): New function. (prompt_for_continue): Emit style escapes. (fputs_maybe_filtered): Likewise. (fputs_styled, fprintf_styled): New functions. * ui-out.h (enum class ui_out_style_kind): New. (class ui_out) <field_string, field_stream, do_field_string>: Add style parameter. * ui-out.c (ui_out::field_stream, ui_out::field_string): Add style parameter. * tui/tui-out.h (class tui_ui_out) <do_field_string>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_string): Add style parameter. (tui_ui_out::do_field_string): Update. * tracepoint.c (print_one_static_tracepoint_marker): Style output. * stack.c (print_frame_info, print_frame): Style output. * source.c (print_source_lines_base): Style output. * skip.c (info_skip_command): Style output. * record-btrace.c (btrace_call_history_src_line): Style output. (btrace_call_history): Likewise. * python/py-framefilter.c (py_print_frame): Style output. * mi/mi-out.h (class mi_ui_out) <do_field_string>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_table_header) (mi_ui_out::do_field_int): Update. (mi_ui_out::do_field_string): Update. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Style output. * cli/cli-style.h: New file. * cli/cli-style.c: New file. * cli-out.h (class cli_ui_out) <do_field_string>: Add style parameter. * cli-out.c (cli_ui_out::do_table_header) (cli_ui_out::do_field_int, cli_ui_out::do_field_skip): Update. (cli_ui_out::do_field_string): Add style parameter. Style the output. * breakpoint.c (print_breakpoint_location): Style output. (update_static_tracepoint): Likewise. * Makefile.in (SUBDIR_CLI_SRCS): Add cli-style.c. (HFILES_NO_SRCDIR): Add cli-style.h. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: New file. * gdb.base/style.c: New file.
2018-12-28Change gdb test suite's TERM settingTom Tromey1-45/+49
This changes the gdb test suite to set TERM to "dumb" by default. This setting disables terminal styling, so that the existing tests do not need to be updated. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * lib/gdb.exp (gdb_init): Set the TERM environment variable to "dumb". * gdb.base/readline.exp (operate_and_get_next): Save and restore the TERM environment variable.
2018-12-21gdb: Fix "info os <unknown>" commandPaul Marechal1-0/+3
Running `info os someUnknownOsType` is crashing when gdb is built with -D_GLIBCXX_DEBUG: /usr/include/c++/5/debug/vector:439:error: attempt to access an element in an empty container. In target_read_stralloc from target.c, the call to target_read_alloc_1 can return an empty vector, we then call vector::back on this vector, which is invalid. This commit adds a check for emptiness before trying to call vector::back on it. It also adds test to check for `info os <unknown>` to return the proper error message. This is a regression in gdb 8.2 and this patch restores the behavior of previous versions. gdb/ChangeLog: PR gdb/23974 * target.c (target_read_stralloc): Check for empty vector. gdb/testsuite/ChangeLog: PR gdb/23974 * gdb.base/info-os.exp: Check return for unknown "info os" type.
2018-12-12gdb: Update test pattern to deal with native-extended-gdbserverAndrew Burgess1-2/+21
When running the test gdb.base/annota1.exp with: make check-gdb RUNTESTFLAGS="--target_board=native-extended-gdbserver gdb.base/annota1.exp" I would see a failure due to some unexpected lines in GDB's output. The extra lines (when compared with a native run) were about file transfer from the remote back to GDB. This commit extends the regexp for this test to allow for these extra lines, and also splits the rather long regexp up into a list of parts. With this change in place I see no failures for gdb.base/annota1.exp when using the native-extended-gdbserver target board, nor with a native run on X86-64/Linux. gdb/testsuite/ChangeLog: * gdb.base/annota1.exp: Update a test regexp.
2018-12-11gdb/riscv: Update test to handle targets without an fpuAndrew Burgess1-1/+9
The FPU is optional on RISC-V. The gdb.base/float.exp test currently assumes that an fpu is always available on RISC-V. Update the test so that this is not the case. gdb/testsuite/ChangeLog: * gdb.base/float.exp: Handle RISC-V targets without an FPU.
2018-12-08Merge forward-search/reverse-search, use gdb::def_vector, remove limitPedro Alves1-2/+15
Back in: commit 85ae1317add94adef4817927e89cff80b92813dd Author: Stan Shebs <shebs@codesourcery.com> AuthorDate: Thu Dec 8 02:27:47 1994 +0000 * source.c: Various cosmetic changes. (forward_search_command): Handle very long source lines correctly. a buffer with a hard limit was converted to a heap buffer: @@ -1228,15 +1284,26 @@ forward_search_command (regex, from_tty) stream = fdopen (desc, FOPEN_RT); clearerr (stream); while (1) { -/* FIXME!!! We walk right off the end of buf if we get a long line!!! */ - char buf[4096]; /* Should be reasonable??? */ - register char *p = buf; + static char *buf = NULL; + register char *p; + int cursize, newsize; + + cursize = 256; + buf = xmalloc (cursize); + p = buf; However, reverse_search_command has the exact same problem, and that wasn't fixed. We still have that "we walk right off" comment... Recently, the xmalloc above was replaced with a xrealloc, because as can be seen above, that 'buf' variable above was a static local, otherwise we'd be leaking. This commit replaces that and the associated manual buffer growing with a gdb::def_vector<char>. I don't think there's much point in reusing the buffer across command invocations. While doing this, I realized that reverse_search_command is almost identical to forward_search_command. So this commit factors out a common helper function instead of duplicating a lot of code. There are some tests for "forward-search" in gdb.base/list.exp, but since they use the "search" alias, they were a bit harder to find than expected. That's now fixed, both by testing both variants, and by adding some commentary. Also, there are no tests for the "reverse-search" command, so this commit adds some for that too. gdb/ChangeLog: 2018-12-08 Pedro Alves <palves@redhat.com> * source.c (forward_search_command): Rename to ... (search_command_helper): ... this. Add 'forward' parameter. Tweak to use a gdb::def_vector<char> instead of a xrealloc'ed buffer. Handle backward searches too. (forward_search_command, reverse_search_command): Reimplement by calling search_command_helper. gdb/testsuite/ChangeLog: 2018-12-08 Pedro Alves <palves@redhat.com> * gdb.base/list.exp (test_forward_search): Rename to ... (test_forward_reverse_search): ... this. Also test reverse-search and the forward-search alias.
2018-12-01[gdb/testsuite] Add gdb-caching-proc.exp testcaseTom de Vries1-0/+112
When caching a proc using gdb_caching_proc, it will become less likely to be executed, and consequently it's going to be harder to detect that the proc is racy. OTOH, in general the proc is easy to rerun. So, add a test-case to run all uncached gdb_caching_procs a number of times and detect inconsistent results. The purpose of caching is to reduce runtime, so rerunning is somewhat counter-productive in that aspect, but it's better than uncached, because the number of reruns is constant-bounded, and the increase in runtime is bound to this test-case, and can be disabled on slow targets. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2018-12-01 Tom de Vries <tdevries@suse.de> * gdb.base/gdb-caching-proc.exp: New file.
2018-11-20Test case for 'info variables|functions' with minimal symbols.Philippe Waroquiers2-0/+67
2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/info_minsym.c: New file. * gdb.base/info_minsym.exp: New file.
2018-11-19gdb.base/warning.exp tweaksPedro Alves1-5/+5
#1- Check that the warning is emitted. #2- Avoid overriding INTERNAL_GDBFLAGS, as per documentated in gdb/testsuite/README: ~~~ The testsuite does not override a value provided by the user. ~~~ We don't actually need to tweak INTERNAL_GDBFLAGS, we just need to append out -data-directory to GDBFLAGS, because each passed -data-directory option leads to a call to the warning: $ ./gdb -data-directory=foo -data-directory=bar Warning: foo: No such file or directory. Warning: bar: No such file or directory. [...] gdb/ChangeLog 2018-11-19 Pedro Alves <palves@redhat.com> * gdb.base/warning.exp: Don't override INTERNAL_FLAGS. Use gdb_spawn_with_cmdline_opts instead of gdb_start. Check that we see the expected warning.
2018-11-12Add completer for skip numbersSimon Marchi1-0/+36
Add completer to various commands that accept skip numbers: - skip enable - skip disable - skip delete - info skip These commands also accept ranges, the completer works for that but is not very smart. It will suggest invalid ranges, for example when doing "2-<TAB>" it will suggest "1", which would not result in a valid range. Also, it will keep suggesting when doing "1-2-<TAB>", even though it's an invalid syntax. A future idea would be to make a re-usable and well-tested completer for numbers and ranges. I think it could at least be re-used for breakpoint and thread numbers (for example with the "enable breakpoints" command). gdb/ChangeLog: * skip.c (complete_skip_number): New function. (_initialize_step_skip): Add completers to some skip commands. gdb/testsuite/ChangeLog: * gdb.base/skip.exp: Add standard_testfile. Add "skip delete" completer tests.
2018-11-09[gdb/symtab] Fix language of duplicate static minimal symbolTom de Vries3-0/+75
Consider a test-case with source files msym.c: ... static int foo (void) { return 1; } ... and msym_main.c: ... static int foo (void) { return 2; } int main (void) { return 0; } .. compiled as c++ with minimal symbols: ... $ g++ msym_main.c msym.c ... With objdump -x we find the two foo symbols prefixed with their corresponding files in the symbol table: ... 0000000000000000 l df *ABS* 0000000000000000 msym_main.c 00000000004004c7 l F .text 000000000000000b _ZL3foov 0000000000000000 l df *ABS* 0000000000000000 msym.c 00000000004004dd l F .text 000000000000000b _ZL3foov ... However, when we use gdb to print info on foo, both foos are listed, but we get one symbol mangled and one symbol demangled: ... $ gdb ./a.out -batch -ex "info func foo" All functions matching regular expression "foo": Non-debugging symbols: 0x00000000004004c7 foo() 0x00000000004004dd _ZL3foov ... During minimal symbol reading symbol_set_names is called for each symbol. First, it's called with foo from msym.c, an entry is created in per_bfd->demangled_names_hash and symbol_find_demangled_name is called, which has the side effect of setting the language of the symbol to language_cplus. Then, it's called with foo from msym_main.c. Since per_bfd->demangled_names_hash already has an entry for that name, symbol_find_demangled_name is not called, and the language of the symbol remains language_auto. Fix this by doing the symbol_find_demangled_name call unconditionally. Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2018-11-09 Tom de Vries <tdevries@suse.de> * symtab.c (symbol_set_names): Call symbol_find_demangled_name unconditionally, to set the language of the symbol. Manage freeing returned pointer using gdb::unique_xmalloc_ptr. gdb/testsuite/ChangeLog: 2018-11-09 Tom de Vries <tdevries@suse.de> * gdb.base/msym-lang.c: New test. * gdb.base/msym-lang.exp: New file. * gdb.base/msym-lang-main.c: New test.
2018-11-08Avoid crash when calling warning too earlyTom Tromey1-0/+36
I noticed that if you pass the name of an existing file (not a directory) as the argument to --data-directory, gdb will crash: $ ./gdb -nx --data-directory ./gdb ../../binutils-gdb/gdb/target.c:590:56: runtime error: member call on null pointer of type 'struct target_ops' This was later reported as PR gdb/23838. This happens because warning ends up calling target_supports_terminal_ours, which calls current_top_target, which returns nullptr this early. This fixes the problem by handling this case specially in target_supports_terminal_ours. I also changed target_supports_terminal_ours to return bool. gdb/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> PR gdb/23555: PR gdb/23838: * target.h (target_supports_terminal_ours): Return bool. * target.c (target_supports_terminal_ours): Handle case where current_top_target returns nullptr. Return bool. gdb/testsuite/ChangeLog 2018-11-08 Tom Tromey <tom@tromey.com> PR gdb/23555: PR gdb/23838: * gdb.base/warning.exp: New file.
2018-11-06[gdb] Fix gdb crash when reading core fileTom de Vries2-0/+117
Consider the test-case from this patch, compiled with O0. The executable segfaults, and generates a core dump: ... $ ./a.out Segmentation fault (core dumped) ... When loading the core file, limiting stack size to 4MB, gdb crashes: ... $ ulimit -s 4096 $ gdb -batch ./a.out core.saved [New LWP 19379] Segmentation fault (core dumped) ... The crash originates here in linux_vsyscall_range_raw, where we call alloca with phdrs_size == 4194112 (roughly 4MB): ... phdrs = (Elf_Internal_Phdr *) alloca (phdrs_size); ... While for this test-case gdb runs fine with the system default stack limit of 8MB, there are cases reported of 12MB phdrs_size where gdb also crashes with the system default stack limit. Fix this by using xmalloc instead of alloca, which prevents the crash provided the stack limit is at least 112kb. Build and reg-tested on x86_64-linux. 2018-11-06 Tom de Vries <tdevries@suse.de> * linux-tdep.c (linux_vsyscall_range_raw): Use xmalloc to allocate program headers. * gdb.base/many-headers.c: New test. * gdb.base/many-headers.exp: New file.
2018-11-06RISC-V: Force variables to .data for code_elim.Jim Wilson1-0/+5
RISC-V puts a global variable in .sdata by default, which causes the add-symbol-file commands with -s .data to fail as there is no .data section. This fixes 3 testsuite failures. gdb/testsuite/ * gdb.base/code_elim.exp: For riscv, set additional_flags to include -msmall-data-limit=0.
2018-10-31[gdb/testsuite] Factor out lib/valgrind.expTom de Vries3-204/+12
Factor out common code related to vgdb setup and cleanup in valgrind-bt.exp, valgrind-disp-step.exp and gdb.base/valgrind-infcall.exp. Tested on x86_64-linux with and without --target_board=native-gdbserver. 2018-10-31 Tom de Vries <tdevries@suse.de> * lib/valgrind.exp: New file. (vgdb_start, vgdb_stop): New procs, factored out of ... * gdb.base/valgrind-bt.exp: ... here, ... * gdb.base/valgrind-disp-step.exp: ... here and ... * gdb.base/valgrind-infcall.exp: ... here.
2018-10-27Remove a bunch of usages of gdb_suppress_tests in 'runto_main'.Philippe Waroquiers14-27/+42
In the 'info -q -t' patch series, I started a new test from gdb.threads/threadapply.exp, that uses an obsolete way to do runto_main. This patch changes all occurrences of runto_main using gdb_suppress_tests to use instead fail+return. Note that there are still about 220 occurrences of gdb_suppress_tests but unclear (to me) if these can be similarly trivially be replaced by a fail+return. Further cleanup can be done in follow-up patches. Tests run on Debian/x86_64. gdb/testsuite/ChangeLog 2018-10-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.arch/altivec-regs.exp: Do not use gdb_suppress_tests in runto_main, use fail + return instead. gdb.arch/amd64-byte.exp: Likewise. gdb.arch/amd64-dword.exp: Likewise. gdb.arch/amd64-word.exp: Likewise. gdb.arch/e500-abi.exp: Likewise. gdb.arch/e500-regs.exp: Likewise. gdb.arch/gdb1291.exp: Likewise. gdb.arch/gdb1431.exp: Likewise. gdb.arch/i386-avx.exp: Likewise. gdb.arch/i386-byte.exp: Likewise. gdb.arch/i386-prologue.exp: Likewise. gdb.arch/i386-sse.exp: Likewise. gdb.arch/i386-word.exp: Likewise. gdb.arch/iwmmxt-regs.exp: Likewise. gdb.arch/pa-nullify.exp: Likewise. gdb.arch/powerpc-prologue.exp: Likewise. gdb.arch/s390-tdbregs.exp: Likewise. gdb.arch/vsx-regs.exp: Likewise. gdb.asm/asm-source.exp: Likewise. gdb.base/auxv.exp: Likewise. gdb.base/bigcore.exp: Likewise. gdb.base/overlays.exp: Likewise. gdb.base/savedregs.exp: Likewise. gdb.base/setshow.exp: Likewise. gdb.base/sigaltstack.exp: Likewise. gdb.base/sigbpt.exp: Likewise. gdb.base/siginfo-addr.exp: Likewise. gdb.base/siginfo-obj.exp: Likewise. gdb.base/siginfo-thread.exp: Likewise. gdb.base/siginfo.exp: Likewise. gdb.base/signull.exp: Likewise. gdb.base/sigrepeat.exp: Likewise. gdb.base/structs2.exp: Likewise. gdb.threads/threadapply.exp: Likewise. gdb.threads/watchthreads.exp: Likewise. gdb.threads/watchthreads2.exp: Likewise.
2018-10-27Add a test case for info args|functions|locals|variables [-q] [-t ↵Philippe Waroquiers2-0/+321
TYPEREGEXP] [NAMEREGEXP] Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP] gdb/testsuite/ChangeLog 2018-10-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/info_qt.c: New file. * gdb.base/info_qt.exp: New file.
2018-10-25[gdb/testsuite] Move valgrind-db-attach.{c,exp} to valgrind-bt.{c,exp}Tom de Vries2-0/+0
Now that valgrind-db-attach.exp no longer use --db-attach, rename valgrind-db-attach.{c,exp} to valgrind-bt.{c,exp}. 2018-10-25 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-db-attach.c: Rename to ... * gdb.base/valgrind-bt.c: ... this. * gdb.base/valgrind-db-attach.exp: Rename to ... * gdb.base/valgrind-bt.exp: ... this.
2018-10-25[gdb/testsuite] Rewrite valgrind-db-attach.exp to use vgdbTom de Vries1-25/+55
The valgrind option --db-attach has been deprecated in version 3.10.0, and removed in version 3.11.0, so the valgrind-db-attach.exp testcase is unsupported starting version 3.11.0. Rewrite the test-case to use vgdb instead (making it supported starting version 3.7.0). Tested on x86_64-linux with and without --target_board=native-gdbserver. 2018-10-25 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-db-attach.exp: Rewrite to use vgdb.
2018-10-24[gdb/testsuite] Rewrite catch-follow-exec.exp using gdb_testTom de Vries1-50/+13
The testcase catch-follow-exec.exp is written use gdb -batch in order to avoid a GDB SIGTTOU. After the commit of "Avoid GDB SIGTTOU on catch exec + set follow-exec-mode new (PR 23368)", that no longer is necessary. Rewrite the test using regular gdb_test commands. Tested with x86_64-linux. 2018-10-24 Tom de Vries <tdevries@suse.de> * gdb.base/catch-follow-exec.exp: Rewrite using gdb_test.
2018-10-24[gdb/testsuite] Handle removed valgrind option --db-attachTom de Vries1-0/+4
When running valgrind-db-attach.exp with valgrind version 3.13.0, we get: ... PASS: gdb.base/valgrind-db-attach.exp: spawn valgrind valgrind: Unknown option: --db-attach=yes valgrind: Use --help for more information or consult the user manual. ERROR: Process no longer exists UNRESOLVED: gdb.base/valgrind-db-attach.exp: valgrind started ... The valgrind option --db-attach has been deprecated in version 3.10.0, and removed in version 3.11.0. Fix valgrind-db-attach.exp to replace the ERROR/UNRESOLVED with: ... UNSUPPORTED: gdb.base/valgrind-db-attach.exp: valgrind started ... Tested on x86_64-linux. 2018-10-24 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-db-attach.exp: Handle removed support for --db-attach in valgrind.
2018-10-19Testsuite: vla-optimized-out.exp is too pessimisticAlan Hayward1-2/+2
On aarch64 (and possibly other ports), for O3 the sizeof "a" can still be shown. 2018-10-19 Alan Hayward <alan.hayward@arm.com> * gdb.base/vla-optimized-out.exp: Allow either optimized out or 6.
2018-10-18Fix PR cli/23785: Check if file exists when invoking "restore FILE binary"Sergio Durigan Junior1-0/+8
This simple patch fixes the segfault reported on PR cli/23785, which happens when using the "restore FILE binary" command with a non-existent file. We just have to check if the file handler returned by "gdb_fopen_cloexec" is not NULL, and error out if it is. A test has also been added to gdb.base/restore.exp in order to exercise this scenario. No regressions introduced. gdb/ChangeLog: 2018-10-18 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/23785 * cli/cli-dump.c (restore_binary_file): Check if "file" is NULL. gdb/testsuite/ChangeLog: 2018-10-18 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/23785 * gdb.base/restore.exp: New test to check if "restore" with an invalid file doesn't segfault.
2018-10-18[gdb/testsuite] Fix capitalized test namesTom de Vries1-1/+1
At https://sourceware.org/gdb/wiki/GDBTestcaseCookbook\ #Follow_the_test_name_convention we find: .. Test names should start with a lower case and don't need to end with a period (they are not sentences). ... Fix some capitalized test names. Tested on x86_64-linux. 2018-10-18 Tom de Vries <tdevries@suse.de> * gdb.ada/bp_inlined_func.exp: Fix capitalized test name. * gdb.ada/excep_handle.exp: Same. * gdb.ada/mi_string_access.exp: Same. * gdb.ada/mi_var_union.exp: Same. * gdb.arch/arc-analyze-prologue.exp: Same. * gdb.arch/arc-decode-insn.exp: Same. * gdb.base/readnever.exp: Same. * gdb.fortran/printing-types.exp: Same. * gdb.guile/scm-lazy-string.exp: Same.
2018-10-16[gdb/testsuite] Rewrite catch-follow-exec.expTom de Vries2-13/+56
There are two problems with the current catch-follow-exec.exp: - INTERNAL_GDBFLAGS (containing the datadir setting) is not used - remote host testing doesn't work Fix the former by using gdb_spawn_with_cmdline_opts. Fix the latter by requiring gdb-native. Build on x86_64-linux with and without ubsan, and tested. 2018-10-16 Tom de Vries <tdevries@suse.de> PR gdb/23730 * gdb.base/catch-follow-exec.c: Add copyright notice. * gdb.base/catch-follow-exec.exp: Rewrite to use gdb_spawn_with_cmdline_opts. Require gdb-native.
2018-10-11Fix pathname regexp in gdb.base/solib-vanish.exp.Sandra Loosemore1-1/+1
2018-10-11 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/solib-vanish.exp: Fix regexp not to require a POSIX directory prefix on the filename.
2018-10-06Use standard_output_file in a couple more placesTom Tromey1-1/+1
I noticed a few files left over in the testsuite/ directory in the build tree after running tests. Normally output files should not wind up there, but instead should end up in the test's subdirectory. This isn't always crucial, but in the past there were problems with tests clashing, preventing parallel runs, and so it is better to be clean here. This patch changes a couple of tests to use standard_output_file to fix this problem. Tested by re-running the tests in question and examining the directory. gdb/testsuite/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> * gdb.base/gnu-ifunc.exp (build): Use standard_output_file. * gdb.trace/unavailable-dwarf-piece.exp: Use standard_output_file.
2018-10-06Update string expected from "help info proc" on gdb.base/info-proc.expSergio Durigan Junior1-1/+1
Commit 73f1bd769a5 ("Make the "info proc" documentation more consistent.") updated the output from "help info proc", but forgot to update the test on gdb.base/info-proc.exp. This obvious patch does that. Checked-in as obvious. gdb/testsuite/ChangeLog: 2018-10-06 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/info-proc.exp: Update string expected from "help info proc".
2018-10-04Clean up "Reading symbols" outputTom Tromey12-29/+29
This patch is another attempt to fix PR cli/19551. Unlike my previous attempt, it doesn't print progress. Instead, it just changes some messages and adds newlines to make the output a bit nicer. It also removes the "done." text that was previously emitted. The idea here is that it is obvious when gdb is done reading debug info, as it starts then doing something else; and that while this message did not provide much benefit to users, it did make it harder to make the output clean. After this change the output from "./gdb -iex 'set complaint 1' -nx ./gdb" reads: Reading symbols from ./gdb... .debug_ranges entry has start address of zero [in module /home/tromey/gdb/build/gdb/gdb] DW_AT_low_pc 0x0 is zero for DIE at 0x17116c1 [in module /home/tromey/gdb/build/gdb/gdb] .debug_line address at offset 0xa22f5 is 0 [in module /home/tromey/gdb/build/gdb/gdb] During symbol reading, unsupported tag: 'DW_TAG_unspecified_type'. During symbol reading, const value length mismatch for 'std::ratio<1, 1000000000>::num', got 8, expected 0. gdb/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> PR cli/19551: * symfile.c (symbol_file_add_with_addrs): Update output. * psymtab.c (require_partial_symbols): Update output. gdb/testsuite/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> PR cli/19551: * lib/mi-support.exp (mi_gdb_file_cmd): Update. * lib/gdb.exp (gdb_file_cmd): Update. * gdb.stabs/weird.exp (print_weird_var): Update. * gdb.server/solib-list.exp: Update. * gdb.multi/remove-inferiors.exp (test_remove_inferiors): Update. * gdb.mi/mi-cli.exp: Update. * gdb.linespec/linespec.exp: Update. * gdb.dwarf2/dw2-stack-boundary.exp: Update. * gdb.dwarf2/dw2-objfile-overlap.exp: Update. * gdb.cp/cp-relocate.exp: Update. * gdb.base/sym-file.exp: Update. * gdb.base/relocate.exp: Update. * gdb.base/readnever.exp: Update. * gdb.base/print-symbol-loading.exp (test_load_core): Update. * gdb.base/kill-detach-inferiors-cmd.exp: Update. * gdb.base/dbx.exp (gdb_file_cmd): Update. * gdb.base/code_elim.exp: Update. * gdb.base/break-unload-file.exp (test_break): Update. * gdb.base/break-interp.exp (test_attach_gdb): Update. * gdb.base/break-idempotent.exp (force_breakpoint_re_set): Update. * gdb.base/attach.exp (do_attach_tests): Update. * gdb.base/sepdebug.exp: Update. * gdb.python/py-section-script.exp: Update.
2018-10-04Avoid pagination in attach.expTom Tromey1-2/+3
While re-testing the complaint series, I saw some unresolved tests in attach.exp. In particular, the tests were failing because the pager was active. This is partly a new problem, introduced because that series changes some prints from unfiltered to filtered. However, it is also a latent bug, which you can see by shrinking your window very small and then running the test. This patch avoids the problem by passing -quiet to gdb and arranging to set the window height and width in one other test. Arguably instead of -quiet we should disable the pager during gdb's welcome message. I can do that if it seems desirable; but meanwhile this patch is safe. gdb/testsuite/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> * gdb.base/attach.exp (test_command_line_attach_run): Use -quiet; set width and height to 0. (test_command_line_attach_run): Use -quiet.
2018-10-03Skip gdb ifunc tests on targets that don't support this feature.Sandra Loosemore1-3/+8
2018-10-03 Sandra Loosemore <sandra@codesourcery.com> * lib/gdb.exp (skip_ifunc_tests): New. * gdb.base/gnu-ifunc.exp: Skip if no ifunc support. Handle other compile failures. * gdb.compile/compile-ifunc.exp: Skip if no ifunc support.
2018-09-28gdb: Change how frames are selected for 'frame' and 'info frame'.Andrew Burgess2-0/+240
The 'frame' command, and thanks to code reuse the 'info frame' and 'select-frame' commands, currently have an overloaded mechanism for selecting a frame. These commands take one or two parameters, if it's one parameter then we first try to use the parameter as an integer to select a frame by level (or depth in the stack). If that fails then we treat the parameter as an address and try to select a stack frame by stack-address. If we still have not selected a stack frame, or we initially had two parameters, then GDB allows the user to view a stack frame that is not part of the current backtrace. Internally, a new frame is created with the given stack and pc addresses, and this is shown to the user. The result of this is that a typo by the user, entering the wrong stack frame level for example, can result in a brand new frame being viewed rather than an error. The purpose of this commit is to remove this overloading, while still offering the same functionality through some new sub-commands. By making the default behaviour of 'frame' (and friends) be to select a stack frame by level index, it is hoped that enough backwards-compatibility is maintained that users will not be overly inconvenienced. The 'frame', 'select-frame', and 'info frame' commands now all take a frame specification string as an argument, this string can be any of the following: (1) An integer. This is treated as a frame level. If a frame for that level does not exist then the user gets an error. (2) A string like 'level <LEVEL>', where <LEVEL> is a frame level as in option (1) above. (3) A string like 'address <STACK-ADDRESS>', where <STACK-ADDRESS> is a stack-frame address. If there is no frame for this address then the user gets an error. (4) A string like 'function <NAME>', where <NAME> is a function name, the inner most frame for function <NAME> is selected. If there is no frame for function <NAME> then the user gets an error. (5) A string like 'view <STACK-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS>. (6) A string like 'view <STACK-ADDRESS> <PC-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS> and the pc <PC-ADDRESS>. This change assumes that the most common use of the commands like 'frame' is to select a frame by frame level, it is for this reason that this is the behaviour that is kept for backwards compatibility. Any of the alternative behaviours, which are assumed to be less used, now require a change in user behaviour. The MI command '-stack-select-frame' has not been changed. This ensures that we maintain backwards compatibility for existing frontends. gdb/ChangeLog: (NEWS): Mention changes to frame related commands. * cli/cli-decode.c (add_cmd_suppress_notification): New function. (add_prefix_cmd_suppress_notification): New function. (add_com_suppress_notification): Call add_cmd_suppress_notification. * command.h (add_cmd_suppress_notification): Declare. (add_prefix_cmd_suppress_notification): Declare. * mi/mi-cmd-stack.c: Add 'safe-ctype.h' include. (parse_frame_specification): Moved from stack.c, with simplification to handle a single argument. (mi_cmd_stack_select_frame): Use parse_frame_specification, the switch to the selected frame. Add a header comment. * stack.c: Remove 'safe-ctype.h' include. (find_frame_for_function): Add declaration. (find_frame_for_address): New function. (parse_frame_specification): Moved into mi/mi-cmd-stack.c. (frame_selection_by_function_completer): New function. (info_frame_command): Rename to... (info_frame_command_core): ...this, and update parameter types. (select_frame_command): Rename to... (select_frame_command_core): ...this, and update parameter types. (frame_command): Rename to... (frame_command_core): ...this, and update parameter types. (class frame_command_helper): New class to wrap implementations of frame related sub-commands. (frame_apply_cmd_list): New static global. (frame_cmd_list): Make static. (select_frame_cmd_list): New global for sub-commands. (info_frame_cmd_list): New global for sub-commands. (_initialize_stack): Register sub-commands for 'frame', 'select-frame', and 'info frame'. Update 'frame apply' commands to use frame_apply_cmd_list. Move function local static frame_apply_list to file static frame_apply_cmd_list for consistency. * stack.h (select_frame_command): Delete declarationn. (select_frame_for_mi): Declare new function. gdb/doc/ChangeLog: * gdb.texinfo (Frames): Rewrite the description of 'frame number' to highlight that the number is also the frame's level. (Selection): Rewrite documentation for 'frame' and 'select-frame' commands. (Frame Info): Rewrite documentation for 'info frame' command. gdb/testsuite/ChangeLog: * gdb.base/frame-selection.exp: New file. * gdb.base/frame-selection.c: New file.
2018-09-26gdb/riscv: Improve non-dwarf stack unwindingAndrew Burgess4-0/+138
This commit improves the prologue scanning stack unwinder, to better support AUIPC, LUI, and more variants of ADD and ADDI. This allows unwinding over frames containing large local variables, where the frame size does not fit into a single instruction immediate, and is first loaded into a temporary register, before being added to the stack pointer. A new test is added that tests this behaviour. As there's nothing truely RiscV specific about this test I've added it into gdb.base, but as this depends on target specific code to perform the unwind it is possible that some targets might fail this new test. gdb/ChangeLog: * riscv-tdep.c (riscv_insn::decode): Decode c.lui. (riscv_scan_prologue): Split handling of AUIPC, LUI, ADD, ADDI, and NOP. gdb/testsuite/ChangeLog: * gdb.base/large-frame-1.c: New file. * gdb.base/large-frame-2.c: New file. * gdb.base/large-frame.exp: New file. * gdb.base/large-frame.h: New file.
2018-09-24Fix PR gdb/20948: --write option to GDB causes segmentation faultJozef Lawrynowicz2-0/+67
When opening a BFD for update, as gdb --write does, modifications to anything but the contents of sections is restricted. Do not try to write back any ELF headers in this case. bfd/ChangeLog 2018-09-24 Jozef Lawrynowicz <jozef.l@mittosystems.com> PR gdb/20948 * elf.c (_bfd_elf_write_object_contents): Return from function early if abfd->direction == both_direction. gdb/testsuite/ChangeLog 2018-09-24 Jozef Lawrynowicz <jozef.l@mittosystems.com> PR gdb/20948 * gdb.base/write_mem.exp: New test. * gdb.base/write_mem.c: Likewise.
2018-09-20Add '_' in the match pattern.Hafiz Abid Qadeer1-1/+1
I was looking at GDB testcase results for arm-eabi target with qemu and noticed that register groups returned by the qemu can have '_' in the name e.g. 'cp_regs'. The reggroups.exp fails to recognize that as group name. Fixed by adding '_' in the pattern. 2018-09-20 Hafiz Abid Qadeer <abidh@codesourcery.com> gdb.base/reggroups.exp (fetch_reggroups): Add '_' in match pattern.
2018-09-19Skip GDB tab-completion tests if no readline.Sandra Loosemore2-0/+16
2018-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/complete-empty.exp: Skip tab-completion tests if no readline. * gdb.base/utf8-identifiers.exp: Likewise. * gdb.cp/cpcompletion.exp: Likewise. * gdb.linespec/cpcompletion.exp: Likewise. * gdb.linespec/cpls-abi-tag.exp: Likewise. * gdb.linespec/cpls-ops.exp: Likewise.
2018-09-16Use GNU style for metasyntactic variables in gdbTom Tromey2-2/+2
I searched for other spots that did not use the GNU style for metasyntactic syntactic variables. This patch fixes most of the ones I found in gdb proper. There are a few remaining in MI, but I was unsure whether those should be touched. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * top.c (new_ui_command): Use GNU style for metasyntactic variables. * breakpoint.c (stopat_command): Use GNU style for metasyntactic variables. * maint.c (maintenance_translate_address): Remove "<>" around text. * interps.c (interpreter_exec_cmd): Use GNU style for metasyntactic variables. * nto-procfs.c (nto_procfs_target_info): Use GNU style for metasyntactic variables. * tracepoint.c (tfind_range_command): Use GNU style for metasyntactic variables. (tfind_outside_command): Likewise. (_initialize_tracepoint): Likewise. * remote.c (extended_remote_target::create_inferior): Use GNU style for metasyntactic variables. * sparc64-tdep.c (adi_examine_command): Use GNU style for metasyntactic variables. (adi_assign_command): Likewise. gdb/testsuite/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * gdb.base/new-ui.exp (do_execution_tests): Update. * gdb.base/dbx.exp (test_breakpoints): Update.
2018-09-07gdb/testsuite: Make test names unique in gdb.base/watchpoint.expAndrew Burgess1-24/+28
Extend test names and add test name prefixes to make test names unique. gdb/testsuite/ChangeLog: * gdb.base/watchpoint.exp (test_complex_watchpoint): Extend test names, and add test prefixes to make test names unique.