translate: improve vararg handling a bit more
[ia32rtools.git] / unresolved_call.h
... / ...
CommitLineData
1#define unresolved_call(n, p) do {\
2 printf("%s: unresolved_call %p %s\n", n, p, addr_to_sym(p)); \
3 fflush(stdout); \
4} while (0)
5
6/* mingw is missing dbghelp stuff.. */
7static const char *addr_to_sym(void *addr)
8{
9 static HMODULE dbgh;
10 static BOOL WINAPI (*pSymFromAddr)(HANDLE hProcess, DWORD64 Address,
11 DWORD64* Displacement, void *Symbol);
12 static BOOL WINAPI (*pSymInitialize)(HANDLE hProcess,
13 PCSTR UserSearchPath, BOOL fInvadeProcess);
14 static char info[88 + 256];
15
16 if (dbgh == NULL)
17 dbgh = LoadLibraryA("dbghelp.dll");
18 if (dbgh == NULL)
19 return "(no dbghelp)";
20 if (pSymFromAddr == NULL)
21 pSymFromAddr = (void *)GetProcAddress(dbgh, "SymFromAddr");
22 if (pSymFromAddr == NULL)
23 return "(no SymFromAddr)";
24 if (pSymInitialize == NULL) {
25 pSymInitialize = (void *)GetProcAddress(dbgh, "SymInitialize");
26 if (pSymInitialize == NULL)
27 return "(no SymInitialize)";
28 pSymInitialize(GetCurrentProcess(), NULL, TRUE);
29 }
30
31 *(ULONG *)&info[0] = 88; // SizeOfStruct
32 *(ULONG *)&info[80] = 256; // MaxNameLen
33 if (!pSymFromAddr(GetCurrentProcess(), (DWORD64)(unsigned int)addr, NULL, info))
34 return "(no sym)";
35
36 return info + 84;
37}
38