summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Stelmach <l.stelmach@samsung.com>2018-08-07 13:46:13 +0200
committerKarol Lewandowski <k.lewandowsk@samsung.com>2018-08-22 07:51:37 +0200
commitb426a75e5fbdcc5e75693977ccdd0aba7611071e (patch)
tree8213164d746e9584a0365aab51483eff8e225312
parente9b9331580c00744df96ffbbaac481c03a1fb9da (diff)
downloadcrash-worker-b426a75e5fbdcc5e75693977ccdd0aba7611071e.tar.gz
crash-worker-b426a75e5fbdcc5e75693977ccdd0aba7611071e.tar.bz2
crash-worker-b426a75e5fbdcc5e75693977ccdd0aba7611071e.zip
Support x86
Change-Id: I6cb87b61072be11341e6956357b05af63a620646 Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
-rw-r--r--src/crash-stack/crash-stack-x86.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/crash-stack/crash-stack-x86.c b/src/crash-stack/crash-stack-x86.c
index a72a198..e42de30 100644
--- a/src/crash-stack/crash-stack-x86.c
+++ b/src/crash-stack/crash-stack-x86.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016,2018 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.
@@ -49,6 +49,37 @@ void _crash_stack_set_ptrace_registers(void *regbuf)
*/
}
+unsigned long _get_register_value(int n)
+{
+ const static int reg_map[] = {
+#if defined(__x86_64__)
+ [UNW_X86_64_RAX] = offsetof(struct user_regs_struct, rax) / sizeof(long),
+ [UNW_X86_64_RDX] = offsetof(struct user_regs_struct, rdx) / sizeof(long),
+ [UNW_X86_64_RCX] = offsetof(struct user_regs_struct, rcx) / sizeof(long),
+ [UNW_X86_64_RBX] = offsetof(struct user_regs_struct, rbx) / sizeof(long),
+ [UNW_X86_64_RSI] = offsetof(struct user_regs_struct, rsi) / sizeof(long),
+ [UNW_X86_64_RDI] = offsetof(struct user_regs_struct, rdi) / sizeof(long),
+ [UNW_X86_64_RBP] = offsetof(struct user_regs_struct, rbp) / sizeof(long),
+ [UNW_X86_64_RSP] = offsetof(struct user_regs_struct, rsp) / sizeof(long),
+ [UNW_X86_64_RIP] = offsetof(struct user_regs_struct, rip) / sizeof(long),
+#else
+ [UNW_X86_EAX] = offsetof(struct user_regs_struct, eax) / sizeof(long),
+ [UNW_X86_EDX] = offsetof(struct user_regs_struct, edx) / sizeof(long),
+ [UNW_X86_ECX] = offsetof(struct user_regs_struct, ecx) / sizeof(long),
+ [UNW_X86_EBX] = offsetof(struct user_regs_struct, ebx) / sizeof(long),
+ [UNW_X86_ESI] = offsetof(struct user_regs_struct, esi) / sizeof(long),
+ [UNW_X86_EDI] = offsetof(struct user_regs_struct, edi) / sizeof(long),
+ [UNW_X86_EBP] = offsetof(struct user_regs_struct, ebp) / sizeof(long),
+ [UNW_X86_ESP] = offsetof(struct user_regs_struct, esp) / sizeof(long),
+ [UNW_X86_EIP] = offsetof(struct user_regs_struct, eip) / sizeof(long),
+ [UNW_X86_EFLAGS] = offsetof(struct user_regs_struct, eflags) / sizeof(long),
+ [UNW_X86_TRAPNO] = offsetof(struct user_regs_struct, orig_eax) / sizeof(long),
+#endif
+ };
+ n = reg_map[n];
+ return ((elf_greg_t*)&g_registers)[n];
+}
+
void _crash_stack_print_regs(FILE* outputfile)
{
fprintf(outputfile, "\nRegister Information\n");