Package vdb :: Class Vdb
[hide private]
[frames] | no frames]

Class Vdb

source code

          cmd.Cmd --+        
                    |        
     envi.cli.EnviCli --+    
                        |    
  envi.cli.EnviMutableCli --+
                            |
               object --+   |
                        |   |
vtrace.notifiers.Notifier --+
                            |
 vtrace.util.TraceManager --+
                            |
                           Vdb

A VDB object is a debugger object which may be used to embed full debugger like functionality into a python application. The Vdb object contains a CLI impelementation which extends envi.cli>

Instance Methods [hide private]
 
__init__(self, trace=None)
Instantiate a line-oriented interpreter framework.
source code
 
loadConfig(self) source code
 
loadDefaultRenderers(self, trace) source code
 
verror(self, msg, addnl=True) source code
 
loadExtensions(self, trace)
Load up any extensions which are relevant for the current tracer's platform/arch/etc...
source code
 
getTrace(self) source code
 
newTrace(self)
Generate a new trace for this vdb instance.
source code
 
setupSignalLookups(self) source code
 
getSignal(self, sig)
If given an int, return the name, for a name, return the int ;)
source code
 
parseExpression(self, exprstr) source code
 
getExpressionLocals(self)
Over-ride this to have things like the eval command and the python command use more locals than the sybolic defaults.
source code
 
reprPointer(self, address)
Return a string representing the best known name for the given address
source code
 
script(self, filename, args=[])
Execute a vdb script.
source code
 
scriptstring(self, script, filename, args=[])
Do the actual compile and execute for the script data contained in script which was read from filename.
source code
 
notify(self, event, trace) source code
 
do_vstruct(self, line)
List the available structure modules and optionally structure definitions from a particular module in the current vstruct.
source code
 
do_dis(self, line)
Print out the opcodes for a given address expression
source code
 
do_var(self, line)
Set a variable in the expression parsing context.
source code
 
do_alloc(self, args)
Allocate a chunk of memory in the target process.
source code
 
do_memload(self, line)
Load a file into memory.
source code
 
do_struct(self, args)
Break out a strcuture from memory.
source code
 
do_signal(self, args)
Show the current pending signal/exception code.
source code
 
do_snapshot(self, line)
Take a process snapshot of the current (stopped) trace and save it to the specified file.
source code
 
do_ignore(self, args)
Add the specified signal id (exception id for windows) to the ignored signals list for the current trace.
source code
 
do_exec(self, cmd)
Execute a program with the given command line and attach to it.
source code
 
do_threads(self, line)
List the current threads in the target process or select the current thread context for the target tracer.
source code
 
do_suspend(self, line)
Suspend a thread.
source code
 
do_restart(self, line)
Restart the current process.
source code
 
do_resume(self, line)
Resume a thread.
source code
 
do_mode(self, args)
Set modes in the tracers...
source code
 
do_reg(self, args)
Show the current register values.
source code
 
do_stepi(self, line)
Single step the target tracer.
source code
 
do_go(self, line)
Continue the target tracer.
source code
 
do_gui(self, line)
Attempt to spawn the VDB gui.
source code
 
do_waitlib(self, line)
Run the target process until the specified library (by normalized name such as 'kernel32' or 'libc') is loaded.
source code
 
do_server(self, port)
Start a vtrace server on the local box.
source code
 
do_syms(self, line)
List symbols and by file.
source code
 
do_call(self, string)
Allows a C-like syntax for calling functions inside the target process (from his context).
source code
 
do_bestname(self, args)
Return the "best name" string for an address.
source code
 
do_EOF(self, string) source code
 
do_quit(self, args)
Quit VDB
source code
 
do_detach(self, args)
Detach from the current tracer
source code
 
do_attach(self, args)
Attach to a process by PID or by process name.
source code
 
do_autocont(self, line)
Manipulate the auto-continue behavior for the trace.
source code
 
emptyline(self)
Called when an empty line is entered in response to the prompt.
source code
 
do_bt(self, line)
Show a stack backtrace for the currently selected thread.
source code
 
do_lm(self, args)
Show the loaded libraries and their base addresses.
source code
 
do_guid(self, line)
Parse and display a Global Unique Identifier (GUID) from memory (eventually, use GUID db to lookup the name/meaning of the GUID).
source code
 
do_bpfile(self, line)
Set the python code for a breakpoint from the contents of a file.
source code
 
do_bpedit(self, line)
Manipulcate the python code that will be run for a given breakpoint by ID.
source code
 
do_bp(self, line)
Show, add, and enable/disable breakpoints USAGE: bp [-d <addr>] [-a <addr>] [-o <addr>] [[-c pycode] <address> [vdb cmds]] -C - Clear All Breakpoints -c "py code" - Set the breakpoint code to the given python string -d <id> - Disable Breakpoint -e <id> - Enable Breakpoint -r <id> - Remove Breakpoint -o <addr> - Create a OneTimeBreak -L <libname> - Add bp's to all functions in <libname> -F <filename> - Load bpcode from file -W perms:size - Set a hardware Watchpoint with perms/size (ie -W rw:4) -f - Make added breakpoints from this command into "fastbreaks" -S <libname>:<regex> - Add bp's to all matching funcs in <libname>
source code
 
do_fds(self, args)
Show all the open Handles/FileDescriptors for the target process.
source code
 
do_ps(self, args)
Show the current process list.
source code
 
do_break(self, args)
Send the break signal to the target tracer to stop it's execution.
source code
 
do_meta(self, line)
Show the metadata for the current trace.
source code
 
do_memdiff(self, line)
Save and compare snapshots of memory to enumerate changes.
source code
 
_getDiffs(self) source code
 
do_dope(self, line)
Cli interface to the "stack doping" api inside recon.
source code
 
do_recon(self, line)
Cli front end to the vdb recon subsystem which allows runtime analysis of known API calls.
source code
 
do_stalker(self, line)
Cli front end to the VDB code coverage subsystem.
source code
 
do_status(self, line)
Print out the status of the debugger / trace...
source code
 
FIXME_do_remote(self, line)
Act as a remote debugging client to the server running on the specified host/ip.
source code

Inherited from envi.cli.EnviMutableCli: do_memcpy, do_memprotect, do_writemem

Inherited from envi.cli.EnviCli: __getattr__, cmdloop, doAlias, do_alias, do_binstr, do_config, do_eval, do_maps, do_mem, do_memcmp, do_memdump, do_python, do_script, do_search, get_names, onecmd, registerCmdExtension, setCanvas, vprint, write

Inherited from cmd.Cmd: columnize, complete, complete_help, completedefault, completenames, default, do_help, parseline, postcmd, postloop, precmd, preloop, print_topics

Inherited from vtrace.notifiers.Notifier: handleEvent

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Inherited from vtrace.util.TraceManager: deregisterNotifier, fireLocalNotifiers, getMeta, getMode, manageTrace, registerNotifier, setMeta, setMode, unManageTrace

Class Variables [hide private]

Inherited from cmd.Cmd: doc_header, doc_leader, identchars, intro, lastcmd, misc_header, nohelp, prompt, ruler, undoc_header, use_rawinput

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, trace=None)
(Constructor)

source code 

Instantiate a line-oriented interpreter framework.

The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used.

Overrides: vtrace.util.TraceManager.__init__

newTrace(self)

source code 

Generate a new trace for this vdb instance. This fixes many of the new attach/exec data munging issues because tracer re-use is *very* sketchy...

parseExpression(self, exprstr)

source code 
Overrides: envi.cli.EnviCli.parseExpression

getExpressionLocals(self)

source code 

Over-ride this to have things like the eval command and the python command use more locals than the sybolic defaults.

Overrides: envi.cli.EnviCli.getExpressionLocals
(inherited documentation)

reprPointer(self, address)

source code 

Return a string representing the best known name for the given address

Overrides: envi.cli.EnviCli.reprPointer

notify(self, event, trace)

source code 
Overrides: vtrace.notifiers.Notifier.notify

do_vstruct(self, line)

source code 

List the available structure modules and optionally structure definitions from a particular module in the current vstruct.

Usage: vstruct [modname]

do_dis(self, line)

source code 

Print out the opcodes for a given address expression

Usage: dis <address expression> [<size expression>]

do_var(self, line)

source code 

Set a variable in the expression parsing context. This allows for scratchspace names (python compatable names) to be used in expressions.

Usage: var <name> <addr_expression>

NOTE: The address expression *must* resolve at the time you set it.

do_alloc(self, args)

source code 

Allocate a chunk of memory in the target process. It will be allocated with rwx permissions.

Usage: alloc <size expr>

