summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2016-12-14 07:10:59 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-12-14 07:10:59 -0800
commit31b3f9e8de4685b42eccf14813c01d7c2b757436 (patch)
treeb7915a164546736d70dbf0dcc6c1f3cb52cabc39
parent31472ebf0024fc84e562c1afad933659703ec51b (diff)
parent3ec012cb708cb5f1535ecde6fef3990ca3e73cfb (diff)
downloadcrash-worker-31b3f9e8de4685b42eccf14813c01d7c2b757436.tar.gz
crash-worker-31b3f9e8de4685b42eccf14813c01d7c2b757436.tar.bz2
crash-worker-31b3f9e8de4685b42eccf14813c01d7c2b757436.zip
Merge "crash-stack: align output format with sys-assert" into tizen_3.0
-rw-r--r--src/crash-stack/CMakeLists.txt5
-rw-r--r--src/crash-stack/crash-stack-aarch64.c35
-rw-r--r--src/crash-stack/crash-stack-arm.c34
-rw-r--r--src/crash-stack/crash-stack-x86.c102
-rw-r--r--src/crash-stack/crash-stack-x86_64.c73
5 files changed, 138 insertions, 111 deletions
diff --git a/src/crash-stack/CMakeLists.txt b/src/crash-stack/CMakeLists.txt
index 34c44ea..ccf845e 100644
--- a/src/crash-stack/CMakeLists.txt
+++ b/src/crash-stack/CMakeLists.txt
@@ -14,7 +14,10 @@ else()
set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-aarch64.c)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c)
- set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86_64.c)
+ set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c)
+ elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
+ set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c)
+ set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-x86.c)
else()
set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-libelf.c)
set(CRASH_STACK_SRCS ${CRASH_STACK_SRCS} crash-stack-stub.c)
diff --git a/src/crash-stack/crash-stack-aarch64.c b/src/crash-stack/crash-stack-aarch64.c
index 6461284..0c67286 100644
--- a/src/crash-stack/crash-stack-aarch64.c
+++ b/src/crash-stack/crash-stack-aarch64.c
@@ -103,24 +103,25 @@ void *_get_place_for_register_value(const char *regname, int regnum)
void _crash_stack_print_regs(FILE* outputfile)
{
- int i,top_reg;
-
- if ((g_registers.pstate & (PSR_MODE32_BIT | PSR_MODE_MASK)) == PSR_MODE32_BIT) {
- top_reg = 12;
- } else {
- top_reg = 29;
- }
+ int i;
fprintf(outputfile, "\nRegister Information\n");
- fprintf(outputfile, "pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n",
- g_registers.pc, g_registers.regs[30], g_registers.pstate);
- fprintf(outputfile, "sp : %016llx\n", g_registers.sp);
-
- for (i = top_reg; i >= 0; i--) {
- fprintf(outputfile, "x%-2d: %016llx ", i, g_registers.regs[i]);
- if ((i%2) == 0) {
- fprintf(outputfile,"\n");
- }
+ for (i = 0; i <= 30; i++) {
+ fprintf(outputfile, "x%-2d = 0x%016llx", i, g_registers.regs[i]);
+ if (i != 30 && 0 == i % 2)
+ fprintf(outputfile, ", ");
+ else
+ fprintf(outputfile, "\n");
}
- fprintf(outputfile,"\n");
+ fprintf(outputfile, "\n");
+ fprintf(outputfile, "xr = 0x%016llx, ip0 = 0x%016llx\nip1 = 0x%016llx, pr = 0x%016llx\n",
+ g_registers.regs[8], /* Indirect result location register */
+ g_registers.regs[16], /* Intra-procedure call scratch register 0 */
+ g_registers.regs[17], /* Intra-procedure call scratch register 1 */
+ g_registers.regs[18]); /* Platform register */
+ fprintf(outputfile, "fp = 0x%016llx, lr = 0x%016llx\npc = 0x%016llx, sp = 0x%016llx\n",
+ g_registers.regs[29], /* Frame register */
+ g_registers.regs[30], /* Procedure link register */
+ g_registers.pc, /* Program counter */
+ g_registers.sp); /* Stack pointer */
}
diff --git a/src/crash-stack/crash-stack-arm.c b/src/crash-stack/crash-stack-arm.c
index 8d91486..5f9033f 100644
--- a/src/crash-stack/crash-stack-arm.c
+++ b/src/crash-stack/crash-stack-arm.c
@@ -89,24 +89,18 @@ void _crash_stack_set_ptrace_registers(void *regbuf)
void _crash_stack_print_regs(FILE* outputfile)
{
fprintf(outputfile, "\nRegister Information\n");
- fprintf(outputfile, "pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n",
- g_ptrace_registers.uregs[REG_PC], g_ptrace_registers.uregs[REG_LR],
- g_ptrace_registers.uregs[REG_SPSR]
- );
- fprintf(outputfile, "sp : %08lx ip : %08lx fp : %08lx\n",
- g_ptrace_registers.uregs[REG_SP], g_ptrace_registers.uregs[REG_IP],
- g_ptrace_registers.uregs[REG_FP]
- );
- fprintf(outputfile, "r10: %08lx r9 : %08lx r8 : %08lx\n",
- g_ptrace_registers.uregs[10], g_ptrace_registers.uregs[9],
- g_ptrace_registers.uregs[8]
- );
- fprintf(outputfile, "r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
- g_ptrace_registers.uregs[7], g_ptrace_registers.uregs[6],
- g_ptrace_registers.uregs[5], g_ptrace_registers.uregs[4]
- );
- fprintf(outputfile, "r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
- g_ptrace_registers.uregs[3], g_ptrace_registers.uregs[2],
- g_ptrace_registers.uregs[1], g_ptrace_registers.uregs[0]
- );
+ fprintf(outputfile, "r0 = 0x%08lx, r1 = 0x%08lx\nr2 = 0x%08lx, r3 = 0x%08lx\n",
+ g_ptrace_registers.uregs[0], g_ptrace_registers.uregs[1],
+ g_ptrace_registers.uregs[2], g_ptrace_registers.uregs[3]);
+ fprintf(outputfile, "r4 = 0x%08lx, r5 = 0x%08lx\nr6 = 0x%08lx, r7 = 0x%08lx\n",
+ g_ptrace_registers.uregs[4], g_ptrace_registers.uregs[5],
+ g_ptrace_registers.uregs[6], g_ptrace_registers.uregs[7]);
+ fprintf(outputfile, "r8 = 0x%08lx, r9 = 0x%08lx\nr10 = 0x%08lx, fp = 0x%08lx\n",
+ g_ptrace_registers.uregs[8], g_ptrace_registers.uregs[9],
+ g_ptrace_registers.uregs[10], g_ptrace_registers.uregs[REG_FP]);
+ fprintf(outputfile, "ip = 0x%08lx, sp = 0x%08lx\nlr = 0x%08lx, pc = 0x%08lx\n",
+ g_ptrace_registers.uregs[REG_IP], g_ptrace_registers.uregs[REG_SP],
+ g_ptrace_registers.uregs[REG_LR], g_ptrace_registers.uregs[REG_PC]);
+ /* XXX the label should probably write "spsr" */
+ fprintf(outputfile, "cpsr = 0x%08lx\n", g_ptrace_registers.uregs[REG_SPSR]);
}
diff --git a/src/crash-stack/crash-stack-x86.c b/src/crash-stack/crash-stack-x86.c
new file mode 100644
index 0000000..b63f279
--- /dev/null
+++ b/src/crash-stack/crash-stack-x86.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors: Adrian Szyndela <adrian.s@samsung.com>
+ * Łukasz Stelmach <l.stelmach@samsung.com>
+ */
+/**
+ * @file crash-stack-x86_64.c
+ * @brief unwinding call stacks, functions specific for x86_64
+ */
+#include "crash-stack.h"
+#include <sys/user.h>
+#include <string.h>
+
+struct user_regs_struct g_registers; ///< static storage for ptrace buffer for registers
+
+void *_crash_stack_get_memory_for_ptrace_registers(size_t *size)
+{
+ if (NULL != size)
+ *size = sizeof(g_registers);
+ return &g_registers;
+}
+
+void _crash_stack_set_ptrace_registers(void *regbuf)
+{
+ void *rsp = _get_place_for_register_value("rsp", 0);
+ void *rip = _get_place_for_register_value("rip", 0);
+
+ struct user_regs_struct *regs = regbuf;
+
+#if defined(__x86_64__)
+ memcpy(rsp, &regs->rsp, sizeof(regs->rsp));
+ memcpy(rip, &regs->rip, sizeof(regs->rip));
+#else
+ memcpy(rsp, &regs->esp, sizeof(regs->esp));
+ memcpy(rip, &regs->eip, sizeof(regs->eip));
+#endif
+}
+
+void _crash_stack_print_regs(FILE* outputfile)
+{
+ fprintf(outputfile, "\nRegister Information\n");
+#if defined(__x86_64__)
+ fprintf(outputfile, "gs = 0x%016llx, fs = 0x%016llx\nes = 0x%016llx, ds = 0x%016llx\n",
+ g_registers.gs,
+ g_registers.fs,
+ g_registers.es,
+ g_registers.ds);
+ fprintf(outputfile, "rdi = 0x%016llx, rsi = 0x%016llx\nrbp = 0x%016llx, rsp = 0x%016llx\n",
+ g_registers.rdi,
+ g_registers.rsi,
+ g_registers.rbp,
+ g_registers.rsp);
+ fprintf(outputfile, "rax = 0x%016llx, rbx = 0x%016llx\nrcx = 0x%016llx, rdx = 0x%016llx\n",
+ g_registers.rax,
+ g_registers.rbx,
+ g_registers.rcx,
+ g_registers.rdx);
+ fprintf(outputfile, "r8 = 0x%016llx, r9 = 0x%016llx\nr10 = 0x%016llx, r11 = 0x%016llx\n",
+ g_registers.r8,
+ g_registers.r9,
+ g_registers.r10,
+ g_registers.r11);
+ fprintf(outputfile, "r12 = 0x%016llx, r13 = 0x%016llx\nr14 = 0x%016llx, r15 = 0x%016llx\n",
+ g_registers.r12,
+ g_registers.r13,
+ g_registers.r14,
+ g_registers.r15);
+ fprintf(outputfile, "rip = 0x%016llx\n",
+ g_registers.rip);
+#else
+ fprintf(outputfile, "gs = 0x%08lx, fs = 0x%08lx\nes = 0x%08lx, ds = 0x%08lx\n",
+ g_registers.xgs,
+ g_registers.xfs,
+ g_registers.xes,
+ g_registers.xds);
+ fprintf(outputfile, "edi = 0x%08lx, esi = 0x%08lx\nebp = 0x%08lx, esp = 0x%08lx\n",
+ g_registers.edi,
+ g_registers.esi,
+ g_registers.ebp,
+ g_registers.esp);
+ fprintf(outputfile, "eax = 0x%08lx, ebx = 0x%08lx\necx = 0x%08lx, edx = 0x%08lx\n",
+ g_registers.eax,
+ g_registers.ebx,
+ g_registers.ecx,
+ g_registers.edx);
+ fprintf(outputfile, "eip = 0x%08lx\n",
+ g_registers.eip);
+#endif
+}
diff --git a/src/crash-stack/crash-stack-x86_64.c b/src/crash-stack/crash-stack-x86_64.c
deleted file mode 100644
index 1aad750..0000000
--- a/src/crash-stack/crash-stack-x86_64.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Authors: Adrian Szyndela <adrian.s@samsung.com>
- * Łukasz Stelmach <l.stelmach@samsung.com>
- */
-/**
- * @file crash-stack-x86_64.c
- * @brief unwinding call stacks, functions specific for x86_64
- */
-#include "crash-stack.h"
-#include <sys/user.h>
-#include <string.h>
-
-struct user_regs_struct g_registers; ///< static storage for ptrace buffer for registers
-
-void *_crash_stack_get_memory_for_ptrace_registers(size_t *size)
-{
- if (NULL != size)
- *size = sizeof(g_registers);
- return &g_registers;
-}
-
-void _crash_stack_set_ptrace_registers(void *regbuf)
-{
- void *rsp = _get_place_for_register_value("rsp", 0);
- void *rip = _get_place_for_register_value("rip", 0);
-
- struct user_regs_struct *regs = regbuf;
-
- memcpy(rsp, &regs->rsp, sizeof(regs->rsp));
- memcpy(rip, &regs->rip, sizeof(regs->rip));
-}
-
-void _crash_stack_print_regs(FILE* outputfile)
-{
-#define _PRINT_REGISTERS(a,b,c) \
- fprintf(outputfile, "%3s: %016llx %3s: %016llx %3s: %016llx\n", \
- #a, g_registers.a, \
- #b, g_registers.b, \
- #c, g_registers.c)
- fprintf(outputfile, "\nRegister Information\n");
-#ifdef __x86_64__
- fprintf(outputfile, "rip: %04llx:[<%016llx>]\n",
- g_registers.cs & 0xffff,
- g_registers.rip);
- fprintf(outputfile, "rsp: %04llx:%016llx eflags: %08llx\n",
- g_registers.ss,
- g_registers.rsp,
- g_registers.eflags);
- _PRINT_REGISTERS(rax, rbx, rcx);
- _PRINT_REGISTERS(rdx, rsi, rdi);
- _PRINT_REGISTERS(rbp, r8, r9);
- _PRINT_REGISTERS(r10, r11, r12);
- _PRINT_REGISTERS(r13, r14, r15);
-#else
- fprintf(outputfile, "Unsupported architecture\n")
-#endif
- fprintf(outputfile, "\n");
-#undef _PRINT_REGISTERS
-}