libdebug.state.thread_context
ThreadContext
This object represents a thread in the context of the target process. It holds information about the thread's state, registers and stack.
Source code in libdebug/state/thread_context.py
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 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
dead: bool
property
Whether the thread is dead.
debugger: Debugger
property
The debugging context this thread belongs to.
exit_code: int | None
property
The thread's exit code.
exit_signal: str | None
property
The thread's exit signal.
instruction_pointer: int
instance-attribute
The thread's instruction pointer.
mem: AbstractMemoryView
property
Alias for the memory
property.
Get the memory view of the process.
memory: AbstractMemoryView
property
The memory view of the debugged process.
pid: int
property
Alias for process_id
property.
The process ID.
process_id: int
property
The process ID.
regs: Registers = regs_class(thread_id, self._register_holder.provide_regs())
instance-attribute
The thread's registers.
running: bool
property
Whether the process is running.
saved_ip: int
property
The return address of the current function.
signal: str | None
property
writable
The signal will be forwarded to the thread.
signal_number: int
property
The signal number to forward to the thread.
syscall_arg0: int
instance-attribute
The thread's syscall argument 0.
syscall_arg1: int
instance-attribute
The thread's syscall argument 1.
syscall_arg2: int
instance-attribute
The thread's syscall argument 2.
syscall_arg3: int
instance-attribute
The thread's syscall argument 3.
syscall_arg4: int
instance-attribute
The thread's syscall argument 4.
syscall_arg5: int
instance-attribute
The thread's syscall argument 5.
syscall_number: int
instance-attribute
The thread's syscall number.
syscall_return: int
instance-attribute
The thread's syscall return value.
thread_id: int
property
The thread ID.
tid: int
property
The thread ID.
__init__(thread_id, registers)
Initializes the Thread Context.
Source code in libdebug/state/thread_context.py
__repr__()
Returns a string representation of the object.
Source code in libdebug/state/thread_context.py
backtrace(as_symbols=False)
Returns the current backtrace of the thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_symbols |
bool
|
Whether to return the backtrace as symbols |
False
|
Source code in libdebug/state/thread_context.py
fin(heuristic='backtrace')
Alias for the finish
method. Continues execution until the current function returns or the process stops.
The command requires a heuristic to determine the end of the function. The available heuristics are:
- backtrace
: The debugger will place a breakpoint on the saved return address found on the stack and continue execution on all threads.
- step-mode
: The debugger will step on the specified thread until the current function returns. This will be slower.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heuristic |
str
|
The heuristic to use. Defaults to "backtrace". |
'backtrace'
|
Source code in libdebug/state/thread_context.py
finish(heuristic='backtrace')
Continues execution until the current function returns or the process stops.
The command requires a heuristic to determine the end of the function. The available heuristics are:
- backtrace
: The debugger will place a breakpoint on the saved return address found on the stack and continue execution on all threads.
- step-mode
: The debugger will step on the specified thread until the current function returns. This will be slower.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heuristic |
str
|
The heuristic to use. Defaults to "backtrace". |
'backtrace'
|
Source code in libdebug/state/thread_context.py
next()
Executes the next instruction of the process. If the instruction is a call, the debugger will continue until the called function returns.
ni()
Alias for the next
method. Executes the next instruction of the process. If the instruction is a call, the debugger will continue until the called function returns.
Source code in libdebug/state/thread_context.py
pprint_backtrace()
Pretty prints the current backtrace of the thread.
Source code in libdebug/state/thread_context.py
pprint_registers()
pprint_registers_all()
Pretty prints all the thread's registers.
Source code in libdebug/state/thread_context.py
pprint_regs()
Alias for the pprint_registers
method.
Pretty prints the thread's registers.
pprint_regs_all()
Alias for the pprint_registers_all
method.
Pretty prints all the thread's registers.
set_as_dead()
si()
step()
step_until(position, max_steps=-1, file='hybrid')
Executes instructions of the process until the specified location is reached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
int | bytes
|
The location to reach. |
required |
max_steps |
int
|
The maximum number of steps to execute. Defaults to -1. |
-1
|
file |
str
|
The user-defined backing file to resolve the address in. Defaults to "hybrid" (libdebug will first try to solve the address as an absolute address, then as a relative address w.r.t. the "binary" map file). |
'hybrid'
|
Source code in libdebug/state/thread_context.py
su(position, max_steps=-1)
Alias for the step_until
method.
Executes instructions of the process until the specified location is reached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
int | bytes
|
The location to reach. |
required |
max_steps |
int
|
The maximum number of steps to execute. Defaults to -1. |
-1
|