From a155687265c946a3187f2afe42ed118287babff1 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 25 Feb 2019 10:55:42 +0900 Subject: [PATCH] dump_systemstate: dump installed package list Some package information is required to debug crash. Add it as an option of dump_systemstate. Change-Id: I140e2d00b35157c7f463426483dea074d739b73e Signed-off-by: Sunmin Lee [ Backported from different repository ] Signed-off-by: Karol Lewandowski --- src/crash-manager/crash-manager.c | 2 +- src/dump_systemstate/dump_systemstate.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 9d3bec5..8aba8ae 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -687,7 +687,7 @@ exit: static bool dump_system_state(const struct crash_info *cinfo, pid_t *pid) { - char *av[] = {"/usr/bin/dump_systemstate", "-d", "-k", "-j", "-f", cinfo->log_path, NULL}; + char *av[] = {"/usr/bin/dump_systemstate", "-d", "-k", "-j", "-p", "-f", cinfo->log_path, NULL}; return spawn(av, NULL, NULL, NULL, pid, NULL); } diff --git a/src/dump_systemstate/dump_systemstate.c b/src/dump_systemstate/dump_systemstate.c index 2d2c5b5..0d79cca 100644 --- a/src/dump_systemstate/dump_systemstate.c +++ b/src/dump_systemstate/dump_systemstate.c @@ -67,11 +67,12 @@ static struct dump_item { static void usage() { - fprintf(stderr, "usage: dump_systemstate [-k] [-d] [-f file]\n" + fprintf(stderr, "usage: dump_systemstate [-k] [-d] [-j] [-p] [-f file]\n" " -f: write to file (instead of stdout)\n" " -k: dump kernel messages (only root)\n" " -d: dump dlog messages\n" " -j: dump journal log messages\n" + " -p: dump list of installed packages\n" ); } @@ -99,12 +100,13 @@ int main(int argc, char *argv[]) bool arg_dlog = false; bool arg_dmesg = false; bool arg_journal = false; + bool arg_pkgs = false; char timestr[80]; time_t cur_time; struct tm gm_tm; struct tm loc_tm; - while ((c = getopt(argc, argv, "hf:kdj")) != -1) { + while ((c = getopt(argc, argv, "hf:kdjp")) != -1) { switch (c) { case 'd': arg_dlog = true; @@ -115,6 +117,9 @@ int main(int argc, char *argv[]) case 'j': arg_journal = true; break; + case 'p': + arg_pkgs = true; + break; case 'f': arg_file = optarg; break; @@ -206,6 +211,12 @@ int main(int argc, char *argv[]) spawn_wait_checked(get_sys_args, NULL); } + if (arg_pkgs) { + fprintf_fd(out_fd, "\n==== Installed packages (/usr/bin/pkgcmd -l)\n"); + char *pkgcmd_args[] = {"/usr/bin/pkgcmd", "-l", NULL}; + spawn_wait_checked(pkgcmd_args, NULL); + } + if (arg_dmesg && is_root) { fprintf_fd(out_fd, "\n==== Kernel messages (TZ=UTC /bin/dmesg -T)\n"); char *dmesg_args[] = {"/bin/dmesg", "-T", NULL}; -- 2.7.4