* This file is part of the oGRAC project.
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
*
* oGRAC is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*
* srv_blackbox.h
*
*
* IDENTIFICATION
* src/server/srv_blackbox.h
*
* -------------------------------------------------------------------------
*/
#ifndef __SRV_BLACKBOX_H__
#define __SRV_BLACKBOX_H__
#include <signal.h>
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SIGMAX 0xFF
#define BOX_STACK_SIZE (1536)
#define STACK_SIZE_EACH_ROW (16)
mainly to locate the abnormal program. */
#define BOX_INS_CONT_LEN (32)
#define BOX_VERSION_LEN (64)
#define BOX_STACK_FUNC_LEN (128)
#define BOX_SPACE_SIZE (2)
#define BOX_EXCP_MAGIC (0xECECECEC)
#define BOX_EXCP_TO_LOG (0x12345678)
#define BOX_TAIL_MAGIC (0xFFFFFFFF)
#define BOX_SPACE_SIZE (2)
typedef enum en_hook_func_type {
HOOK_FUNC_SQL = 0,
HOOK_FUNC_KERNEL = 1,
HOOK_FUNC_TAIL
} hook_func_type_t;
#if (defined __x86_64__)
typedef struct st_box_reg_info {
int64 r8;
int64 r9;
int64 r10;
int64 r11;
int64 r12;
int64 r13;
int64 r14;
int64 r15;
int64 rdi;
int64 rsi;
int64 rbp;
int64 rbx;
int64 rdx;
int64 rax;
int64 rcx;
int64 rsp;
int64 rip;
int64 eflags;
int64 cs;
int64 err;
int64 trapno;
int64 oldmask;
int64 cr2;
} box_reg_info_t;
#elif (defined __aarch64__)
typedef struct st_box_reg_info {
uint64 reg[31];
uint64 sp;
uint64 pc;
} box_reg_info_t;
#endif
extern char *oGRACd_get_dbversion(void);
typedef struct st_box_excp_item {
uint32 magic;
uint64 loc_id;
pthread_t thread_id;
uint32 sig_index;
int32 sig_code;
showing the cause of the signal */
box_reg_info_t reg_info;
uintptr_t stack_addr;
char sig_name[OG_NAME_BUFFER_SIZE];
char loc_name[OG_FILE_NAME_BUFFER_SIZE + 1];
char platform[OG_NAME_BUFFER_SIZE];
uchar stack_memory[BOX_STACK_SIZE];
uchar ins_content[BOX_INS_CONT_LEN];
instruction address */
char version[BOX_VERSION_LEN];
char date[OG_MAX_TIME_STRLEN];
uint32 trace_tail[BOX_SPACE_SIZE];
} box_excp_item_t;
typedef void (*signal_handle_hook_func)(box_excp_item_t *, int32, siginfo_t *, void *);
status_t sigcap_handle_reg(void);
status_t reg_sign_proc(int32 sig, signal_handle_hook_func func, hook_func_type_t type);
status_t unreg_sign_proc(int32 sig, hook_func_type_t type);
#ifdef __cplusplus
}
#endif
#endif