]>
git.ipfire.org Git - thirdparty/bird.git/blob - bird-gdb.py
2 def __init__(self
, val
):
7 if val
.type.code
!= cls
.typeCode
:
9 if val
.type.tag
!= cls
.typeTag
:
15 class BIRDFValPrinter(BIRDPrinter
):
16 "Print BIRD\s struct f_val"
17 typeCode
= gdb
.TYPE_CODE_STRUCT
26 "T_ENUM_BGP_ORIGIN": "i",
31 "T_ENUM_NETTYPE": "i",
32 "T_ENUM_RA_PREFERENCE": "i",
36 "T_PATH_MASK": "path_mask",
44 "T_PATH_MASK_ITEM": "pmi",
50 code
= self
.val
['type']
51 if code
.type.code
!= gdb
.TYPE_CODE_ENUM
or code
.type.tag
!= "f_type":
52 raise Exception("Strange 'type' element in f_val")
54 if str(code
) == "T_VOID":
57 return "(%(c)s) %(v)s" % { "c": code
, "v": self
.val
['val'][self
.codemap
[str(code
)]] }
59 def display_hint(self
):
62 class BIRDFInstPrinter(BIRDPrinter
):
63 "Print BIRD's struct f_inst"
64 typeCode
= gdb
.TYPE_CODE_STRUCT
68 code
= self
.val
['fi_code']
69 if str(code
) == "FI_NOP":
70 return str(code
) + ": " + str(self
.val
.cast(gdb
.lookup_type("const char [%(siz)d]" % { "siz": self
.val
.type.sizeof
})))
71 return str(code
) + ": " + str(self
.val
['i_' + str(code
)])
73 # def children(self): # children iterator
74 def display_hint(self
):
78 def register_printers(objfile
):
79 objfile
.pretty_printers
.append(BIRDFInstPrinter
.lookup
)
80 objfile
.pretty_printers
.append(BIRDFValPrinter
.lookup
)
82 register_printers(gdb
.current_objfile())
84 print("BIRD pretty printers loaded OK.")