summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2015-12-08 19:10:42 +0100
committerMark Wielaard <mjw@redhat.com>2016-01-03 12:17:16 +0100
commita8a22a33a8c5886d6818bd8377f11dd8f38fdc2b (patch)
treea8b16193ad410e5404da7eaef1f58eb69c77ebed
parent73be3d2d1a5dbdb6aa954b244524d21346af27d8 (diff)
downloadelfutils-a8a22a33a8c5886d6818bd8377f11dd8f38fdc2b.tar.gz
elfutils-a8a22a33a8c5886d6818bd8377f11dd8f38fdc2b.tar.xz
backends: sparc: support for core backtraces
This patch adds sparc support to the unwinder, providing a default CFI program that works in both sparcv9-*-* and sparc64-*-* targets. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--backends/ChangeLog10
-rw-r--r--backends/Makefile.am3
-rw-r--r--backends/sparc_cfi.c83
-rw-r--r--backends/sparc_corenote.c10
-rw-r--r--backends/sparc_init.c7
-rw-r--r--tests/ChangeLog8
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/backtrace.sparc.core.bz2bin0 -> 9628 bytes
-rwxr-xr-xtests/backtrace.sparc.exec.bz2bin0 -> 348964 bytes
-rwxr-xr-xtests/run-backtrace-core-sparc.sh20
10 files changed, 142 insertions, 3 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 7f0d1c0..7ee8c2c 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,13 @@
+2015-12-08 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * sparc_corenote.c: Header comment typo fixed.
+ (PRSTATUS_REGSET_ITEMS): Defined, so the PC can be fetched from
+ core files.
+ * Makefile.am (sparc_SRCS): Added sparc_cfi.c
+ * sparc_cfi.c: New file.
+ * sparc_init.c (sparc_init): Set eh->frame_nregs, eh->ra_offset
+ and hook sparc_abi_cfi.
+
2015-10-21 Chih-Hung Hsieh <chh@google.com>
* ia64_retval.c (hfa_type): Move nested function 'hfa' to file scope.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index f7002fb..f07b202 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -84,7 +84,8 @@ libebl_aarch64_pic_a_SOURCES = $(aarch64_SRCS)
am_libebl_aarch64_pic_a_OBJECTS = $(aarch64_SRCS:.c=.os)
sparc_SRCS = sparc_init.c sparc_symbol.c sparc_regs.c sparc_retval.c \
- sparc_corenote.c sparc64_corenote.c sparc_auxv.c sparc_attrs.c
+ sparc_corenote.c sparc64_corenote.c sparc_auxv.c sparc_attrs.c \
+ sparc_cfi.c
libebl_sparc_pic_a_SOURCES = $(sparc_SRCS)
am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os)
diff --git a/backends/sparc_cfi.c b/backends/sparc_cfi.c
new file mode 100644
index 0000000..dcc17bd
--- /dev/null
+++ b/backends/sparc_cfi.c
@@ -0,0 +1,83 @@
+/* SPARC defaults for DWARF CFI.
+ Copyright (C) 2015 Oracle Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils 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 copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <dwarf.h>
+
+#define BACKEND sparc_
+#include "libebl_CPU.h"
+
+int
+sparc_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info)
+{
+ static const uint8_t abi_cfi[] =
+ {
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+ /* %g0 .. %g7 */
+ SV (0), SV (1), SV (2), SV (3), SV (4), SV (5), SV (6), SV (7),
+ /* %o0 .. %o7 */
+ SV (8), SV (9), SV (10), SV (11), SV (12), SV (13), SV (14), SV (15),
+ /* %l0 .. %l7 */
+ SV (16), SV (17), SV (18), SV (19), SV (20), SV (21), SV (22), SV (23),
+ /* %i0 .. %i7 */
+ SV (24), SV (25), SV (26), SV (27), SV (28), SV (29), SV (30), SV (31),
+ /* %f0 .. %f32 */
+ SV (32), SV (33), SV (34), SV (35), SV (36), SV (37), SV (38), SV (39),
+ SV (40), SV (41), SV (42), SV (43), SV (44), SV (45), SV (46), SV (47),
+ SV (48), SV (49), SV (50), SV (51), SV (52), SV (53), SV (54), SV (55),
+ SV (56), SV (57), SV (58), SV (59), SV (60), SV (61), SV (52), SV (63),
+ /* %f33 .. %63
+ Note that there are DWARF columns for the odd registers, even
+ if they don't exist in hardware) */
+ SV (64), SV (65), SV (66), SV (67), SV (68), SV (69), SV (70), SV (71),
+ SV (72), SV (73), SV (74), SV (75), SV (76), SV (77), SV (78), SV (79),
+ SV (80), SV (81), SV (82), SV (83), SV (84), SV (85), SV (86), SV (87),
+ SV (88), SV (89), SV (90), SV (91), SV (92), SV (93), SV (94), SV (95),
+ /* %fcc[0123] */
+ SV (96), SV (97), SV (98), SV (99),
+ /* %icc/%xcc */
+ SV (100),
+ /* Soft frame-pointer */
+ SV (101),
+ /* %gsr */
+ SV (102)
+#undef SV
+ };
+
+ abi_info->initial_instructions = abi_cfi;
+ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+ abi_info->data_alignment_factor = 4;
+
+ abi_info->return_address_register = 31; /* %i7 */
+
+ return 0;
+}
+
diff --git a/backends/sparc_corenote.c b/backends/sparc_corenote.c
index 7912539..c9b6ff3 100644
--- a/backends/sparc_corenote.c
+++ b/backends/sparc_corenote.c
@@ -1,5 +1,6 @@
-/* PowerPC specific core note handling.
+/* SPARC specific core note handling.
Copyright (C) 2007 Red Hat, Inc.
+ Copyright (C) 2015 Oracle, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -109,4 +110,11 @@ static const Ebl_Register_Location fpregset_regs[] =
#define ALIGN_PID_T 4
#define TYPE_PID_T ELF_T_SWORD
+#define PRSTATUS_REGSET_ITEMS \
+ { \
+ .name = "pc", .type = ELF_T_ADDR, .format = 'x', \
+ .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[33]), \
+ .group = "register", .pc_register = true \
+ }
+
#include "linux-core-note.c"
diff --git a/backends/sparc_init.c b/backends/sparc_init.c
index f8a7cfb..98b697c 100644
--- a/backends/sparc_init.c
+++ b/backends/sparc_init.c
@@ -76,6 +76,13 @@ sparc_init (Elf *elf __attribute__ ((unused)),
HOOK (eh, register_info);
HOOK (eh, return_value_location);
HOOK (eh, check_object_attribute);
+ HOOK (eh, abi_cfi);
+ /* gcc/config/sparc.h define FIRST_PSEUDO_REGISTER */
+ eh->frame_nregs = 103;
+ /* The CFI Dwarf register with the "return address" in sparc
+ actually contains the call address. The return address is
+ located 8 bytes after it. */
+ eh->ra_offset = 8;
return MODVERSION;
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2940e38..b8d1d95 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2015-12-08 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * run-backtrace-core-sparc.sh: New file.
+ * backtrace.sparc.core.bz2: New file.
+ * backtrace.sparc.exec.bz2: New file.
+ * Makefile.am (EXTRA_DIST): ... and added all here.
+ (TESTS): Added run-backtrace-core-sparc.sh.
+
2015-12-02 Mark Wielaard <mjw@redhat.com>
* Makefile.am (valgrind_cmd): Use --leak-check=full.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0077c0f..8fca801 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,7 +114,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-backtrace-core-x32.sh \
run-backtrace-core-i386.sh run-backtrace-core-ppc.sh \
run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
- run-backtrace-core-aarch64.sh \
+ run-backtrace-core-aarch64.sh run-backtrace-core-sparc.sh \
run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
run-stack-demangled-test.sh \
run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
@@ -287,6 +287,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
run-backtrace-core-aarch64.sh \
backtrace.aarch64.core.bz2 backtrace.aarch64.exec.bz2 \
+ run-backtrace-core-sparc.sh \
+ backtrace.sparc.core.bz2 backtrace.sparc.exec.bz2 \
run-backtrace-demangle.sh testfile-backtrace-demangle.bz2 \
testfile-backtrace-demangle.cc \
testfile-backtrace-demangle.core.bz2 \
diff --git a/tests/backtrace.sparc.core.bz2 b/tests/backtrace.sparc.core.bz2
new file mode 100644
index 0000000..ad37f75
--- /dev/null
+++ b/tests/backtrace.sparc.core.bz2
Binary files differ
diff --git a/tests/backtrace.sparc.exec.bz2 b/tests/backtrace.sparc.exec.bz2
new file mode 100755
index 0000000..b049ec5
--- /dev/null
+++ b/tests/backtrace.sparc.exec.bz2
Binary files differ
diff --git a/tests/run-backtrace-core-sparc.sh b/tests/run-backtrace-core-sparc.sh
new file mode 100755
index 0000000..60399ba
--- /dev/null
+++ b/tests/run-backtrace-core-sparc.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Copyright (C) 2015 Oracle, Inc.
+# This file is part of elfutils.
+#
+# This file 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.
+#
+# elfutils 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/>.
+
+. $srcdir/backtrace-subr.sh
+
+check_core sparc