X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fcoredumpctl.c;h=fefd02bc9b26ec3a693afa91538a55d2109004fa;hp=731468330909589842de9c29db0c260823972bf7;hb=81cef14fce9c64afed600614403ecae7cd79781d;hpb=0c51aada566403039544bc8ef094fadb4af29e23 diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index 731468330..fefd02bc9 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -85,15 +85,16 @@ static int help(void) { printf("%s [OPTIONS...]\n\n" "List or retrieve coredumps from the journal.\n\n" "Flags:\n" - " -o --output=FILE Write output to FILE\n" + " -h --help Show this help\n" + " --version Print version string\n" " --no-pager Do not pipe output into a pager\n" - " --no-legend Do not print the column headers.\n\n" + " --no-legend Do not print the column headers.\n" + " -1 Show information about most recent entry only\n" + " -F --field=FIELD List all values a certain field takes\n" + " -o --output=FILE Write output to FILE\n\n" "Commands:\n" - " -h --help Show this help\n" - " --version Print version string\n" - " -F --field=FIELD List all values a certain field takes\n" - " list [MATCHES...] List available coredumps\n" + " list [MATCHES...] List available coredumps (default)\n" " info [MATCHES...] Show detailed information about one or more coredumps\n" " dump [MATCHES...] Print first matching coredump to stdout\n" " gdb [MATCHES...] Start gdb for the first matching coredump\n" @@ -279,7 +280,7 @@ static int retrieve(const void *data, return 0; } -#define filename_escape(s) xescape((s), "./") +#define filename_escape(s) xescape((s), "./ ") static int make_coredump_path(sd_journal *j, char **ret) { _cleanup_free_ char @@ -383,15 +384,15 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) { if (!had_legend && !arg_no_legend) fprintf(file, "%-*s %*s %*s %*s %*s %s\n", - FORMAT_TIMESTAMP_MAX-1, "TIME", + FORMAT_TIMESTAMP_WIDTH, "TIME", 6, "PID", 5, "UID", 5, "GID", 3, "SIG", "EXE"); - fprintf(file, "%*s %*s %*s %*s %*s %s\n", - FORMAT_TIMESTAMP_MAX-1, buf, + fprintf(file, "%-*s %*s %*s %*s %*s %s\n", + FORMAT_TIMESTAMP_WIDTH, buf, 6, strna(pid), 5, strna(uid), 5, strna(gid), @@ -408,9 +409,10 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { *unit = NULL, *user_unit = NULL, *session = NULL, *boot_id = NULL, *machine_id = NULL, *hostname = NULL, *coredump = NULL, *slice = NULL, *cgroup = NULL, - *owner_uid = NULL, *message = NULL; + *owner_uid = NULL, *message = NULL, *timestamp = NULL; const void *d; size_t l; + int r; assert(file); assert(j); @@ -429,6 +431,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { retrieve(d, l, "COREDUMP_OWNER_UID", &owner_uid); retrieve(d, l, "COREDUMP_SLICE", &slice); retrieve(d, l, "COREDUMP_CGROUP", &cgroup); + retrieve(d, l, "COREDUMP_TIMESTAMP", ×tamp); retrieve(d, l, "_BOOT_ID", &boot_id); retrieve(d, l, "_MACHINE_ID", &machine_id); retrieve(d, l, "_HOSTNAME", &hostname); @@ -438,9 +441,14 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { if (need_space) fputs("\n", file); - fprintf(file, - " PID: %s%s%s\n", - ansi_highlight(), strna(pid), ansi_highlight_off()); + if (comm) + fprintf(file, + " PID: %s%s%s (%s)\n", + ansi_highlight(), strna(pid), ansi_highlight_off(), comm); + else + fprintf(file, + " PID: %s%s%s\n", + ansi_highlight(), strna(pid), ansi_highlight_off()); if (uid) { uid_t n; @@ -485,12 +493,26 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { fprintf(file, " Signal: %s\n", sgnl); } - if (exe) - fprintf(file, " Executable: %s%s%s\n", ansi_highlight(), exe, ansi_highlight_off()); - if (comm) - fprintf(file, " Comm: %s\n", comm); + if (timestamp) { + usec_t u; + + r = safe_atou64(timestamp, &u); + if (r >= 0) { + char absolute[FORMAT_TIMESTAMP_MAX], relative[FORMAT_TIMESPAN_MAX]; + + fprintf(file, + " Timestamp: %s (%s)\n", + format_timestamp(absolute, sizeof(absolute), u), + format_timestamp_relative(relative, sizeof(relative), u)); + + } else + fprintf(file, " Timestamp: %s\n", timestamp); + } + if (cmdline) fprintf(file, " Command Line: %s\n", cmdline); + if (exe) + fprintf(file, " Executable: %s%s%s\n", ansi_highlight(), exe, ansi_highlight_off()); if (cgroup) fprintf(file, " Control Group: %s\n", cgroup); if (unit)