summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
Commit message (Collapse)AuthorAgeFilesLines
* Make skip without argument skip the current inline functionBernd Edlinger2020-01-141-0/+14
| | | | | | | | | | | | | | | | | | Previously always the outermost function block was used, but since skip is now able to skip over inline functions it is more natural to skip the inline function that the program is currently executing. gdb: 2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de> * skip.c (skip_function_command): Make skip w/o arguments use the name of the inlined function if pc is inside any inlined function. gdb/testsuite: 2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de> * gdb.base/skip-inline.exp: Extend test.
* Add "info connections" command, "info inferiors" connection number/stringPedro Alves2020-01-103-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extends the CLI a bit for multi-target, in three ways. #1 - New "info connections" command. This is a new command that lists the open connections (process_stratum targets). For example, if you're debugging two remote connections, a couple local/native processes, and a core dump, all at the same time, you might see something like this: (gdb) info connections Num What Description 1 remote 192.168.0.1:9999 Remote serial target in gdb-specific protocol 2 remote 192.168.0.2:9998 Remote serial target in gdb-specific protocol * 3 native Native process 4 core Local core dump file #2 - New "info inferiors" "Connection" column You'll also see a new matching "Connection" column in "info inferiors", showing you which connection an inferior is bound to: (gdb) info inferiors Num Description Connection Executable 1 process 18526 1 (remote 192.168.0.1:9999) target:/tmp/a.out 2 process 18531 2 (remote 192.168.0.2:9998) target:/tmp/a.out 3 process 19115 3 (native) /tmp/prog1 4 process 6286 4 (core) myprogram * 5 process 19122 3 (native) /bin/hello #3 - Makes "add-inferior" show the inferior's target connection "add-inferior" now shows you the connection you've just bound the inferior to, which is the current process_stratum target: (gdb) add-inferior [New inferior 2] Added inferior 2 on connection 1 (extended-remote localhost:2346) gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add target-connection.c. * inferior.c (uiout_field_connection): New function. (print_inferior): Add new "connection-id" column. (add_inferior_command): Show connection number/string of added inferior. * process-stratum-target.h (process_stratum_target::connection_string): New virtual method. (process_stratum_target::connection_number): New field. * remote.c (remote_target::connection_string): New override. * target-connection.c: New file. * target-connection.h: New file. * target.c (decref_target): Remove process_stratum targets from the connection list. (target_stack::push): Add process_stratum targets to the connection list. gdb/testsuite/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/kill-detach-inferiors-cmd.exp: Adjust expected output of "add-inferior". * gdb.base/quit-live.exp: Likewise. * gdb.base/remote-exec-file.exp: Likewise. * gdb.guile/scm-progspace.exp: Likewise. * gdb.linespec/linespec.exp: Likewise. * gdb.mi/new-ui-mi-sync.exp: Likewise. * gdb.mi/user-selected-context-sync.exp: Likewise. * gdb.multi/multi-target.exp (setup): Add "info connection" and "info inferiors" tests. * gdb.multi/remove-inferiors.exp: Adjust expected output of "add-inferior". * gdb.multi/watchpoint-multi.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.server/extended-remote-restart.exp: Likewise. * gdb.threads/fork-plus-threads.exp: Adjust expected output of "info inferiors". * gdb.threads/forking-threads-plus-breakpoint.exp: Likewise. * gdb.trace/report.exp: Likewise.
* Make "show remote exec-file" inferior-awarePedro Alves2020-01-101-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "set remote exec-file" setting is per-inferior, but the "show remote exec-file" command always shows the last set exec-file, irrespective of the current inferior. E.g.: # Set inferior 1's exec-file: (gdb) set remote exec-file prog1 # Add inferior 2, switch to it, and set its exec-file: (gdb) add-inferior Added inferior 2 (gdb) inferior 2 (gdb) set remote exec-file prog2 # Switch back to inferior 1, and show its exec-file: (gdb) inferior 1 (gdb) show remote exec-file prog2 ^^^^^ should show "prog1" instead here. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * remote.c (show_remote_exec_file): Show the current inferior's exec-file instead of the command variable's value. gdb/testsuite/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/remote-exec-file.exp: New file.
* Preserve selected thread in all-stop w/ background executionPedro Alves2020-01-101-14/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In non-stop mode, if you resume the program in the background (with "continue&", for example), then gdb makes sure to not switch the current thread behind your back. That means that you can be sure that the commands you type apply to the thread you selected, even if some other thread that was running in the background hits some event just while you're typing. In all-stop mode, however, if you resume the program in the background, gdb let's the current thread switch behind your back. This is bogus, of course. All-stop and non-stop background resumptions should behave the same. This patch fixes that, and adds a testcase that exposes the bad behavior in current master. The fork-running-state.exp changes are necessary because that preexisting testcase was expecting the old behavior: Before: continue & Continuing. (gdb) [Attaching after process 8199 fork to child process 8203] [New inferior 2 (process 8203)] info threads Id Target Id Frame 1.1 process 8199 "fork-running-st" (running) * 2.1 process 8203 "fork-running-st" (running) (gdb) After: continue & Continuing. (gdb) [Attaching after process 24660 fork to child process 24664] [New inferior 2 (process 24664)] info threads Id Target Id Frame * 1.1 process 24660 "fork-running-st" (running) 2.1 process 24664 "fork-running-st" (running) (gdb) Here we see that before this patch GDB switches current inferior to the new inferior behind the user's back, as a side effect of handling the fork. The delete_exited_threads call in inferior_appeared is there to fix an issue that Baris found in a previous version of this patch. The fetch_inferior_event change increases the refcount of the current thread, and in case the fetched inferior event denotes a thread exit, the thread will not be deleted right away. A non-deleted but exited thread stays in the inferior's thread list. This, in turn, causes the "init_thread_list" call in inferior.c to be skipped. A consequence is that the global thread ID counter is not restarted if the current thread exits, and then the inferior is restarted: (gdb) start Temporary breakpoint 1 at 0x4004d6: file main.c, line 21. Starting program: /tmp/main Temporary breakpoint 1, main () at main.c:21 21 foo (); (gdb) info threads -gid Id GId Target Id Frame * 1 1 process 16106 "main" main () at main.c:21 (gdb) c Continuing. [Inferior 1 (process 16106) exited normally] (gdb) start Temporary breakpoint 2 at 0x4004d6: file main.c, line 21. Starting program: /tmp/main Temporary breakpoint 2, main () at main.c:21 21 foo (); (gdb) info threads -gid Id GId Target Id Frame * 1 2 process 16138 "main" main () at main.c:21 ^^^ Notice that GId == 2 above. It should have been "1" instead. The new tids-git-reset.exp testcase exercises the problem above. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdbthread.h (scoped_restore_current_thread) <dont_restore, restore, m_dont_restore>: Declare. * thread.c (thread_alive): Add assertion. Return bool. (switch_to_thread_if_alive): New. (prune_threads): Switch inferior/thread. (print_thread_info_1): Switch thread before calling target methods. (scoped_restore_current_thread::restore): New, factored out from ... (scoped_restore_current_thread::~scoped_restore_current_thread): ... this. (scoped_restore_current_thread::scoped_restore_current_thread): Add assertion. (thread_apply_all_command, thread_select): Use switch_to_thread_if_alive. gdb/testsuite/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/fork-running-state.exp (do_test): Adjust expected output. * gdb.threads/async.c: New. * gdb.threads/async.exp: New. * gdb.multi/tids-gid-reset.c: New. * gdb.multi/tids-gid-reset.exp: New.
* Fix handling of null stap semaphoresGeorge Barrett2020-01-102-7/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the SystemTap documentation on user-space probes[0], stap probe points without semaphores are denoted by setting the semaphore address in the probe's note to zero. At present the code does do a comparison of the semaphore address against zero, but only after it's been relocated; as such it will (almost?) always fail, commonly resulting in GDB trying to overwrite the ELF magic located at the image's base address. This commit tests the address as specified in the SDT note rather than the relocated value in order to correctly detect absent probe semaphores. [0]: https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation gdb/Changelog: 2020-01-11 George Barrett <bob@bob131.so> * stap-probe.c (stap_modify_semaphore): Don't check for null semaphores. (stap_probe::set_semaphore, stap_probe::clear_semaphore): Check for null semaphores. gdb/testsuite/ChangeLog: 2020-01-11 George Barrett <bob@bob131.so> * gdb.base/stap-probe.c (relocation_marker): Add dummy variable to help in finding the image relocation offset. * gdb.base/stap-probe.exp (stap_test): Accept arbitrary compile options in arguments. (stap_test_no_debuginfo): Likewise. (stap-probe-nosem-noopt-pie, stap-probe-nosem-noopt-nopie): Add test variants. (stap_test): Add null semaphore relocation test.
* gdb/testsuite/gdb.base/stap-probe: Minor clean-upGeorge Barrett2020-01-102-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | This patch resolves a couple of issues with the test case for SystemTap user-space probe points: 1. The preprocessor macro guarding the semaphore variables in the C file is (rather confusingly) named USE_PROBES. This has been renamed to USE_SEMAPHORES, to better reflect its function. 2. The test procedures in the expect file improperly pass the flag defining USE_PROBES to prepare_for_testing; as such, the test binary that's supposed to have probes with semaphores is the same as the one without. This has also been fixed. 3. No test is performed to check that `info probes' returns information about probe semaphores. Such a test is included in this patch. gdb/testsuite/ChangeLog 2020-01-10 George Barrett <bob@bob131.so> * gdb.base/stap-probe.c: Rename USE_PROBES to USE_SEMAPHORES. * gdb.base/stap-probe.exp: Likewise. (stap_test): Pass argument as an additional flag. (stap_test_no_debuginfo): Likewise. (stap_test): Check `info probes stap' output for semaphore addresses if the test binary is supposed to have them.
* gdb/testsuite: Fix race condition in gdb.base/skip.expAndrew Burgess2020-01-091-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit: commit 5024637fac653914d471808288dc3221bc7ec089 Date: Sun Dec 15 11:05:47 2019 +0100 Fix skip.exp test failure observed with gcc-9.2.0 A race condition was introduced into the gdb.base/skip.exp test when this line: gdb_test "step" "foo \\(\\) at.*" "step 3" Was changed to this: gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at .*" "step" Before the above change we expected GDB to behave like this: (gdb) step foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) However, when the test is compiled with GCC 9.2.0 we get a different behaviour, and so we need a second 'step', like this: (gdb) step main () at /path/to/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) step foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) Now the change to the test matches against 'main () at .*', however if GDB or expect is being slow then we might only get to see output like this: (gdb) step main () at /path/to/g This will happily match the question pattern, so we send 'step' to GDB again. Now GDB continues to produce output which expect accepts, we now see this: b.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) This has carried on from where the previous block of output left off. This doesn't match the final pattern 'foo \\(\\) at.*', but it does match the prompt pattern that gdb_test_multiple adds, and so we report the test as failing. The solution is to simply ensure that the question consumes everything up to, and including the prompt. This ensures that the prompt can't then match the failure case. The new test line becomes: gdb_test "step" "foo \\(\\) at.*" "step 3" \ "main \\(\\) at .*\r\n$gdb_prompt " "step" gdb/testsuite/ChangeLog: * gdb.base/skip.exp: Fix race condition in test. Change-Id: I9f0b0b52ef1b4f980bfaa8fe405ff06d520f3482
* gdb: Fix backtrace with disassemble-next-line onAndrew Burgess2020-01-062-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit: commit ec8e2b6d3051f0b4b2a8eee9917898e95046c62f Date: Fri Jun 14 23:43:00 2019 +0100 gdb: Don't allow annotations to influence what else GDB prints A change was accidentally made that moved a call to do_gdb_disassembly out of an if block guarded by 'if (source_print && sal.symtab)'. The result was that if a user has 'set disassemble-next-line on' then the backtrace would now include some disassembly of a few instructions in each frame. This change was not intentional, but was not spotted by any tests. This commit restores the old behaviour and adds a test to ensure this doesn't break again in the future. gdb/ChangeLog: * stack.c (print_frame_info): Move disassemble_next_line code inside source_print block. gdb/testsuite/ChangeLog: * gdb.base/backtrace.c: New file. * gdb.base/backtrace.exp: New file. Change-Id: I47c52a202fa74be138382646b695827940178689
* Ensure GDB warnings are styled.Philippe Waroquiers2020-01-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While handling the comments of Tom related to [RFC] Have an option to tell GDB to detect and possibly handle mismatched exec-files. https://sourceware.org/ml/gdb-patches/2019-12/msg00621.html I saw that GDB warnings are produced ignoring the given styles. This patch: * ensures that style markups are properly handled by "warning". * changes 'set/show data-directory' so that file style is used in warnings and in 'show message' * changes all other messages in top.c to use file style when appropriate. * Uses the above data-directory changes in gdb.base/style.exp 2020-01-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * ui-file.c (stdio_file::can_emit_style_escape) (tee_file::can_emit_style_escape): Ensure style is used also on gdb_stderr when gdb_stderr is a tty supporting styling, similarly to gdb_stdout. * main.c (set_gdb_data_directory): Use file style to output the warning that the given pathname is not a directory. * top.c (show_history_filename, gdb_safe_append_history) (show_gdb_datadir): Use file style. 2020-01-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Test that warnings are styled.
* Update copyright year range in all GDB files.Joel Brobecker2020-01-01929-929/+929
| | | | | | gdb/ChangeLog: Update copyright year range in all GDB files.
* Fix setting breakpoints or stepping on line 65535Bernd Edlinger2019-12-292-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | This removes code that was present from the very first git revisison 7b4ac7e1ed2c4616bce56d1760807798be87ac9e from 1988. It was in the gdb/dbxread.c at the time (and makes more sense for dbx line info format since line numbers are 16-bit entities in that debug format and debugging files with more than 65535 lines would not work anyway) but moved from there to gdb/buildsym.c which is used for dwarf line info as well, and excluding an arbitrary line number does certainly not make sense nowadays. Add a test case for line 65535 gdb: 2019-12-29 Bernd Edlinger <bernd.edlinger@hotmail.de> * buildsym.c (buildsym_compunit::record_line): Do no longer ignore line 65535. gdb/testsuite: 2019-12-29 Bernd Edlinger <bernd.edlinger@hotmail.de> * gdb.base/line65535.exp: New file. * gdb.base/line65535.c: New file.
* Update gdb.base/default.exp for GDB 10Simon Marchi2019-12-181-1/+1
| | | | | | | | | | | | | Now that the version number in master has been bumped to 10, I get this failure: FAIL: gdb.base/default.exp: show convenience ($_gdb_major = 9 not found) Update the test accordingly. gdb/testsuite/ChangeLog: * gdb.base/default.exp: Update value of $_gdb_major.
* Fix skip.exp test failure observed with gcc-9.2.0Bernd Edlinger2019-12-171-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to step a second time with this gcc version. The first step jumps back to main before entering foo. Previously the control flow was from bar directly to foo. Further ananlysis suggests, that this change in behavior started with gcc-8.1.0 when -gcolumn-info was enabled by default. The option -gcolumn-info was first implemented in gcc-7.1.0 but default-disabled, so you can get the altered behavior already with gcc-7 if you manually enable -gcolumn-info. Previously there was just one point where line 30 (of skip.c) started: [0x00000032] Advance Line by 27 to 28 [0x00000034] Copy [0x00000035] Special opcode 63: advance Address by 4 to 0x4004cb and Line by 2 to 30 [0x00000036] Advance PC by constant 17 to 0x4004dc [0x00000037] Special opcode 7: advance Address by 0 to 0x4004dc and Line by 2 to 32 But with -gcolumn-info enabled, we have line 30 three times with different column: [0x00000034] Advance Line by 27 to 28 [0x00000036] Copy [0x00000037] Set column to 9 [0x00000039] Special opcode 63: advance Address by 4 to 0x4004c6 and Line by 2 to 30 [0x0000003a] Set column to 17 [0x0000003c] Special opcode 75: advance Address by 5 to 0x4004cb and Line by 0 to 30 [0x0000003d] Set column to 3 [0x0000003f] Special opcode 75: advance Address by 5 to 0x4004d0 and Line by 0 to 30 [0x00000040] Special opcode 105: advance Address by 7 to 0x4004d7 and Line by 2 to 32 That could probably be filtered in dwarf2read.c to keep the old behavior, but the new behavior makes still sense, even if we cannot really make use of the column in the line number info for now.
* Whitespace fix in gdb.base/skip.expBernd Edlinger2019-12-171-2/+2
| | | | Just use tabs instead of spaces here.
* Add a test case for skip with inlined functionsBernd Edlinger2019-12-162-0/+142
|
* Fix double-free when creating more than one block in JIT debug info readerSimon Marchi2019-12-164-31/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A double-free happens when using a JIT debug info reader that creates more than one block. In the loop that frees blocks in finalize_symtab, at the very end, the gdb_block_iter_tmp variable is set initially, but not changed as the loop advances. If we have two blocks, the first iteration frees the first block, the second iteration frees the second block, but the third iteration tries to free the second block again, as gdb_block_iter_tmp keeps pointing on the second block. Fix it by assigning the gdb_block_iter_tmp variable in the loop. I have improved the jit-reader.exp test to cover this case, by adding a second "JIT-ed" function and creating a block for it. I have renamed the existing function to something I find a bit more descriptive. There are no significant changes to jit-reader.exp itself, only updates following the renaming. The important changes are in jithost.c (generate a new function) and in jitreader.c (create a gdb_block for that function). This was found because of an ASan report: $ ./gdb testsuite/outputs/gdb.base/jit-reader/jit-reader -ex "jit-reader-load /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/jit-reader/jitreader.so" -ex r Reading symbols from testsuite/outputs/gdb.base/jit-reader/jit-reader... Starting program: /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/jit-reader/jit-reader ================================================================= ==1751048==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000042eb8 at pc 0x5650ef8eec88 bp 0x7ffe52767290 sp 0x7ffe52767280 READ of size 8 at 0x604000042eb8 thread T0 #0 0x5650ef8eec87 in finalize_symtab /home/simark/src/binutils-gdb/gdb/jit.c:768 #1 0x5650ef8eef88 in jit_object_close_impl /home/simark/src/binutils-gdb/gdb/jit.c:797 #2 0x7fbbda986278 in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:71 #3 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #4 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #5 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #6 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] 0x604000042eb8 is located 40 bytes inside of 48-byte region [0x604000042e90,0x604000042ec0) freed by thread T0 here: #0 0x7fbbe57376b0 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:122 #1 0x5650ef8f350b in xfree<gdb_block> /home/simark/src/binutils-gdb/gdb/gdbsupport/common-utils.h:62 #2 0x5650ef8eeca9 in finalize_symtab /home/simark/src/binutils-gdb/gdb/jit.c:769 #3 0x5650ef8eef88 in jit_object_close_impl /home/simark/src/binutils-gdb/gdb/jit.c:797 #4 0x7fbbda986278 in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:71 #5 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #6 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #7 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #8 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] previously allocated by thread T0 here: #0 0x7fbbe5737cd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153 #1 0x5650eef662f3 in xcalloc /home/simark/src/binutils-gdb/gdb/alloc.c:100 #2 0x5650ef8f34ea in xcnew<gdb_block> /home/simark/src/binutils-gdb/gdb/gdbsupport/poison.h:122 #3 0x5650ef8ed467 in jit_block_open_impl /home/simark/src/binutils-gdb/gdb/jit.c:557 #4 0x7fbbda98620a in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:60 #5 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #6 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #7 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #8 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] gdb/ChangeLog: * jit.c (finalize_symtab): Set gdb_block_iter_tmp in loop. gdb/testsuite/ChangeLog: * gdb.base/jit-reader.exp (jit_reader_test): Rename jit_function_00 to jit_function_stack_mangle. * gdb.base/jithost.c (jit_function_t): Rename to... (jit_function_stack_mangle_t): ... this. (jit_function_add_t): New typedef. (jit_function_00_code): Rename to... (jit_function_stack_mangle_code): ... this, make static. (jit_function_add_code): New. (main): Generate "add" function and call it. Adjust to changes in jithost_abi. * gdb.base/jithost.h (struct jithost_abi_bounds): New. (struct jithost_abi) <begin, end>: Remove fields. <object, function_stack_mangle, function_add>: New fields. * gdb.base/jitreader.c (struct reader_state) <code_begin, code_end>: Remove fields. <func_stack_mangle>: New field. (read_debug_info): Adjust to renaming, create block for "add" function. (read_sp, unwind_frame, get_frame_id): Adjust to other changes.
* Implement 'print -raw-values' and 'set print raw-values on|off'Philippe Waroquiers2019-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The option framework documentation was speaking about a 'print -raw' option, but this option does not exist. This patch implements -raw-values option that tells to ignore the active pretty printers when printing a value. As we already have -raw-frame-arguments, I thought -raw-values was more clear, in particular to differentiate set print raw-values and set print raw-frame-arguments. gdb/doc/ChangeLog 2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Command Options): Use -p and -pretty in the example, as -r is ambiguous. Update the print - TAB TAB completion result. (Data): Document new option -raw-values. Use -p and -pretty in the example, as -r is ambiguous. (Print Settings): Document set print raw values. (Pretty-Printer Commands): Document interaction between enabled pretty printers and -raw-values/-raw-frame-arguments. gdb/ChangeLog 2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Document -raw-values option and the related setting commands. * printcmd.c (print_command_parse_format): Do not set opts->raw off, only set it on when /r is given. * valprint.c (value_print_option_defs): New element raw-values. * Makefile.in: Add the new file. gdb/testsuite/ChangeLog 2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/options.exp: Add -raw-values in the print completion list. * gdb.python/py-prettyprint.exp: Add tests for -raw-values.
* Core file build-id supportKeith Seitz2019-12-074-0/+401
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch uses new BFD support for detecting build-ids in core files. After this patch, it is possible to run gdb with only the core file, and gdb will automatically load the executable and debug info [example from tests]: $ gdb -nx -q (gdb) core-file corefile-buildid.core [New LWP 29471] Reading symbols from gdb.base/corefile-buildid/debugdir-exec/.build-id/36/fe5722c5a7ca3ac746a84e223c6a2a69193a24... Core was generated by `outputs/gdb.base/coref'. Program terminated with signal SIGABRT, Aborted. (gdb) This work is based on functionality available in Fedora originally written by Jan Kratochvil. Regression tested on buildbot. gdb/ChangeLog: 2019-12-07 Keith Seitz <keiths@redhat.com> * build-id.c (build_id_bfd_get): Permit bfd_core, too. (build_id_to_debug_bfd): Make static, rewriting to use build_id_to_bfd_suffix. (build_id_to_bfd_suffix): Copy of build_id_to_debug_bfd, adding `suffix' parameter. Append SUFFIX to file names when searching for matching files. (build_id_to_debug_bfd): Use build_id_to_bfd_suffix. (build_id_to_exec_bfd): Likewise. * build-id.h (build_id_to_debug_bfd): Clarify that function searches for BFD of debug info file. (build_id_to_exec_bfd): Declare. * corelow.c: Include build-id.h. (locate_exec_from_corefile_build_id): New function. (core_target_open): If no executable BFD is found, search for a core file BFD using build-id. gdb/testsuite/ChangeLog: 2019-12-07 Keith Seitz <keiths@redhat.com> * gdb.base/corefile-buildid-shlib-shr.c: New file. * gdb.base/corefile-buildid-shlib.c: New file. * gdb.base/corefile-buildid.c: New file. * gdb.base/corefile-buildid.exp: New file. Change-Id: I15e9e8e58f10c68b5cae55e2eba58df1e8aef529
* Fix crash when command arg is missing in faas/taas/tfaas commands.Philippe Waroquiers2019-12-061-0/+2
| | | | | | | | | | | | | | | | | | | GDB crashes when doing: (gdb) faas Aborted Do the needed check to avoid crashing. gdb/ChangeLog 2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be> * stack.c (faas_command): Check a command is provided. * thread.c (taas_command, tfaas_command): Likewise. gdb/testsuite/ChangeLog 2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.threads/pthreads.exp: Test taas and tfaas without command. * gdb.base/frameapply.exp: Test faas without command.
* Add bit-field test for scalar_storage_orderTom Tromey2019-12-042-3/+5
| | | | | | | | | | | | | This adds a bit-field test for scalar_storage_order. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.base/endianity.c (struct other) <x>: New field. (main): Initialize it. * gdb.base/endianity.exp: Update. Change-Id: I9e07d1b3e08e7c3384832b68ef286afe1d11479a
* Add scalar_storage_order support for floating pointTom Tromey2019-12-042-3/+10
| | | | | | | | | | | | | | | | | | | | | | | Testing the scalar_storage_order patch pointed out that it does not handle floating point properly. This patch fixes this problem. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * dwarf2read.c (dwarf2_init_float_type) (dwarf2_init_complex_target_type): Add byte_order parameter. (read_base_type): Compute byte order earlier. * gdbtypes.c (init_float_type): Add byte_order parameter. * gdbtypes.h (init_float_type): Add byte_order parameter. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.base/endianity.c (struct otherendian) <f>: New field. (main): Initialize it. * gdb.base/endianity.exp: Update. Change-Id: Ic02eb711d80ce678ef0ecf8c506a626e441b8440
* Allow . character as part of command names.Philippe Waroquiers2019-11-302-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds . as an allowed character for user defined commands. Combined with 'define-prefix', this allows to e.g. define a set of Valgrind specific user command corresponding to the Valgrind monitor commands (such as check_memory, v.info, v.set, ...). gdb/ChangeLog 2019-11-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * command.h (valid_cmd_char_p): Declare. * cli/cli-decode.c (valid_cmd_char_p): New function factorizing the check of valid command char. (find_command_name_length, valid_user_defined_cmd_name_p): Use valid_cmd_char_p. * cli/cli-script.c (validate_comname): Likewise. * completer.c (gdb_completer_command_word_break_characters): Do not remove . from the word break char, update comments. (complete_line_internal_1): Use valid_cmd_char_p. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. gdb/testsuite/ChangeLog 2019-11-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/define.exp: Test . in command names. * gdb.base/setshow.exp: Update test, as . is now part of command name.
* Test define-prefix.Philippe Waroquiers2019-11-301-0/+164
| | | | | | | | Adds a test testing the new define-prefix command. 2019-11-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/define-prefix.exp: New file.
* Adjust byte order variable display/change if DW_AT_endianity is present.Peeter Joot2019-11-212-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rationale: It is possible for compilers to indicate the desired byte order interpretation of scalar variables using the DWARF attribute: DW_AT_endianity A type flagged with this variable would typically use one of: DW_END_big DW_END_little which instructs the debugger what the desired byte order interpretation of the variable should be. The GCC compiler (as of V6) has a mechanism for setting the desired byte ordering of the fields within a structure or union. For, example, on a little endian target, a structure declared as: struct big { int v; short a[4]; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); could be used to ensure all the structure members have a big-endian interpretation (the compiler would automatically insert byte swap instructions before and after respective store and load instructions). - To reproduce GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes in all situations when the scalar_storage_order attribute is used. A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found in the URL field of the following PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509 - Test-case: A new test case (testsuite/gdb.base/endianity.*) is included with this patch. Manual testing for mixed endianity code has also been done with GCC V8. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4 - Observed vs. expected: Without this change, using scalar_storage_order that doesn't match the target, such as struct otherendian { int v; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); would behave like the following on a little endian target: Breakpoint 1 at 0x401135: file endianity.c, line 41. (gdb) run Starting program: /home/pjoot/freeware/t/a.out Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64 Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $1 = {v = 50331648} (gdb) p /x $2 = {v = 0x3000000} whereas with this gdb enhancement we can access the variable with the user specified endianity: Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) p o $1 = {v = 0} (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $2 = {v = 3} (gdb) p o.v = 4 $3 = 4 (gdb) p o.v $4 = 4 (gdb) x/4xb &o.v 0x7fffffffd90c: 0x00 0x00 0x00 0x04 (observe that the 4 byte int variable has a big endian representation in the hex dump.) gdb/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> Byte reverse display of variables with DW_END_big, DW_END_little (DW_AT_endianity) dwarf attributes if different than the native byte order. * ada-lang.c (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * ada-valprint.c (printstr): (ada_val_print_string): * ada-lang.c (value_pointer): (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * c-lang.c (c_get_string): Use type_byte_order instead of gdbarch_byte_order. * c-valprint.c (c_val_print_array): Use type_byte_order instead of gdbarch_byte_order. * cp-valprint.c (cp_print_class_member): Use type_byte_order instead of gdbarch_byte_order. * dwarf2loc.c (rw_pieced_value): Use type_byte_order instead of gdbarch_byte_order. * dwarf2read.c (read_base_type): Handle DW_END_big, DW_END_little * f-lang.c (f_get_encoding): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (default_read_var_value): Use type_byte_order instead of gdbarch_byte_order. * gdbtypes.c (check_types_equal): Require matching TYPE_ENDIANITY_NOT_DEFAULT if set. (recursive_dump_type): Print TYPE_ENDIANITY_BIG, and TYPE_ENDIANITY_LITTLE if set. (type_byte_order): new function. * gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro. (struct main_type) <flag_endianity_not_default>: New field. (type_byte_order): New function. * infcmd.c (default_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. * p-lang.c (pascal_printstr): Use type_byte_order instead of gdbarch_byte_order. * p-valprint.c (pascal_val_print): Use type_byte_order instead of gdbarch_byte_order. * printcmd.c (print_scalar_formatted): Use type_byte_order instead of gdbarch_byte_order. * solib-darwin.c (darwin_current_sos): Use type_byte_order instead of gdbarch_byte_order. * solib-svr4.c (solib_svr4_r_ldsomap): Use type_byte_order instead of gdbarch_byte_order. * stap-probe.c (stap_modify_semaphore): Use type_byte_order instead of gdbarch_byte_order. * target-float.c (target_float_same_format_p): Use type_byte_order instead of gdbarch_byte_order. * valarith.c (scalar_binop): (value_bit_index): Use type_byte_order instead of gdbarch_byte_order. * valops.c (value_cast): Use type_byte_order instead of gdbarch_byte_order. * valprint.c (generic_emit_char): (generic_printstr): (val_print_string): Use type_byte_order instead of gdbarch_byte_order. * value.c (unpack_long): (unpack_bits_as_long): (unpack_value_bitfield): (modify_field): (pack_long): (pack_unsigned_long): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (unsigned_pointer_to_address): (signed_pointer_to_address): (unsigned_address_to_pointer): (address_to_signed_pointer): (default_read_var_value): (default_value_from_register): Use type_byte_order instead of gdbarch_byte_order. * gnu-v3-abi.c (gnuv3_make_method_ptr): Use type_byte_order instead of gdbarch_byte_order. * riscv-tdep.c (riscv_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. gdb/testsuite/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> * gdb.base/endianity.c: New test. * gdb.base/endianity.exp: New file. Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
* [gdb] Only force INTERP_CONSOLE ui_out for breakpoint commands in MI modeTom de Vries2019-11-211-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem reported in PR mi/25055 is that the output of the backtrace command, when executed as breakpoint command does not show when executing using the MI interpreter: ... $ gdb a.out Reading symbols from a.out... (gdb) break main Breakpoint 1 at 0x4003c0: file test.c, line 19. (gdb) commands Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >bt >end (gdb) interpreter-exec mi "-exec-run" ^done Breakpoint 1, main () at test.c:19 19 return foo (4); (gdb) ... Interestingly, the function print_frame is called twice during -exec-run: - once during tui_on_normal_stop where the ui_out is temporarily set to tui->interp_ui_out (), resulting in the part after the comma in "Breakpoint 1, main () at test.c:19" - once during execute_control_command, where the ui_out is the default for the current interpreter: mi_ui_out, which ignores calls to output text. The commit 3a87ae656c2 "Use console uiout when executing breakpoint commands" fixes the problem by temporarily switching to the ui_out of INTERP_CONSOLE in execute_control_command. This however caused a regression in redirection (escaping '#' using '\' for git commit message convenience): ... $ rm -f gdb.txt; gdb a.out Reading symbols from a.out... (gdb) break main Breakpoint 1 at 0x4003c0: file test.c, line 19. (gdb) commands Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >bt >end (gdb) set logging redirect on (gdb) set logging on Redirecting output to gdb.txt. Copying debug output to gdb.txt. (gdb) run \#0 main () at test.c:19 (gdb) q A debugging session is active. Inferior 1 [process 22428] will be killed. Quit anyway? (y or n) y $ cat gdb.txt Starting program: /data/gdb_versions/devel/a.out Breakpoint 1, main () at test.c:19 19 return foo (4); ... The problem is that the '#0 main () at test.c:19' ends up in the gdb output output rather than in gdb.txt. This is due to the fact that the redirect is setup for the current ui_out (which is tui->interp_ui_out ()), while the backtrace output is printed to the INTERP_CONSOLE ui_out. Fix this by limiting switching to INTERP_CONSOLE ui_out to when INTERP_MI is active. Tested on x86_64-linux. gdb/ChangeLog: 2019-11-21 Tom de Vries <tdevries@suse.de> PR gdb/24956 * cli/cli-script.c (execute_control_command): Only switch to INTERP_CONSOLE's ui_out when INTERP_MI is active. gdb/testsuite/ChangeLog: 2019-11-21 Tom de Vries <tdevries@suse.de> PR gdb/24956 * gdb.base/ui-redirect.exp: Test output of user-defined command. Change-Id: Id1771e7fcc9496a7d97ec2b2ea6b1487596f1ef7
* gdb/testsuite: Merge whatis.exp and ctf-whatis.expAndrew Burgess2019-11-193-1142/+463
| | | | | | | | | | | | | | | | | The recently added gdb.base/ctf-whatis.exp test is a slightly modified version of gdb.base/whatis.exp, with a few tests removed, and the source compiled with different compiler options. This patch merges the two tests together into a single test script. I tested using a version of GCC with CTF support added. gdb/testsuite/ChangeLog: * gdb.base/ctf-whatis.c: Delete. * gdb.base/ctf-whatis.exp: Delete. * gdb.base/whatis.exp: Rewrite to compile as both dwarf and ctf. Change-Id: I09e11c70f197b79d2b1e0ae8c86a21c622be6c51
* gdb/testsuite: Merge cvexpr.exp and ctf-cvexpr.expAndrew Burgess2019-11-192-718/+242
| | | | | | | | | | | | | | | The recently added gdb.base/ctf-cvexpr.exp is just a copy of gdb.base/cvexpr.exp but compiled with different options. This patch merges these two tests together into a single test script. I tested this change using a version of GCC with CTF support added. gdb/testsuite/ChangeLog: * gdb.base/ctf-cvexpr.exp: Delete. * gdb.base/cvexpr.exp: Rewrite to compile as both dwarf and ctf. Change-Id: If678c3e38cb444867defa970203d26563f15dba4
* gdb/testsuite: Introduce skip_ctf_tests guard functionAndrew Burgess2019-11-193-20/+23
| | | | | | | | | | | | | | | | | | | | | Most versions of GCC in the wild don't support CTF debug format right now, so, rather than attempting to compile the tests and failing each time, this patch introduces a guard function to check if the compiler supports CTF. If we don't have CTF support then the CTF tests are skipped. This patch only updates 3 of the 4 CTF tests, the fourth will be handled in the next patch. gdb/testsuite/ChangeLog: * gdb.base/ctf-constvars.exp: Skip test if CTF is not supported in the compiler. Clean up header comment a little. * gdb.base/ctf-ptype.exp: Likewise. * gdb.base/ctf-whatis.exp: Likewise. * lib/gdb.exp (skip_ctf_tests): New proc. Change-Id: I505c11169a9bc9871a31fc0c61e119f92f32cc63
* Allow re-assigning to convenience variablesTom Tromey2019-11-141-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (4)Tom de Vries2019-11-0242-397/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Test the convenience functions $_gdb_setting and $_gdb_setting_str.Philippe Waroquiers2019-10-313-10/+169
| | | | | | | | | | | | | 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] Fix more typos in comments (2)Tom de Vries2019-10-263-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Compile infcall-nested-structs.exp with -O2Tom de Vries2019-10-212-35/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/tdep] Fix inferior call arg passing for amd64Tom de Vries2019-10-161-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-161-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 regexp for reg value in jit-reader.expTom de Vries2019-10-161-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 typos in infcall-nested-structs.cAndreas Arnez2019-10-101-10/+10
| | | | | | | | | | | | | | | | | | 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] Update expected _gdb_major/_gdb_minor in default.expTom de Vries2019-10-071-2/+2
| | | | | | | | | | | | | | | | | | 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-071-30/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-077-0/+2013
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Reduce test name duplication in gdb.base testsAndrew Burgess2019-10-039-174/+239
| | | | | | | | | | | | | | | | | | | 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] Fix list-missing-source.exp with gcc 4.8Tom de Vries2019-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Make print-file-var.exp test attribute visibility hidden, dlopen, and main ↵Pedro Alves2019-10-025-78/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | symbol Make gdb.base/print-file-var.exp test all combinations of: - attribute hidden in the this_version_id symbols or not - dlopen or not - this_version_id symbol in main file or not - C++ gdb/testsuite/ChangeLog 2019-10-02 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> * gdb.base/print-file-var-lib1.c: Include <stdio.h> and "print-file-var.h". (this_version_id) Use ATTRIBUTE_VISIBILITY. (get_version_1): Print this_version_id and its address. Add extern "C" wrappers around interface functions. * gdb.base/print-file-var-lib2.c: Include <stdio.h> and "print-file-var.h". (this_version_id) Use ATTRIBUTE_VISIBILITY. (get_version_2): Print this_version_id and its address. Add extern "C" wrappers around interface functions. * gdb.base/print-file-var-main.c: Include <dlfcn.h>, <assert.h>, <stddef.h> and "print-file-var.h". Add extern "C" wrappers around interface functions. [VERSION_ID_MAIN] (this_version_id): Define. (main): Define v0. Use dlopen if SHLIB_NAME is defined. * gdb.base/print-file-var.h: Add some #defines to simplify setting up extern "C" blocks. * gdb.base/print-file-var.exp (test): New, factored out from top level. (top level): Test all combinations of attribute hidden or not, dlopen or not, and this_version_id symbol in main file or not. Compile tests as both C++ and C, make test names unique.
* Use styled_string for "show logging filename"Tom Tromey2019-10-011-0/+3
| | | | | | | | | | | | | | This changes "show logging filename" to style its output. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * cli/cli-logging.c (show_logging_filename): Use styled_string. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Test "show logging filename".
* Introduce metadata styleTom Tromey2019-10-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
* Style "pwd" outputTom Tromey2019-10-011-0/+2
| | | | | | | | | | | | | | This changes the "pwd" command to style its output. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * cli/cli-cmds.c (pwd_command): Style output. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Test "pwd".
* Introduce gdb-specific %p format suffixesPedro Alves2019-10-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a few gdb-specific %p format suffixes. This is useful for emitting gdb-specific output in an ergonomic way. It also yields code that is more i18n-friendly. The comment before ui_out::message explains the details. Note that the tests had to change a little. When using one of the gdb printf functions with styling, there can be spurious style changes emitted to the output. This did not seem worthwhile to fix, as the low-level output functions are rather spaghetti-ish already, and I didn't want to make them even worse. This change also necessitated adding support for "*" as precision and width in format_pieces. These are used in various spots in gdb, and it seemed better to me to implement them than to remove the uses. gdb/ChangeLog 2019-10-01 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/format_pieces-selftests.c: Add gdb_format parameter. (test_gdb_formats): New function. (run_tests): Call it. (test_format_specifier): Update. * utils.h (fputs_filtered): Update comment. (vfprintf_styled, vfprintf_styled_no_gdbfmt) (fputs_styled_unfiltered): Declare. * utils.c (fputs_styled_unfiltered): New function. (vfprintf_maybe_filtered): Add gdbfmt parameter. (vfprintf_filtered): Update. (vfprintf_unfiltered, vprintf_filtered): Update. (vfprintf_styled, vfprintf_styled_no_gdbfmt): New functions. * ui-out.h (enum ui_out_flag) <unfiltered_output, disallow_ui_out_field>: New constants. (enum class field_kind): New. (struct base_field_s, struct signed_field_s): New. (signed_field): New function. (struct string_field_s): New. (string_field): New function. (struct styled_string_s): New. (styled_string): New function. (class ui_out) <message>: Add comment. <vmessage, call_do_message>: New methods. <do_message>: Add style parameter. * ui-out.c (ui_out::call_do_message, ui_out::vmessage): New methods. (ui_out::message): Rewrite. * mi/mi-out.h (class mi_ui_out) <do_message>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_message): Add style parameter. * gdbsupport/format.h (class format_pieces) <format_pieces>: Add gdb_extensions parameter. (class format_piece): Add parameter to constructor. (n_int_args): New field. * gdbsupport/format.c (format_pieces::format_pieces): Add gdb_extensions parameter. Handle '*'. * cli-out.h (class cli_ui_out) <do_message>: Add style parameter. * cli-out.c (cli_ui_out::do_message): Add style parameter. Call vfprintf_styled_no_gdbfmt. (cli_ui_out::do_field_string, cli_ui_out::do_spaces) (cli_ui_out::do_text, cli_ui_out::field_separator): Allow unfiltered output. * ui-style.h (struct ui_file_style) <ptr>: New method. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Update tests.
* gdb/testsuite: Fix pretty-print.exp on big-endian platformsAndreas Arnez2019-10-012-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pretty-print test case fails on s390/s390x because it relies on a little-endian representation of bit fields. Little-endian architectures typically allocate bit fields from least to most significant bit, but big-endian architectures typically use the reverse order, allocating the most significant bit first. Thus the two bit fields in each of the test case's unions overlap either in their lower or in their higher bits, depending on the target's endianness: union { int three : 3; int four : 4; }; Now, when initializing 'three' with 3, 'four' will become 3 on little endian targets, but 6 on big-endian targets, making it FAIL there. Fix this by initializing the longer bit field instead and using an all-ones bit pattern. In this way the result does not depend on endianness. Use 'unsigned' instead of int for one of the bit fields in each of the unions, to increase the variety of resulting values. gdb/testsuite/ChangeLog: * gdb.base/pretty-print.c (struct s1_t): Change fields 'three' and 'six' to unsigned. (s1): Initialize fields 'four' and 'six' instead of 'three' and 'five'. Use an all-ones bit pattern for each. * gdb.base/pretty-print.exp: Adjust expected output of "print s1" to its changed values.
* [gdb/testsuite] Allow some tests in gdb.base/restore.exp to be unsupportedTom de Vries2019-09-221-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | We currently run into: ... 248 n = callee1 (n + l5); (gdb) PASS: gdb.base/restore.exp: caller5 calls callee1; return callee now print l1 $51 = <optimized out> (gdb) FAIL: gdb.base/restore.exp: caller5 calls callee1; return restored l1 \ to 32492 ... The problem is that we try to access the value of l1 in function caller5, but variable l1 has no DW_AT_location attribute. Since l1 is declared using the register keyword, it's valid for gcc to emit no DW_AT_location at -O0. Change the FAIL into an UNSUPPORTED. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-09-22 Tom de Vries <tdevries@suse.de> * gdb.base/restore.exp: Allow register variables to be optimized out at -O0.