do_memload(self, line)

source code 

Load a file into memory. (straight mapping, no parsing)

Usage: memload <filename>

do_struct(self, args)

source code 

Break out a strcuture from memory. You may use the command "vstruct" to show the known structures in vstruct.

Usage: struct <StructName> <vtrace expression>

do_signal(self, args)

source code 

Show the current pending signal/exception code.

Usage: signal

do_snapshot(self, line)

source code 

Take a process snapshot of the current (stopped) trace and save it to the specified file.

Usage: snapshot <filename>

do_ignore(self, args)

source code 

Add the specified signal id (exception id for windows) to the ignored
signals list for the current trace.  This will make the smallest possible
performance impact for that particular signal but will also not alert
you that it has occured.

Usage: ignore [options] [-c | <sigcode>...]
-d - Remove the specified signal codes.
-c - Include the *current* signal in the sigcode list
-C - Clear the list of ignored signals

Example: ignore -c # Ignore the currently posted signal
         ignore -d 0x80000001 # Remove 0x80000001 from the ignores

do_exec(self, cmd)

source code 

Execute a program with the given command line and attach to it. Usage: exec </some/where and some args>

do_threads(self, line)

source code 

List the current threads in the target process or select the current thread context for the target tracer. Usage: threads [thread id]

do_suspend(self, line)

source code 

Suspend a thread.

Usage: suspend <-A | <tid>[ <tid>...]>

do_restart(self, line)

source code 

Restart the current process.

Usage: restart

NOTE: This only works if the process was exec'd to begin with!

TODO: Plumb options for persisting bp's etc...

do_resume(self, line)

source code 

Resume a thread.

Usage: resume <-A | <tid>[ <tid>...]>

do_mode(self, args)

source code 

Set modes in the tracers... mode Foo=True/False

do_reg(self, args)

source code 

Show the current register values. Additionally, you may specify name=<expression> to set a register

Usage: reg [regname=vtrace_expression]

do_stepi(self, line)

source code 

Single step the target tracer. Usage: stepi [ options ]

-A <addr> - Step to <addr> -B - Step past the next branch instruction -C <count> - Step <count> instructions -R - Step to return from this function -V - Show operand values during single step (verbose!)

do_go(self, line)

source code 

Continue the target tracer. -I go icount linear instructions forward (step over style) -U go *out* of fcount frames (step out style) <until addr> go until explicit address

Usage: go [-U <fcount> | -I <icount> | <until addr expression>]

do_gui(self, line)

source code 

Attempt to spawn the VDB gui. Assuming GTK etc are all installed.

do_waitlib(self, line)

source code 

Run the target process until the specified library (by normalized name such as 'kernel32' or 'libc') is loaded. Disable waiting with -D.

Usage: waitlib [ -D | <libname> ]

do_server(self, port)

source code 

Start a vtrace server on the local box. If the server is already running, show which processes are being remotely debugged.

Usage: server

do_syms(self, line)

source code 

List symbols and by file.

Usage: syms [-s <pattern>] [filename]

