Output of 'log' compared to 'log -s': - Suppress struct header (len, addr, message_lost...) - Display only non-empty buffers - Display buffer name at the beginning of line Signed-off-by: Shogo Matsumoto <shogo.matsumoto@xxxxxxxxxxx> --- kernel.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/kernel.c b/kernel.c index 57fe355..138ac3c 100644 --- a/kernel.c +++ b/kernel.c @@ -5057,6 +5057,7 @@ cmd_log(void) } dump_log(msg_flags); + dump_printk_safe_seq_buf(msg_flags); } @@ -11561,6 +11562,9 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags) int cpu, buffer_size; char *buffer; ulong base_addr, len_addr, message_lost_addr, buffer_addr; + bool show_header; + + show_header = msg_flags & SHOW_LOG_SAFE; if (!symbol_exists(buf_name)) { return; @@ -11576,7 +11580,8 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags) buffer_size = SIZE(printk_safe_seq_buf_buffer); buffer = GETBUF(buffer_size); - fprintf(fp, "PRINTK_SAFE_SEQ_BUF: %s\n", buf_name); + if (show_header) + fprintf(fp, "PRINTK_SAFE_SEQ_BUF: %s\n", buf_name); for (cpu = 0; cpu < kt->cpus; cpu++) { int len, message_lost; ulong per_cpu_offset; @@ -11584,17 +11589,26 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags) readmem(len_addr + per_cpu_offset, KVADDR, &len, sizeof(int), "printk_safe_seq_buf len", FAULT_ON_ERROR); - readmem(message_lost_addr + per_cpu_offset, KVADDR, - &message_lost, sizeof(int), - "printk_safe_seq_buf message_lost", FAULT_ON_ERROR); - fprintf(fp, "CPU: %d ADDR: %lx LEN: %d MESSAGE_LOST: %d\n", - cpu, base_addr + per_cpu_offset, len, message_lost); + + if (show_header) { + readmem(message_lost_addr + per_cpu_offset, KVADDR, + &message_lost, sizeof(int), + "printk_safe_seq_buf message_lost", FAULT_ON_ERROR); + fprintf(fp, "CPU: %d ADDR: %lx LEN: %d MESSAGE_LOST: %d\n", + cpu, base_addr + per_cpu_offset, len, message_lost); + } if (len > 0) { - int i, n; + int i, n, ilen; char *p; bool start_of_line; + ilen = 0; + if (show_header) { + ilen = PRINTK_SAFE_SEQ_BUF_INDENT; + } else { + ilen = strlen(buf_name) + 3; // "[%s] " + } readmem(buffer_addr + per_cpu_offset, KVADDR, buffer, buffer_size, "printk_safe_seq_buf buffer", FAULT_ON_ERROR); @@ -11610,12 +11624,15 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags) if (!sol) fprintf(fp, "\n"); - fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT)); + if (show_header) + fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT)); + else + fprintf(fp, "[%s] ", buf_name); continue; } else { if (sol) - fprintf(fp, "%s", space(PRINTK_SAFE_SEQ_BUF_INDENT)); + fprintf(fp, "%s", space(ilen)); if (isprint(*p) || isspace(*p)) { fputc(*p, fp); @@ -11628,8 +11645,9 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags) } if (!start_of_line) fputc('\n', fp); - fputc('\n', fp); - } else { + if (show_header) + fputc('\n', fp); + } else if (show_header) { fprintf(fp, "%s(empty)\n\n", space(PRINTK_SAFE_SEQ_BUF_INDENT)); } } @@ -11660,7 +11678,8 @@ dump_printk_safe_seq_buf(int msg_flags) INVALID_MEMBER(printk_safe_seq_buf_message_lost) || INVALID_MEMBER(printk_safe_seq_buf_buffer) || INVALID_SIZE(printk_safe_seq_buf_buffer)) { - error(INFO, "-s not supported with this kernel version\n"); + if (msg_flags & SHOW_LOG_SAFE) + error(INFO, "-s not supported with this kernel version\n"); return; } -- 2.29.2 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility