[PATCH 5/8] gdbserver/s390: Switch on tracepoint support.

Marcin Kościelnicki
2016-01-24T12:12:34Z

Also adds s390 support to gdb.trace testsuite.

gdb/gdbserver/ChangeLog:

* linux-s390-low.c (s390_supports_tracepoints): New function.
(struct linux_target_ops): Fill supports_tracepoints hook.

gdb/testsuite/ChangeLog:

* gdb.trace/ftrace.exp: Select $r2 as test register for s390.
* gdb.trace/mi-trace-frame-collected.exp: Expect 2 registers on s390.
* gdb.trace/trace-common.h (x86_trace_dummy): Add s390 fast tracepoint
placeholder.
* lib/trace-support.exp: Add s390 registers.
---
gdb/gdbserver/ChangeLog | 5 +++++
gdb/gdbserver/linux-s390-low.c | 8 +++++++-
gdb/testsuite/ChangeLog | 8 ++++++++
gdb/testsuite/gdb.trace/ftrace.exp | 2 ++
gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp | 14 +++++++++++---
gdb/testsuite/gdb.trace/trace-common.h | 8 ++++++++
gdb/testsuite/lib/trace-support.exp | 4 ++++
7 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 5e47b46..e0d8c67 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-24 Marcin KoÅ›cielnicki <koriakin@0x04.net>
+
+ * linux-s390-low.c (s390_supports_tracepoints): New function.
+ (struct linux_target_ops): Fill supports_tracepoints hook.
+
2016-01-21 Marcin KoÅ›cielnicki <koriakin@0x04.net>

* linux-s390-low.c (s390_supports_z_point_type): New function.
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index 420430b..ab3e62b 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -688,6 +688,12 @@ s390_regs_info (void)
return &regs_info;
}

+static int
+s390_supports_tracepoints (void)
+{
+ return 1;
+}
+
struct linux_target_ops the_low_target = {
s390_arch_setup,
s390_regs_info,
@@ -714,7 +720,7 @@ struct linux_target_ops the_low_target = {
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
- NULL, /* supports_tracepoints */
+ s390_supports_tracepoints,
NULL, /* get_thread_area */
NULL, /* install_fast_tracepoint_jump_pad */
NULL, /* emit_ops */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a201b66..98e7970 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2016-01-24 Marcin KoÅ›cielnicki <koriakin@0x04.net>
+
+ * gdb.trace/ftrace.exp: Select $r2 as test register for s390.
+ * gdb.trace/mi-trace-frame-collected.exp: Expect 2 registers on s390.
+ * gdb.trace/trace-common.h (x86_trace_dummy): Add s390 fast tracepoint
+ placeholder.
+ * lib/trace-support.exp: Add s390 registers.
+
2016-01-23 Marcin KoÅ›cielnicki <koriakin@0x04.net>

* gdb.trace/backtrace.exp: Bump stack collection fudge factor.
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index 15ad7e7..cca3a9c 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -246,6 +246,8 @@ if [is_amd64_regs_target] {
set arg0exp "*(int *) (\$ebp + 8)"
} elseif { [istarget "aarch64*-*-*"] } {
set arg0exp "\$x0"
+} elseif { [istarget "s390*-*-*"] } {
+ set arg0exp "\$r2"
} else {
set arg0exp ""
}
diff --git a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
index 0daaa25..499d3fb 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
@@ -93,9 +93,17 @@ proc test_trace_frame_collected { data_source } {

# Test MI command '-trace-frame-collected' dumps only
# collected registers.
- mi_gdb_test "-trace-frame-collected" \
- "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",value=\".*\"\}\\\],computed-expressions=\\\[\\\],registers=\\\[\{number=\"$decimal\",value=\"$hex\"\}\\\],tvars=\\\[\\\],memory=\\\[\{address=\"$hex\",length=\"1\"\}\\\]"\
- "-trace-frame-collected (register)"
+ if { [istarget "s390*-*-*"] } {
+ # Only PC is collected, but on s390 PC is a pseudo-register -
+ # collecting it also collects the underlying PSWA register.
+ mi_gdb_test "-trace-frame-collected" \
+ "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",value=\".*\"\}\\\],computed-expressions=\\\[\\\],registers=\\\[\{number=\"$decimal\",value=\"$hex\"\},\{number=\"$decimal\",value=\"$hex\"\}\\\],tvars=\\\[\\\],memory=\\\[\{address=\"$hex\",length=\"1\"\}\\\]"\
+ "-trace-frame-collected (register)"
+ } else {
+ mi_gdb_test "-trace-frame-collected" \
+ "\\^done,explicit-variables=\\\[\{name=\"gdb_char_test\",value=\".*\"\}\\\],computed-expressions=\\\[\\\],registers=\\\[\{number=\"$decimal\",value=\"$hex\"\}\\\],tvars=\\\[\\\],memory=\\\[\{address=\"$hex\",length=\"1\"\}\\\]"\
+ "-trace-frame-collected (register)"
+ }

mi_gdb_test "-trace-find frame-number 1" \
".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"1\",frame=\{.*" \
diff --git a/gdb/testsuite/gdb.trace/trace-common.h b/gdb/testsuite/gdb.trace/trace-common.h
index eceb182..a330024 100644
--- a/gdb/testsuite/gdb.trace/trace-common.h
+++ b/gdb/testsuite/gdb.trace/trace-common.h
@@ -48,6 +48,14 @@ x86_trace_dummy ()
" nop\n" \
)

+#elif (defined __s390__)
+
+#define FAST_TRACEPOINT_LABEL(name) \
+ asm (" .global " SYMBOL(name) "\n" \
+ SYMBOL(name) ":\n" \
+ " mvc 0(8, %r15), 0(%r15)\n" \
+ )
+
#else

#error "unsupported architecture for trace tests"
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
index f593c43..70f7b7f 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -36,6 +36,10 @@ if [is_amd64_regs_target] {
set fpreg "x29"
set spreg "sp"
set pcreg "pc"
+} elseif [istarget "s390*-*-*"] {
+ set fpreg "r11"
+ set spreg "r15"
+ set pcreg "pc"
} else {
set fpreg "fp"
set spreg "sp"
--
2.7.0