/*
- * 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.
*/
}
+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");