ATLAS Offline Software
Tools
GdbUtils
python
offsets.py
Go to the documentation of this file.
1
# noqa: ATL902
2
# origin: https://github.com/PhilArmstrong/pahole-gdb
3
# Original licenced under GPLv3.
4
#
5
# File: GdbUtils/python/offsets.py
6
# Purpose: Dump the offsets of fields in a structure.
7
#
8
9
import
gdb
10
11
class
Offsets
(gdb.Command):
12
"""Dump offsets of members in a structure type."""
13
14
def
__init__
(self):
15
super (Offsets, self).__init__ (
'offsets-of'
, gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL)
16
17
def
invoke
(self, arg, from_tty):
18
argv = gdb.string_to_argv(arg)
19
if
len(argv) != 1:
20
raise
gdb.GdbError(
'offsets-of takes exactly 1 argument.'
)
21
22
stype = gdb.lookup_type(argv[0])
23
24
print
(argv[0],
'{'
)
25
for
field
in
stype.fields():
26
print
(
' %s => %d'
% (field.name, field.bitpos//8))
27
print
(
'}'
)
28
29
Offsets
()
python.offsets.Offsets.invoke
def invoke(self, arg, from_tty)
Definition:
offsets.py:17
python.offsets.Offsets.__init__
def __init__(self)
Definition:
offsets.py:14
python.offsets.Offsets
Definition:
offsets.py:11
Generated on Mon Sep 29 2025 21:16:12 for ATLAS Offline Software by
1.8.18