Support x86 43/186143/3
authorŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 7 Aug 2018 11:46:13 +0000 (13:46 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 22 Aug 2018 05:51:37 +0000 (07:51 +0200)
Change-Id: I6cb87b61072be11341e6956357b05af63a620646
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/crash-stack/crash-stack-x86.c

index a72a198f81718842b179de37e7a324b492bdd50c..e42de302c7f30cf72c4c11cd2efe5a26afbde9bd 100644 (file)
@@ -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");