aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.reverse
AgeCommit message (Collapse)AuthorFilesLines
7 hoursgdb/record: add support to vzeroupper instructionGuinevere Larsen2-0/+56
This commit adds recording support for the AVX instruction vzeroupper, which zeroes the high bits of ymm registers 0..15. In the programmer's manual, it is explicitly states that ymm registers 16..31 won't be affected if present, so we only need to record the first 16 registers. We record ymm_h registers since only the higher bits are touched, and that reduces the memory footprint of the instruction. This instruction is tested differently as we want to confirm we're only saving the relevant registers, and we want to ensure we're saving all of them, so it makes use of "maint print record-instruction" to see exactly what was recorded. Approved-By: Tom Tromey <tom@tromey.com>
7 hoursgdb/record: support AVX instructions VMOVDQ(U|A) when recordingGuinevere Larsen2-4/+66
This commit adds support for the instructions VMOVDQU and VMOVDQA, used to move values to/from 256 bit registers. Unfortunately, the programmer's manual is very incomplete (if not wrong) about these instructions, so the logic had to be reverse engineered from how gcc actually encodes the instruction. This commit also changes the memory regions from the test to store 256 bits, so its easier to test the instructions and that we're recording ymm registers correctly. Approved-By: Tom Tromey <tom@tromey.com>
7 hoursgdb/record: Add recording support to vpbroadcast instructionsGuinevere Larsen2-0/+58
This commit adds recording support to all AVX and AVX2 instructions of the form vpbroadcast. GDB is not yet concerned about AVX512 in recording mode, so for now we only support the AVX2 registers and instructions. This commit also updates the gdb.reverse/i386-avx-reverse.exp to test broadcast instructions. Approved-By: Tom Tromey <tom@tromey.com>
7 hoursgdb/record: add support to AVX unpack instructionsGuinevere Larsen2-1/+105
This commit adds support to recording instructions to unpack high or low data from XMM registers, identified by the mnemonics in the form: VPUNPCK [L|H] [BW|WD|DQ|QDQ]. All these instructions are encoded the exact same way, and only affect the destination register, making them trivial to implement together. It also updates the test gdb.reverse/i386-avx-reverse.exp to test these new instructions. The test always uses ymm because the vpunpck instructions overwrite the high bits, so we have to be able to record the full ymm register, not just the output size. Approved-By: Tom Tromey <tom@tromey.com>
7 hoursgdb/record: add support to vmovd and vmovq instructionsGuinevere Larsen3-1/+288
This commit adds support to the x86_64 AVX instructions vmovd and vmovq. The programmers manuals for Intel and AMD describe these 2 instructions as being almost the same, but my local testing, using gcc 13.2 on Fedora 39, showed several differences and inconsistencies. The instruction is supposed to always use the 3-byte VEX prefix, but I could only find 2-byte versions. The instructions aren't differentiated by the VEX.w bit, but by opcodes and VEX.pp. This patch adds a test with many different uses for both vmovd and vmovq. It also updates the test gdb.reverse/step-precsave.exp to reference the generic "missing avx support" bug open in the bug tracker (17346), instead of pointing to one that specifically calls out to vmovd instructions. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23188 Approved-By: Tom Tromey <tom@tromey.com>
7 hoursgdb: Start supporting AVX instructionGuinevere Larsen1-1/+1
This patch introduces the information needed to properly identify the VEX prefix, used to signal an AVX and AVX2 instruction, and introduces a helper function to handle all AVX instruction, instead of adding to the 3000 line long recording function. This new function will temporarily set the current thread as "not executing" so that it can read from pseudo registers as we record, since most AVX/AVX2 instructions would benefit from recording ymm registers. The new helper also handles unsupported instructions so that the largest part of the i386_process_record doesn't have to be shifted by 2 spaces, which made an unreadably big patch file. The only expected difference to the end user added by this patch is a small change to the unsupported message. This patch also updates the test gdb.reverse/step-precsave.exp, by recognizing the new output. As a note for the future, we don't handle xmm16-31 and ymm16-31 because those require the EVEX prefix, meaning avx512 support. Approved-By: Tom Tromey <tom@tromey.com>
4 days[gdb/testsuite] Fix some test-cases for check-read1 (gdb_test_lines)Tom de Vries1-2/+2
I ran the testsuite in an environment simulating a stressed system in combination with check-read1. This exposes a few more FAILs. Fix some by using gdb_test_lines, as well as related gdb_get_lines. Tested on x86_64-linux.
2024-10-06[gdb] Fix common misspellingsTom de Vries3-8/+8
Fix the following common misspellings: ... accidently -> accidentally additonal -> additional addresing -> addressing adress -> address agaisnt -> against albiet -> albeit arbitary -> arbitrary artifical -> artificial auxillary -> auxiliary auxilliary -> auxiliary bcak -> back begining -> beginning cannonical -> canonical compatiblity -> compatibility completetion -> completion diferent -> different emited -> emitted emiting -> emitting emmitted -> emitted everytime -> every time excercise -> exercise existance -> existence fucntion -> function funtion -> function guarentee -> guarantee htis -> this immediatly -> immediately layed -> laid noone -> no one occurances -> occurrences occured -> occurred originaly -> originally preceeded -> preceded preceeds -> precedes propogate -> propagate publically -> publicly refering -> referring substract -> subtract substracting -> subtracting substraction -> subtraction taht -> that targetting -> targeting teh -> the thier -> their thru -> through transfered -> transferred transfering -> transferring upto -> up to vincinity -> vicinity whcih -> which whereever -> wherever wierd -> weird withing -> within writen -> written wtih -> with doesnt -> doesn't ... Tested on x86_64-linux.
2024-09-03[gdb] Fix typosTom de Vries1-1/+1
Fix a few typos. unconditionaly -> unconditionally gratuitiously -> gratuitously configureable -> configurable represention -> representation distiguished -> distinguished breakpointer -> breakpoint asssignments -> assignments architectual -> architectural compatibity -> compatibility adjustement -> adjustment unexcepted -> unexpected propogated -> propagated consistant -> consistent succeding -> succeeding higlight -> highlight detachs -> detach Tested by rebuilding on x86_64-linux. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-08-26Change message when reaching end of reverse history.Guinevere Larsen6-10/+12
In a record session, when we move backward, GDB switches from normal execution to simulation. Moving forward again, the emulation continues until the end of the reverse history. When the end is reached, the execution stops, and a warning message is shown. This message has been modified to indicate that the forward emulation has reached the end, but the execution can continue as normal, and the recording will also continue. Before this patch, the warning message shown in that case was the same as in the reverse case. This meant that when the end of history was reached in either backward or forward emulation, the same message was displayed: "No more reverse-execution history." This message has changed for these two cases. Backward emulation: "Reached end of recorded history; stopping. Backward execution from here not possible." Forward emulation: "Reached end of recorded history; stopping. Following forward execution will be added to history." The reason for this change is that the initial message was deceiving, for the forward case, making the user believe that forward debugging could not continue. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31224 Reviewed-By: Markus T. Metzger <markus.t.metzger@intel.com> (btrace) Approved-By: Guinevere Larsen <blarsen@redhat.com>
2024-07-15Fix loading a saved recordingHannes Domani1-0/+2
Currently you get this assertion failure if you try to execute the inferior after loading a saved recording, when no recording was done earlier in the same gdb session: ``` $ gdb -q c -ex "record restore test.rec" Reading symbols from c... [New LWP 26428] Core was generated by `/tmp/c'. Restored records from core file /tmp/test.rec. (gdb) c Continuing. ../../gdb/inferior.c:293: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ``` The change in step-precsave.exp triggers this bug, since now the recording is loaded in a new gdb session, where record_full_resume_ptid was never set. The fix is to simply set record_full_resume_ptid when resuming a loaded recording. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31971 Approved-By: Guinevere Larsen <blarsen@redhat.com>
2024-06-07gdb/aarch64: Add record support for MOPS instructions.Thiago Jung Bauermann2-0/+264
There are two kinds of MOPS instructions: set instructions and copy instructions. Within each group there are variants with minor differences in how they read or write to memory — e.g., non-temporal read and/or write, unprivileged read and/or write and permutations of those — but they work in the same way in terms of the registers and regions of memory that they modify. The new gdb.reverse/aarch64-mops.exp testcase verifies that MOPS instructions are recorded and correctly reversed. Not all variants of the copy and set instructions are tested, since there are many and the record and replay target processes them in the same way. PR tdep/31666 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666 Approved-By: Luis Machado <luis.machado@arm.com> Tested-By: Luis Machado <luis.machado@arm.com>
2024-04-26gdb_is_target_remote -> gdb_protocol_is_remotePedro Alves1-1/+0
This is similar to the previous patch, but for gdb_protocol_is_remote. gdb_is_target_remote and its MI cousin mi_is_target_remote, use "maint print target-stack", which is unnecessary when checking whether gdb_protocol is "remote" or "extended-remote" would do. Checking gdb_protocol is more efficient, and can be done before starting GDB and running to main, unlike gdb_is_target_remote/mi_is_target_remote. This adds a new gdb_protocol_is_remote procedure, and uses it in place of gdb_is_target_remote/mi_is_target_remote throughout. There are no uses of gdb_is_target_remote/mi_is_target_remote left after this. Those will be eliminated in a following patch. In some spots, we no longer need to defer the check until after starting GDB, so the patch adjusts accordingly. Change-Id: I90267c132f942f63426f46dbca0b77dbfdf9d2ef Approved-By: Tom Tromey <tom@tromey.com>
2024-04-17[gdb/testsuite] Fix end_sequence addressesTom de Vries2-2/+2
I noticed in test-case gdb.reverse/map-to-same-line.exp, that the end of main: ... 00000000004102c4 <end_of_sequence>: 4102c4: 52800000 mov w0, #0x0 // #0 4102c8: 9100c3ff add sp, sp, #0x30 4102cc: d65f03c0 ret ... is not described by the line table: ... File name Line number Starting address View Stmt ... map-to-same-line.c 54 0x4102ac x map-to-same-line.c - 0x4102c4 ... Fix this by ending the line table at $main_end. Likewise in a few other test-cases, found using: ... $ find gdb/testsuite/ -type f \ | xargs grep -B1 DW_LNE_end_sequence \ | grep set_address \ | egrep -v "_end|_len" ... Tested on aarch64-linux.
2024-02-26gdb: Modify the output of "info breakpoints" and "delete breakpoints"Tiezhu Yang1-1/+1
The output of "info breakpoints" includes breakpoint, watchpoint, tracepoint, and catchpoint if they are created, so it should show all the four types are deleted in the output of "info breakpoints" to report empty list after "delete breakpoints". It should also change the output of "delete breakpoints" to make it clear that watchpoints, tracepoints, and catchpoints are also being deleted. This is suggested by Guinevere Larsen, thank you. $ make check-gdb TESTS="gdb.base/access-mem-running.exp" $ gdb/gdb gdb/testsuite/outputs/gdb.base/access-mem-running/access-mem-running [...] (gdb) break main Breakpoint 1 at 0x12000073c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 32. (gdb) watch global_counter Hardware watchpoint 2: global_counter (gdb) trace maybe_stop_here Tracepoint 3 at 0x12000071c: file /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c, line 27. (gdb) catch fork Catchpoint 4 (fork) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x000000012000073c in main at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:32 2 hw watchpoint keep y global_counter 3 tracepoint keep y 0x000000012000071c in maybe_stop_here at /home/loongson/gdb.git/gdb/testsuite/gdb.base/access-mem-running.c:27 not installed on target 4 catchpoint keep y fork Without this patch: (gdb) delete breakpoints Delete all breakpoints? (y or n) y (gdb) info breakpoints No breakpoints or watchpoints. (gdb) info breakpoints 3 No breakpoint or watchpoint matching '3'. With this patch: (gdb) delete breakpoints Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y (gdb) info breakpoints No breakpoints, watchpoints, tracepoints, or catchpoints. (gdb) info breakpoints 3 No breakpoint, watchpoint, tracepoint, or catchpoint matching '3'. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Approved-by: Kevin Buettner <kevinb@redhat.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-02-22[gdb/testsuite] Fix license text in gdb.reverse/map-to-same-line.{c,exp}Tom de Vries2-2/+2
I noticed in gdb.reverse/map-to-same-line.{c,exp} that the license urls are using some kind of indirection via urldefense.proofpoint.com. Fix this by removing this indirection. Tested on x86_64-linux. PR testsuite/31358 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31358
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess94-94/+94
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2024-01-02Fix GDB reverse-step and reverse-next command behaviorCarl Love3-30/+187
Currently GDB when executing in reverse over multiple statements in a single line of source code, GDB stops in the middle of the line. Thus requiring multiple commands to reach the previous line. GDB should stop at the first instruction of the line, not in the middle of the line. The following description of the incorrect behavior was taken from an earlier message by Pedro Alves <pedro@palves.net>: https://sourceware.org/pipermail/gdb-patches/2023-January/196110.html --------------------------------- The source line looks like: func1 (); func2 (); in the test case: (gdb) list 1 1 void func1 () 2 { 3 } 4 5 void func2 () 6 { 7 } 8 9 int main () 10 { 11 func1 (); func2 (); 12 } compiled with: $ gcc reverse.c -o reverse -g3 -O0 $ gcc -v ... gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) Now let's debug it with target record, using current gdb git master (f3d8ae90b236), $ gdb ~/reverse GNU gdb (GDB) 14.0.50.20230124-git ... Reading symbols from /home/pedro/reverse... (gdb) start Temporary breakpoint 1 at 0x1147: file reverse.c, line 11. Starting program: /home/pedro/reverse [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Temporary breakpoint 1, main () at reverse.c:11 11 func1 (); func2 (); (gdb) record (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); => 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. (gdb) n 12 } So far so good, a "next" stepped over the whole of line 11 and stopped at line 12. Let's confirm where we are now: (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } => 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. Good, we're at the first instruction of line 12. Now let's undo the "next", with "reverse-next": (gdb) reverse-next 11 func1 (); func2 (); Seemingly stopped at line 11. Let's see exactly where: (gdb) disassemble /s Dump of assembler code for function main: reverse.c: 10 { 0x000055555555513f <+0>: endbr64 0x0000555555555143 <+4>: push %rbp 0x0000555555555144 <+5>: mov %rsp,%rbp 11 func1 (); func2 (); 0x0000555555555147 <+8>: mov $0x0,%eax 0x000055555555514c <+13>: call 0x555555555129 <func1> => 0x0000555555555151 <+18>: mov $0x0,%eax 0x0000555555555156 <+23>: call 0x555555555134 <func2> 0x000055555555515b <+28>: mov $0x0,%eax 12 } 0x0000555555555160 <+33>: pop %rbp 0x0000555555555161 <+34>: ret End of assembler dump. (gdb) And lo, we stopped in the middle of line 11! That is a bug, we should have stepped back all the way to the beginning of the line. The "reverse-next" should have fully undone the prior "next" command. -------------------- This patch fixes the incorrect GDB behavior by ensuring that GDB stops at the first instruction in the line. The test case gdb.reverse/func-map-to-same-line.exp is added to testsuite to verify this fix when the line table information is and is not available.
2024-01-02PowerPC and aarch64: Fix reverse stepping failureCarl Love2-0/+211
When running GDB's testsuite on aarch64-linux/Ubuntu 20.04 (also spotted on the ppc backend), there are failures in gdb.reverse/solib-precsave.exp and gdb.reverse/solib-reverse.exp. The failure happens around the following code: 38 b[1] = shr2(17); /* middle part two */ 40 b[0] = 6; b[1] = 9; /* generic statement, end part two */ 42 shr1 ("message 1\n"); /* shr1 one */ Normal execution: - step from line 38 will land on line 40. - step from line 40 will land on line 42. Reverse execution: - step from line 42 will land on line 40. - step from line 40 will land on line 40. - step from line 40 will land on line 38. The problem here is that line 40 contains two contiguous but distinct PC ranges in the line table, like so: Line 40 - [0x7ec ~ 0x7f4] Line 40 - [0x7f4 ~ 0x7fc] The two distinct ranges are generated because GCC started outputting source column information, which GDB doesn't take into account at the moment. When stepping forward from line 40, we skip both of these ranges and land on line 42. When stepping backward from line 42, we stop at the start PC of the second (or first, going backwards) range of line 40. Since we've reached ecs->event_thread->control.step_range_start, we stop stepping backwards. The above issues were fixed by introducing a new function that looks for adjacent PC ranges for the same line, until we notice a line change. Then we take that as the start PC of the range. The new start PC for the range is used for the control.step_range_start when setting up a step range. The test case gdb.reverse/map-to-same-line.exp is added to test the fix for the above reverse step issues. Patch has been tested on PowerPC, X86 and AArch64 with no regressions.
2023-12-07gdb/record: Support for rdtscp in i386_process_record.Cupertino Miranda1-1/+12
This patch adds support for process recording of the instruction rdtscp in x86 architecture. Debugging applications with "record full" fail to record with the error message "Process record does not support instruction 0xf01f9". Approved-by: Guinevere Larsen <blarsen@redhat.com>
2023-12-06Fix hardware watchpoints in replay modeHannes Domani1-0/+4
Changes introduced by commit 9e8915c6cee5c37637521b424d723e990e06d597 caused a regression that meant hardware watchpoint stops would not trigger in reverse execution or replay mode. This was documented in PR breakpoints/21969. The problem is that record_check_stopped_by_breakpoint always overwrites record_full_stop_reason, thus loosing the TARGET_STOPPED_BY_WATCHPOINT value which would be checked afterwards. This commit fixes that by not overwriting the stop-reason in record_full_stop_reason if we're not stopped at a breakpoint. And the test for hw watchpoints in gdb.reverse/watch-reverse.exp actually tested sw watchpoints again, since "set can-use-hw-watchpoints 1" doesn't convert enabled watchpoints to use hardware. This is fixed by disabling said watchpoint while enabling hw watchpoints. The same is not done for gdb.reverse/watch-precsave.exp, since it's not possible to use hw watchpoints in restored recordings anyways. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21969 Approved-by: Guinevere Larsen <blarsen@redhat.com>
2023-11-20gdb/record: print frame information when exiting a recursive callGuinevere Larsen2-0/+89
Currently, when GDB is reverse stepping out of a function into the same function due to a recursive call, it doesn't print frame information, as reported by PR record/29178. This happens because when the inferior leaves the current frame, GDB decides to refresh the step information, clobbering the original step_frame_id, making it impossible to figure out later on that the frame has been changed. This commit changes GDB so that, if we notice we're in this exact situation, we won't refresh the step information. Because of implementation details, this change can cause some debug information to be read when it normally wouldn't before, which showed up as a regression on gdb.dwarf2/dw2-out-of-range-end-of-seq. Since that isn't a problem, the test was changed to allow for the new output. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29178 Approved-By: Tom Tromey <tom@tromey.com>
2023-08-29gdb/testsuite: recognize one more unsupported instruction in ↵Simon Marchi1-0/+3
gdb.reverse/step-precsave.exp When running this test on a processor that supports AVX512 (AMD EPYC 9634) on Debian 12 bookwork (system compiler is gcc 12.2.0), I see: continue^M Continuing.^M Process record does not support instruction bound.^M Process record does not support instruction 0x62 at address 0x7ffff7f49b40.^M Process record: failed to record execution log.^M ^M Program stopped.^M 0x00007ffff7f49b40 in ?? () from /lib/x86_64-linux-gnu/libc.so.6^M (gdb) FAIL: gdb.reverse/step-precsave.exp: run to end of main The instruction at this address is: 0x00007ffff7f49b40: 62 e2 7d 48 7a c6 vpbroadcastb %esi,%zmm16 This seems like an AVX512 instruction (given the use of zmm16). Match this byte value in order to produce a KFAIL. Change-Id: I1d20357fa538ba60b9c537160acf511a37d751ee Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30807 Approved-By: Tom Tromey <tom@tromey.com>
2023-08-29[gdb/testsuite] Check for sys/random.h in gdb.reverse/getrandom.expTom de Vries1-0/+1
When running test-case gdb.reverse/getrandom.exp on a system with eglibc 2.19, we run into: ... gdb compile failed, gdb.reverse/getrandom.c:18:24: fatal error: \ sys/random.h: No such file or directory #include <sys/random.h> ^ compilation terminated. === gdb Summary === # of untested testcases 1 ... and: ... UNTESTED: gdb.reverse/getrandom.exp: failed to prepare ... Fix this by testing for the presence of the header, such that we have instead: ... UNSUPPORTED: gdb.reverse/getrandom.exp: require failed: \ have_system_header sys/random.h ... Tested on x86_64-linux and i686-linux.
2023-08-24gdb/testsuite: Multiple improvements for gdb.reverse/insn-reverse.expGuinevere Larsen2-163/+165
This commits tackles 2 problems in the test gdb.reverse/insn-reverse.exp. They are, broadly: flawed logic when an unexpected error occurs, and badly formed asm expressions. For the first, what happens is that if the inferior stops progressing for some reason, the test will emit an UNSUPPORTED and continue testing by reversing from the current location and checking all registers for every instruction. However, due to how the outputs are indexed in the test, this early exit will cause most of the subsequent tests to be de-synced and will emit many unrelated failures. This commit changes the UNSUPPORTED for a FAIL, since the test has in fact failed to record the execution of the whole function, and decrements the recorded instruction count by one so that the indexes are in sync once more. At the time of committing, this reduces the amount of failures when testing with clang-15 from around 150 to 2, and correctly identifies where the issue lies. The second problem is in how the asm statements in the *-x86.c file are written. As an example, let's examine the following line: __asm__ volatile ("rdrand %%ebp;" : "=r" (number)); This statement says that number is being used as the output variable, but is not indicating which registers were clobbered so that the compiler is able to properly output. GCC decides to just not save anything, whereas clang assumes that the output is in %rax, and writes it to the variable. This hid the problem that any compiler is not good at dealing with asm statements that change the rbp register. It can be seen more explicitly by informing gcc that rbp has been clobbered like so: __asm__ volatile ("rdrand %%ebp;" : "=r" (number) : : "%ebp"); This statement gets compiled into the following assembly: rdrandl %ebp movl %eax, -4(%rbp) Which is clearly using the incorrect rbp to find the memory location of the variable. Since the test only exercises GDB's ability to record the register changes, this commit removes the output to memory. Finally, correctly informing the compiler of clobbered registers makes gcc throw an error that the rsp is no longer usable at the end of the function. To avoid that, this commit compresses the 3 asm statements that would save, change and reset registers into a single asm statement. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-24gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clangGuinevere Larsen2-2/+20
When testing using reverse-stepi to fully step through a function, the code checks for an infinite loop by seeing if we land on the line that contains the return statement multiple times. This assumption only works if there is only one instruction associated with that line, which is how GCC handles line information, but other compilers may handle it differently. Clang-15, for instance, associates 6. Because of this, the inferior used to get seriously out of sync with the test expectations, and result in 13 spurious failures. The same issue occurs with gdb.reverse/step-precsave.exp. This commit changes the test so that we check for PC instead of line number. The test still only happens when the same line is detected, to simplify the resulting log. With this change, no new failures are emitted when using clang. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-24gdb/testsuite: fix gdb.reverse/solib-*.exp tests when using clangGuinevere Larsen4-11/+45
The tests gdb.reverse/solib-precsave.exp and solib-reverse.exp have the assumption that line tables will have an entry for the closing } in a function. Not all compiles do this, one example being clang. To fix this, this commit changes the function in shr2.c to have multiple lines, and the test to accept either line as a correct step location. To properly re-sync the inferiors, the function repeat_cmd_until had to be slightly changed to work with empty "current locations", so that we are able to step through multiple lines. This also changes the annotations used to determine the breakpoint locations in solib-reverse.c, adding a simple variable assignment right before the return statement. This way GDB will not set a breakpoint in the closing } line. Approved-By: Tom Tromey <tom@tromey.com>
2023-08-24gdb/testsuite: Fix many errors in gdb.reverse with clangGuinevere Larsen3-6/+6
Clang does not add line information for lines that only contain a closing } in functions. Many tests in the gdb.reverse folder set a breakpoint in that line, but don't seem to use information available after the return statement is executed, so this commit moves the breakpoint to the previous line, where the return statement is. Approved-By: Tom Tromey <tom@tromey.com>
2023-06-23gdb/testsuite: Avoid infinite loop in gdb.reverse/step-reverse.expThiago Jung Bauermann1-3/+25
This testcase sometimes gets stuck in a loop for hours when running in our CI. The problem is that due to an issue unrelated to reverse debugging the inferior exits early, and because of the overly generic ".*" pattern the testcase keeps sending the "next" command without noticing that the inferior is gone. gdb_test_multiple has a pattern to detect that "The program is not being run.", but since it is placed after the patterns from the caller it won't be triggered. It also has a timeout pattern but because it is triggered between successful matches, each time the test matches the '-re -wrap ".*"' this counts as a successful match and the timeout is reset. Since the test binary is compiled with debug information, fix by changing one of the generic patterns to match entering the main function and the other one to match the source code line number that is shown by GDB right after the "step" command. Also, as a precaution add a maximum number of times the "next" command will be sent. Co-Authored-By: Tom de Vries <tdevries@suse.de> Reviewed-By: Bruno Larsen <blarsen@redhat.com> Approved-By: Tom de Vries <tdevries@suse.de>
2023-05-04Revert "gdb/testsuite: add KFAILs to gdb.reverse/step-reverse.exp"Bruno Larsen1-15/+0
This reverts commit 476410b3bca1389ee69e9c8fa18aaee16793a56d. One of Simon's recent commits (2a740b3ba4c9f39c86dd75e0914ee00942cab471) changed the way recording a remote target works and fixed the underlying issue of the bug, so the KFails can be removed from the test. Approved-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb/testsuite: change newline patterns used in gdb_testAndrew Burgess2-60/+60
This commit makes two changes to how we match newline characters in the gdb_test proc. First, for the newline pattern between the command output and the prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'. The old pattern would spot multiple newlines, and so there are a few places where, as part of this commit, I've needed to add an extra trailing '\r\n' to the pattern in the main test file, where GDB's output actually includes a blank line. But I think this is a good thing. If a command produces a blank line then we should be checking for it, the current gdb_test doesn't do that. But also, with the current gdb_test, if a blank line suddenly appears in the output, this is going to be silently ignored, and I think this is wrong, the test should fail in that case. Additionally, the existing pattern will happily match a partial newline. There are a strangely large number of tests that end with a random '.' character. Not matching a literal period, but matching any single character, this is then matching half of the trailing newline sequence, while the \[\r\n\]+ in gdb_test is matching the other half of the sequence. I can think of no reason why this would be intentional, I suspect that the expected output at one time included a period, which has since been remove, but I haven't bothered to check on this. In this commit I've removed all these unneeded trailing '.' characters. The basic rule of gdb_test after this is that the expected pattern needs to match everything up to, but not including the newline sequence immediately before the GDB prompt. This is generally how the proc is used anyway, so in almost all cases, this commit represents no significant change. Second, while I was cleaning up newline matching in gdb_test, I've also removed the '[\r\n]*' that was added to the start of the pattern passed to gdb_test_multiple. The addition of this pattern adds no value. If the user pattern matches at the start of a line then this would match against the newline sequence. But, due to the '*', if the user pattern doesn't match at the start of a line then this group doesn't care, it'll happily match nothing. As such, there's no value to it, it just adds more complexity for no gain, so I'm removing it. No tests will need updating as a consequence of this part of the patch. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-17PowerPC: fix for gdb.reverse/finish-precsave.exp and ↵Carl Love2-0/+315
gdb.reverse/finish-reverse.exp PPC64 multiple entry points, a normal entry point and an alternate entry point. The alternate entry point is to setup the Table of Contents (TOC) register before continuing at the normal entry point. When the TOC is already valid, the normal entry point is used, this is typically the case. The alternate entry point is typically referred to as the global entry point (GEP) in IBM. The normal entry point is typically referred to as the local entry point (LEP). When GDB is executing the finish command in reverse, the function finish_backward currently sets the break point at the alternate entry point. This issue is if the function, when executing in the forward direction, entered the function via the normal entry point, execution in the reverse direction will never sees the break point at the alternate entry point. In this case, the reverse execution continues until the next break point is encountered thus stopping at the wrong place. This patch adds a new address to struct execution_control_state to hold the address of the alternate entry point (GEP). The finish_backwards function is updated, if the stopping point is between the normal entry point (LEP) and the end of the function, a breakpoint is set at the normal entry point. If the stopping point is between the entry points, a breakpoint is set at the alternate entry point. This ensures that GDB will always stop at the normal entry point. If the function did enter via the alternate entry point, GDB will detect that and continue to execute backwards in the function until the alternate entry point is reached. The patch fixes the behavior of the reverse-finish command on PowerPC to match the behavior of the command on other platforms, specifically X86. The patch does not change the behavior of the command on X86. A new test is added to verify the reverse-finish command on PowerPC correctly stops at the instruction where the function call is made. The patch fixes 11 regression errors in test gdb.reverse/finish-precsave.exp and 11 regression errors in test gdb.reverse/finish-reverse.exp. The patch has been tested on Power 10 and X86 processor with no new regression failures.
2023-03-17Move step_until procedureCarl Love1-41/+8
Procedure step_until from test gdb.reverse/step-indirect-call-thunk.exp is moved to lib/gdb.exp and renamed repeat_cmd_until. The existing procedure gdb_step_until in lib/gdb.exp is simpler variant of the new repeat_cmd_until procedure. The existing procedure gdb_step_until is changed to just call the new repeat_cmd_until procedure with the command set to "step" and an optional CURRENT string. The default CURRENT string is set to "\}" to work with the existing uses of procedure gdb_step_until.
2023-03-10Use require with target_infoTom Tromey2-8/+2
This changes many tests to use 'require' when checking target_info. In a few spots, the require is hoisted to the top of the file, to avoid doing any extra work when the test is going to be skipped anyway.
2023-02-22gdb.reverse/time-reverse.exp: test both time syscall and C time functionPedro Alves2-22/+57
Instead of only testing this on systems that have a SYS_time syscall, test it everywhere using the time(2) C function, and in addition, run the tests again using the SYS_time syscall. The C variant ensures that if some platform uses some syscall we are not aware of yet, we'll still exercise it, and likely fail, at which point we should teach GDB about the syscall. The explicit syscall variant is useful on platforms where the C function does not call a syscall at all by default, e.g., on some systems the C time function wraps an implementation provided by the vDSO. Approved-By: Tom de Vries <tdevries@suse.de> Change-Id: Id4b755d76577d02c46b8acbfa249d9c31b587633
2023-02-21[gdb/testsuite] Require istarget x86* in ↵Tom de Vries1-0/+2
gdb.reverse/step-indirect-call-thunk.exp On aarch64-linux, I run into: ... Running gdb.reverse/step-indirect-call-thunk.exp ... gdb compile failed, gcc: error: unrecognized command line option \ '-mindirect-branch=thunk'; did you mean '-findirect-inlining'? gcc: error: unrecognized command line option '-mfunction-return=thunk'; \ did you mean '-Wfunction-elimination'? UNTESTED: gdb.reverse/step-indirect-call-thunk.exp: failed to prepare ... Fix this by requiring istarget "x86*", similar to what was added in gdb.base/step-indirect-call-thunk.exp by commit 43127ae5714 ("Fix gdb.base/step-indirect-call-thunk.exp"), such that we have instead: ... UNSUPPORTED: gdb.reverse/step-indirect-call-thunk.exp: require failed: \ istarget "x86* ... Tested on x86_64-linux and aarch64-linux.
2023-02-21[gdb/testsuite] Require syscall time in gdb.reverse/time-reverse.expTom de Vries1-0/+2
On aarch64-linux, I run into: ... Running gdb.reverse/time-reverse.exp ... gdb compile failed, gdb.reverse/time-reverse.c: In function 'main': gdb.reverse/time-reverse.c:39:12: error: 'SYS_time' undeclared \ (first use in this function); did you mean 'SYS_times'? syscall (SYS_time, &time_global); ^~~~~~~~ SYS_times gdb.reverse/time-reverse.c:39:12: note: each undeclared identifier is \ reported only once for each function it appears in UNTESTED: gdb.reverse/time-reverse.exp: failed to prepare ... Fix this by adding a new proc have_syscall, and requiring syscall time, such that we have instead: ... UNSUPPORTED: gdb.reverse/time-reverse.exp: require failed: \ expr [have_syscall time] ... Tested on x86_64-linux and aarch64-linux.
2023-01-26Use clean_restart in gdb.reverseTom Tromey4-24/+4
Change gdb.reverse to use clean_restart more consistently.
2023-01-26[gdb/testsuite] Add and use is_x86_64_m64_targetTom de Vries2-9/+8
Add new proc is_x86_64_m64_target and use it where appropriate. Tested on x86_64-linux.
2023-01-25Use require with istargetTom Tromey3-15/+3
This changes many tests to use require when checking 'istarget'. A few of these conversions were already done in earlier patches. No change was needed to 'require' to make this work, due to the way it is written. I think the result looks pretty clear, and it has the bonus of helping to ensure that the reason that a test is skipped is always logged.
2023-01-25Rename skip_power_isa_3_1_tests to allow formTom Tromey1-1/+2
This renames skip_power_isa_3_1_tests to allow_power_isa_3_1_tests and updates its users to use require.
2023-01-18Revert "X86: reverse-finish fix"Carl Love7-165/+50
This reverts commit b22548ddb30bfb167708e82d3bb932461c1b703a. This patch is being reverted since the patch series is causing regressions.
2023-01-18Revert "PowerPC: fix for gdb.reverse/finish-precsave.exp and ↵Carl Love2-120/+15
gdb.reverse/finish-reverse.exp" This reverts commit 92e07580db6a5572573d5177ca23933064158f89. Reverting patch as the patch series is causing regressions.
2023-01-17PowerPC: fix for gdb.reverse/finish-precsave.exp and ↵Carl Love2-15/+120
gdb.reverse/finish-reverse.exp PR record/29927 - reverse-finish requires two reverse next instructions to reach previous source line PowerPC uses two entry points called the local entry point (LEP) and the global entry point (GEP). Normally the LEP is used when calling a function. However, if the table of contents (TOC) value in register 2 is not valid the GEP is called to setup the TOC before execution continues at the LEP. When executing in reverse, the function finish_backward sets the break point at the alternate entry point (GEP). However if the forward execution enters via the normal entry point (LEP), the reverse execution never sees the break point at the GEP of the function. Reverse execution continues until the next break point is encountered or the end of the recorded log is reached causing gdb to stop at the wrong place. This patch adds a new address to struct execution_control_state to hold the address of the alternate function start address, known as the GEP on PowerPC. The finish_backwards function is updated. If the stopping point is between the two entry points (the LEP and GEP on PowerPC), the stepping range is set to execute back to the alternate entry point (GEP on PowerPC). Otherwise, a breakpoint is inserted at the normal entry point (LEP on PowerPC). Function process_event_stop_test checks uses a stepping range to stop execution in the caller at the first instruction of the source code line. Note, on systems that only support one entry point, the address of the two entry points are the same. Test finish-reverse-next.exp is updated to include tests for the reverse-finish command when the function is entered via the normal entry point (i.e. the LEP) and the alternate entry point (i.e. the GEP). The patch has been tested on X86 and PowerPC with no regressions.
2023-01-17X86: reverse-finish fixCarl Love7-50/+165
PR record/29927 - reverse-finish requires two reverse next instructions to reach previous source line Currently on X86, when executing the finish command in reverse, gdb does a single step from the first instruction in the callee to get back to the caller. GDB stops on the last instruction in the source code line where the call was made. When stopped at the last instruction of the source code line, a reverse next or step command will stop at the first instruction of the same source code line thus requiring two step/next commands to reach the previous source code line. It should only require one step/next command to reach the previous source code line. By contrast, a reverse next or step command from the first line in a function stops at the first instruction in the source code line where the call was made. This patch fixes the reverse finish command so it will stop at the first instruction of the source line where the function call was made. The behavior on X86 for the reverse-finish command now matches doing a reverse-next from the beginning of the function. The proceed_to_finish flag in struct thread_control_state is no longer used. This patch removes the declaration, initialization and setting of the flag. This patch requires a number of regression tests to be updated. Test gdb.mi/mi-reverse.exp no longer needs to execute two steps to get to the previous line. The gdb output for tests gdb.reverse/until-precsave.exp and gdb.reverse/until-reverse.exp changed slightly. The expected result in tests gdb.reverse/amd64-failcall-reverse.exp and gdb.reverse/singlejmp-reverse.exp are updated to the correct expected result. This patch adds a new test gdb.reverse/finish-reverse-next.exp to test the reverse-finish command when returning from the entry point and from the body of the function. The step_until proceedure in test gdb.reverse/step-indirect-call-thunk.exp was moved to lib/gdb.exp and renamed cmd_until. The patch has been tested on X86 and PowerPC to verify no additional regression failures occured. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29927
2023-01-13Rename to allow_shlib_testsTom Tromey2-2/+2
This changes skip_shlib_tests to invert the sense, and renames it to allow_shlib_tests.
2023-01-13Use require is_x86_like_targetTom Tromey4-21/+4
This changes some tests to use "require is_x86_like_target".
2023-01-13Use require supports_process_recordTom Tromey8-59/+24
This changes some tests to use "require supports_process_record".
2023-01-13Use require supports_reverseTom Tromey29-98/+29
This changes some tests to use "require supports_reverse".
2023-01-13Change 'require' to accept a list of predicatesTom Tromey1-1/+1
This changes 'require' to accept a list of simple predicates. For now, each predicate is just the name of a proc, optionally prefixed with "!" to indicate that the result should be inverted. It's possible to make this fancier, but so far I haven't done so. One idea I had is to allow a predicate to have associated text to display on failure. Another is to convert the predicates that need a running gdb (e.g., skip_python_tests) to start their own gdb, and then 'require' could enforce the rule that gdb not be running when it is called.