aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
authorSangamesh Mallayya <sangamesh.swamy@in.ibm.com>2018-11-01 06:23:59 -0400
committerSangamesh Mallayya <sangamesh.swamy@in.ibm.com>2018-11-01 06:23:59 -0400
commitcdcda965ea4c70c80b9f8c294597e991417ff9d5 (patch)
tree76fbd8536e17add42587a6d4147f85a976b29447 /gdb/testsuite/gdb.arch
parent38642de318119d116c47eaff52ad9a7edb032c11 (diff)
downloadgdb-cdcda965ea4c70c80b9f8c294597e991417ff9d5.zip
gdb-cdcda965ea4c70c80b9f8c294597e991417ff9d5.tar.gz
gdb-cdcda965ea4c70c80b9f8c294597e991417ff9d5.tar.bz2
Reading signal handler frame in AIX
In AIX if gdb is debugging an application which has a signal handler and reaches the signal handler frame, then we need to read the back chain address from sigcontext saved on the stack, similarly the LR. As backchain at an offset 0 will be 0, because we will have a sigconext saved after the minimum stack size. So the correct backchain will be at an offset after minimum stack and the LR at an offset 8 will be of the signal millicode address. If the back chain pointer is NULL and the LR field is in the kernel segment(ex. 0x00004a14) then we can probably assume we are in a signal handler. sample output (gdb) bt 0 sig_handle_aix (signo=11) at aix-sighandle.c:7 1 0x0000000000004a94 in ?? () (gdb) expected output (gdb) bt 0 sig_handle_aix (signo=11) at aix-sighandle.c:7 1 <signal handler called> 2 0x0000000100000748 in foo () at aix-sighandle.c:14 3 0x000000010000079c in main () at aix-sighandle.c:19 gdb/ChangeLog: 2018-11-01 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com> * rs6000-aix-tdep.c: Include "trad-frame.h" and "frame-unwind.h". (SIG_FRAME_LR_OFFSET64): New define. (SIG_FRAME_FP_OFFSET64): New define. (aix_sighandle_frame_cache): New Function. (aix_sighandle_frame_this_id): New Function. (aix_sighandle_frame_prev_register): New Function. (aix_sighandle_frame_sniffer): New Function. (aix_sighandle_frame_unwind): New global variable. (rs6000_aix_init_osabi): Install new frame unwinder. gdb/testsuite/ChangeLog: 2018-11-01 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com> * gdb.arch/aix-sighandle.c: New file. * gdb.arch/aix-sighandle.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/aix-sighandle.c35
-rw-r--r--gdb/testsuite/gdb.arch/aix-sighandle.exp43
2 files changed, 78 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/aix-sighandle.c b/gdb/testsuite/gdb.arch/aix-sighandle.c
new file mode 100644
index 0000000..a889e7e
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aix-sighandle.c
@@ -0,0 +1,35 @@
+/* Copyright 2018 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+
+void sig_handle_aix (int signo)
+{
+ printf ("signal is: %d\n", signo);
+}
+
+void foo()
+{
+ char *ptr;
+ signal (SIGSEGV, sig_handle_aix);
+ strcpy (ptr, "signal");
+}
+
+int main()
+{
+ foo ();
+}
diff --git a/gdb/testsuite/gdb.arch/aix-sighandle.exp b/gdb/testsuite/gdb.arch/aix-sighandle.exp
new file mode 100644
index 0000000..a401ff7
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aix-sighandle.exp
@@ -0,0 +1,43 @@
+# Copyright 2018 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if {![istarget "powerpc*-*-aix*"]} {
+ return
+}
+
+if { [prepare_for_testing "failed to prepare" aix-sighandle aix-sighandle.c] } {
+ return -1
+}
+
+set srcfile aix-sighandle.c
+set binfile aix-sighandle
+
+gdb_test "break sig_handle_aix" \
+ "Breakpoint.1.at.*:.file.*$srcfile,.line.22." \
+ "breakpoint sig_handle_aix"
+gdb_test "run" \
+ "Starting.program:.*$binfile.*\r\nProgram.received.signal.SIGSEGV,.*\r\n.*.in.foo.*.at.*$srcfile:29.*" \
+ "run to breakpoint sig_handle_aix"
+
+gdb_test "continue" \
+ "Continuing.*Breakpoint.1,.sig_handle_aix..signo=11..at.*$srcfile:22.*" \
+ "continue to breakpoint sig_handle_aix"
+
+gdb_test_sequence "backtrace" "backtrace for sighandle" {
+ "\[\r\n\]+#0 .* sig_handle_aix \\(signo=11\\) at "
+ "\[\r\n\]+#1 .* .signal.handler.called."
+ "\[\r\n\]+#2 .* foo \\(\\) at "
+ "\[\r\n\]+#3 .* main \\(\\) at "
+}