Re: [PATCH] scripts/gdb: fix lx-dmesg when CONFIG_PRINTK_CALLER is set
On 10.10.2019 18:14, Jan Kiszka wrote: > On 25.09.19 17:03, Joel Colledge wrote: >> When CONFIG_PRINTK_CALLER is set, struct printk_log contains an >> additional member caller_id. As a result, the offset of the log text is >> different. >> >> This fixes the following error: >> >>(gdb) lx-dmesg >>Python Exception embedded null character: >>Error occurred in Python command: embedded null character >> >> Signed-off-by: Joel Colledge >> --- >> scripts/gdb/linux/constants.py.in | 1 + >> scripts/gdb/linux/dmesg.py| 4 +++- >> 2 files changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/scripts/gdb/linux/constants.py.in >> b/scripts/gdb/linux/constants.py.in >> index 2efbec6b6b8d..3c9794a0bf55 100644 >> --- a/scripts/gdb/linux/constants.py.in >> +++ b/scripts/gdb/linux/constants.py.in >> @@ -74,4 +74,5 @@ LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) >> LX_CONFIG(CONFIG_HIGH_RES_TIMERS) >> LX_CONFIG(CONFIG_NR_CPUS) >> LX_CONFIG(CONFIG_OF) >> +LX_CONFIG(CONFIG_PRINTK_CALLER) >> LX_CONFIG(CONFIG_TICK_ONESHOT) >> diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py >> index 6d2e09a2ad2f..1352680ef731 100644 >> --- a/scripts/gdb/linux/dmesg.py >> +++ b/scripts/gdb/linux/dmesg.py >> @@ -14,6 +14,7 @@ >> import gdb >> import sys >> >> +from linux import constants >> from linux import utils >> >> >> @@ -53,7 +54,8 @@ class LxDmesg(gdb.Command): >> continue >> >> text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) >> -text = log_buf[pos + 16:pos + 16 + text_len].decode( >> +text_start = pos + (20 if constants.LX_CONFIG_PRINTK_CALLER >> else 16) >> +text = log_buf[text_start:text_start + text_len].decode( >> encoding='utf8', errors='replace') >> time_stamp = utils.read_u64(log_buf[pos:pos + 8]) > > Sorry for the delay: > > Reviewed-by: Jan Kiszka > > I suspect we will see more in nearer future with upcoming printk rework... The patch looks correct but I'm curious: is there a reason this code doesn't use struct printk_log? GDB already knows about struct offsets so there should be no need to handle ifdefs with arithmetic. Is it realistic to use gdb without struct layout info? -- Regards, Leonard
Re: [PATCH] scripts/gdb: fix lx-dmesg when CONFIG_PRINTK_CALLER is set
On 25.09.19 17:03, Joel Colledge wrote: > When CONFIG_PRINTK_CALLER is set, struct printk_log contains an > additional member caller_id. As a result, the offset of the log text is > different. > > This fixes the following error: > > (gdb) lx-dmesg > Python Exception embedded null character: > Error occurred in Python command: embedded null character > > Signed-off-by: Joel Colledge > --- > scripts/gdb/linux/constants.py.in | 1 + > scripts/gdb/linux/dmesg.py| 4 +++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/scripts/gdb/linux/constants.py.in > b/scripts/gdb/linux/constants.py.in > index 2efbec6b6b8d..3c9794a0bf55 100644 > --- a/scripts/gdb/linux/constants.py.in > +++ b/scripts/gdb/linux/constants.py.in > @@ -74,4 +74,5 @@ LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) > LX_CONFIG(CONFIG_HIGH_RES_TIMERS) > LX_CONFIG(CONFIG_NR_CPUS) > LX_CONFIG(CONFIG_OF) > +LX_CONFIG(CONFIG_PRINTK_CALLER) > LX_CONFIG(CONFIG_TICK_ONESHOT) > diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py > index 6d2e09a2ad2f..1352680ef731 100644 > --- a/scripts/gdb/linux/dmesg.py > +++ b/scripts/gdb/linux/dmesg.py > @@ -14,6 +14,7 @@ > import gdb > import sys > > +from linux import constants > from linux import utils > > > @@ -53,7 +54,8 @@ class LxDmesg(gdb.Command): > continue > > text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) > -text = log_buf[pos + 16:pos + 16 + text_len].decode( > +text_start = pos + (20 if constants.LX_CONFIG_PRINTK_CALLER else > 16) > +text = log_buf[text_start:text_start + text_len].decode( > encoding='utf8', errors='replace') > time_stamp = utils.read_u64(log_buf[pos:pos + 8]) > > Sorry for the delay: Reviewed-by: Jan Kiszka I suspect we will see more in nearer future with upcoming printk rework... Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Re: [PATCH] scripts/gdb: fix lx-dmesg when CONFIG_PRINTK_CALLER is set
Hi Jan and Kieran, maintainers of scripts/gdb/, CC: Leonard, most recent contributor to scripts/gdb/linux/dmesg.py Could someone look at this fix please? Is there anything I should improve in the code or the format of the contribution? Thanks.