[CP] print core file size when CRASH ERROR

This commit is contained in:
obdev
2022-11-08 06:05:35 +00:00
committed by wangzelin.wzl
parent 92233f2269
commit c36622e1c8
4 changed files with 11 additions and 2 deletions

View File

@ -178,9 +178,13 @@ void coredump_cb(int sig, siginfo_t *si, void *context)
int64_t ip = -1;
int64_t bp = -1;
#endif
char rlimit_core[32] = "unlimited";
if (UINT64_MAX != g_rlimit_core) {
safe_snprintf(rlimit_core, sizeof(rlimit_core), "%lu", g_rlimit_core);
}
ssize_t print_len = safe_snprintf(print_buf, sizeof(print_buf),
"CRASH ERROR!!! IP=%lx, RBP=%lx, sig=%d, sig_code=%d, sig_addr=%p, "COMMON_FMT"\n",
ip, bp, sig, si->si_code, si->si_addr, ts, GETTID(), tname, uval[0], uval[1], uval[2], uval[3],
"CRASH ERROR!!! IP=%lx, RBP=%lx, sig=%d, sig_code=%d, sig_addr=%p, RLIMIT_CORE=%s, "COMMON_FMT"\n",
ip, bp, sig, si->si_code, si->si_addr, rlimit_core, ts, GETTID(), tname, uval[0], uval[1], uval[2], uval[3],
(NULL == extra_info) ? NULL : to_cstring(*extra_info), bt);
write(STDERR_FILENO, print_buf, print_len);
#if MINICORE

View File

@ -25,6 +25,7 @@ namespace common
{
const int MP_SIG = SIGURG;
const int SIG_STACK_SIZE = 16L<<10;
uint64_t g_rlimit_core = 0;
DTraceId DTraceId::gen_trace_id()
{

View File

@ -29,6 +29,7 @@ extern signal_handler_t &get_signal_handler();
extern bool g_redirect_handler;
extern const int MP_SIG; // MP means MULTI-PURPOSE
extern const int SIG_STACK_SIZE;
extern uint64_t g_rlimit_core;
class DTraceId
{

View File

@ -348,6 +348,9 @@ static void print_limit(const char *name, const int resource)
_OB_LOG(INFO, "[%s] %-24s = %ld", __func__, name, limit.rlim_cur);
}
}
if (RLIMIT_CORE == resource) {
g_rlimit_core = limit.rlim_cur;
}
}
static void print_all_limits()