Re: [PATCH] scripts/gdb: fix 'lx-dmesg' on 32 bits arch

From: Petr Mladek
Date: Thu Jun 30 2022 - 09:13:30 EST


On Fri 2022-06-17 16:37:58, Antonio Borneo wrote:
> The type atomic_long_t can have size 4 or 8 bytes, depending on
> CONFIG_64BIT; it's only content, the field 'counter', is either an
> int or a s64 value.
>
> Current code incorrectly uses the fixed size utils.read_u64() to
> read the field 'counter' inside atomic_long_t.
>
> On 32 bits architectures reading the last element 'tail_id' of the
> struct prb_desc_ring:
> struct prb_desc_ring {
> ...
> atomic_long_t tail_id;
> };
> causes the utils.read_u64() to access outside the boundary of the
> struct and the gdb command 'lx-dmesg' exits with error:
> Python Exception <class 'IndexError'>: index out of range
> Error occurred in Python: index out of range
>
> Use the existing utils.read_ulong() to read 'counter' inside the
> atomic_long_t.

I was about to accept this. But then I wondered if we could somehow
detect the really used atomic_long_t counter type size.

I have updated your patch. It works for me on x86_64.
Could you please check it on 32-bit system?

Here is the patch: