Skip to content

Commit

Permalink
Copy ramoops logs to the crashlog folder
Browse files Browse the repository at this point in the history
Crashlog should save console-ramoops and dmesg-ramoops after kernel panic happen.

Original-Tracked-On: OAM-110472
Tracked-On: OAM-120395
Signed-off-by: Jade Guo <[email protected]>
  • Loading branch information
jiaxuan-guo authored and sysopenci committed Jun 11, 2024
1 parent c321a75 commit 30d8ba5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crashlog/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ int crashlog_check_ram_panic(char *reason, const char *extrastring) {
const char *panic_kw[] = {"Kernel panic - not syncing:",
"BUG: unable to handle kernel"};
char crash_ramconsole_name[PATHMAX] = {'\0'};
char crash_ramdmesg_name[PATHMAX] = {'\0'};
char ram_console[PATHMAX] = {'\0'};
char ram_dmesg[PATHMAX] = {'\0'};
char crashtype[32] = {'\0'};
char *dir;
int ret;
Expand All @@ -410,6 +412,11 @@ int crashlog_check_ram_panic(char *reason, const char *extrastring) {
// no file found, should return
return 1;
}

if (file_exists(DMESG_RAMOOPS_NUM(0))) {
strcpy(ram_dmesg, DMESG_RAMOOPS_NUM(0));
}

ret = crashlog_check_ram_panic_found(ram_console, panic_kw, DIM(panic_kw), extrastring);
if (ret < 0) {
return -1;
Expand All @@ -422,12 +429,13 @@ int crashlog_check_ram_panic(char *reason, const char *extrastring) {
dir = generate_crashlog_dir(MODE_CRASH, key);

copy_to_crash = (dir != NULL);

if (copy_to_crash) {
snprintf(crash_ramconsole_name, sizeof(crash_ramconsole_name),
"%s/%s_%s.txt", dir, CONSOLE_RAMOOPS_FILE, dateshort);
// to be homogeneous with do_last_kmsg_copy, we use do_copy_tail
do_copy_tail(ram_console, crash_ramconsole_name, MAXFILESIZE);
do_copy_eof(ram_console, crash_ramconsole_name);
snprintf(crash_ramdmesg_name, sizeof(crash_ramdmesg_name),
"%s/%s_%s.txt", dir, DMESG_RAMOOPS_FILE, dateshort);
do_copy_eof(ram_dmesg, crash_ramdmesg_name);
} else {
LOGE("%s: Cannot get a valid new crash directory...\n", __FUNCTION__);
// use temp file
Expand Down
3 changes: 3 additions & 0 deletions crashlog/privconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ extern enum crashlog_mode g_crashlog_mode;
#define CONSOLE_NAME "console"
#define LAST_KMSG_FILE "last_kmsg"
#define CONSOLE_RAMOOPS_FILE "console-ramoops"
#define DMESG_RAMOOPS_FILE "dmesg-ramoops"
#define CONSOLE_RAMOOPS_FILE_NUM(x) "console-ramoops-"#x""
#define DMESG_RAMOOPS_FILE_NUM(x) "dmesg-ramoops-"#x""
#define FTRACE_RAMOOPS_FILE "ftrace-ramoops"
#define EMMC_HEADER_NAME "emmc_ipanic_header"
#define EMMC_CONSOLE_NAME "emmc_ipanic_console"
Expand All @@ -433,6 +435,7 @@ extern enum crashlog_mode g_crashlog_mode;
#define LAST_KMSG PROC_DIR "/" LAST_KMSG_FILE
#define CONSOLE_RAMOOPS PSTORE_DIR "/" CONSOLE_RAMOOPS_FILE
#define CONSOLE_RAMOOPS_NUM(x) PSTORE_DIR "/" CONSOLE_RAMOOPS_FILE_NUM(x)
#define DMESG_RAMOOPS_NUM(x) PSTORE_DIR "/" DMESG_RAMOOPS_FILE_NUM(x)
#define FTRACE_RAMOOPS PSTORE_DIR "/" FTRACE_RAMOOPS_FILE
#define PANIC_HEADER_NAME PROC_DIR "/" EMMC_HEADER_NAME
#define PANIC_CONSOLE_NAME PROC_DIR "/" EMMC_CONSOLE_NAME
Expand Down

0 comments on commit 30d8ba5

Please sign in to comment.