lkml.org 
[lkml]   [2021]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] scripts/gdb: fix 'lx-symbols' section parsing
Date
Loading a module using 'lx-symbols' in GDB would result in a
gdb.MemoryError when parsing the section names and addresses because of
the way GDB handles flexible array members. This patch fixes that issue
by converting the 'struct module_sect_attr[]' into a pointer before
accessing it.

Signed-off-by: Julian Blaauboer <julian.blaauboer@gmail.com>
---
scripts/gdb/linux/symbols.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index 1be9763cf8bb..6d3a33a00189 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -94,7 +94,8 @@ lx-symbols command."""
sect_attrs = module['sect_attrs'].dereference()
except gdb.error:
return ""
- attrs = sect_attrs['attrs']
+ # Convert from struct module_sect_attr[] to struct module_sect_attr*
+ attrs = sect_attrs['attrs'].dereference().address
section_name_to_address = {
attrs[n]['battr']['attr']['name'].string(): attrs[n]['address']
for n in range(int(sect_attrs['nsections']))}
--
2.30.1
\
 
 \ /
  Last update: 2021-02-23 15:12    [W:0.029 / U:3.960 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site