Fix ebacktrace on 32-bit. (Sorry, we're back to 5 MB.)

git-svn-id: https://svn.eduke32.com/eduke32@3304 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-12-18 09:15:39 +00:00
parent 28695e1d97
commit 50844b6e71
3 changed files with 14 additions and 12 deletions

View file

@ -249,16 +249,18 @@ static char procname[MAX_PATH];
#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) #if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
# define MachineType IMAGE_FILE_MACHINE_AMD64 # define MachineType IMAGE_FILE_MACHINE_AMD64
# define MAYBE64(x) x ## 64
#else #else
# define MachineType IMAGE_FILE_MACHINE_I386 # define MachineType IMAGE_FILE_MACHINE_I386
# define MAYBE64(x) x
#endif #endif
static void static void
_backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT context) _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT context)
{ {
STACKFRAME64 frame; MAYBE64(STACKFRAME) frame;
HANDLE process, thread; HANDLE process, thread;
char symbol_buffer[sizeof(IMAGEHLP_SYMBOL64) + 255]; char symbol_buffer[sizeof(MAYBE64(IMAGEHLP_SYMBOL)) + 255];
char module_name_raw[MAX_PATH]; char module_name_raw[MAX_PATH];
struct bfd_ctx *bc = NULL; struct bfd_ctx *bc = NULL;
@ -283,16 +285,16 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT
process = GetCurrentProcess(); process = GetCurrentProcess();
thread = GetCurrentThread(); thread = GetCurrentThread();
while(StackWalk64(MachineType, while(MAYBE64(StackWalk)(MachineType,
process, process,
thread, thread,
&frame, &frame,
context, context,
NULL, NULL,
SymFunctionTableAccess64, MAYBE64(SymFunctionTableAccess),
SymGetModuleBase64, NULL)) { MAYBE64(SymGetModuleBase), NULL)) {
IMAGEHLP_SYMBOL64 *symbol; MAYBE64(IMAGEHLP_SYMBOL) *symbol;
DWORD64 module_base; MAYBE64(DWORD) module_base;
const char * module_name = "[unknown module]"; const char * module_name = "[unknown module]";
const char * file = NULL; const char * file = NULL;
@ -303,11 +305,11 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT
if (depth < 0) if (depth < 0)
break; break;
symbol = (IMAGEHLP_SYMBOL64 *)symbol_buffer; symbol = (MAYBE64(IMAGEHLP_SYMBOL) *)symbol_buffer;
symbol->SizeOfStruct = (sizeof *symbol) + 255; symbol->SizeOfStruct = (sizeof *symbol) + 255;
symbol->MaxNameLength = 254; symbol->MaxNameLength = 254;
module_base = SymGetModuleBase64(process, frame.AddrPC.Offset); module_base = MAYBE64(SymGetModuleBase)(process, frame.AddrPC.Offset);
if (module_base && if (module_base &&
GetModuleFileNameA((HINSTANCE)(intptr_t)module_base, module_name_raw, MAX_PATH)) { GetModuleFileNameA((HINSTANCE)(intptr_t)module_base, module_name_raw, MAX_PATH)) {
@ -320,8 +322,8 @@ _backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT
} }
if (file == NULL) { if (file == NULL) {
DWORD64 dummy = 0; MAYBE64(DWORD) dummy = 0;
if (SymGetSymFromAddr64(process, frame.AddrPC.Offset, &dummy, symbol)) { if (MAYBE64(SymGetSymFromAddr)(process, frame.AddrPC.Offset, &dummy, symbol)) {
file = symbol->Name; file = symbol->Name;
} }
else { else {

View file

@ -11,7 +11,7 @@ clean=veryclean
# the following file paths are relative to $source # the following file paths are relative to $source
targets=( eduke32.exe mapster32.exe ) targets=( eduke32.exe mapster32.exe )
package=package package=package
not_src_packaged=( psd source/jaudiolib/third-party/vorbis.framework/Versions/A/vorbis Apple/lib ) not_src_packaged=( psd source/jaudiolib/third-party/vorbis.framework/Versions/A/vorbis Apple/lib $package/ebacktrace1.dll $package/ebacktrace1-64.dll )
# group that owns the resulting packages # group that owns the resulting packages
group=dukeworld group=dukeworld