Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BIRD Internet Routing Daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
d4bf7481
Commit
d4bf7481
authored
Feb 18, 2019
by
Maria Matejka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GDB: Added more pretty printers for filters
parent
ea4f55e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
1 deletion
+70
-1
bird-gdb.py
bird-gdb.py
+70
-1
No files found.
bird-gdb.py
View file @
d4bf7481
...
...
@@ -59,6 +59,19 @@ class BIRDFValPrinter(BIRDPrinter):
def
display_hint
(
self
):
return
"map"
class
BIRDFValStackPrinter
(
BIRDPrinter
):
"Print BIRD's struct f_val_stack"
typeCode
=
gdb
.
TYPE_CODE_STRUCT
typeTag
=
"f_val_stack"
def
to_string
(
self
):
cnt
=
self
.
val
[
'cnt'
]
return
(
"Value stack (%(cnt)d):
\n\t
"
%
{
"cnt"
:
cnt
})
+
\
"
\n\t
"
.
join
([
(
".val[%(n) 3d] = "
%
{
"n"
:
n
})
+
str
(
self
.
val
[
'val'
][
n
])
for
n
in
range
(
cnt
-
1
,
-
1
,
-
1
)
])
def
display_hint
(
self
):
return
"map"
class
BIRDFInstPrinter
(
BIRDPrinter
):
"Print BIRD's struct f_inst"
typeCode
=
gdb
.
TYPE_CODE_STRUCT
...
...
@@ -68,16 +81,72 @@ class BIRDFInstPrinter(BIRDPrinter):
code
=
self
.
val
[
'fi_code'
]
if
str
(
code
)
==
"FI_NOP"
:
return
str
(
code
)
+
": "
+
str
(
self
.
val
.
cast
(
gdb
.
lookup_type
(
"const char [%(siz)d]"
%
{
"siz"
:
self
.
val
.
type
.
sizeof
})))
return
str
(
code
)
+
": "
+
str
(
self
.
val
[
'i_'
+
str
(
code
)])
return
"%(code)s:
\t
%(lineno) 6dL
\t
%(size)6dS
\t
next = %(next)s: .i_%(code)s = %(union)s"
%
{
"code"
:
str
(
code
),
"lineno"
:
self
.
val
[
'lineno'
],
"size"
:
self
.
val
[
'size'
],
"next"
:
str
(
self
.
val
[
'next'
]),
"union"
:
str
(
self
.
val
[
'i_'
+
str
(
code
)])
}
# def children(self): # children iterator
def
display_hint
(
self
):
return
"map"
class
BIRDFLineItemPrinter
(
BIRDPrinter
):
"Print BIRD's struct f_line_item"
typeCode
=
gdb
.
TYPE_CODE_STRUCT
typeTag
=
"f_line_item"
def
to_string
(
self
):
code
=
self
.
val
[
'fi_code'
]
if
str
(
code
)
==
"FI_NOP"
:
return
str
(
code
)
+
": "
+
str
(
self
.
val
.
cast
(
gdb
.
lookup_type
(
"const char [%(siz)d]"
%
{
"siz"
:
self
.
val
.
type
.
sizeof
})))
return
"%(code)s:
\t
%(lineno) 6dL
\t
%(flags)2dF: .i_%(code)s = %(union)s"
%
{
"code"
:
str
(
code
),
"lineno"
:
self
.
val
[
'lineno'
],
"flags"
:
self
.
val
[
'flags'
],
"union"
:
str
(
self
.
val
[
'i_'
+
str
(
code
)])
}
class
BIRDFLinePrinter
(
BIRDPrinter
):
"Print BIRD's struct f_line"
typeCode
=
gdb
.
TYPE_CODE_STRUCT
typeTag
=
"f_line"
def
to_string
(
self
):
cnt
=
self
.
val
[
'len'
]
return
(
"FLine (%(cnt)d, args=%(args)d): "
%
{
"cnt"
:
cnt
,
"args"
:
self
.
val
[
'args'
]
}
+
\
", "
.
join
([
".items[%(n) 3d] = %(code)s"
%
{
"n"
:
n
,
"code"
:
str
(
self
.
val
[
'items'
][
n
][
'fi_code'
]),
}
if
n
%
8
==
0
else
str
(
self
.
val
[
'items'
][
n
][
'fi_code'
])
for
n
in
range
(
cnt
)]))
class
BIRDFExecStackPrinter
(
BIRDPrinter
):
"Print BIRD's struct f_exec_stack"
typeCode
=
gdb
.
TYPE_CODE_STRUCT
typeTag
=
"f_exec_stack"
def
to_string
(
self
):
cnt
=
self
.
val
[
'cnt'
]
return
(
"Exec stack (%(cnt)d):
\n\t
"
%
{
"cnt"
:
cnt
})
+
\
"
\n\t
"
.
join
([
".item[%(n) 3d] = %(retflag)d V%(ventry) 3d P%(pos) 4d %(line)s"
%
{
"retflag"
:
self
.
val
[
'item'
][
n
][
'emask'
],
"ventry"
:
self
.
val
[
'item'
][
n
][
'ventry'
],
"pos"
:
self
.
val
[
'item'
][
n
][
'pos'
],
"line"
:
str
(
self
.
val
[
'item'
][
n
][
'line'
].
dereference
()),
"n"
:
n
}
for
n
in
range
(
cnt
-
1
,
-
1
,
-
1
)
])
def
register_printers
(
objfile
):
objfile
.
pretty_printers
.
append
(
BIRDFInstPrinter
.
lookup
)
objfile
.
pretty_printers
.
append
(
BIRDFValPrinter
.
lookup
)
objfile
.
pretty_printers
.
append
(
BIRDFValStackPrinter
.
lookup
)
objfile
.
pretty_printers
.
append
(
BIRDFLineItemPrinter
.
lookup
)
objfile
.
pretty_printers
.
append
(
BIRDFLinePrinter
.
lookup
)
objfile
.
pretty_printers
.
append
(
BIRDFExecStackPrinter
.
lookup
)
register_printers
(
gdb
.
current_objfile
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment