Clang: Use the x86.asm trampoline to pass xsp on ia32

Taking the address of the 'sig' parameter to master_signal_handler to
get the stack pointer at entry doesn't work with Clang.  Without
optimizations, Clang will create a copy in the new frame.

For x64, it's easy to add a 4th parameter without disturbing the stack,
but for ia32 I had to replace an existing param.  The C code puts back
the original 'sig' value.

Review URL: https://codereview.appspot.com/6493070

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1577 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#840: Use the fopen/FILE interface in drconfiglib

Part 1 of porting drconfiglib to Linux.

Also use MAXIMUM_PATH instead of MAX_PATH and make DO_ASSERT work again.

Review URL: https://codereview.appspot.com/6500070

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1578 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#840: Replace uses of WCHAR with TCHAR in dr_config.c

Part 2 of porting drconfiglib to Linux.

This change was relatively mechanical.

Review URL: https://codereview.appspot.com/6498082

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1579 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Fix unreachable code warning in vps build of dr_config.c

Review URL: https://codereview.appspot.com/6492114

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1580 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#891: Use /proc/self/exe to find the application path by default

We still have to use /proc/pid/cmdline when doing early injection, since
/proc/self/exe will point to DR.

I renamed getnamefrompid and get_executable_path so that it clearer
where those implementations are getting their results from.

Fixes issue 891.

Review URL: https://codereview.appspot.com/6488115

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1581 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes http://code.google.com/p/drmemory/issues/detail?id=1025
+ add FILE_SHARE_WRITE to os_file_exists() to prevent sharing
  violations on simulataneous access

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1582 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Revert "i#840: Replace uses of WCHAR with TCHAR in dr_config.c"

This reverts commit ba6afe3406fb298737b9ea561444497ca4df1ca1.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1585 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Revert "i#840: Use the fopen/FILE interface in drconfiglib"

This reverts commit 3e248ae36f2ac28806aec6ddc61a57abfd0d7436.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1586 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Revert "Clang: Use the x86.asm trampoline to pass xsp on ia32"

This reverts commit aea3c424e4a12c51af08246c9fc3cc81e2939757.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1587 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#840: Use fopen in drconfiglib, take two

Instead of manually shifting memory around to read the file line by
line, I switched to fgets for the line reading, and de-nested the
shifting loop.

Once I had done that, I realized that the issue may have been related to
CRLF translation, so I switched the fopen mode to binary.

Review URL: https://codereview.appspot.com/6500070

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1588 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#891: Add dr_get_main_module() to the API

This provides a reliable way for the client to get information about the
main app executable.  The existing pattern for getting the main module
is:

  dr_lookup_module_by_name(dr_get_application_name());

However, the above is unreliable if there are multiple modules with the
same preferred name.  More likely, on Linux, dr_get_application_name()
relies on the proc filesystem, which could be unavailable for various
reasons.  This API is more robust in the face of such corner cases.

Review URL: https://codereview.appspot.com/6492106

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1589 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Re-land "Replace uses of WCHAR with TCHAR in dr_config.c"

Part of issue 840.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1590 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#840: Port the native drconfig tool

Part 3 of porting drconfig and drinject to Linux.

I started with drconfig since it is the smallest tool.  The native
drconfig tool produces a config file similar to the one from the shell
script, but lacking DYNAMORIO_HOME.

To make the drconfig exports cross platform I switched from the .def file to DR_API macros in the header files.

Review URL: https://codereview.appspot.com/6496077

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1591 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixed a bug in r1570
- remove "0x" used by %x before

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1592 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Clang: Pass xsp in the x86.asm signal trampoline without aliasing

Fixes issue 898.

gcc was eliminating the xsp_unsafe to xsp copy because gcc believed
xsp_unsafe had no aliases.  Instead, we create a new stack frame and
read the arguments to the signal handler through xsp.

Unfortunately this means that ia32 and x64 have different signal handler
prototypes again.

I did an ia32 build with !HAVE_SIGALTSTACK, and the signal tests passed.

Review URL: https://codereview.appspot.com/6527048

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1593 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#893: add /safeseh:no

Added /safeseh:no for the core and for all the tests in order to
avoid errors from VS2012 due to our asm code.
Had to move core unit_tests down below the definition of LD_FLAGS.
Long-term we should make tools.asm SEH-compliant, so not resolving
the issue with this workaround.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1594 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 894

Win8 WDK ntdll.lib does not list Ki routines nor string/memory routines so
we make our own .lib.  Because the Ki are stdcall we can't just use a .def
file: we need an .obj file built from stubs w/ the same signatures.

For the string routines, the .def file is sufficient as they're cdecl.
We also have to re-order msvcrt.lib to ensure it's after the new
ntdll_imports.lib.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1595 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 895

fix libutil buffer overflow found by VS2012

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1596 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 896

VS2012 and Win8 WDK support:

1) locate ntdll.lib in Windows 8 WDK
2) locate uuid.lib
3) PEXCEPTION_REGISTRATION_RECORD rename to avoid conflict
4) use editbin instead of the missing bind.exe
5) eliminate C++ keywords becoming macros
6) eliminate macro redefs

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1597 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 897

update winsysnums for proper 64-bit decoding and for win8:
+ honor -ignore_Zw for pdb
+ don't require ecx for wow64
+ don't truncate syscall number
+ build 64-bit and set 64-bit mode for -x64 option
+ build properly w/ latest DynamoRIOConfig.cmake
+ handle win8 call-adjacent wrappers

relaxed asserts in dr_print_{instr,opnd} to allow calling in standalone
mode

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1598 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6