FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
voltron/tests/lldb_api_tests.py at master · nutsi/voltron · GitHub
nutsi
/
voltron
Public
forked from
snare/voltron
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
voltron
/
tests
/
lldb_api_tests.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
165 lines (134 loc) · 4.71 KB
Breadcrumbs
voltron
/
tests
/
lldb_api_tests.py
Copy path
File metadata and controls
165 lines (134 loc) · 4.71 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"""
Tests that exercise the LLDB backend directly by loading an inferior and then
poking at it with the LLDBAdaptor class.
Tests:
LLDBAdaptor
"""
import
tempfile
import
sys
import
json
import
time
import
logging
import
subprocess
import
threading
from
mock
import
Mock
from
nose
.
tools
import
*
import
voltron
from
voltron
.
core
import
*
from
voltron
.
api
import
*
from
voltron
.
plugin
import
PluginManager
,
DebuggerAdaptorPlugin
import
platform
if
platform
.
system
()
==
'Darwin'
:
sys
.
path
.
append
(
"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python"
)
try
:
import
lldb
from
common
import
*
voltron
.
setup_env
()
log
=
logging
.
getLogger
(
'tests'
)
def
setup
():
global
adaptor
,
dbg
,
target
log
.
info
(
"setting up LLDB API tests"
)
# create an LLDBAdaptor
pm
=
PluginManager
()
plugin
=
pm
.
debugger_plugin_for_host
(
'lldb'
)
adaptor
=
plugin
.
adaptor_class
()
# compile and load the test inferior
subprocess
.
call
(
"cc -o tests/inferior tests/inferior.c"
,
shell
=
True
)
target
=
adaptor
.
host
.
CreateTargetWithFileAndArch
(
"tests/inferior"
,
lldb
.
LLDB_ARCH_DEFAULT
)
main_bp
=
target
.
BreakpointCreateByName
(
"main"
,
target
.
GetExecutable
().
GetFilename
())
def
teardown
():
time
.
sleep
(
2
)
def
test_version
():
assert
'lldb'
in
adaptor
.
version
()
def
test_state_invalid
():
try
:
adaptor
.
state
()
exception
=
False
except
NoSuchTargetException
:
exception
=
True
except
:
exception
=
False
assert
exception
def
test_targets_not_running
():
t
=
adaptor
.
targets
()[
0
]
assert
t
[
"state"
]
==
"invalid"
assert
t
[
"arch"
]
==
"x86_64"
assert
t
[
"id"
]
==
0
assert
len
(
t
[
"file"
])
>
0
assert
'inferior'
in
t
[
"file"
]
def
test_targets_stopped
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
t
=
adaptor
.
targets
()[
0
]
assert
t
[
"state"
]
==
"stopped"
process
.
Destroy
()
def
test_registers
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
regs
=
adaptor
.
registers
()
assert
regs
is
not
None
assert
len
(
regs
)
>
0
assert
regs
[
'rip'
]
!=
0
process
.
Destroy
()
def
test_stack_pointer
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
sp
=
adaptor
.
stack_pointer
()
assert
sp
!=
0
process
.
Destroy
()
def
test_program_counter
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
pc_name
,
pc
=
adaptor
.
program_counter
()
assert
pc
!=
0
process
.
Destroy
()
def
test_memory
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
regs
=
adaptor
.
registers
()
mem
=
adaptor
.
memory
(
address
=
regs
[
'rip'
],
length
=
0x40
)
assert
len
(
mem
)
==
0x40
process
.
Destroy
()
def
test_stack
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
stack
=
adaptor
.
stack
(
length
=
0x40
)
assert
len
(
stack
)
==
0x40
process
.
Destroy
()
def
test_disassemble
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
output
=
adaptor
.
disassemble
(
count
=
0x20
)
assert
len
(
output
)
>
0
process
.
Destroy
()
def
test_command
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
output
=
adaptor
.
command
(
"reg read"
)
assert
len
(
output
)
>
0
assert
'rax'
in
output
process
.
Destroy
()
def
test_dereference_main
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
regs
=
adaptor
.
registers
()
output
=
adaptor
.
dereference
(
regs
[
'rip'
])
assert
(
'symbol'
,
'main + 0x0'
)
in
output
process
.
Destroy
()
def
test_dereference_rsp
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
regs
=
adaptor
.
registers
()
output
=
adaptor
.
dereference
(
regs
[
'rsp'
])
assert
(
'symbol'
,
'start + 0x1'
)
in
output
process
.
Destroy
()
def
test_dereference_string
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
regs
=
adaptor
.
registers
()
output
=
adaptor
.
dereference
(
regs
[
'rsp'
]
+
0x20
)
assert
'inferior'
in
list
(
output
[
-
1
])[
-
1
]
process
.
Destroy
()
def
test_breakpoints
():
process
=
target
.
LaunchSimple
(
None
,
None
,
os
.
getcwd
())
bps
=
adaptor
.
breakpoints
()
assert
len
(
bps
)
==
1
assert
bps
[
0
][
'one_shot'
]
==
False
assert
bps
[
0
][
'enabled'
]
assert
bps
[
0
][
'id'
]
==
1
assert
bps
[
0
][
'hit_count'
]
>
0
assert
bps
[
0
][
'locations'
][
0
][
'name'
]
==
"inferior`main"
process
.
Destroy
()
def
test_capabilities
():
assert
adaptor
.
capabilities
()
==
[
'async'
]
except
:
print
(
"No LLDB"
)
Back
|
FazBrowse Home
|
New Git URL