new printk ringbuffer interface
by John Ogness
Hello Dave,
You may or may not be aware that we are working on replacing [0] the
Linux printk ringbuffer. Rather than a single buffer containing a single
struct type, the new ringbuffer makes use of several different structs.
I am writing to ask your advice about how this should be exported for
the crash utility. Should all struct sizes and field offsets be
exported? It would look something like this:
VMCOREINFO_SYMBOL(prb);
VMCOREINFO_STRUCT_SIZE(printk_ringbuffer);
VMCOREINFO_OFFSET(printk_ringbuffer, desc_ring);
VMCOREINFO_OFFSET(printk_ringbuffer, text_data_ring);
VMCOREINFO_OFFSET(printk_ringbuffer, dict_data_ring);
VMCOREINFO_OFFSET(printk_ringbuffer, fail);
VMCOREINFO_STRUCT_SIZE(prb_desc_ring);
VMCOREINFO_OFFSET(prb_desc_ring, count_bits);
VMCOREINFO_OFFSET(prb_desc_ring, descs);
VMCOREINFO_OFFSET(prb_desc_ring, head_id);
VMCOREINFO_OFFSET(prb_desc_ring, tail_id);
VMCOREINFO_STRUCT_SIZE(prb_desc);
VMCOREINFO_OFFSET(prb_desc, info);
VMCOREINFO_OFFSET(prb_desc, state_var);
VMCOREINFO_OFFSET(prb_desc, text_blk_lpos);
VMCOREINFO_OFFSET(prb_desc, dict_blk_lpos);
VMCOREINFO_STRUCT_SIZE(prb_data_blk_lpos);
VMCOREINFO_OFFSET(prb_data_blk_lpos, begin);
VMCOREINFO_OFFSET(prb_data_blk_lpos, next);
VMCOREINFO_STRUCT_SIZE(printk_info);
VMCOREINFO_OFFSET(printk_info, seq);
VMCOREINFO_OFFSET(printk_info, ts_nsec);
VMCOREINFO_OFFSET(printk_info, text_len);
VMCOREINFO_OFFSET(printk_info, dict_len);
VMCOREINFO_OFFSET(printk_info, caller_id);
VMCOREINFO_STRUCT_SIZE(prb_data_ring);
VMCOREINFO_OFFSET(prb_data_ring, size_bits);
VMCOREINFO_OFFSET(prb_data_ring, data);
VMCOREINFO_OFFSET(prb_data_ring, head_id);
VMCOREINFO_OFFSET(prb_data_ring, tail_id);
Or would it be enough to just recognize the new "prb" symbol and have
all the structures defined in the crash utility? If the latter is
preferred, should some sort of version number be exported? Or is the
kernel version number enough?
I appreciate your feedback.
John Ogness
[0] lkml.kernel.org/r/20200128161948.8524-1-john.ogness@linutronix.de
4 years, 7 months
Re: [Crash-utility] Crash-utility Digest, Vol 175, Issue 27
by Jon Deacon
Would you please take me off your list totally ridiculous
Sent from my iPhone
> On Apr 19, 2020, at 4:01 PM, crash-utility-request(a)redhat.com wrote:
>
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. Re: [PATCH] add log -T option to display the message text
> with human readable timestamp (Dave Anderson)
> 2. Re: [PATCH] add log -T option to display the message text
> with human readable timestamp (Dave Anderson)
> 3. Re: [PATCH] add log -T option to display the message text
> with human readable timestamp (Moore, Martin (Linux ERT))
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 19 Apr 2020 15:34:46 -0400 (EDT)
> From: Dave Anderson <anderson(a)redhat.com>
> To: Wang Long <w(a)laoqinren.net>
> Cc: crash-utility(a)redhat.com
> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
> message text with human readable timestamp
> Message-ID:
> <116726603.23908736.1587324886732.JavaMail.zimbra(a)redhat.com>
> Content-Type: text/plain; charset=utf-8
>
>
>
> ----- Original Message -----
>> Sometimes, we need to know the accurate time of the log, which
>> helps us analyze the problem.
>>
>> add -T option(like dmesg -T command) for log command to display
>> the message text with human readable timestamp.
>>
>> Signed-off-by: Wang Long <w(a)laoqinren.net>
>
> Did you attempt this patch on a live system? Because your patch to
> kernel_init() hangs the session. I didn't bother to investigate beyond
> adding these two debug statements around your addition to kernel_init():
>
> error(INFO, "start patch...\n");
> get_uptime(NULL, &uptime_jiffies);
> uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
> kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
> kt->boot_date.tv_nsec = 0;
> error(INFO, "end patch...\n");
>
> And that's where it hangs:
>
> $ ./crash
>
> crash 7.2.9rc13
> Copyright (C) 2002-2020 Red Hat, Inc.
> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
> Copyright (C) 1999-2006 Hewlett-Packard Co
> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
> Copyright (C) 2005, 2011 NEC Corporation
> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
> This program is free software, covered by the GNU General Public License,
> and you are welcome to change it and/or distribute copies of it under
> certain conditions. Enter "help copying" to see the conditions.
> This program has absolutely no warranty. Enter "help warranty" for details.
>
> GNU gdb (GDB) 7.6
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-unknown-linux-gnu"...
>
> WARNING: kernel relocated [796MB]: patching 85687 gdb minimal_symbol values
>
> crash: start patch...
>
> <hang>
>
> And it shows a cpu spinning at 100%:
>
> $ top
> top - 15:26:43 up 38 days, 3:41, 5 users, load average: 1.00, 0.89, 0.65
> Tasks: 280 total, 2 running, 278 sleeping, 0 stopped, 0 zombie
> %Cpu(s): 3.9 us, 8.7 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
> KiB Mem : 15907600 total, 455876 free, 1232832 used, 14218892 buff/cache
> KiB Swap: 8060924 total, 7395580 free, 665344 used. 14176220 avail Mem
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 26668 root 20 0 350268 213688 5680 R 100.0 1.3 5:42.70 crash
> 1707 root 20 0 115692 1184 688 S 0.3 0.0 2:16.52 ksmtuned
> 12852 anderson 20 0 4235240 274608 20320 S 0.3 1.7 601:46.85 gnome-shell
> 13060 anderson 20 0 804924 14100 3744 S 0.3 0.1 118:44.59 gsd-color
> 27045 anderson 20 0 172452 2532 1648 R 0.3 0.0 0:00.08 top
> 1 root 20 0 210504 5592 3224 S 0.0 0.0 18:14.19 systemd
> ...
>
> I'll let you figure it out...
>
> Dave
>
>
>
>
>
>
>> ---
>> defs.h | 2 ++
>> help.c | 28 +++++++++++++++++++++++++++-
>> kernel.c | 22 ++++++++++++++++++++--
>> 3 files changed, 49 insertions(+), 3 deletions(-)
>>
>> diff --git a/defs.h b/defs.h
>> index d8eda5e..1644dbd 100644
>> --- a/defs.h/
>> +++ b/defs.h
>> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data */
>> ulong kernel_module;
>> int mods_installed;
>> struct timespec date;
>> + struct timespec boot_date;
>> char proc_version[BUFSIZE];
>> struct new_utsname utsname;
>> uint kernel_version[3];
>> @@ -5577,6 +5578,7 @@ void dump_log(int);
>> #define SHOW_LOG_DICT (0x2)
>> #define SHOW_LOG_TEXT (0x4)
>> #define SHOW_LOG_AUDIT (0x8)
>> +#define SHOW_LOG_CTIME (0x10)
>> void set_cpu(int);
>> void clear_machdep_cache(void);
>> struct stack_hook *gather_text_list(struct bt_info *);
>> diff --git a/help.c b/help.c
>> index c443cad..1ee70f7 100644
>> --- a/help.c
>> +++ b/help.c
>> @@ -3892,12 +3892,13 @@ NULL
>> char *help_log[] = {
>> "log",
>> "dump system message buffer",
>> -"[-tdma]",
>> +"[-Ttdma]",
>> " This command dumps the kernel log_buf contents in chronological order.
>> The",
>> " command supports the older log_buf formats, which may or may not contain
>> a",
>> " timestamp inserted prior to each message, as well as the newer
>> variable-length",
>> " record format, where the timestamp is contained in each log entry's
>> header.",
>> " ",/
>> +" -T Display the message text with human readable timestamp.",
>> " -t Display the message text without the timestamp; only applicable to
>> the",
>> " variable-length record format.",
>> " -d Display the dictionary of key/value pair properties that are
>> optionally",
>> @@ -4031,6 +4032,31 @@ char *help_log[] = {
>> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
>> " ...",
>> " ",
>> +" Display the message text with human readable timestamp.\n"
>> +" %s> log -T",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x0000000000000000-0x000000000009fbff] usable",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x000000000009fc00-0x000000000009ffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x00000000000f0000-0x00000000000fffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x0000000000100000-0x00000000dffeffff] usable",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x00000000fec00000-0x00000000fec00fff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x00000000fee00000-0x00000000fee00fff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x00000000fffc0000-0x00000000ffffffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>> 0x0000000100000000-0x000000011fffffff] usable",
>> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
>> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
>> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox,
>> BIOS VirtualBox 12/01/2006",
>> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and
>> 4b564d00",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary cpu
>> clock",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of 11838753697
>> cycles",
>> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask:
>> 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns",
>> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff]
>> usable ==> reserved",
>> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff]
>> usable",
>> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn =
>> 0x400000000",
>> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
>> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
>> +" ...",/
>> NULL
>> };
>>
>> diff --git a/kernel.c b/kernel.c
>> index 7604fac..016d8d9 100644
>> --- a/kernel.c
>> +++ b/kernel.c
>> @@ -111,6 +111,8 @@ kernel_init()
>> char *irq_desc_type_name;
>> ulong pv_init_ops;/
>> struct gnu_request req;
>> + ulonglong uptime_jiffies;
>> + ulong uptime_sec;
>>
>> if (pc->flags & KERNEL_DEBUG_QUERY)
>> return;
>> @@ -294,6 +296,14 @@ kernel_init()
>> } else
>> error(INFO, "cannot determine base kernel version\n");
>>
>> + get_uptime(NULL, &uptime_jiffies);
>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>> + kt->boot_date.tv_nsec = 0;
>> +
>> + if (CRASHDEBUG(1))
>> + fprintf(fp, "boot_date: %lx: %s\n",
>> + kt->boot_date.tv_sec, strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>>
>> verify_version();
>>
>> @@ -4912,9 +4922,12 @@ cmd_log(void)
>>
>> msg_flags = 0;
>>
>> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
>> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
>> switch(c)
>> {
>> + case 'T':
>> + msg_flags |= SHOW_LOG_CTIME;
>> + break;
>> case 't':
>> msg_flags |= SHOW_LOG_TEXT;
>> break;
>> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
>> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
>> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
>> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
>> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>> + if (msg_flags & SHOW_LOG_CTIME) {
>> + time_t t = kt->boot_date.tv_sec + nanos;
>> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
>> + }
>> + else
>> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>> ilen = strlen(buf);
>> fprintf(fp, "%s", buf);
>> }
>> --
>> 1.8.3.1
>>
>>
>>
>>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 19 Apr 2020 15:48:55 -0400 (EDT)
> From: Dave Anderson <anderson(a)redhat.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
> message text with human readable timestamp
> Message-ID:
> <2105444223.23908999.1587325735354.JavaMail.zimbra(a)redhat.com>
> Content-Type: text/plain; charset=utf-8
>
>
> FWIW, I tried it on another RHEL7 machine running live,
> but then also on a RHEL8 kernel dumpfile, and they all hang:
>
> $ crash vmlinux vmcore
>
> crash 7.2.9rc13
> Copyright (C) 2002-2020 Red Hat, Inc.
> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
> Copyright (C) 1999-2006 Hewlett-Packard Co
> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
> Copyright (C) 2005, 2011 NEC Corporation
> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
> This program is free software, covered by the GNU General Public License,
> and you are welcome to change it and/or distribute copies of it under
> certain conditions. Enter "help copying" to see the conditions.
> This program has absolutely no warranty. Enter "help warranty" for details.
>
> GNU gdb (GDB) 7.6
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-unknown-linux-gnu"...
>
> WARNING: kernel relocated [950MB]: patching 94929 gdb minimal_symbol values
>
> crash: start patch...
>
>
>
> ----- Original Message -----
>>
>>
>> ----- Original Message -----
>>> Sometimes, we need to know the accurate time of the log, which
>>> helps us analyze the problem.
>>>
>>> add -T option(like dmesg -T command) for log command to display
>>> the message text with human readable timestamp.
>>>
>>> Signed-off-by: Wang Long <w(a)laoqinren.net>
>>
>> Did you attempt this patch on a live system? Because your patch to
>> kernel_init() hangs the session. I didn't bother to investigate beyond
>> adding these two debug statements around your addition to kernel_init():
>>
>> error(INFO, "start patch...\n");
>> get_uptime(NULL, &uptime_jiffies);
>> uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>> kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>> kt->boot_date.tv_nsec = 0;
>> error(INFO, "end patch...\n");
>>
>> And that's where it hangs:
>>
>> $ ./crash
>>
>> crash 7.2.9rc13
>> Copyright (C) 2002-2020 Red Hat, Inc.
>> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
>> Copyright (C) 1999-2006 Hewlett-Packard Co
>> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
>> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
>> Copyright (C) 2005, 2011 NEC Corporation
>> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
>> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
>> This program is free software, covered by the GNU General Public License,
>> and you are welcome to change it and/or distribute copies of it under
>> certain conditions. Enter "help copying" to see the conditions.
>> This program has absolutely no warranty. Enter "help warranty" for
>> details.
>>
>> GNU gdb (GDB) 7.6
>> Copyright (C) 2013 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-unknown-linux-gnu"...
>>
>> WARNING: kernel relocated [796MB]: patching 85687 gdb minimal_symbol values
>>
>> crash: start patch...
>>
>> <hang>
>>
>> And it shows a cpu spinning at 100%:
>>
>> $ top
>> top - 15:26:43 up 38 days, 3:41, 5 users, load average: 1.00, 0.89, 0.65
>> Tasks: 280 total, 2 running, 278 sleeping, 0 stopped, 0 zombie
>> %Cpu(s): 3.9 us, 8.7 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.0 hi, 0.0 si,
>> 0.0 st
>> KiB Mem : 15907600 total, 455876 free, 1232832 used, 14218892 buff/cache
>> KiB Swap: 8060924 total, 7395580 free, 665344 used. 14176220 avail Mem
>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
>> 26668 root 20 0 350268 213688 5680 R 100.0 1.3 5:42.70 crash
>> 1707 root 20 0 115692 1184 688 S 0.3 0.0 2:16.52
>> ksmtuned
>> 12852 anderson 20 0 4235240 274608 20320 S 0.3 1.7 601:46.85
>> gnome-shell
>> 13060 anderson 20 0 804924 14100 3744 S 0.3 0.1 118:44.59
>> gsd-color
>> 27045 anderson 20 0 172452 2532 1648 R 0.3 0.0 0:00.08 top
>> 1 root 20 0 210504 5592 3224 S 0.0 0.0 18:14.19 systemd
>> ...
>>
>> I'll let you figure it out...
>>
>> Dave
>>
>>
>>
>>
>>
>>
>>> ---
>>> defs.h | 2 ++
>>> help.c | 28 +++++++++++++++++++++++++++-
>>> kernel.c | 22 ++++++++++++++++++++--
>>> 3 files changed, 49 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/defs.h b/defs.h
>>> index d8eda5e..1644dbd 100644
>>> --- a/defs.h/
>>> +++ b/defs.h
>>> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data
>>> */
>>> ulong kernel_module;
>>> int mods_installed;
>>> struct timespec date;
>>> + struct timespec boot_date;
>>> char proc_version[BUFSIZE];
>>> struct new_utsname utsname;
>>> uint kernel_version[3];
>>> @@ -5577,6 +5578,7 @@ void dump_log(int);
>>> #define SHOW_LOG_DICT (0x2)
>>> #define SHOW_LOG_TEXT (0x4)
>>> #define SHOW_LOG_AUDIT (0x8)
>>> +#define SHOW_LOG_CTIME (0x10)
>>> void set_cpu(int);
>>> void clear_machdep_cache(void);
>>> struct stack_hook *gather_text_list(struct bt_info *);
>>> diff --git a/help.c b/help.c
>>> index c443cad..1ee70f7 100644
>>> --- a/help.c
>>> +++ b/help.c
>>> @@ -3892,12 +3892,13 @@ NULL
>>> char *help_log[] = {
>>> "log",
>>> "dump system message buffer",
>>> -"[-tdma]",
>>> +"[-Ttdma]",
>>> " This command dumps the kernel log_buf contents in chronological order.
>>> The",
>>> " command supports the older log_buf formats, which may or may not
>>> contain
>>> a",
>>> " timestamp inserted prior to each message, as well as the newer
>>> variable-length",
>>> " record format, where the timestamp is contained in each log entry's
>>> header.",
>>> " ",/
>>> +" -T Display the message text with human readable timestamp.",
>>> " -t Display the message text without the timestamp; only applicable
>>> to
>>> the",
>>> " variable-length record format.",
>>> " -d Display the dictionary of key/value pair properties that are
>>> optionally",
>>> @@ -4031,6 +4032,31 @@ char *help_log[] = {
>>> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
>>> " ...",
>>> " ",
>>> +" Display the message text with human readable timestamp.\n"
>>> +" %s> log -T",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000000000000-0x000000000009fbff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x000000000009fc00-0x000000000009ffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000000f0000-0x00000000000fffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000000100000-0x00000000dffeffff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fec00000-0x00000000fec00fff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fee00000-0x00000000fee00fff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fffc0000-0x00000000ffffffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000100000000-0x000000011fffffff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
>>> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
>>> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox,
>>> BIOS VirtualBox 12/01/2006",
>>> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and
>>> 4b564d00",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary
>>> cpu
>>> clock",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of
>>> 11838753697
>>> cycles",
>>> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask:
>>> 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483
>>> ns",
>>> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff]
>>> usable ==> reserved",
>>> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff]
>>> usable",
>>> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn =
>>> 0x400000000",
>>> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
>>> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
>>> +" ...",/
>>> NULL
>>> };
>>>
>>> diff --git a/kernel.c b/kernel.c
>>> index 7604fac..016d8d9 100644
>>> --- a/kernel.c
>>> +++ b/kernel.c
>>> @@ -111,6 +111,8 @@ kernel_init()
>>> char *irq_desc_type_name;
>>> ulong pv_init_ops;/
>>> struct gnu_request req;
>>> + ulonglong uptime_jiffies;
>>> + ulong uptime_sec;
>>>
>>> if (pc->flags & KERNEL_DEBUG_QUERY)
>>> return;
>>> @@ -294,6 +296,14 @@ kernel_init()
>>> } else
>>> error(INFO, "cannot determine base kernel version\n");
>>>
>>> + get_uptime(NULL, &uptime_jiffies);
>>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>> + kt->boot_date.tv_nsec = 0;
>>> +
>>> + if (CRASHDEBUG(1))
>>> + fprintf(fp, "boot_date: %lx: %s\n",
>>> + kt->boot_date.tv_sec, strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>>>
>>> verify_version();
>>>
>>> @@ -4912,9 +4922,12 @@ cmd_log(void)
>>>
>>> msg_flags = 0;
>>>
>>> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
>>> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
>>> switch(c)
>>> {
>>> + case 'T':
>>> + msg_flags |= SHOW_LOG_CTIME;
>>> + break;
>>> case 't':
>>> msg_flags |= SHOW_LOG_TEXT;
>>> break;
>>> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
>>> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
>>> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
>>> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
>>> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>> + if (msg_flags & SHOW_LOG_CTIME) {
>>> + time_t t = kt->boot_date.tv_sec + nanos;
>>> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
>>> + }
>>> + else
>>> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>> ilen = strlen(buf);
>>> fprintf(fp, "%s", buf);
>>> }
>>> --
>>> 1.8.3.1
>>>
>>>
>>>
>>>
>>
>> --
>> Crash-utility mailing list
>> Crash-utility(a)redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
>>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 19 Apr 2020 20:01:12 +0000
> From: "Moore, Martin (Linux ERT)" <martin.moore(a)hpe.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>, "anderson(a)redhat.com"
> <anderson(a)redhat.com>
> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
> message text with human readable timestamp
> Message-ID:
> <AT5PR8401MB05480CDBEEE71C6F900654B991D70(a)AT5PR8401MB0548.NAMPRD84.PROD.OUTLOOK.COM>
>
> Content-Type: text/plain; charset=WINDOWS-1252
>
> Just to mention an alternative possibility, the pykdump extension to crash (https://sourceforge.net/projects/pykdump/) includes the 'tslog' command to accomplish this.
>
> Martin Moore
> Linux Engineering Resolution Team
> HPE Pointnext Services
> Hewlett Packard Enterprise
>
> Martin.Moore(a)hpe.com?
> 8AM-5PM EDT (GMT-4) Monday-Friday
> Manager: Becky McBride (becky.mcbride(a)hpe.com)
>
> -----Original Message-----
> From: crash-utility-bounces(a)redhat.com <crash-utility-bounces(a)redhat.com> On Behalf Of Wang Long
> Sent: Saturday, April 18, 2020 10:21 PM
> To: anderson(a)redhat.com; crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH] add log -T option to display the message text with human readable timestamp
>
> Sometimes, we need to know the accurate time of the log, which helps us analyze the problem.
>
> add -T option(like dmesg -T command) for log command to display the message text with human readable timestamp.
>
> Signed-off-by: Wang Long <w(a)laoqinren.net>
> ---
> defs.h | 2 ++
> help.c | 28 +++++++++++++++++++++++++++-
> kernel.c | 22 ++++++++++++++++++++--
> 3 files changed, 49 insertions(+), 3 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index d8eda5e..1644dbd 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data */
> ulong kernel_module;
> int mods_installed;
> struct timespec date;
> + struct timespec boot_date;
> char proc_version[BUFSIZE];
> struct new_utsname utsname;
> uint kernel_version[3];
> @@ -5577,6 +5578,7 @@ void dump_log(int); #define SHOW_LOG_DICT (0x2) #define SHOW_LOG_TEXT (0x4) #define SHOW_LOG_AUDIT (0x8)
> +#define SHOW_LOG_CTIME (0x10)
> void set_cpu(int);
> void clear_machdep_cache(void);
> struct stack_hook *gather_text_list(struct bt_info *); diff --git a/help.c b/help.c index c443cad..1ee70f7 100644
> --- a/help.c
> +++ b/help.c
> @@ -3892,12 +3892,13 @@ NULL
> char *help_log[] = {
> "log",
> "dump system message buffer",
> -"[-tdma]",
> +"[-Ttdma]",
> " This command dumps the kernel log_buf contents in chronological order. The", " command supports the older log_buf formats, which may or may not contain a", " timestamp inserted prior to each message, as well as the newer variable-length", " record format, where the timestamp is contained in each log entry's header.", " ",
> +" -T Display the message text with human readable timestamp.",
> " -t Display the message text without the timestamp; only applicable to the",
> " variable-length record format.",
> " -d Display the dictionary of key/value pair properties that are optionally",
> @@ -4031,6 +4032,31 @@ char *help_log[] = {
> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
> " ...",
> " ",
> +" Display the message text with human readable timestamp.\n"
> +" %s> log -T",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved",
> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable",
> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006",
> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and 4b564d00",
> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary cpu clock",
> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of 11838753697 cycles",
> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns",
> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved",
> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff] usable",
> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn = 0x400000000",
> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
> +" ...",
> NULL
> };
>
> diff --git a/kernel.c b/kernel.c
> index 7604fac..016d8d9 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -111,6 +111,8 @@ kernel_init()
> char *irq_desc_type_name;
> ulong pv_init_ops;
> struct gnu_request req;
> + ulonglong uptime_jiffies;
> + ulong uptime_sec;
>
> if (pc->flags & KERNEL_DEBUG_QUERY)
> return;
> @@ -294,6 +296,14 @@ kernel_init()
> } else
> error(INFO, "cannot determine base kernel version\n");
>
> + get_uptime(NULL, &uptime_jiffies);
> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
> + kt->boot_date.tv_nsec = 0;
> +
> + if (CRASHDEBUG(1))
> + fprintf(fp, "boot_date: %lx: %s\n",
> + kt->boot_date.tv_sec,
> +strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>
> verify_version();
>
> @@ -4912,9 +4922,12 @@ cmd_log(void)
>
> msg_flags = 0;
>
> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
> switch(c)
> {
> + case 'T':
> + msg_flags |= SHOW_LOG_CTIME;
> + break;
> case 't':
> msg_flags |= SHOW_LOG_TEXT;
> break;
> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
> + if (msg_flags & SHOW_LOG_CTIME) {
> + time_t t = kt->boot_date.tv_sec + nanos;
> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
> + }
> + else
> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
> ilen = strlen(buf);
> fprintf(fp, "%s", buf);
> }
> --
> 1.8.3.1
>
>
>
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 175, Issue 27
> **********************************************
>
4 years, 7 months
[PATCH] add log -T option to display the message text with human readable timestamp
by Wang Long
Sometimes, we need to know the accurate time of the log, which
helps us analyze the problem.
add -T option(like dmesg -T command) for log command to display
the message text with human readable timestamp.
Signed-off-by: Wang Long <w(a)laoqinren.net>
---
defs.h | 2 ++
help.c | 28 +++++++++++++++++++++++++++-
kernel.c | 22 ++++++++++++++++++++--
3 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/defs.h b/defs.h
index d8eda5e..1644dbd 100644
--- a/defs.h
+++ b/defs.h
@@ -689,6 +689,7 @@ struct kernel_table { /* kernel data */
ulong kernel_module;
int mods_installed;
struct timespec date;
+ struct timespec boot_date;
char proc_version[BUFSIZE];
struct new_utsname utsname;
uint kernel_version[3];
@@ -5577,6 +5578,7 @@ void dump_log(int);
#define SHOW_LOG_DICT (0x2)
#define SHOW_LOG_TEXT (0x4)
#define SHOW_LOG_AUDIT (0x8)
+#define SHOW_LOG_CTIME (0x10)
void set_cpu(int);
void clear_machdep_cache(void);
struct stack_hook *gather_text_list(struct bt_info *);
diff --git a/help.c b/help.c
index c443cad..1ee70f7 100644
--- a/help.c
+++ b/help.c
@@ -3892,12 +3892,13 @@ NULL
char *help_log[] = {
"log",
"dump system message buffer",
-"[-tdma]",
+"[-Ttdma]",
" This command dumps the kernel log_buf contents in chronological order. The",
" command supports the older log_buf formats, which may or may not contain a",
" timestamp inserted prior to each message, as well as the newer variable-length",
" record format, where the timestamp is contained in each log entry's header.",
" ",
+" -T Display the message text with human readable timestamp.",
" -t Display the message text without the timestamp; only applicable to the",
" variable-length record format.",
" -d Display the dictionary of key/value pair properties that are optionally",
@@ -4031,6 +4032,31 @@ char *help_log[] = {
" type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
" ...",
" ",
+" Display the message text with human readable timestamp.\n"
+" %s> log -T",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved",
+" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable",
+" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
+" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
+" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006",
+" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
+" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and 4b564d00",
+" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary cpu clock",
+" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of 11838753697 cycles",
+" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns",
+" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved",
+" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff] usable",
+" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn = 0x400000000",
+" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
+" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
+" ...",
NULL
};
diff --git a/kernel.c b/kernel.c
index 7604fac..016d8d9 100644
--- a/kernel.c
+++ b/kernel.c
@@ -111,6 +111,8 @@ kernel_init()
char *irq_desc_type_name;
ulong pv_init_ops;
struct gnu_request req;
+ ulonglong uptime_jiffies;
+ ulong uptime_sec;
if (pc->flags & KERNEL_DEBUG_QUERY)
return;
@@ -294,6 +296,14 @@ kernel_init()
} else
error(INFO, "cannot determine base kernel version\n");
+ get_uptime(NULL, &uptime_jiffies);
+ uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
+ kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
+ kt->boot_date.tv_nsec = 0;
+
+ if (CRASHDEBUG(1))
+ fprintf(fp, "boot_date: %lx: %s\n",
+ kt->boot_date.tv_sec, strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
verify_version();
@@ -4912,9 +4922,12 @@ cmd_log(void)
msg_flags = 0;
- while ((c = getopt(argcnt, args, "tdma")) != EOF) {
+ while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
switch(c)
{
+ case 'T':
+ msg_flags |= SHOW_LOG_CTIME;
+ break;
case 't':
msg_flags |= SHOW_LOG_TEXT;
break;
@@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
if ((msg_flags & SHOW_LOG_TEXT) == 0) {
nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
- sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
+ if (msg_flags & SHOW_LOG_CTIME) {
+ time_t t = kt->boot_date.tv_sec + nanos;
+ sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
+ }
+ else
+ sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
ilen = strlen(buf);
fprintf(fp, "%s", buf);
}
--
1.8.3.1
4 years, 7 months
Re: [Crash-utility] Crash-utility Digest, Vol 175, Issue 28
by Jon Deacon
Stop sending please
Sent from my iPhone
> On Apr 19, 2020, at 7:11 PM, crash-utility-request(a)redhat.com wrote:
>
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. Re: Crash-utility Digest, Vol 175, Issue 27 (Jon Deacon)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 19 Apr 2020 19:10:49 -0400
> From: Jon Deacon <jdeacon60(a)gmail.com>
> To: crash-utility(a)redhat.com
> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 175, Issue 27
> Message-ID: <BBA9A8B9-A0EA-404C-AC73-7814A9544219(a)gmail.com>
> Content-Type: text/plain; charset=utf-8
>
> Would you please take me off your list totally ridiculous
>
> Sent from my iPhone
>
>> On Apr 19, 2020, at 4:01 PM, crash-utility-request(a)redhat.com wrote:
>>
>> ?Send Crash-utility mailing list submissions to
>> crash-utility(a)redhat.com
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://www.redhat.com/mailman/listinfo/crash-utility
>> or, via email, send a message with subject or body 'help' to
>> crash-utility-request(a)redhat.com
>>
>> You can reach the person managing the list at
>> crash-utility-owner(a)redhat.com
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Crash-utility digest..."
>>
>>
>> Today's Topics:
>>
>> 1. Re: [PATCH] add log -T option to display the message text
>> with human readable timestamp (Dave Anderson)
>> 2. Re: [PATCH] add log -T option to display the message text
>> with human readable timestamp (Dave Anderson)
>> 3. Re: [PATCH] add log -T option to display the message text
>> with human readable timestamp (Moore, Martin (Linux ERT))
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sun, 19 Apr 2020 15:34:46 -0400 (EDT)
>> From: Dave Anderson <anderson(a)redhat.com>
>> To: Wang Long <w(a)laoqinren.net>
>> Cc: crash-utility(a)redhat.com
>> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
>> message text with human readable timestamp
>> Message-ID:
>> <116726603.23908736.1587324886732.JavaMail.zimbra(a)redhat.com>
>> Content-Type: text/plain; charset=utf-8
>>
>>
>>
>> ----- Original Message -----
>>> Sometimes, we need to know the accurate time of the log, which
>>> helps us analyze the problem.
>>>
>>> add -T option(like dmesg -T command) for log command to display
>>> the message text with human readable timestamp.
>>>
>>> Signed-off-by: Wang Long <w(a)laoqinren.net>
>>
>> Did you attempt this patch on a live system? Because your patch to
>> kernel_init() hangs the session. I didn't bother to investigate beyond
>> adding these two debug statements around your addition to kernel_init():
>>
>> error(INFO, "start patch...\n");
>> get_uptime(NULL, &uptime_jiffies);
>> uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>> kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>> kt->boot_date.tv_nsec = 0;
>> error(INFO, "end patch...\n");
>>
>> And that's where it hangs:
>>
>> $ ./crash
>>
>> crash 7.2.9rc13
>> Copyright (C) 2002-2020 Red Hat, Inc.
>> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
>> Copyright (C) 1999-2006 Hewlett-Packard Co
>> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
>> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
>> Copyright (C) 2005, 2011 NEC Corporation
>> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
>> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
>> This program is free software, covered by the GNU General Public License,
>> and you are welcome to change it and/or distribute copies of it under
>> certain conditions. Enter "help copying" to see the conditions.
>> This program has absolutely no warranty. Enter "help warranty" for details.
>>
>> GNU gdb (GDB) 7.6
>> Copyright (C) 2013 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-unknown-linux-gnu"...
>>
>> WARNING: kernel relocated [796MB]: patching 85687 gdb minimal_symbol values
>>
>> crash: start patch...
>>
>> <hang>
>>
>> And it shows a cpu spinning at 100%:
>>
>> $ top
>> top - 15:26:43 up 38 days, 3:41, 5 users, load average: 1.00, 0.89, 0.65
>> Tasks: 280 total, 2 running, 278 sleeping, 0 stopped, 0 zombie
>> %Cpu(s): 3.9 us, 8.7 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
>> KiB Mem : 15907600 total, 455876 free, 1232832 used, 14218892 buff/cache
>> KiB Swap: 8060924 total, 7395580 free, 665344 used. 14176220 avail Mem
>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
>> 26668 root 20 0 350268 213688 5680 R 100.0 1.3 5:42.70 crash
>> 1707 root 20 0 115692 1184 688 S 0.3 0.0 2:16.52 ksmtuned
>> 12852 anderson 20 0 4235240 274608 20320 S 0.3 1.7 601:46.85 gnome-shell
>> 13060 anderson 20 0 804924 14100 3744 S 0.3 0.1 118:44.59 gsd-color
>> 27045 anderson 20 0 172452 2532 1648 R 0.3 0.0 0:00.08 top
>> 1 root 20 0 210504 5592 3224 S 0.0 0.0 18:14.19 systemd
>> ...
>>
>> I'll let you figure it out...
>>
>> Dave
>>
>>
>>
>>
>>
>>
>>> ---
>>> defs.h | 2 ++
>>> help.c | 28 +++++++++++++++++++++++++++-
>>> kernel.c | 22 ++++++++++++++++++++--
>>> 3 files changed, 49 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/defs.h b/defs.h
>>> index d8eda5e..1644dbd 100644
>>> --- a/defs.h/
>>> +++ b/defs.h
>>> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data */
>>> ulong kernel_module;
>>> int mods_installed;
>>> struct timespec date;
>>> + struct timespec boot_date;
>>> char proc_version[BUFSIZE];
>>> struct new_utsname utsname;
>>> uint kernel_version[3];
>>> @@ -5577,6 +5578,7 @@ void dump_log(int);
>>> #define SHOW_LOG_DICT (0x2)
>>> #define SHOW_LOG_TEXT (0x4)
>>> #define SHOW_LOG_AUDIT (0x8)
>>> +#define SHOW_LOG_CTIME (0x10)
>>> void set_cpu(int);
>>> void clear_machdep_cache(void);
>>> struct stack_hook *gather_text_list(struct bt_info *);
>>> diff --git a/help.c b/help.c
>>> index c443cad..1ee70f7 100644
>>> --- a/help.c
>>> +++ b/help.c
>>> @@ -3892,12 +3892,13 @@ NULL
>>> char *help_log[] = {
>>> "log",
>>> "dump system message buffer",
>>> -"[-tdma]",
>>> +"[-Ttdma]",
>>> " This command dumps the kernel log_buf contents in chronological order.
>>> The",
>>> " command supports the older log_buf formats, which may or may not contain
>>> a",
>>> " timestamp inserted prior to each message, as well as the newer
>>> variable-length",
>>> " record format, where the timestamp is contained in each log entry's
>>> header.",
>>> " ",/
>>> +" -T Display the message text with human readable timestamp.",
>>> " -t Display the message text without the timestamp; only applicable to
>>> the",
>>> " variable-length record format.",
>>> " -d Display the dictionary of key/value pair properties that are
>>> optionally",
>>> @@ -4031,6 +4032,31 @@ char *help_log[] = {
>>> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
>>> " ...",
>>> " ",
>>> +" Display the message text with human readable timestamp.\n"
>>> +" %s> log -T",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000000000000-0x000000000009fbff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x000000000009fc00-0x000000000009ffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000000f0000-0x00000000000fffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000000100000-0x00000000dffeffff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fec00000-0x00000000fec00fff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fee00000-0x00000000fee00fff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x00000000fffc0000-0x00000000ffffffff] reserved",
>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>> 0x0000000100000000-0x000000011fffffff] usable",
>>> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
>>> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
>>> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox,
>>> BIOS VirtualBox 12/01/2006",
>>> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and
>>> 4b564d00",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary cpu
>>> clock",
>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of 11838753697
>>> cycles",
>>> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask:
>>> 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns",
>>> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff]
>>> usable ==> reserved",
>>> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff]
>>> usable",
>>> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn =
>>> 0x400000000",
>>> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
>>> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
>>> +" ...",/
>>> NULL
>>> };
>>>
>>> diff --git a/kernel.c b/kernel.c
>>> index 7604fac..016d8d9 100644
>>> --- a/kernel.c
>>> +++ b/kernel.c
>>> @@ -111,6 +111,8 @@ kernel_init()
>>> char *irq_desc_type_name;
>>> ulong pv_init_ops;/
>>> struct gnu_request req;
>>> + ulonglong uptime_jiffies;
>>> + ulong uptime_sec;
>>>
>>> if (pc->flags & KERNEL_DEBUG_QUERY)
>>> return;
>>> @@ -294,6 +296,14 @@ kernel_init()
>>> } else
>>> error(INFO, "cannot determine base kernel version\n");
>>>
>>> + get_uptime(NULL, &uptime_jiffies);
>>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>> + kt->boot_date.tv_nsec = 0;
>>> +
>>> + if (CRASHDEBUG(1))
>>> + fprintf(fp, "boot_date: %lx: %s\n",
>>> + kt->boot_date.tv_sec, strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>>>
>>> verify_version();
>>>
>>> @@ -4912,9 +4922,12 @@ cmd_log(void)
>>>
>>> msg_flags = 0;
>>>
>>> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
>>> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
>>> switch(c)
>>> {
>>> + case 'T':
>>> + msg_flags |= SHOW_LOG_CTIME;
>>> + break;
>>> case 't':
>>> msg_flags |= SHOW_LOG_TEXT;
>>> break;
>>> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
>>> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
>>> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
>>> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
>>> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>> + if (msg_flags & SHOW_LOG_CTIME) {
>>> + time_t t = kt->boot_date.tv_sec + nanos;
>>> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
>>> + }
>>> + else
>>> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>> ilen = strlen(buf);
>>> fprintf(fp, "%s", buf);
>>> }
>>> --
>>> 1.8.3.1
>>>
>>>
>>>
>>>
>>
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Sun, 19 Apr 2020 15:48:55 -0400 (EDT)
>> From: Dave Anderson <anderson(a)redhat.com>
>> To: "Discussion list for crash utility usage, maintenance and
>> development" <crash-utility(a)redhat.com>
>> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
>> message text with human readable timestamp
>> Message-ID:
>> <2105444223.23908999.1587325735354.JavaMail.zimbra(a)redhat.com>
>> Content-Type: text/plain; charset=utf-8
>>
>>
>> FWIW, I tried it on another RHEL7 machine running live,
>> but then also on a RHEL8 kernel dumpfile, and they all hang:
>>
>> $ crash vmlinux vmcore
>>
>> crash 7.2.9rc13
>> Copyright (C) 2002-2020 Red Hat, Inc.
>> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
>> Copyright (C) 1999-2006 Hewlett-Packard Co
>> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
>> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
>> Copyright (C) 2005, 2011 NEC Corporation
>> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
>> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
>> This program is free software, covered by the GNU General Public License,
>> and you are welcome to change it and/or distribute copies of it under
>> certain conditions. Enter "help copying" to see the conditions.
>> This program has absolutely no warranty. Enter "help warranty" for details.
>>
>> GNU gdb (GDB) 7.6
>> Copyright (C) 2013 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-unknown-linux-gnu"...
>>
>> WARNING: kernel relocated [950MB]: patching 94929 gdb minimal_symbol values
>>
>> crash: start patch...
>>
>>
>>
>> ----- Original Message -----
>>>
>>>
>>> ----- Original Message -----
>>>> Sometimes, we need to know the accurate time of the log, which
>>>> helps us analyze the problem.
>>>>
>>>> add -T option(like dmesg -T command) for log command to display
>>>> the message text with human readable timestamp.
>>>>
>>>> Signed-off-by: Wang Long <w(a)laoqinren.net>
>>>
>>> Did you attempt this patch on a live system? Because your patch to
>>> kernel_init() hangs the session. I didn't bother to investigate beyond
>>> adding these two debug statements around your addition to kernel_init():
>>>
>>> error(INFO, "start patch...\n");
>>> get_uptime(NULL, &uptime_jiffies);
>>> uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>> kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>> kt->boot_date.tv_nsec = 0;
>>> error(INFO, "end patch...\n");
>>>
>>> And that's where it hangs:
>>>
>>> $ ./crash
>>>
>>> crash 7.2.9rc13
>>> Copyright (C) 2002-2020 Red Hat, Inc.
>>> Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
>>> Copyright (C) 1999-2006 Hewlett-Packard Co
>>> Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
>>> Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
>>> Copyright (C) 2005, 2011 NEC Corporation
>>> Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
>>> Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
>>> This program is free software, covered by the GNU General Public License,
>>> and you are welcome to change it and/or distribute copies of it under
>>> certain conditions. Enter "help copying" to see the conditions.
>>> This program has absolutely no warranty. Enter "help warranty" for
>>> details.
>>>
>>> GNU gdb (GDB) 7.6
>>> Copyright (C) 2013 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-unknown-linux-gnu"...
>>>
>>> WARNING: kernel relocated [796MB]: patching 85687 gdb minimal_symbol values
>>>
>>> crash: start patch...
>>>
>>> <hang>
>>>
>>> And it shows a cpu spinning at 100%:
>>>
>>> $ top
>>> top - 15:26:43 up 38 days, 3:41, 5 users, load average: 1.00, 0.89, 0.65
>>> Tasks: 280 total, 2 running, 278 sleeping, 0 stopped, 0 zombie
>>> %Cpu(s): 3.9 us, 8.7 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.0 hi, 0.0 si,
>>> 0.0 st
>>> KiB Mem : 15907600 total, 455876 free, 1232832 used, 14218892 buff/cache
>>> KiB Swap: 8060924 total, 7395580 free, 665344 used. 14176220 avail Mem
>>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
>>> 26668 root 20 0 350268 213688 5680 R 100.0 1.3 5:42.70 crash
>>> 1707 root 20 0 115692 1184 688 S 0.3 0.0 2:16.52
>>> ksmtuned
>>> 12852 anderson 20 0 4235240 274608 20320 S 0.3 1.7 601:46.85
>>> gnome-shell
>>> 13060 anderson 20 0 804924 14100 3744 S 0.3 0.1 118:44.59
>>> gsd-color
>>> 27045 anderson 20 0 172452 2532 1648 R 0.3 0.0 0:00.08 top
>>> 1 root 20 0 210504 5592 3224 S 0.0 0.0 18:14.19 systemd
>>> ...
>>>
>>> I'll let you figure it out...
>>>
>>> Dave
>>>
>>>
>>>
>>>
>>>
>>>
>>>> ---
>>>> defs.h | 2 ++
>>>> help.c | 28 +++++++++++++++++++++++++++-
>>>> kernel.c | 22 ++++++++++++++++++++--
>>>> 3 files changed, 49 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/defs.h b/defs.h
>>>> index d8eda5e..1644dbd 100644
>>>> --- a/defs.h/
>>>> +++ b/defs.h
>>>> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data
>>>> */
>>>> ulong kernel_module;
>>>> int mods_installed;
>>>> struct timespec date;
>>>> + struct timespec boot_date;
>>>> char proc_version[BUFSIZE];
>>>> struct new_utsname utsname;
>>>> uint kernel_version[3];
>>>> @@ -5577,6 +5578,7 @@ void dump_log(int);
>>>> #define SHOW_LOG_DICT (0x2)
>>>> #define SHOW_LOG_TEXT (0x4)
>>>> #define SHOW_LOG_AUDIT (0x8)
>>>> +#define SHOW_LOG_CTIME (0x10)
>>>> void set_cpu(int);
>>>> void clear_machdep_cache(void);
>>>> struct stack_hook *gather_text_list(struct bt_info *);
>>>> diff --git a/help.c b/help.c
>>>> index c443cad..1ee70f7 100644
>>>> --- a/help.c
>>>> +++ b/help.c
>>>> @@ -3892,12 +3892,13 @@ NULL
>>>> char *help_log[] = {
>>>> "log",
>>>> "dump system message buffer",
>>>> -"[-tdma]",
>>>> +"[-Ttdma]",
>>>> " This command dumps the kernel log_buf contents in chronological order.
>>>> The",
>>>> " command supports the older log_buf formats, which may or may not
>>>> contain
>>>> a",
>>>> " timestamp inserted prior to each message, as well as the newer
>>>> variable-length",
>>>> " record format, where the timestamp is contained in each log entry's
>>>> header.",
>>>> " ",/
>>>> +" -T Display the message text with human readable timestamp.",
>>>> " -t Display the message text without the timestamp; only applicable
>>>> to
>>>> the",
>>>> " variable-length record format.",
>>>> " -d Display the dictionary of key/value pair properties that are
>>>> optionally",
>>>> @@ -4031,6 +4032,31 @@ char *help_log[] = {
>>>> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
>>>> " ...",
>>>> " ",
>>>> +" Display the message text with human readable timestamp.\n"
>>>> +" %s> log -T",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x0000000000000000-0x000000000009fbff] usable",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x000000000009fc00-0x000000000009ffff] reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x00000000000f0000-0x00000000000fffff] reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x0000000000100000-0x00000000dffeffff] usable",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x00000000fec00000-0x00000000fec00fff] reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x00000000fee00000-0x00000000fee00fff] reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x00000000fffc0000-0x00000000ffffffff] reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem
>>>> 0x0000000100000000-0x000000011fffffff] usable",
>>>> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
>>>> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
>>>> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox,
>>>> BIOS VirtualBox 12/01/2006",
>>>> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
>>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and
>>>> 4b564d00",
>>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary
>>>> cpu
>>>> clock",
>>>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of
>>>> 11838753697
>>>> cycles",
>>>> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask:
>>>> 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483
>>>> ns",
>>>> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff]
>>>> usable ==> reserved",
>>>> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff]
>>>> usable",
>>>> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn =
>>>> 0x400000000",
>>>> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
>>>> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
>>>> +" ...",/
>>>> NULL
>>>> };
>>>>
>>>> diff --git a/kernel.c b/kernel.c
>>>> index 7604fac..016d8d9 100644
>>>> --- a/kernel.c
>>>> +++ b/kernel.c
>>>> @@ -111,6 +111,8 @@ kernel_init()
>>>> char *irq_desc_type_name;
>>>> ulong pv_init_ops;/
>>>> struct gnu_request req;
>>>> + ulonglong uptime_jiffies;
>>>> + ulong uptime_sec;
>>>>
>>>> if (pc->flags & KERNEL_DEBUG_QUERY)
>>>> return;
>>>> @@ -294,6 +296,14 @@ kernel_init()
>>>> } else
>>>> error(INFO, "cannot determine base kernel version\n");
>>>>
>>>> + get_uptime(NULL, &uptime_jiffies);
>>>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>>> + kt->boot_date.tv_nsec = 0;
>>>> +
>>>> + if (CRASHDEBUG(1))
>>>> + fprintf(fp, "boot_date: %lx: %s\n",
>>>> + kt->boot_date.tv_sec, strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>>>>
>>>> verify_version();
>>>>
>>>> @@ -4912,9 +4922,12 @@ cmd_log(void)
>>>>
>>>> msg_flags = 0;
>>>>
>>>> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
>>>> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
>>>> switch(c)
>>>> {
>>>> + case 'T':
>>>> + msg_flags |= SHOW_LOG_CTIME;
>>>> + break;
>>>> case 't':
>>>> msg_flags |= SHOW_LOG_TEXT;
>>>> break;
>>>> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
>>>> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
>>>> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
>>>> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
>>>> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>>> + if (msg_flags & SHOW_LOG_CTIME) {
>>>> + time_t t = kt->boot_date.tv_sec + nanos;
>>>> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
>>>> + }
>>>> + else
>>>> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>>>> ilen = strlen(buf);
>>>> fprintf(fp, "%s", buf);
>>>> }
>>>> --
>>>> 1.8.3.1
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> Crash-utility mailing list
>>> Crash-utility(a)redhat.com
>>> https://www.redhat.com/mailman/listinfo/crash-utility
>>>
>>
>>
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Sun, 19 Apr 2020 20:01:12 +0000
>> From: "Moore, Martin (Linux ERT)" <martin.moore(a)hpe.com>
>> To: "Discussion list for crash utility usage, maintenance and
>> development" <crash-utility(a)redhat.com>, "anderson(a)redhat.com"
>> <anderson(a)redhat.com>
>> Subject: Re: [Crash-utility] [PATCH] add log -T option to display the
>> message text with human readable timestamp
>> Message-ID:
>> <AT5PR8401MB05480CDBEEE71C6F900654B991D70(a)AT5PR8401MB0548.NAMPRD84.PROD.OUTLOOK.COM>
>>
>> Content-Type: text/plain; charset=WINDOWS-1252
>>
>> Just to mention an alternative possibility, the pykdump extension to crash (https://sourceforge.net/projects/pykdump/) includes the 'tslog' command to accomplish this.
>>
>> Martin Moore
>> Linux Engineering Resolution Team
>> HPE Pointnext Services
>> Hewlett Packard Enterprise
>>
>> Martin.Moore(a)hpe.com?
>> 8AM-5PM EDT (GMT-4) Monday-Friday
>> Manager: Becky McBride (becky.mcbride(a)hpe.com)
>>
>> -----Original Message-----
>> From: crash-utility-bounces(a)redhat.com <crash-utility-bounces(a)redhat.com> On Behalf Of Wang Long
>> Sent: Saturday, April 18, 2020 10:21 PM
>> To: anderson(a)redhat.com; crash-utility(a)redhat.com
>> Subject: [Crash-utility] [PATCH] add log -T option to display the message text with human readable timestamp
>>
>> Sometimes, we need to know the accurate time of the log, which helps us analyze the problem.
>>
>> add -T option(like dmesg -T command) for log command to display the message text with human readable timestamp.
>>
>> Signed-off-by: Wang Long <w(a)laoqinren.net>
>> ---
>> defs.h | 2 ++
>> help.c | 28 +++++++++++++++++++++++++++-
>> kernel.c | 22 ++++++++++++++++++++--
>> 3 files changed, 49 insertions(+), 3 deletions(-)
>>
>> diff --git a/defs.h b/defs.h
>> index d8eda5e..1644dbd 100644
>> --- a/defs.h
>> +++ b/defs.h
>> @@ -689,6 +689,7 @@ struct kernel_table { /* kernel data */
>> ulong kernel_module;
>> int mods_installed;
>> struct timespec date;
>> + struct timespec boot_date;
>> char proc_version[BUFSIZE];
>> struct new_utsname utsname;
>> uint kernel_version[3];
>> @@ -5577,6 +5578,7 @@ void dump_log(int); #define SHOW_LOG_DICT (0x2) #define SHOW_LOG_TEXT (0x4) #define SHOW_LOG_AUDIT (0x8)
>> +#define SHOW_LOG_CTIME (0x10)
>> void set_cpu(int);
>> void clear_machdep_cache(void);
>> struct stack_hook *gather_text_list(struct bt_info *); diff --git a/help.c b/help.c index c443cad..1ee70f7 100644
>> --- a/help.c
>> +++ b/help.c
>> @@ -3892,12 +3892,13 @@ NULL
>> char *help_log[] = {
>> "log",
>> "dump system message buffer",
>> -"[-tdma]",
>> +"[-Ttdma]",
>> " This command dumps the kernel log_buf contents in chronological order. The", " command supports the older log_buf formats, which may or may not contain a", " timestamp inserted prior to each message, as well as the newer variable-length", " record format, where the timestamp is contained in each log entry's header.", " ",
>> +" -T Display the message text with human readable timestamp.",
>> " -t Display the message text without the timestamp; only applicable to the",
>> " variable-length record format.",
>> " -d Display the dictionary of key/value pair properties that are optionally",
>> @@ -4031,6 +4032,31 @@ char *help_log[] = {
>> " type=1307 audit(1489384479.809:4346): cwd=\"/proc\"",
>> " ...",
>> " ",
>> +" Display the message text with human readable timestamp.\n"
>> +" %s> log -T",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved",
>> +" [Sat Apr 4 07:41:09 2020] BIOS-e820: [mem 0x0000000100000000-0x000000011fffffff] usable",
>> +" [Sat Apr 4 07:41:09 2020] NX (Execute Disable) protection: active",
>> +" [Sat Apr 4 07:41:09 2020] SMBIOS 2.5 present.",
>> +" [Sat Apr 4 07:41:09 2020] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006",
>> +" [Sat Apr 4 07:41:09 2020] Hypervisor detected: KVM",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: Using msrs 4b564d01 and 4b564d00",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: cpu 0, msr 6de01001, primary cpu clock",
>> +" [Sat Apr 4 07:41:09 2020] kvm-clock: using sched offset of 11838753697 cycles",
>> +" [Sat Apr 4 07:41:09 2020] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns",
>> +" [Sat Apr 4 07:41:09 2020] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved",
>> +" [Sat Apr 4 07:41:09 2020] e820: remove [mem 0x000a0000-0x000fffff] usable",
>> +" [Sat Apr 4 07:41:09 2020] last_pfn = 0x120000 max_arch_pfn = 0x400000000",
>> +" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
>> +" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
>> +" ...",
>> NULL
>> };
>>
>> diff --git a/kernel.c b/kernel.c
>> index 7604fac..016d8d9 100644
>> --- a/kernel.c
>> +++ b/kernel.c
>> @@ -111,6 +111,8 @@ kernel_init()
>> char *irq_desc_type_name;
>> ulong pv_init_ops;
>> struct gnu_request req;
>> + ulonglong uptime_jiffies;
>> + ulong uptime_sec;
>>
>> if (pc->flags & KERNEL_DEBUG_QUERY)
>> return;
>> @@ -294,6 +296,14 @@ kernel_init()
>> } else
>> error(INFO, "cannot determine base kernel version\n");
>>
>> + get_uptime(NULL, &uptime_jiffies);
>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>> + kt->boot_date.tv_nsec = 0;
>> +
>> + if (CRASHDEBUG(1))
>> + fprintf(fp, "boot_date: %lx: %s\n",
>> + kt->boot_date.tv_sec,
>> +strip_linefeeds(ctime(&kt->boot_date.tv_sec)));
>>
>> verify_version();
>>
>> @@ -4912,9 +4922,12 @@ cmd_log(void)
>>
>> msg_flags = 0;
>>
>> - while ((c = getopt(argcnt, args, "tdma")) != EOF) {
>> + while ((c = getopt(argcnt, args, "Ttdma")) != EOF) {
>> switch(c)
>> {
>> + case 'T':
>> + msg_flags |= SHOW_LOG_CTIME;
>> + break;
>> case 't':
>> msg_flags |= SHOW_LOG_TEXT;
>> break;
>> @@ -5154,7 +5167,12 @@ dump_log_entry(char *logptr, int msg_flags)
>> if ((msg_flags & SHOW_LOG_TEXT) == 0) {
>> nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
>> rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
>> - sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>> + if (msg_flags & SHOW_LOG_CTIME) {
>> + time_t t = kt->boot_date.tv_sec + nanos;
>> + sprintf(buf, "[%s] ", strip_linefeeds(ctime(&t)));
>> + }
>> + else
>> + sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
>> ilen = strlen(buf);
>> fprintf(fp, "%s", buf);
>> }
>> --
>> 1.8.3.1
>>
>>
>>
>>
>> --
>> Crash-utility mailing list
>> Crash-utility(a)redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
>>
>>
>>
>>
>> ------------------------------
>>
>> --
>> Crash-utility mailing list
>> Crash-utility(a)redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
>>
>> End of Crash-utility Digest, Vol 175, Issue 27
>> **********************************************
>>
>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 175, Issue 28
> **********************************************
>
4 years, 7 months
zram decompress support for gcore/crash-utility
by 赵乾利
Hello list,
When i try to use gcore to parse coredump from fulldump,I got below issue that make the coredump unavailable.
1. Zram is very common feature,in current android system supports zram swap,but gcore/crash-utility does not support,even zram swap can decoded from ram,many page fault due to this reason.
I added zram decompress feature to gcore,and i’m also considering wheather support zram in crash-utility,but for this feature,i have to add miniLZO to codebase, I'm not sure if it's acceptable,plase help give some advice.
miniLZO :miniLZO is a very lightweight subset of the LZO library,Distributed under the terms of the GNU General Public License<http://www.oberhumer.com/opensource/gpl.html> (GPL v2+).
http://www.oberhumer.com/opensource/lzo/
This change is a bit big,I attached it to the mail,if attachment is not available,you can also see these patch in github: https://github.com/zhaoqianli0202/crash-gcore/commits/upstream
Please review.
2. For historical reasons,kernel reserved top 8/16 bytes of stacks,but after kernel-4.14, this reservation was cancelled,so gcore needs to improve compatibility.
kernel change as below:
commit 34be98f4944f99076f049a6806fc5f5207a755d3
Author: Ard Biesheuvel <ard.biesheuvel(a)linaro.org<mailto:ard.biesheuvel@linaro.org>>
Date: Thu Jul 20 17:15:45 2017 +0100
arm64: kernel: remove {THREAD,IRQ_STACK}_START_SP
For historical reasons, we leave the top 16 bytes of our task and IRQ
stacks unused, a practice used to ensure that the SP can always be
masked to find the base of the current stack (historically, where
thread_info could be found).™
====
Patch for this issue:
commit d1031df4617351a58b8edfb0121c306baaa34f9d
Author: zhaoqianli <zhaoqianli(a)xiaomi.com>
Date: Mon Mar 30 12:07:02 2020 +0800
gcore: ARM/ARM64 reserved 8/16 byte in the top of stacks before 4.14,
but this reservation was removed after 4.14
Without this patch,gcore counld't parse full callstack in version after 4.14
diff --git a/gcore.c b/gcore.c
index f75701d..f6e1787 100644
--- a/gcore.c
+++ b/gcore.c
@@ -558,4 +558,16 @@ static void gcore_machdep_init(void)
if (!gcore_arch_vsyscall_has_vm_alwaysdump_flag())
gcore_machdep->vm_alwaysdump = 0x00000000;
+
+#if defined(ARM) || defined(ARM64)
+#ifdef ARM
+#define STACK_RESERVE_SIZE 8
+#else
+#define STACK_RESERVE_SIZE 16
+#endif
+ if (THIS_KERNEL_VERSION >= LINUX(4,14,0))
+ gcore_machdep->stack_reserve = 0;
+ else
+ gcore_machdep->stack_reserve = STACK_RESERVE_SIZE;
+#endif
}
diff --git a/libgcore/gcore_arm.c b/libgcore/gcore_arm.c
index 891d01e..c8aefdf 100644
--- a/libgcore/gcore_arm.c
+++ b/libgcore/gcore_arm.c
@@ -29,7 +29,7 @@ static int gpr_get(struct task_context *target,
BZERO(regs, sizeof(*regs));
- readmem(machdep->get_stacktop(target->task) - 8 - SIZE(pt_regs), KVADDR,
+ readmem(machdep->get_stacktop(target->task) - gcore_machdep->stack_reserve - SIZE(pt_regs), KVADDR,
regs, SIZE(pt_regs), "genregs_get: pt_regs",
gcore_verbose_error_handle());
diff --git a/libgcore/gcore_arm64.c b/libgcore/gcore_arm64.c
index 3257389..ed3fdc8 100644
--- a/libgcore/gcore_arm64.c
+++ b/libgcore/gcore_arm64.c
@@ -28,7 +28,7 @@ static int gpr_get(struct task_context *target,
BZERO(regs, sizeof(*regs));
- readmem(machdep->get_stacktop(target->task) - 16 - SIZE(pt_regs), KVADDR,
+ readmem(machdep->get_stacktop(target->task) - gcore_machdep->stack_reserve - SIZE(pt_regs), KVADDR,
regs, sizeof(struct user_pt_regs), "gpr_get: user_pt_regs",
gcore_verbose_error_handle());
@@ -124,7 +124,7 @@ static int compat_gpr_get(struct task_context *target,
BZERO(&pt_regs, sizeof(pt_regs));
BZERO(regs, sizeof(*regs));
- readmem(machdep->get_stacktop(target->task) - 16 - SIZE(pt_regs), KVADDR,
+ readmem(machdep->get_stacktop(target->task) - gcore_machdep->stack_reserve - SIZE(pt_regs), KVADDR,
&pt_regs, sizeof(struct pt_regs), "compat_gpr_get: pt_regs",
gcore_verbose_error_handle());
diff --git a/libgcore/gcore_defs.h b/libgcore/gcore_defs.h
index b0f5603..f31036c 100644
--- a/libgcore/gcore_defs.h
+++ b/libgcore/gcore_defs.h
@@ -1177,6 +1177,7 @@ extern struct gcore_size_table gcore_size_table;
struct gcore_machdep_table
{
ulong vm_alwaysdump;
+ uint8_t stack_reserve;
};
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
4 years, 7 months
[PATCH] Add REFRESH_TASK_TABLE flag to mount command
by Wang Long
when we launch a crash first and then create a docker container.
now we run mount command to see the mount namespaces info, we get
the error:
crash> mount -n 2020
mount: invalid task or pid value: 2020
This patch fix it by add REFRESH_TASK_TABLE flag to mount command.
Signed-off-by: Wang Long <w(a)laoqinren.net>
---
global_data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/global_data.c b/global_data.c
index cbacc42..a316d1c 100644
--- a/global_data.c
+++ b/global_data.c
@@ -93,7 +93,7 @@ struct command_table_entry linux_command_table[] = {
{"mach", cmd_mach, help_mach, 0},
{"map", cmd_map, help_map, HIDDEN_COMMAND},
{"mod", cmd_mod, help_mod, 0},
- {"mount", cmd_mount, help_mount, 0},
+ {"mount", cmd_mount, help_mount, REFRESH_TASK_TABLE},
{"net", cmd_net, help_net, REFRESH_TASK_TABLE},
{"p", cmd_p, help_p, 0},
{"ps", cmd_ps, help_ps, REFRESH_TASK_TABLE},
--
1.8.3.1
4 years, 7 months
[PATCH] fix "kmem -[sS]" for caches created during SLUB bootstrap
by Hari Bathini
Fix for "kmem -[sS]" options on Linux 4.14 and later kernels built
with CONFIG_SLAB_FREELIST_HARDENED enabled. Without the patch, there
will error messages of the type "kmem: <cache name> slab: <address>
invalid freepointer: <obfuscated address>" for caches created during
SLUB bootstrap, as they are likely to have s->random == 0.
Signed-off-by: Hari Bathini <hbathini(a)linux.ibm.com>
---
memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/memory.c b/memory.c
index ccc2944..c2433eb 100644
--- a/memory.c
+++ b/memory.c
@@ -19244,7 +19244,7 @@ count_free_objects(struct meminfo *si, ulong freelist)
static ulong
freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr)
{
- if (si->random)
+ if (VALID_MEMBER(kmem_cache_random))
/* CONFIG_SLAB_FREELIST_HARDENED */
return (ptr ^ si->random ^ ptr_addr);
else
4 years, 7 months
[PATCH] raw_data_dump: display only 8/16/32 bits if requested
by Dominique Martinet
Previously, calling raw_data_dump() with e.g. len 4 on 64bit systems
would dump 8 bytes anyway, making it hard to tell what one wants to see.
For example, with task_struct.rt_priority a uint32.
before patch:
crash> struct -r task_struct.rt_priority ffff8d9b36186180
ffff8d9b361861dc: 9741dec000000063 c.....A.
after patch:
crash-patched> struct -r task_struct.rt_priority ffff8d9b36186180
ffff8d9b361861dc: 00000063 c...
---
Here's the promised follow-up.
Two remarks:
- I wasn't sure about an explicit DISPLAY_64 flag, but if we're 32bit
and want to print 8 bytes it is just as likely to be two entities than
a single one so it makes more sense to leave default to me.
- I wasn't sure on what to do if someone wants to print some odd size,
e.g. 6 bits? Should that be DISPLAY_8 anyway?
I tried on some bitmap and it looks like raw_data_dump is called with 8
anyway even if the bitmap part is less than 8, I'm not sure this can
ever be called with weird values, so probably best left as is.
Thanks!
memory.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/memory.c b/memory.c
index 4f7b6a0..ccc2944 100644
--- a/memory.c
+++ b/memory.c
@@ -2113,6 +2113,7 @@ raw_data_dump(ulong addr, long count, int symbolic)
long wordcnt;
ulonglong address;
int memtype;
+ ulong flags = HEXADECIMAL;
switch (sizeof(long))
{
@@ -2132,6 +2133,22 @@ raw_data_dump(ulong addr, long count, int symbolic)
break;
}
+ switch (count)
+ {
+ case SIZEOF_8BIT:
+ flags |= DISPLAY_8;
+ break;
+ case SIZEOF_16BIT:
+ flags |= DISPLAY_16;
+ break;
+ case SIZEOF_32BIT:
+ flags |= DISPLAY_32;
+ break;
+ default:
+ flags |= DISPLAY_DEFAULT;
+ break;
+ }
+
if (pc->curcmd_flags & MEMTYPE_FILEADDR) {
address = pc->curcmd_private;
memtype = FILEADDR;
@@ -2144,7 +2161,7 @@ raw_data_dump(ulong addr, long count, int symbolic)
}
display_memory(address, wordcnt,
- HEXADECIMAL|DISPLAY_DEFAULT|(symbolic ? SYMBOLIC : ASCII_ENDLINE),
+ flags|(symbolic ? SYMBOLIC : ASCII_ENDLINE),
memtype, NULL);
}
--
2.26.0
4 years, 7 months
Faster iteration on list of struct.field
by Dominique Martinet
Hi,
I often find myself dumping a bunch of addresses to files to iterate
with 'struct_name.field < file_with_addresses', but that is horribly
slow for large number of iterations.
`help list` comment for -S vs. -s made me try to use `rd` instead,
e.g. get offset manually from `struct -o` then use rd instead like
`rd -o xx < addr_list | awk '{ print $2 }' > value_list` -- and that is
infinitely better.
Would it make sense to add a similar option to 'struct' instead so one
could do e.g. `struct -S struct_name.field addr` instead of the dance I
was doing?
(That would require to cache field offset in crash and not query it
again everytime, from a quick look at the code, but we could only cache
one and still gain a lot for such iterations...)
Am I missing another more practical way of doing this?
(I guess it's not so bad now I came up with using 'rd', but that was
non-obvious to me. My use case here involved following a couple of
pointers from a list so I dumped the first pointer to follow from list
with -S struct1.field1, but then the following iteration just wouldn't
end naively)
Thanks,
--
Dominique
4 years, 7 months