Skip to content

Commit 4d040cb

Browse files
Kuan-Ying Leeakpm00
authored andcommitted
scripts/gdb/utils: add common type usage
Since we often use 'unsigned long', 'size_t', 'usigned int' and 'struct page', we add these common types to utils. Link: https://lkml.kernel.org/r/20230808083020.22254-4-Kuan-Ying.Lee@mediatek.com Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: Chinwen Chang <chinwen.chang@mediatek.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 8214154 commit 4d040cb

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

scripts/gdb/linux/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,32 @@ def get_type(self):
3535

3636

3737
long_type = CachedType("long")
38+
ulong_type = CachedType("unsigned long")
39+
uint_type = CachedType("unsigned int")
3840
atomic_long_type = CachedType("atomic_long_t")
41+
size_t_type = CachedType("size_t")
42+
struct_page_type = CachedType("struct page")
43+
44+
def get_uint_type():
45+
global uint_type
46+
return uint_type.get_type()
47+
48+
def get_page_type():
49+
global struct_page_type
50+
return struct_page_type.get_type()
3951

4052
def get_long_type():
4153
global long_type
4254
return long_type.get_type()
4355

56+
def get_ulong_type():
57+
global ulong_type
58+
return ulong_type.get_type()
59+
60+
def get_size_t_type():
61+
global size_t_type
62+
return size_t_type.get_type()
63+
4464
def offset_of(typeobj, field):
4565
element = gdb.Value(0).cast(typeobj)
4666
return int(str(element[field].address).split()[0], 16)

0 commit comments

Comments
 (0)