All the debuggee*.* files are supposed to hold all the source code for the debug information we'll gather
Next patches will actually do the reading of debug information
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/tests/Makefile.in | 4 ++- dlls/dbghelp/tests/dbghelp.c | 3 ++ dlls/dbghelp/tests/debuggee.h | 23 ++++++++++++++ dlls/dbghelp/tests/debuggee1.c | 64 ++++++++++++++++++++++++++++++++++++++++ dlls/dbghelp/tests/debuggee2.c | 7 ++++ 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 dlls/dbghelp/tests/debuggee.h create mode 100644 dlls/dbghelp/tests/debuggee1.c create mode 100644 dlls/dbghelp/tests/debuggee2.c
diff --git a/dlls/dbghelp/tests/Makefile.in b/dlls/dbghelp/tests/Makefile.in index 31e5b01e8a8..e87f1abf504 100644 --- a/dlls/dbghelp/tests/Makefile.in +++ b/dlls/dbghelp/tests/Makefile.in @@ -2,4 +2,6 @@ TESTDLL = dbghelp.dll IMPORTS = dbghelp
C_SRCS = \ - dbghelp.c + dbghelp.c \ + debuggee1.c \ + debuggee2.c diff --git a/dlls/dbghelp/tests/dbghelp.c b/dlls/dbghelp/tests/dbghelp.c index a6c524177bf..123989442bf 100644 --- a/dlls/dbghelp/tests/dbghelp.c +++ b/dlls/dbghelp/tests/dbghelp.c @@ -258,3 +258,6 @@ START_TEST(dbghelp) close_process(&dbg); } } + +START_TEST(debuggee1) {} +START_TEST(debuggee2) {} diff --git a/dlls/dbghelp/tests/debuggee.h b/dlls/dbghelp/tests/debuggee.h new file mode 100644 index 00000000000..9e181f1ba17 --- /dev/null +++ b/dlls/dbghelp/tests/debuggee.h @@ -0,0 +1,23 @@ +/* avoid including standard headers, just to keep debug information as lean as possible */ +typedef void* HANDLE; +typedef unsigned long DWORD; +typedef unsigned long long DWORD64; + +extern HANDLE __stdcall GetCurrentThread(void); +extern HANDLE __stdcall GetCurrentProcess(void); +extern DWORD __stdcall SuspendThread(HANDLE h); + +#define UNREFERENCED_PARAMETER(u) (void)(u) + +/* end of standard definitions */ + +#if defined(__GNUC__) +#define NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +#define NOINLINE __declspec(noinline) +#else +#define NOINLINE +#endif + +extern DWORD trucmuche(DWORD*); +extern DWORD stack_walk_bottom(void); diff --git a/dlls/dbghelp/tests/debuggee1.c b/dlls/dbghelp/tests/debuggee1.c new file mode 100644 index 00000000000..e73f36759e2 --- /dev/null +++ b/dlls/dbghelp/tests/debuggee1.c @@ -0,0 +1,64 @@ +#include "debuggee.h" + +inline DWORD verify1(HANDLE ht) +{ + if (ht == (HANDLE)1) return 15; + return SuspendThread(ht); +} + +inline DWORD verify2(HANDLE ht) +{ + if (ht == (HANDLE)2) return 16; + if (ht) return verify1(ht); + return 0; +} + +inline DWORD verify3(HANDLE ht) +{ + if (ht == (HANDLE)3) return 17; + if (ht) return verify2(ht); + return 0; +} + +#ifdef INLINE_OFF +#pragma auto_inline(off) +#endif +NOINLINE DWORD stack_walk_bottom(void) +{ + return verify3(GetCurrentThread()); +} +#ifdef INLINE_OFF +#pragma auto_inline(on) +#endif + +struct foobar +{ + char ch; + char* array[12]; + unsigned bf1 : 3, bf2 : 7, bf3 : 2; + unsigned u; +}; + +static struct foobar myfoobar; + +/* this complicated function serves mainly to fool the compiler + * for keeping it inside the debug information + * not 100% bullet proof + */ +NOINLINE unsigned function_AA(struct foobar* fb, DWORD64 base) +{ + DWORD other = (DWORD)base; +scaramouche: + other = (other * 57) + 127 * ++fb->ch + fb->u * (fb->bf1 += 2); + if ((other = trucmuche(&other)) != 0) goto scaramouche; + return ((other * base) & (1UL << 18)) != 0; +} + +int __stdcall WinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int nCmdShow) +{ + UNREFERENCED_PARAMETER(hInstance); + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + return function_AA(&myfoobar, nCmdShow ? 0 : 123) + stack_walk_bottom(); +} diff --git a/dlls/dbghelp/tests/debuggee2.c b/dlls/dbghelp/tests/debuggee2.c new file mode 100644 index 00000000000..e4d53a38c0e --- /dev/null +++ b/dlls/dbghelp/tests/debuggee2.c @@ -0,0 +1,7 @@ +#include "debuggee.h" + +unsigned mysdff = 12; +DWORD trucmuche(DWORD* a) +{ + return 0 * *a; +}