Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 from __future__ import print_function
10 import gdb
11 
12 class Offsets(gdb.Command):
13  """Dump offsets of members in a structure type."""
14 
15  def __init__(self):
16  super (Offsets, self).__init__ ('offsets-of', gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL)
17 
18  def invoke(self, arg, from_tty):
19  argv = gdb.string_to_argv(arg)
20  if len(argv) != 1:
21  raise gdb.GdbError('offsets-of takes exactly 1 argument.')
22 
23  stype = gdb.lookup_type(argv[0])
24 
25  print (argv[0], '{')
26  for field in stype.fields():
27  print (' %s => %d' % (field.name, field.bitpos//8))
28  print ('}')
29 
30 Offsets()
python.offsets.Offsets.invoke
def invoke(self, arg, from_tty)
Definition: offsets.py:18
python.offsets.Offsets.__init__
def __init__(self)
Definition: offsets.py:15
python.offsets.Offsets
Definition: offsets.py:12