#define CRASH_TEMP_SUBDIR "/temp/"
#define CRASH_PATH_SUBDIR "/dump/"
+#define LIVE_PATH_SUBDIR "/livedump/"
#define WAIT_FOR_OPT_TIMEOUT_SEC 60
return ret;
}
-static int prepare_paths(void)
+static int prepare_paths(struct crash_info* cinfo)
{
int tmp_len;
- tmp_len = strlen(config.crash_root_path) + strlen(CRASH_PATH_SUBDIR);
+ const char *crash_subdir = cinfo->livedump ? LIVE_PATH_SUBDIR : CRASH_PATH_SUBDIR;
+
+ tmp_len = strlen(config.crash_root_path) + strlen(crash_subdir);
crash_crash_path = (char*)malloc(tmp_len + 1);
if (crash_crash_path == NULL) {
_E("Couldn't allocate memory for crash_crash_path: %m\n");
return 0;
}
- snprintf(crash_crash_path, tmp_len + 1, "%s%s", config.crash_root_path, CRASH_PATH_SUBDIR);
+ snprintf(crash_crash_path, tmp_len + 1, "%s%s", config.crash_root_path, crash_subdir);
tmp_len = strlen(config.crash_root_path) + strlen(CRASH_TEMP_SUBDIR);
crash_temp_path = (char*)malloc(tmp_len + 1);
#undef GET_NUMBER
}
-static int set_crash_info(struct crash_info *cinfo, int argc, char *argv[])
+static int set_crash_info(struct crash_info *cinfo)
{
int ret;
char *temp_dir_ret = NULL;
char date[80];
struct tm loc_tm;
- cinfo->livedump = false;
- cinfo->kill = false;
- cinfo->print_result_path = false;
- cinfo->tid_info = -1;
- cinfo->time_info = 0;
-
- if (!parse_args(cinfo, argc, argv))
- return -1;
-
if (cinfo->livedump) {
if (cinfo->kill)
cinfo->sig_info = 9;
#endif
}
+static void crash_info_init(struct crash_info *cinfo)
+{
+ cinfo->prstatus_fd = -1;
+ cinfo->livedump = false;
+ cinfo->kill = false;
+ cinfo->print_result_path = false;
+ cinfo->tid_info = -1;
+ cinfo->time_info = 0;
+}
+
int main(int argc, char *argv[])
{
- struct crash_info cinfo = {.prstatus_fd = -1};
+ struct crash_info cinfo;
/* Execute processes in parallel */
static pid_t dump_state_pid = 0, extra_script_pid = 0;
int debug_mode = access(DEBUGMODE_PATH, F_OK) == 0;
int res = 0;
+ crash_info_init(&cinfo);
+
/*
* prctl(PR_SET_DUMPABLE, 0) is not neccessary. Kernel runs the
* crash-manager and sets RLIMIT_CORE to 1 for the process. This is special
goto exit;
}
- if (!prepare_paths()) {
+ if (!parse_args(&cinfo, argc, argv)) {
+ res = EXIT_FAILURE;
+ goto exit;
+ }
+
+ if (!prepare_paths(&cinfo)) {
res = EXIT_FAILURE;
goto exit;
}
}
/* Set crash info */
- if (set_crash_info(&cinfo, argc, argv) < 0) {
+ if (set_crash_info(&cinfo) < 0) {
res = EXIT_FAILURE;
goto exit;
}