Alter VM_ScriptInfo() to take a ptr to the script to disassemble, and dump disassembly to the log at startup when an internal compiler error occurs.

git-svn-id: https://svn.eduke32.com/eduke32@5513 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-01-07 03:30:07 +00:00
parent 085333a5fb
commit 748d9ac22f
5 changed files with 16 additions and 12 deletions

View File

@ -4937,7 +4937,7 @@ static void G_DumpDebugInfo(void)
int32_t i,j,x;
// FILE * fp=fopen("condebug.log","w");
VM_ScriptInfo();
VM_ScriptInfo(insptr, 64);
OSD_Printf("\n");
OSD_Printf("Current gamevar values:\n");
@ -11417,7 +11417,7 @@ static int32_t G_EndOfLevel(void)
void app_crashhandler(void)
{
G_CloseDemoWrite();
VM_ScriptInfo();
VM_ScriptInfo(insptr, 64);
G_GameQuit();
}

View File

@ -1388,6 +1388,7 @@ static int32_t C_SetScriptSize(int32_t newsize)
{
g_numCompilerErrors++;
initprintf("Internal compiler error at %" PRIdPTR " (0x%" PRIxPTR ")\n",i,i);
VM_ScriptInfo(&script[i], 16);
}
scriptptrs[i] = 1;

View File

@ -39,6 +39,8 @@ extern "C" {
#define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings)
extern intptr_t const * insptr;
extern void VM_ScriptInfo(intptr_t const *ptr, int32_t range);
extern hashtable_t h_gamefuncs;
#if !defined LUNATIC

View File

@ -94,22 +94,22 @@ GAMEEXEC_STATIC void VM_Execute(int32_t loop);
} \
}
void VM_ScriptInfo(void)
extern void VM_ScriptInfo(intptr_t const *ptr, int32_t range)
{
#if !defined LUNATIC
if (!script)
return;
if (insptr)
if (ptr)
{
initprintf("\n");
for (intptr_t const *p = insptr - 32; p < insptr + 32; p++)
for (intptr_t const *p = ptr - (range>>1); p < ptr + (range>>1); p++)
{
if ((int32_t)(p - script) >= g_scriptSize)
break;
initprintf("%5d: %3d: ", (int32_t) (p - script), (int32_t) (p - insptr));
initprintf("%5d: %3d: ", (int32_t) (p - script), (int32_t) (p - ptr));
if (*p >> 12 && (*p & VM_INSTMASK) < CON_END)
initprintf("%5d %s\n", (int32_t) (*p >> 12), keyw[*p & VM_INSTMASK]);
@ -120,10 +120,13 @@ void VM_ScriptInfo(void)
initprintf("\n");
}
if (vm.g_i)
initprintf("current actor: %d (%d)\n", vm.g_i, TrackerCast(vm.g_sp->picnum));
if (ptr == insptr)
{
if (vm.g_i)
initprintf("current actor: %d (%d)\n", vm.g_i, TrackerCast(vm.g_sp->picnum));
initprintf("g_errorLineNum: %d, g_tw: %d\n", g_errorLineNum, g_tw);
initprintf("g_errorLineNum: %d, g_tw: %d\n", g_errorLineNum, g_tw);
}
#endif
}
@ -5471,7 +5474,7 @@ finish_qsprintf:
continue;
default:
VM_ScriptInfo();
VM_ScriptInfo(insptr, 64);
G_GameExit("An error has occurred in the EDuke32 virtual machine.\n\n"
"If you are an end user, please e-mail the file eduke32.log\n"

View File

@ -90,8 +90,6 @@ static inline int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlay
return VM_HaveEvent(iEventID) ? VM_OnEvent_(iEventID, iActor, iPlayer) : 0;
}
void VM_ScriptInfo(void);
#define CON_ERRPRINTF(Text, ...) do { \
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, keyw[g_tw], ## __VA_ARGS__); \
} while (0)