* [PATCH][gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32
@ 2021-01-12 14:36 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-01-12 14:36 UTC (permalink / raw)
To: gdb-patches
Hi,
When executing test-case gdb.base/step-over-syscall.exp with target board
unix/-m32, we run into:
...
(gdb) x/2i $pc^M
=> 0xf7fd5155 <__kernel_vsyscall+5>: sysenter ^M
0xf7fd5157 <__kernel_vsyscall+7>: int $0x80^M
(gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: \
pc before/after syscall instruction
stepi^M
[Detaching after fork from child process 23593]^M
0xf7fd5159 in __kernel_vsyscall ()^M
1: x/i $pc^M
=> 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp^M
(gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: stepi fork insn
print /x $pc^M
$2 = 0xf7fd5159^M
(gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: pc after stepi
FAIL: gdb.base/step-over-syscall.exp: fork: displaced=off: \
pc after stepi matches insn addr after syscall
...
The test tries to verify that after doing a stepi at a syscall insn, the $pc
is matching the insn after the syscall insn.
However, in the case that the syscall insn is "sysenter", the stepi will land
further away, so in this case:
...
0xf7fd5155 <__kernel_vsyscall+5>: sysenter ^M
0xf7fd5157 <__kernel_vsyscall+7>: int $0x80^M
0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp^M
...
the stepi will land at 0xf7fd5159 instead of 0xf7fd5157.
Fix this by detecting the sysenter/int sequence and adjusting the expected
pc.
Tested on x86_64-linux.
Any comments?
Thanks,
- Tom
[gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32
gdb/testsuite/ChangeLog:
2021-01-12 Tom de Vries <tdevries@suse.de>
* gdb.base/step-over-syscall.exp: Detect and handle sysenter/int
sequence.
---
gdb/testsuite/gdb.base/step-over-syscall.exp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp
index e6f58aecd3d..ecfb7be481d 100644
--- a/gdb/testsuite/gdb.base/step-over-syscall.exp
+++ b/gdb/testsuite/gdb.base/step-over-syscall.exp
@@ -155,11 +155,34 @@ proc setup { syscall } {
gdb_test_multiple "x/2i \$pc" "pc before/after syscall instruction" {
-re "x/2i .*=> ($hex) .*:.*$syscall_insn.* ($hex) .*:.*$gdb_prompt $" {
set syscall_insn_addr $expect_out(1,string)
+ set actual_syscall_insn $expect_out(2,string)
set next_insn_addr $expect_out(3,string)
pass $gdb_test_name
}
}
+ # If we encounter a sequence:
+ # 0xf7fd5155 <__kernel_vsyscall+5>: sysenter
+ # 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80
+ # 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp
+ # then a stepi at sysenter will step over the int insn, so make sure
+ # next_insn_addr points after the int insn.
+ if { $actual_syscall_insn == "sysenter" } {
+ set test "pc after sysenter instruction"
+ set re_int_insn "\[ \t\]*int\[ \t\]\[^\r\n\]*"
+ set re [multi_line \
+ "x/2i $hex" \
+ "\[^\r\n\]* $hex \[^\r\n\]*:$re_int_insn" \
+ "\[^\r\n\]* ($hex) \[^\r\n\]*:\[^\r\n\]*"]
+ gdb_test_multiple "x/2i $next_insn_addr" $test {
+ -re -wrap $re {
+ set next_insn_addr $expect_out(1,string)
+ }
+ -re -wrap "" {
+ }
+ }
+ }
+
if {[gdb_test "stepi" "x/i .*=>.*" "stepi $syscall insn"] != 0} {
return { -1, -1 }
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-12 14:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 14:36 [PATCH][gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32 Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).