Improve logging

This commit is contained in:
Simon Lindholm 2022-06-29 15:24:58 +02:00
parent e0017ac105
commit 81e85504de
3 changed files with 11 additions and 5 deletions

View File

@ -6,12 +6,12 @@
#include <assert.h>
#define WIN_FUNC __attribute__((stdcall))
// inline void DEBUG_LOG(const char *fmt, ...) {}
#define DEBUG_LOG(...) wibo::debug_log(__VA_ARGS__)
namespace wibo {
extern uint32_t lastError;
extern char *commandLine;
extern bool debugEnabled;
void debug_log(const char *fmt, ...);

View File

@ -30,7 +30,7 @@ namespace kernel32 {
void *lpStartupInfo,
void *lpProcessInformation
) {
DEBUG_LOG("CreateProcessA %s \"%s\" %p %p %d 0x%x %p %s %p %p\n",
printf("CreateProcessA %s \"%s\" %p %p %d 0x%x %p %s %p %p\n",
lpApplicationName,
lpCommandLine,
lpProcessAttributes,

View File

@ -9,11 +9,13 @@
uint32_t wibo::lastError = 0;
char *wibo::commandLine;
wibo::Executable *wibo::mainModule = 0;
bool wibo::debugEnabled = false;
void wibo::debug_log(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
if (wibo::debugEnabled)
vprintf(fmt, args);
va_end(args);
}
@ -24,8 +26,8 @@ static char stubFuncNames[0x100][0x100];
static void stubBase(int index) {
// should go through all the functions imported by mwcceppc.exe
// and create template stubs for them, at least...
DEBUG_LOG("Unhandled function %s (%s)\n", stubFuncNames[index], stubDlls[index]);
exit(0);
printf("Unhandled function %s (%s)\n", stubFuncNames[index], stubDlls[index]);
exit(1);
}
void (*stubFuncs[0x100])(void) = {
@ -112,6 +114,10 @@ int main(int argc, char **argv) {
return 1;
}
if (getenv("WIBO_DEBUG")) {
wibo::debugEnabled = true;
}
// Create TIB
TIB tib;
tib.tib = &tib;