coredumpctl,man: mark truncated messages as such in output

Unit systemd-coredump@1-3854-0.service is failed/failed, not counting it.
TIME                            PID   UID   GID SIG COREFILE  EXE
Fri 2017-02-24 11:11:00 EST   10002  1000  1000   6 none      /home/zbyszek/src/systemd-work/.libs/lt-Sat 2017-02-25 00:49:32 EST   26921     0     0  11 error     /usr/libexec/fprintd
Sat 2017-02-25 11:56:30 EST   30703  1000  1000   - -         /usr/bin/python3.5
Sat 2017-02-25 13:16:54 EST    3275  1000  1000  11 present   /usr/bin/bash
Sat 2017-02-25 17:25:40 EST    4049  1000  1000  11 truncated /usr/bin/bash

For info and gdb output, the filename is marked in red and "(truncated)" is
appended. (Red is necessary because the annotation is hard to see when running
under a pager.)

Fixed #3883.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-02-25 17:29:14 -05:00
parent 7bbf2d8423
commit cc4419ed92
3 changed files with 82 additions and 13 deletions

View File

@ -154,6 +154,57 @@
matching specified characteristics. If no command is
specified, this is the implied default.</para>
<para>The output is designed to be human readable and contains list contains
a table with the following columns:</para>
<variablelist>
<varlistentry>
<term>TIME</term>
<listitem><para>The timestamp of the crash, as reported by the kernel.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>PID</term>
<listitem><para>The identifier of the process that crashed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>UID</term>
<term>GID</term>
<listitem><para>The user and group identifiers of the process that crashed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SIGNAL</term>
<listitem><para>The signal that caused the process to crash, when applicable.
</para></listitem>
</varlistentry>
<varlistentry>
<term>COREFILE</term>
<listitem><para>Information whether the coredump was stored, and whether
it is still accessible: <literal>none</literal> means the the core was
not stored, <literal>-</literal> means that it was not available (for
example because the process was not terminated by a signal),
<literal>present</literal> means that the core file is accessible by the
current user, <literal>journal</literal> means that the core was stored
in the <literal>journal</literal>, <literal>truncated</literal> is the
same as one of the previous two, but the core was too large and was not
stored in its entirety, <literal>error</literal> means that the core file
cannot be accessed, most likely because of insufficient permissions, and
<literal>missing</literal> means that the core was stored in a file, but
this file has since been removed.</para></listitem>
</varlistentry>
<varlistentry>
<term>EXE</term>
<listitem><para>The full path to the executable. For backtraces of scripts
this is the name of the interpreter.</para></listitem>
</varlistentry>
</variablelist>
<para>It's worth noting that different restrictions apply to
data saved in the journal and core dump files saved in
<filename>/var/lib/systemd/coredump</filename>, see overview in
@ -223,9 +274,9 @@
<varlistentry>
<term><replaceable>MATCH</replaceable></term>
<listitem><para>General journalctl predicates (see
<listitem><para>General journalctl predicate (see
<citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>).
Must contain an equal sign. </para></listitem>
Must contain an equals sign (<literal>=</literal>).</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -325,7 +325,7 @@ static int save_external_coredump(
int *ret_node_fd,
int *ret_data_fd,
uint64_t *ret_size,
bool *truncated) {
bool *ret_truncated) {
_cleanup_free_ char *fn = NULL, *tmp = NULL;
_cleanup_close_ int fd = -1;
@ -374,8 +374,8 @@ static int save_external_coredump(
log_error_errno(r, "Cannot store coredump of %s (%s): %m", context[CONTEXT_PID], context[CONTEXT_COMM]);
goto fail;
}
*truncated = r == 1;
if (*truncated)
*ret_truncated = r == 1;
if (*ret_truncated)
log_struct(LOG_INFO,
LOG_MESSAGE("Core file was truncated to %zu bytes.", max_size),
"SIZE_LIMIT=%zu", max_size,

View File

@ -343,7 +343,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
_cleanup_free_ char
*mid = NULL, *pid = NULL, *uid = NULL, *gid = NULL,
*sgnl = NULL, *exe = NULL, *comm = NULL, *cmdline = NULL,
*filename = NULL, *coredump = NULL;
*filename = NULL, *truncated = NULL, *coredump = NULL;
const void *d;
size_t l;
usec_t t;
@ -365,6 +365,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
RETRIEVE(d, l, "COREDUMP_COMM", comm);
RETRIEVE(d, l, "COREDUMP_CMDLINE", cmdline);
RETRIEVE(d, l, "COREDUMP_FILENAME", filename);
RETRIEVE(d, l, "COREDUMP_TRUNCATED", truncated);
RETRIEVE(d, l, "COREDUMP", coredump);
}
@ -380,13 +381,13 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
format_timestamp(buf, sizeof(buf), t);
if (!had_legend && !arg_no_legend)
fprintf(file, "%-*s %*s %*s %*s %*s %*s %s\n",
fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n",
FORMAT_TIMESTAMP_WIDTH, "TIME",
6, "PID",
5, "UID",
5, "GID",
3, "SIG",
8, "COREFILE",
9, "COREFILE",
"EXE");
normal_coredump = streq_ptr(mid, SD_MESSAGE_COREDUMP_STR);
@ -405,13 +406,16 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
else
present = "-";
if (STR_IN_SET(present, "present", "journal") && streq_ptr(truncated, "yes"))
present = "truncated";
fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n",
FORMAT_TIMESTAMP_WIDTH, buf,
6, strna(pid),
5, strna(uid),
5, strna(gid),
3, normal_coredump ? strna(sgnl) : "-",
8, present,
9, present,
strna(exe ?: (comm ?: cmdline)));
return 0;
@ -425,7 +429,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
*boot_id = NULL, *machine_id = NULL, *hostname = NULL,
*slice = NULL, *cgroup = NULL, *owner_uid = NULL,
*message = NULL, *timestamp = NULL, *filename = NULL,
*coredump = NULL;
*truncated = NULL, *coredump = NULL;
const void *d;
size_t l;
bool normal_coredump;
@ -451,6 +455,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
RETRIEVE(d, l, "COREDUMP_CGROUP", cgroup);
RETRIEVE(d, l, "COREDUMP_TIMESTAMP", timestamp);
RETRIEVE(d, l, "COREDUMP_FILENAME", filename);
RETRIEVE(d, l, "COREDUMP_TRUNCATED", truncated);
RETRIEVE(d, l, "COREDUMP", coredump);
RETRIEVE(d, l, "_BOOT_ID", boot_id);
RETRIEVE(d, l, "_MACHINE_ID", machine_id);
@ -569,9 +574,22 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
if (hostname)
fprintf(file, " Hostname: %s\n", hostname);
if (filename)
fprintf(file, " Storage: %s%s\n", filename,
access(filename, R_OK) < 0 ? " (inaccessible)" : "");
if (filename) {
bool inacc = access(filename, R_OK) < 0;
bool trunc = streq_ptr(truncated, "yes");
if (inacc || trunc)
fprintf(file, " Storage: %s%s (%s%s%s)%s\n",
ansi_highlight_red(),
filename,
inacc ? "inaccessible" : "",
inacc && trunc ? ", " : "",
trunc ? "truncated" : "",
ansi_normal());
else
fprintf(file, " Storage: %s\n", filename);
}
else if (coredump)
fprintf(file, " Storage: journal\n");
else