Skip to content

Commit

Permalink
arch/x86_64:Adapt coredump
Browse files Browse the repository at this point in the history
Signed-off-by: liwenxiang1 <[email protected]>
  • Loading branch information
xianglyc authored and XuNeo committed Jan 22, 2025
1 parent d1843eb commit 749e00a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
38 changes: 38 additions & 0 deletions arch/x86_64/include/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,42 @@

#define EF_FLAG 0

/* Segment register layout in coredumps. */

struct user_regs_struct
{
uint64_t r15;
uint64_t r14;
uint64_t r13;
uint64_t r12;
uint64_t bp;
uint64_t bx;
uint64_t r11;
uint64_t r10;
uint64_t r9;
uint64_t r8;
uint64_t ax;
uint64_t cx;
uint64_t dx;
uint64_t si;
uint64_t di;
uint64_t orig_ax;
uint64_t ip;
uint64_t cs;
uint64_t flags;
uint64_t sp;
uint64_t ss;
uint64_t fs_base;
uint64_t gs_base;
uint64_t ds;
uint64_t es;
uint64_t fs;
uint64_t gs;
};

typedef uint64_t elf_greg_t;

#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];

#endif /* __ARCH_X86_64_INCLUDE_ELF_H */
28 changes: 16 additions & 12 deletions arch/x86_64/src/common/x86_64_tcbinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,33 @@

static const uint16_t g_reg_offs[] =
{
TCB_REG_OFF(REG_RAX), /* RAX */
TCB_REG_OFF(REG_R15), /* R15 */
TCB_REG_OFF(REG_R14), /* R14 */
TCB_REG_OFF(REG_R13), /* R13 */
TCB_REG_OFF(REG_R12), /* R12 */
TCB_REG_OFF(REG_RBP), /* RBP */
TCB_REG_OFF(REG_RBX), /* RBX */
TCB_REG_OFF(REG_R11), /* R11 */
TCB_REG_OFF(REG_R10), /* R10 */
TCB_REG_OFF(REG_R9), /* R9 */
TCB_REG_OFF(REG_R8), /* R8 */
TCB_REG_OFF(REG_RAX), /* RAX */
TCB_REG_OFF(REG_RCX), /* RCX */
TCB_REG_OFF(REG_RDX), /* RDX */
TCB_REG_OFF(REG_RSI), /* RSI */
TCB_REG_OFF(REG_RDI), /* RDI */
TCB_REG_OFF(REG_RBP), /* RBP */
TCB_REG_OFF(REG_RSP), /* RSP */
TCB_REG_OFF(REG_R8), /* R8 */
TCB_REG_OFF(REG_R9), /* R9 */
TCB_REG_OFF(REG_R10), /* R10 */
TCB_REG_OFF(REG_R11), /* R11 */
TCB_REG_OFF(REG_R12), /* R12 */
TCB_REG_OFF(REG_R13), /* R13 */
TCB_REG_OFF(REG_R14), /* R14 */
TCB_REG_OFF(REG_R15), /* R15 */
TCB_REG_OFF(REG_RAX), /* RAX */
TCB_REG_OFF(REG_RIP), /* RIP */
TCB_REG_OFF(REG_RFLAGS), /* EFLAGS */
TCB_REG_OFF(REG_CS), /* CS */
TCB_REG_OFF(REG_RFLAGS), /* RFLAGS */
TCB_REG_OFF(REG_RSP), /* RSP */
TCB_REG_OFF(REG_SS), /* SS */
TCB_REG_OFF(REG_FS), /* FS_BASE */
TCB_REG_OFF(REG_GS), /* GS_BASE */
TCB_REG_OFF(REG_DS), /* DS */
TCB_REG_OFF(REG_ES), /* ES */
TCB_REG_OFF(REG_FS), /* FS */
TCB_REG_OFF(REG_GS), /* GS */
};

/****************************************************************************
Expand Down
9 changes: 8 additions & 1 deletion sched/misc/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@

#define PROGRAM_ALIGNMENT 64

/* Architecture can overwrite the default XCPTCONTEXT alignment */

#ifndef XCPTCONTEXT_ALIGN
# define XCPTCONTEXT_ALIGN 16
#endif

/****************************************************************************
* Private Types
****************************************************************************/
Expand All @@ -74,7 +80,8 @@ struct elf_dumpinfo_s
* Private Data
****************************************************************************/

static uint8_t g_running_regs[XCPTCONTEXT_SIZE] aligned_data(16);
static uint8_t g_running_regs[XCPTCONTEXT_SIZE]
aligned_data(XCPTCONTEXT_ALIGN);

#ifdef CONFIG_BOARD_COREDUMP_COMPRESSION
static struct lib_lzfoutstream_s g_lzfstream;
Expand Down

0 comments on commit 749e00a

Please sign in to comment.