Sunday, March 7, 2010

Bust a grind with Valgrind

Made a bunch of changes. In particular, its moved to a proprety based configuration at the core. Other small features include a version embedded in libuvudec for verifying a good version was linked against and removal of a large number of global variables leftover from its C days. The global situation still has mostly a band aid on it since most of them just used a global configuration object now instead, but its probably still better than it was before.
Heres an old --help screen:
[mcmaster@gespenst uvudec]$ ./uvudec --help
uvudec version 0.2.0.0
Copyright 2009 John McMaster
Portions copyright GNU (MD5 implementation)
JohnDMcMaster@gmail.com

Usage: ./uvudec <args>
Args:
--verbose: verbose output. Equivilent to --verbose=3
--verbose=<level>: set verbose level. 0 (none) - 3 (most)
--verbose-init: for selectivly debugging configuration file reading
--verbose-analysis: for selectivly debugging code analysis
--verbose-processing: for selectivly debugging code post-analysis
--verbose-printing: for selectivly debugging print routine
--config-language=<language>: default config interpreter language (plugins may require specific)
python: use Python
javascript: use javascript
--addr-min=<min>: minimum analysis address
--addr-max=<max>: maximum analysis address
--addr-exclude-min=<min>: minimum exclusion address
--addr-exclude-max=<max>: maximum exclusion address
--addr-comment: put comments on addresses
--addr-label: label addresses for jumping
--analysis-only[=<bool>]: only do analysis, don't print data
--analysis-address=<address>: only output analysis data for specified address
--opcode-usage: opcode usage count table
--analysis-dir=<dir>: create skeleton data suitible for stored analysis
--input=<file>: source for data
--output=<file>: output program (default: stdout)
--debug=<file>: debug output (default: stdout)
--print-jumped-addresses=<bool>: whether to print information about jumped to addresses (*1)
--print-called-addresses=<bool>: whether to print information about called to addresses (*1)
--useless-ascii-art: append nifty ascii art headers to output files
--help: print this message and exit
--version: print version and exit

Special files: -: stdin
<bool>:
true includes case insensitive "true", non-zero numbers (ie 1)
false includes case insensitve "false", 0

*1: WARNING: currently slow, may be fixed in future releases


And heres the new:
[mcmaster@gespenst bin]$ ./uvudec --help
***main
uvudec version 0.3.0
libuvudec version 0.3.0
Copyright 2009 John McMaster <johndmcmaster@gmail.com>
Portions copyright GNU (MD5 implementation)

Usage: ./uvudec <args>
Args:
--help (action.help): print this message and exit
--version (action.version): print version and exit
--verbose (debug.level): debug verbosity level
--verbose-init (debug.init): selectivly debug initialization
--verbose-analysis (debug.processing): selectivly debugging code analysis
--verbose-processing (debug.analysis): selectivly debugging code post-analysis
--verbose-printing (debug.printing): selectivly debugging print routine
--debug-file (debug.file): debug output (default: stdout)
--config-language (config.language): default config interpreter language (plugins may require specific)
python: use Python
javascript: use javascript
--addr-include-min (target.address_include.min): minimum analysis address
--addr-include-max (target.address_include.max): maximum analysis address
--addr-exclude-min (target.address_exclude.min): minimum exclusion address
--addr-exclude-max (target.address_exclude.max): maximum exclusion address
--analysis-address (target.address): only output analysis data for specified address
--analysis-only (analysis.only): only do analysis, don't print data
--analysis-dir (analysis.dir): create data suitible for stored analysis
--flow-analysis (analysis.flow_technique): how to trace jump, calls
linear: start at beginning, read all instructions linearly, then find jump/calls (default)
trace: start at all vectors, analyze all segments called/branched recursivly
--opcode-usage (output.opcode_usage): opcode usage count table
--print-jumped-addresses (output.jumped_addresses): whether to print information about jumped to addresses (*1)
--print-called-addresses (output.called_addresses): whether to print information about called to addresses (*1)
--useless-ascii-art (output.useless_ascii_art): append nifty ascii art headers to output files
--addr-comment (output.address_comment): put comments on addresses
--addr-label (output.address_label): label addresses for jumping
--input (target.file): source file for data
--output (output.file): output program (default: stdout)


SEVERE ERROR
Received signal: SIGSEGV

Which seems to have gone okay, including the parsing. Except one little thing you may notice at the bottom. Oops. I found the place roughly where the error occurred, but having issues. In fact, the program will run until about when the disassembling to intermediate representation is done and then will crash on the first instruction.
So, enter Valgrind. I've played with it for some trivial programs before and its probably time I learn how to do some more serious automated bug analysis anyway as it might give me some good ideas for this project. However, getting a large number of false positives and the suppression file doesn't seem to be helping. Grr. Oh and blogspot didn't like my angle brackets so I had to escape them.

No comments:

Post a Comment