From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/7] Step over fork/vfork syscall insn in gdbserver
Date: Fri, 26 Feb 2016 14:04:00 -0000 [thread overview]
Message-ID: <1456495426-7520-5-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1456495426-7520-1-git-send-email-yao.qi@linaro.org>
We can also extend disp-step-syscall.exp to test GDBserver step over
breakpoint on syscall instruction. That is, we set a breakpoint
with a false condition on syscall instruction, so that GDBserver will
step over it.
This test triggers a GDBserver internal error, which can be fixed by
this series.
(gdb) PASS: gdb.base/disp-step-syscall.exp: fork: break cond on target: break on syscall insns
continue^M
Continuing.^M
Remote connection closed^M
(gdb) FAIL: gdb.base/disp-step-syscall.exp: fork: break cond on target: continue to fork again
In GDBserver, there is an internal error,
/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1922: A problem internal to GDBserver has been detected.
unsuspend LWP 25554, suspended=-1
the simplified reproducer is like,
$ ./gdb ./testsuite/outputs/gdb.base/disp-step-syscall/disp-step-fork
(gdb) b main
(gdb) c
(gdb) disassemble fork // in order to find the address of insn 'syscall'
....
0x00007ffff7ad6023 <+179>: syscall
(gdb) b *0x00007ffff7ad6023 if main == 0
(gdb) c
gdb/testsuite:
2016-02-26 Yao Qi <yao.qi@linaro.org>
* gdb.base/disp-step-syscall.exp (break_cond_on_syscall): New.
If target supports condition evaluation on target, invoke
break_cond_on_syscall for fork and vfork.
---
gdb/testsuite/gdb.base/disp-step-syscall.exp | 57 ++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/gdb/testsuite/gdb.base/disp-step-syscall.exp b/gdb/testsuite/gdb.base/disp-step-syscall.exp
index 3cf436d..9ecf2a5 100644
--- a/gdb/testsuite/gdb.base/disp-step-syscall.exp
+++ b/gdb/testsuite/gdb.base/disp-step-syscall.exp
@@ -168,5 +168,62 @@ proc disp_step_cross_syscall { syscall } {
}
}
+# Set a breakpoint with a condition that evals false on syscall
+# instruction. In fact, it tests GDBserver steps over syscall
+# instruction.
+
+proc break_cond_on_syscall { syscall } {
+ with_test_prefix "break cond on target : $syscall" {
+ set testfile "disp-step-$syscall"
+
+ set ret [setup $syscall]
+
+ set syscall_insn_addr [lindex $ret 0]
+ set syscall_insn_next_addr [lindex $ret 1]
+ if { $syscall_insn_addr == -1 } {
+ return -1
+ }
+
+ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \
+ "continue to $syscall"
+ # Delete breakpoint syscall insns to avoid interference to other syscalls.
+ delete_breakpoints
+
+
+ # Create a breakpoint with a condition that evals false.
+ gdb_test "break \*$syscall_insn_addr if main == 0" \
+ "Breakpoint \[0-9\]* at .*"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*"
+ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \
+ "continue to marker ($syscall)"
+ }
+}
+
disp_step_cross_syscall "fork"
disp_step_cross_syscall "vfork"
+
+set testfile "disp-step-fork"
+clean_restart $testfile
+if { ![runto main] } then {
+ fail "run to main"
+ return -1
+}
+
+set cond_bp_target 1
+
+set test "set breakpoint condition-evaluation target"
+gdb_test_multiple $test $test {
+ -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" {
+ # Target doesn't support breakpoint condition
+ # evaluation on its side.
+ set cond_bp_target 0
+ }
+ -re "^$test\r\n$gdb_prompt $" {
+ }
+}
+
+if { $cond_bp_target } {
+ break_cond_on_syscall "fork"
+ break_cond_on_syscall "vfork"
+}
--
1.9.1
next prev parent reply other threads:[~2016-02-26 14:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 14:36 [PATCH 0/8] Leave child suspended when step over parent Yao Qi
2016-02-19 14:36 ` [PATCH 3/8] Use loop in disp-step-fork.c and disp-step-vfork.c Yao Qi
2016-02-25 17:28 ` Pedro Alves
2016-02-19 14:36 ` [PATCH 5/8] Step over fork/vfork syscall insn in gdbserver Yao Qi
2016-02-23 20:28 ` Luis Machado
2016-02-25 17:31 ` Pedro Alves
2016-02-19 14:36 ` [PATCH 2/8] Refactor gdb.base/disp-step-syscall.exp for general step over test Yao Qi
2016-02-19 14:36 ` [PATCH 4/8] Step over syscalll insn with disp-step on and off Yao Qi
2016-02-25 17:27 ` Pedro Alves
2016-02-19 14:37 ` [PATCH 8/8] New test about step over clone syscall Yao Qi
2016-02-23 20:31 ` Luis Machado
2016-02-25 17:43 ` Pedro Alves
2016-02-25 17:43 ` Pedro Alves
2016-02-19 14:37 ` [PATCH 7/8] Rename disp-step-syscall.exp to step-over-syscall.exp Yao Qi
2016-02-25 17:32 ` Pedro Alves
2016-02-19 14:37 ` [PATCH 1/8] [GDBserver] Leave child suspended when step over parent Yao Qi
2016-02-23 20:23 ` Luis Machado
2016-02-25 17:12 ` Pedro Alves
2016-02-19 14:37 ` [PATCH 6/8] Reformat disp-step-syscall.exp Yao Qi
2016-02-26 14:03 ` [PATCH 0/7 V2] Leave child suspended when step over parent Yao Qi
2016-02-26 14:04 ` [PATCH 6/7] Reformat gdb.base/step-over-syscall.exp Yao Qi
2016-02-26 14:04 ` [PATCH 1/7] [GDBserver] Leave child suspended when step over parent Yao Qi
2016-02-26 14:04 ` [PATCH 7/7] New test about step over clone syscall Yao Qi
2016-02-26 14:04 ` [PATCH 2/7] Refactor gdb.base/disp-step-syscall.exp for general step over test Yao Qi
2016-02-26 14:04 ` [PATCH 5/7] Rename disp-step-syscall.exp to step-over-syscall.exp Yao Qi
2016-02-26 14:04 ` [PATCH 3/7] Step over syscalll insn with disp-step on and off Yao Qi
2016-02-26 14:04 ` Yao Qi [this message]
2016-02-26 15:02 ` [PATCH 4/7] Step over fork/vfork syscall insn in gdbserver Luis Machado
2016-02-26 15:50 ` Yao Qi
2016-03-03 9:21 ` [PATCH 0/7 V2] Leave child suspended when step over parent Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456495426-7520-5-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).