Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kuan-Ying Lee and committed by
Andrew Morton
4d040cbc 82141540

+20
+20
scripts/gdb/linux/utils.py
··· 35 35 36 36 37 37 long_type = CachedType("long") 38 + ulong_type = CachedType("unsigned long") 39 + uint_type = CachedType("unsigned int") 38 40 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() 39 51 40 52 def get_long_type(): 41 53 global long_type 42 54 return long_type.get_type() 55 + 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() 43 63 44 64 def offset_of(typeobj, field): 45 65 element = gdb.Value(0).cast(typeobj)