[1/2,next] scripts/gdb: add utils.read_ulong()
diff mbox series

Message ID 20200814212525.6118-2-john.ogness@linutronix.de
State In Next
Commit 6ccd3a9318375ccc5d4568de0c00b7474a3c59f2
Headers show
Series
  • update gdb scripts for lockless printk ringbuffer
Related show

Commit Message

John Ogness Aug. 14, 2020, 9:25 p.m. UTC
Add a function for reading unsigned long values, which vary in size
depending on the architecture.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---

 based on next-20200814

 scripts/gdb/linux/utils.py | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Nick Desaulniers Aug. 14, 2020, 10:29 p.m. UTC | #1
On Fri, Aug 14, 2020 at 2:25 PM John Ogness <john.ogness@linutronix.de> wrote:
>
> Add a function for reading unsigned long values, which vary in size
> depending on the architecture.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

/me wonders if there's any non-ILP32 or LP64 ARCH='s supported by the kernel.

> ---
>
>  based on next-20200814
>
>  scripts/gdb/linux/utils.py | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
> index ea94221dbd39..ff7c1799d588 100644
> --- a/scripts/gdb/linux/utils.py
> +++ b/scripts/gdb/linux/utils.py
> @@ -123,6 +123,13 @@ def read_u64(buffer, offset):
>          return read_u32(buffer, offset + 4) + (read_u32(buffer, offset) << 32)
>
>
> +def read_ulong(buffer, offset):
> +    if get_long_type().sizeof == 8:
> +        return read_u64(buffer, offset)
> +    else:
> +        return read_u32(buffer, offset)
> +
> +
>  target_arch = None
>
>
> --
> 2.20.1
>

Patch
diff mbox series

diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index ea94221dbd39..ff7c1799d588 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -123,6 +123,13 @@  def read_u64(buffer, offset):
         return read_u32(buffer, offset + 4) + (read_u32(buffer, offset) << 32)
 
 
+def read_ulong(buffer, offset):
+    if get_long_type().sizeof == 8:
+        return read_u64(buffer, offset)
+    else:
+        return read_u32(buffer, offset)
+
+
 target_arch = None