----- Original Message -----
----- Original Message -----
> Hi Dave,
>
> Currently the log command does not print '\n' and '\t'. The reason
> is that isprint() does not return true for those characters.
> This patch adds the isspace() test in order to print these characters
> properly.
>
> Michael
> ---
> kernel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/kernel.c
> +++ b/kernel.c
> @@ -4164,7 +4164,7 @@ dump_log_entry(char *logptr, int msg_fla
> }
>
> for (i = 0, p = msg; i < text_len; i++, p++)
> - fputc(isprint(*p) ? *p : '.', fp);
> + fputc(isprint(*p) || isspace(*p) ? *p : '.', fp);
>
> if (dict_len & (msg_flags & SHOW_LOG_DICT)) {
> fprintf(fp, "\n");
>
Hmmm, that's OK, but it still looks a bit strange.
For example, without the patch, entries 003371 and 003695 show
the issue:
crash> log
...
[ 0.003371] ENERGY_PERF_BIAS: Set to 'normal', was
'performance'.ENERGY_PERF_BIAS: View and update with
x86_energy_perf_policy(8)
[ 0.003678] mce: CPU supports 7 MCE banks
[ 0.003687] CPU0: Thermal monitoring enabled (TM1)
[ 0.003692] process: using mwait in idle threads
[ 0.003695] Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0.Last
level dTLB entries: 4KB 512, 2MB 32, 4MB 32.tlb_flushall_shift is
0x1
[ 0.004676] ACPI: Core revision 20120711
...
With your patch applied:
crash> log
...
[ 0.003371] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 0.003678] mce: CPU supports 7 MCE banks
[ 0.003687] CPU0: Thermal monitoring enabled (TM1)
[ 0.003692] process: using mwait in idle threads
[ 0.003695] Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0
Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32
tlb_flushall_shift is 0x1
[ 0.004676] ACPI: Core revision 20120711
...
But, note that the dmesg(1) command repeats the timestamp for each
line:
$ dmesg
...
[ 0.003371] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 0.003371] ENERGY_PERF_BIAS: View and update with
x86_energy_perf_policy(8)
[ 0.003678] mce: CPU supports 7 MCE banks
[ 0.003687] CPU0: Thermal monitoring enabled (TM1)
[ 0.003692] process: using mwait in idle threads
[ 0.003695] Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0
[ 0.003695] Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32
[ 0.003695] tlb_flushall_shift is 0x1
[ 0.004676] ACPI: Core revision 20120711
...
I think that the log command should either (1) repeat the timestamp as
dmesg(1) does, or (2) insert "ilen" number of spaces before printing the
extra message lines.
What do you think?
Dave
IMHO, for readability, despite diverging from dmesg(1), I actually prefer
inserting spaces instead of repeating the timestamp, so that it looks
like this:
crash> log
...
[ 0.003371] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 0.003678] mce: CPU supports 7 MCE banks
[ 0.003687] CPU0: Thermal monitoring enabled (TM1)
[ 0.003692] process: using mwait in idle threads
[ 0.003695] Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0
Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32
tlb_flushall_shift is 0x1
[ 0.004676] ACPI: Core revision 20120711
...
And doing it that way maintains a bit of continuity w/respect to the
way that dictionary data can be dumped with "runq -d":
crash> log
...
[ 0.214952] pci 0000:00:00.0: [8086:0154] type 00 class 0x060000
[ 0.214987] pci 0000:00:02.0: [8086:0166] type 00 class 0x030000
[ 0.214995] pci 0000:00:02.0: reg 10: [mem 0xf0000000-0xf03fffff 64bit]
[ 0.215000] pci 0000:00:02.0: reg 18: [mem 0xe0000000-0xefffffff 64bit pref]
[ 0.215003] pci 0000:00:02.0: reg 20: [io 0x5000-0x503f]
...
crash> log -d
...
[ 0.214952] pci 0000:00:00.0: [8086:0154] type 00 class 0x060000
SUBSYSTEM=pci
DEVICE=+pci:0000:00:00.0
[ 0.214987] pci 0000:00:02.0: [8086:0166] type 00 class 0x030000
SUBSYSTEM=pci
DEVICE=+pci:0000:00:02.0
[ 0.214995] pci 0000:00:02.0: reg 10: [mem 0xf0000000-0xf03fffff 64bit]
SUBSYSTEM=pci
DEVICE=+pci:0000:00:02.0
[ 0.215000] pci 0000:00:02.0: reg 18: [mem 0xe0000000-0xefffffff 64bit pref]
SUBSYSTEM=pci
DEVICE=+pci:0000:00:02.0
[ 0.215003] pci 0000:00:02.0: reg 20: [io 0x5000-0x503f]
SUBSYSTEM=pci
DEVICE=+pci:0000:00:02.0
...
This patch work for you?
--- kernel.c 15 Oct 2012 19:05:39 -0000 1.286
+++ kernel.c 25 Oct 2012 18:48:59 -0000
@@ -4166,8 +4166,14 @@
fprintf(fp, buf);
}
- for (i = 0, p = msg; i < text_len; i++, p++)
- fputc(isprint(*p) ? *p : '.', fp);
+ for (i = 0, p = msg; i < text_len; i++, p++) {
+ if (*p == '\n')
+ fprintf(fp, "\n%s", space(ilen));
+ else if (isprint(*p) || isspace(*p))
+ fputc(*p, fp);
+ else
+ fputc('.', fp);
+ }
if (dict_len & (msg_flags & SHOW_LOG_DICT)) {
fprintf(fp, "\n");
Dave