From: Mateusz Moscicki Date: Tue, 17 Jul 2018 08:30:31 +0000 (+0200) Subject: Copy /proc//maps file to temporary directory X-Git-Tag: submit/tizen/20180720.100756~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2c75ee58c9523a14131381290c73787879f8557;p=platform%2Fcore%2Fsystem%2Fcrash-worker.git Copy /proc//maps file to temporary directory To save as much time as possible, we can parse maps file when coredump is already saved and process is probably cleaned up. Change-Id: I136d1c462fe2fe9c204deea09b1d0269cee32530 --- diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 0ec94e6..3e2af24 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -65,6 +65,7 @@ #define WAIT_FOR_OPT_TIMEOUT_SEC 60 #define MINICOREDUMPER_TIMEOUT 12*60 +#define TEMP_MAPS_FILENAME "maps.temp" enum { RET_EXCEED = 1, @@ -466,13 +467,36 @@ static int dump_system_state(void) return system_command_parallel(command); } -static void save_so_info() +static void copy_maps() { char maps_path[PATH_MAX]; - char so_info_path[PATH_MAX]; + char temp_maps_path[PATH_MAX]; snprintf(maps_path, sizeof(maps_path), "/proc/%s/maps", crash_info.pid_info); + snprintf(temp_maps_path, sizeof(temp_maps_path), "%s/%s", + crash_info.temp_dir, TEMP_MAPS_FILENAME); + + copy_file(maps_path, temp_maps_path); +} + +static void remove_maps() +{ + char temp_maps_path[PATH_MAX]; + + snprintf(temp_maps_path, sizeof(temp_maps_path), "%s/%s", + crash_info.temp_dir, TEMP_MAPS_FILENAME); + if (unlink(temp_maps_path) < 0) + _E("Cannot remove %s: %m\n", temp_maps_path); +} + +static void save_so_info() +{ + char maps_path[PATH_MAX]; + char so_info_path[PATH_MAX]; + snprintf(maps_path, sizeof(maps_path), "%s/%s", + crash_info.temp_dir, TEMP_MAPS_FILENAME); + snprintf(so_info_path, sizeof(so_info_path), "%s/%s.%s", crash_info.pfx, crash_info.name, "so_info"); @@ -907,12 +931,16 @@ int main(int argc, char *argv[]) /* Exec dump_systemstate */ dump_state_pid = dump_system_state(); - /* Save shared objects info (file names, bulid IDs, rpm package names) */ - save_so_info(); + /* Copy maps file to temp dir */ + copy_maps(); /* Exec crash modules */ execute_crash_modules(argc, argv); + /* Save shared objects info (file names, bulid IDs, rpm package names) */ + save_so_info(); + remove_maps(); + /* Wait dump_system_state */ wait_system_command(dump_state_pid);