With no arguments, syms will self.vprint(the possible libraries with symbol resolvers. Specify a library to see all the symbols for it.

do_call(self, string)

source code 

Allows a C-like syntax for calling functions inside the target process (from his context). Example: call printf("yermom %d", 10)

do_bestname(self, args)

source code 

Return the "best name" string for an address.

Usage: bestname <vtrace expression>

do_EOF(self, string)

source code 
Overrides: envi.cli.EnviCli.do_EOF

do_quit(self, args)

source code 

Quit VDB

use "quit force" to hard-force a quit regardless of everything.

Overrides: envi.cli.EnviCli.do_quit

do_attach(self, args)

source code 

Attach to a process by PID or by process name. In the event of more than one process by a given name, attach to the last (most recently created) one in the list.

Usage: attach [<pid>,<name>]

NOTE: This is *not* a regular expression. The given string must be found as a substring of the process name...

do_autocont(self, line)

source code 

Manipulate the auto-continue behavior for the trace. This will cause particular event types to automagically continue execution.

Usage: autocont [event name]

emptyline(self)

source code 

Called when an empty line is entered in response to the prompt.

If this method is not overridden, it repeats the last nonempty command entered.

Overrides: cmd.Cmd.emptyline
(inherited documentation)

do_bt(self, line)

source code 

Show a stack backtrace for the currently selected thread.

Usage: bt

do_lm(self, args)

source code 

Show the loaded libraries and their base addresses.

Usage: lm [libname]

do_guid(self, line)

source code 

Parse and display a Global Unique Identifier (GUID) from memory (eventually, use GUID db to lookup the name/meaning of the GUID).

Usage: guid <addr_exp>

do_bpfile(self, line)

source code 

Set the python code for a breakpoint from the contents of a file.

Usage: bpfile <bpid> <filename>

do_bpedit(self, line)

source code 

Manipulcate the python code that will be run for a given breakpoint by ID. (Also the way to view the code).

Usage: bpedit <id> ["optionally new code"]

NOTE: Your code must be surrounded by "s and may not contain any "s

do_bp(self, line)

source code 

Show, add,  and enable/disable breakpoints
USAGE: bp [-d <addr>] [-a <addr>] [-o <addr>] [[-c pycode] <address> [vdb cmds]]
-C - Clear All Breakpoints
-c "py code" - Set the breakpoint code to the given python string
-d <id> - Disable Breakpoint
-e <id> - Enable Breakpoint
-r <id> - Remove Breakpoint
-o <addr> - Create a OneTimeBreak
-L <libname> - Add bp's to all functions in <libname>
-F <filename> - Load bpcode from file
-W perms:size - Set a hardware Watchpoint with perms/size (ie -W rw:4)
-f - Make added breakpoints from this command into "fastbreaks"
-S <libname>:<regex> - Add bp's to all matching funcs in <libname>

<address>... - Create Breakpoint

[vdb cmds].. - (optional) vdb cli comand to run on BP hit (seperate
               multiple commands with ;; )

NOTE: -c adds python code to the breakpoint.  The python code will
    be run with the following objects mapped into it's namespace
    automagically:
        vtrace  - the vtrace package
        trace   - the tracer
        bp      - the breakpoint object

do_fds(self, args)

source code 

Show all the open Handles/FileDescriptors for the target process. The "typecode" shown in []'s is the vtrace typecode for that kind of fd/handle.

Usage: fds

do_ps(self, args)

source code 

Show the current process list.

Usage: ps

do_break(self, args)

source code 

Send the break signal to the target tracer to stop it's execution.

Usage: break

do_meta(self, line)

source code 

Show the metadata for the current trace.

Usage: meta

do_memdiff(self, line)

source code 

Save and compare snapshots of memory to enumerate changes.

Usage: memdiff [options]
-C             Clear all current memory diff snapshots.
-A <va:size>   Add the given virtual address to the list.
-M <va>        Add the entire memory map which contains VA to the list.
-D             Compare currently tracked memory with the target process
               and show any differences.

do_dope(self, line)

source code 

Cli interface to the "stack doping" api inside recon. *BETA*

(Basically, set all un-initialized stack memory to V's to tease out uninitialized stack bugs)

Usage: dope [ options ] -E Enable automagic thread stack doping on all continue events -D Disable automagic thread stack doping on all continue events -A Dope all current thread stacks

do_recon(self, line)

source code 

Cli front end to the vdb recon subsystem which allows runtime
analysis of known API calls.

Usage: recon [options]
-A <sym_expr>:<recon_fmt> - Add a recon breakpoint with the given format
-C - Clear the current list of recon breakpoint hits.
-H - Print the current list of recon breakpoint hits.
-Q - Toggle "quiet" mode which prints nothing on bp hits.
-S <sym_expr>:<argidx> - Add a sniper break for arg index

NOTE: A "recon format" is a special format sequence which tells the
      recon subsystem how to present the argument data for a given
      breakpoint hit.

Recon Format:
C - A character
I - A decimal integer
P - A pointer (display symbol if possible)
S - An ascii string (up to 260 chars)
U - A unicode string (up to 260 chars)
X - A hex number

do_stalker(self, line)

source code 

Cli front end to the VDB code coverage subsystem. FIXME MORE DOCS!

Usage: stalker [options] -C - Cleanup stalker breaks and hit info -c - Clear the current hits (so you can make more ;) -E <addr_expr> - Add the specified entry point for tracking -H - Show the current hits -L <lib>:<regex> - Add stalker breaks to all matching library symbols -R - Reset all breakpoints to enabled and clear hit info

FIXME_do_remote(self, line)

source code 

Act as a remote debugging client to the server running on the specified host/ip.

Usage: remote <host>