Add posix API as a set of perl hashes

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Better define always/never wrapped APIs in terms of POSIX

never wrap string functions or math functions

always wrap everything else

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Allow ELF syscall extraction to prioritize always/never lists

When defining the white (always wrap) and black (never wrap) lists in terms of
POSIX APIs, there can be symbols that appear in both lists. For example, we want
to wrap all POSIX thread APIs, except pthread_mutex_lock/unlock. These symbols
will appear in both the white and black lists.

To choose between them, there is now a new option: "-prio [1|2]".
1 == check "always" list first (prioritize the white list)
2 == check "never" list first (prioritize the black list)

default is 2 (prioritize the black list)

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Update wraplib.sh to use "-prio" symbols parsing arg

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
don't wrap some memory/thread fcns for now

The goal is to revert this commit later on by providing a way to efficiently log
these functions.

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Move BT log size to _after_ log buffer, fixup bt_printf

Hopefully this will fix the occasional "4 bytes of zero" bug

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Provide an easy way to export all symbols for debugging

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Log DVM backtraces on JNI calls

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
bugfix! libdvm low-level interface sucks

There is at least one obscure bug in dvmGetThreadName() that causes occasional
crashes. We don't really need the java thread name, so I've just disabled it.

A more insidius offender is the dvmFillStackTraceArray() function. It takes an
array and a length as parameters and fills in the method pointers corresponding
to the Dalvik stack. However, it effectively ignores the length parameter, and
proceeds to continue writing into memory beyond the bound of your array if the
actual stack is too big for your array. Thanks guys.

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
bugfix! guard against bad/invalid unwind info

This issue shows up when there is bad/corrupt/invalid unwind information
somewhere in the middle of your stack trace. In manifests itself as an infinite
loop where the trace function gets called indefinitely with the same frame
pointer.

I put a max recursion depth counter on my tracing state structure to guard
against this, and cut off the tracing if we're not doing anymore valid work.

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
bugfix! check for library init recursion, and other NULL dereferences

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Move wrapped cache to flag based creation

better way of adding functionality... like say a couple extra flags :-)

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Enable tracing of memory/pthread functions

This is _slow_ but manageable.

There is no backtracing for these symbols, and most do not include timing
information either.

malloc, realloc, and calloc are timed so that we can potentially infer whether
or not a syscall was made.

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
remove cruft in java_backtrace files

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Adding a few more android-specific APIs

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Helpful android scripts

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Add some more android specific functions

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
header externs for local string utils (add strlen)

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Add "NOARGS" symbol param

This gives me the ability to selectively print arguments to functions whose
backtrace is not taken. For example, I would like to print the arguments to
malloc, but not memset.

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>
Logging speed enhancements / refactor

slightly refactor the backtrace logging code:
  *) stash a pre-formatted version of the timestamp for multiple
     calls to bt_printf
  *) move some of the macro code into real functions to save on
     code size and hopefully fit more in cache
     (this also allow me to create a really raw print function)

Signed-off-by: Jeremy C. Andrus <jeremya@cs.columbia.edu>