1
0
Fork 0

print stack trace (#1210)

This commit is contained in:
Torusrxxx 2016-11-02 15:38:09 +00:00 committed by Duncan Ogilvie
parent fa15877303
commit da5b38f657
3 changed files with 30 additions and 9 deletions

View File

@ -2,6 +2,8 @@
#include "stringformat.h"
#include "console.h"
#include "variable.h"
#include "stackinfo.h"
#include "debugger.h"
#include "simplescript.h"
bool cbScriptLoad(int argc, char* argv[])
@ -14,22 +16,16 @@ bool cbScriptLoad(int argc, char* argv[])
bool cbScriptMsg(int argc, char* argv[])
{
if(argc < 2)
{
dputs(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "not enough arguments!")));
if(IsArgumentsLessThan(argc, 2))
return false;
}
GuiScriptMessage(stringformatinline(argv[1]).c_str());
return true;
}
bool cbScriptMsgyn(int argc, char* argv[])
{
if(argc < 2)
{
dputs(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "not enough arguments!")));
if(IsArgumentsLessThan(argc, 2))
return false;
}
varset("$RESULT", GuiScriptMsgyn(stringformatinline(argv[1]).c_str()), false);
return true;
}
@ -53,4 +49,27 @@ bool cbInstrLog(int argc, char* argv[])
dputs_untranslated(stringformat(argv[1], formatArgs).c_str());
}
return true;
}
bool cbInstrPrintStack(int argc, char* argv[])
{
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
std::vector<CALLSTACKENTRY> callstackVector;
stackgetcallstack(csp, callstackVector, false);
if(callstackVector.size() == 0)
dputs(QT_TRANSLATE_NOOP("DBG", "No call stack."));
else
{
duint cip = GetContextDataEx(hActiveThread, UE_CIP);
#ifdef _WIN64
duint cbp = GetContextDataEx(hActiveThread, UE_RBP);
dprintf(QT_TRANSLATE_NOOP("DBG", "%llu call stack frames (RIP = %p , RSP = %p , RBP = %p ):\n"), callstackVector.size(), cip, csp, cbp);
#else //x86
duint cbp = GetContextDataEx(hActiveThread, UE_EBP);
dprintf(QT_TRANSLATE_NOOP("DBG", "%u call stack frames (EIP = %p , ESP = %p , EBP = %p ):\n"), callstackVector.size(), cip, csp, cbp);
#endif //_WIN64
for(auto & i : callstackVector)
dprintf_untranslated("%p %s\n", i.addr, i.comment);
}
return true;
}

View File

@ -5,4 +5,5 @@
bool cbScriptLoad(int argc, char* argv[]);
bool cbScriptMsg(int argc, char* argv[]);
bool cbScriptMsgyn(int argc, char* argv[]);
bool cbInstrLog(int argc, char* argv[]);
bool cbInstrLog(int argc, char* argv[]);
bool cbInstrPrintStack(int argc, char* argv[]);

View File

@ -423,6 +423,7 @@ static void registercommands()
dbgcmdnew("meminfo", cbInstrMeminfo, true); //command to debug memory map bugs
dbgcmdnew("briefcheck", cbInstrBriefcheck, true); //check if mnemonic briefs are missing
dbgcmdnew("focusinfo", cbInstrFocusinfo, false);
dbgcmdnew("printstack\1logstack", cbInstrPrintStack, true); //print the call stack
};
bool cbCommandProvider(char* cmd, int maxlen)