GUI/DBG/BRIDGE: symbol downloading progress bar
DBG: fixed memory problems with vectors DBG: seperate symbol log GUI: symbol log implemented DBG: draft of the symbol loader
This commit is contained in:
parent
2f3c1eab0d
commit
da61240e3e
|
@ -22,6 +22,7 @@ x64_dbg_*/x64/*
|
|||
!bin/*/test.dll
|
||||
!bin/*/test.exe
|
||||
!bin/*/dbghelp.dll
|
||||
!bin/*/symsrv.dll
|
||||
!bin/*/sqlite.dll
|
||||
!bin/*/BeaEngine.dll
|
||||
!bin/*/Scylla.dll
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -641,6 +641,11 @@ BRIDGE_IMPEXP void GuiSymbolUpdateList(int count, SYMBOLMODULEINFO* modules)
|
|||
_gui_sendmessage(GUI_SYMBOL_UPDATE_LIST, (void*)(duint)count, (void*)modules);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiSymbolSetProgress(int percent)
|
||||
{
|
||||
_gui_sendmessage(GUI_SYMBOL_SET_PROGRESS, (void*)(duint)percent, 0);
|
||||
}
|
||||
|
||||
//Main
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
|
|
|
@ -304,7 +304,8 @@ enum GUIMSG
|
|||
|
||||
GUI_SYMBOL_LOG_ADD, // param1(const char*)msg, param2=unused
|
||||
GUI_SYMBOL_LOG_CLEAR, // param1=unused, param2=unused
|
||||
GUI_SYMBOL_UPDATE_LIST // param1=int count, param2=SYMBOLMODULEINFO* modules
|
||||
GUI_SYMBOL_UPDATE_LIST, // param1=int count, param2=SYMBOLMODULEINFO* modules
|
||||
GUI_SYMBOL_SET_PROGRESS // param1=int percent param2=unused
|
||||
};
|
||||
|
||||
//GUI functions
|
||||
|
@ -333,6 +334,7 @@ BRIDGE_IMPEXP int GuiScriptMsgyn(const char* message);
|
|||
BRIDGE_IMPEXP void GuiSymbolLogAdd(const char* message);
|
||||
BRIDGE_IMPEXP void GuiSymbolLogClear();
|
||||
BRIDGE_IMPEXP void GuiSymbolUpdateList(int count, SYMBOLMODULEINFO* modules);
|
||||
BRIDGE_IMPEXP void GuiSymbolSetProgress(int percent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ bool modload(uint base, uint size, const char* fullpath)
|
|||
strcpy(info.name, name);
|
||||
_strlwr(info.name);
|
||||
modinfo.push_back(info);
|
||||
symbolupdategui();
|
||||
symbolloadmodule(&info);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ bool modunload(uint base)
|
|||
if(modinfo.at(i).base==base)
|
||||
{
|
||||
modinfo.erase(modinfo.begin()+i);
|
||||
symbolunloadmodule(base);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +116,8 @@ bool modunload(uint base)
|
|||
|
||||
void modclear()
|
||||
{
|
||||
modinfo.clear();
|
||||
std::vector<MODINFO>().swap(modinfo);
|
||||
symbolclear();
|
||||
}
|
||||
|
||||
bool modnamefromaddr(uint addr, char* modname, bool extension)
|
||||
|
|
|
@ -209,7 +209,7 @@ static void cbMemoryBreakpoint(void* ExceptionAddress)
|
|||
wait(WAITID_RUN);
|
||||
}
|
||||
|
||||
BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64 UserContext)
|
||||
static BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64 UserContext)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hProcess);
|
||||
UNREFERENCED_PARAMETER(UserContext);
|
||||
|
@ -217,12 +217,56 @@ BOOL CALLBACK SymRegisterCallbackProc64(HANDLE hProcess, ULONG ActionCode, ULONG
|
|||
switch (ActionCode)
|
||||
{
|
||||
case CBA_EVENT:
|
||||
{
|
||||
evt=(PIMAGEHLP_CBA_EVENT)CallbackData;
|
||||
dprintf("%s", (PTSTR)evt->desc);
|
||||
break;
|
||||
const char* text=(const char*)evt->desc;
|
||||
int len=strlen(text);
|
||||
bool suspress=false;
|
||||
for(int i=0; i<len; i++)
|
||||
if(text[i]==0x08)
|
||||
{
|
||||
suspress=true;
|
||||
break;
|
||||
}
|
||||
int percent=0;
|
||||
static bool zerobar=false;
|
||||
if(zerobar)
|
||||
{
|
||||
zerobar=false;
|
||||
GuiSymbolSetProgress(0);
|
||||
}
|
||||
if(strstr(text, " bytes - "))
|
||||
{
|
||||
char* newtext=(char*)emalloc(len+1, "SymRegisterCallbackProc64:newtext");
|
||||
strcpy(newtext, text);
|
||||
strstr(newtext, " bytes - ")[8]=0;
|
||||
GuiSymbolLogAdd(newtext);
|
||||
efree(newtext, "SymRegisterCallbackProc64:newtext");
|
||||
suspress=true;
|
||||
}
|
||||
else if(strstr(text, " copied "))
|
||||
{
|
||||
GuiSymbolSetProgress(100);
|
||||
GuiSymbolLogAdd(" downloaded!\n");
|
||||
suspress=true;
|
||||
zerobar=true;
|
||||
}
|
||||
else if(sscanf(text, "%*s %d percent", &percent)==1 or sscanf(text, "%d percent", &percent)==1)
|
||||
{
|
||||
GuiSymbolSetProgress(percent);
|
||||
suspress=true;
|
||||
}
|
||||
|
||||
if(!suspress)
|
||||
GuiSymbolLogAdd(text);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -359,6 +403,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
|
|||
dprintf("Database file: %s\n", dbpath);
|
||||
dbinit();
|
||||
SymSetOptions(SYMOPT_DEBUG|SYMOPT_LOAD_LINES);
|
||||
GuiSymbolLogClear();
|
||||
SymInitialize(fdProcessInfo->hProcess, 0, false); //initialize symbols
|
||||
SymRegisterCallback64(fdProcessInfo->hProcess, SymRegisterCallbackProc64, 0);
|
||||
SymLoadModuleEx(fdProcessInfo->hProcess, CreateProcessInfo->hFile, DebugFileName, 0, (DWORD64)base, 0, 0, 0);
|
||||
|
@ -629,7 +674,6 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
|||
SymCleanup(fdProcessInfo->hProcess);
|
||||
dbclose();
|
||||
modclear();
|
||||
GuiSymbolUpdateList(0, 0); //empty the symbol list
|
||||
GuiSetDebugState(stopped);
|
||||
dputs("debugging stopped!");
|
||||
varset("$hp", 0, true);
|
||||
|
@ -1512,6 +1556,7 @@ static void cbAttachDebugger()
|
|||
|
||||
static DWORD WINAPI threadAttachLoop(void* lpParameter)
|
||||
{
|
||||
lock(WAITID_STOP);
|
||||
bIsAttached=true;
|
||||
bSkipExceptions=false;
|
||||
uint pid=(uint)lpParameter;
|
||||
|
@ -1520,7 +1565,6 @@ static DWORD WINAPI threadAttachLoop(void* lpParameter)
|
|||
//do some init stuff
|
||||
bFileIsDll=IsFileDLL(szFileName, 0);
|
||||
BridgeSettingSet("Recent Files", "path", szFileName);
|
||||
lock(WAITID_STOP);
|
||||
ecount=0;
|
||||
//NOTE: set custom handlers
|
||||
SetCustomHandler(UE_CH_CREATEPROCESS, (void*)cbCreateProcess);
|
||||
|
|
|
@ -70,7 +70,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
char temp[256]="";
|
||||
LINEMAPENTRY entry;
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
linemap.clear();
|
||||
std::vector<LINEMAPENTRY>().swap(linemap);
|
||||
for(int i=0,j=0; i<len; i++) //make raw line map
|
||||
{
|
||||
if(filedata[i]=='\r' and filedata[i+1]=='\n') //windows file
|
||||
|
@ -138,7 +138,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
char message[256]="";
|
||||
sprintf(message, "Empty label detected on line %d!", i+1);
|
||||
GuiScriptError(0, message);
|
||||
linemap.clear();
|
||||
std::vector<LINEMAPENTRY>().swap(linemap);
|
||||
return false;
|
||||
}
|
||||
int foundlabel=scriptlabelfind(cur.u.label);
|
||||
|
@ -147,7 +147,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
char message[256]="";
|
||||
sprintf(message, "Duplicate label \"%s\" detected on lines %d and %d!", cur.u.label, foundlabel, i+1);
|
||||
GuiScriptError(0, message);
|
||||
linemap.clear();
|
||||
std::vector<LINEMAPENTRY>().swap(linemap);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
char message[256]="";
|
||||
sprintf(message, "Invalid branch label \"%s\" detected on line %d!", cur.u.branch.branchlabel, i+1);
|
||||
GuiScriptError(0, message);
|
||||
linemap.clear();
|
||||
std::vector<LINEMAPENTRY>().swap(linemap);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ static DWORD WINAPI scriptLoadThread(void* filename)
|
|||
{
|
||||
GuiScriptClear();
|
||||
scriptIp=0;
|
||||
scriptbplist.clear(); //clear breakpoints
|
||||
std::vector<SCRIPTBP>().swap(scriptbplist); //clear breakpoints
|
||||
bAbort=false;
|
||||
if(!scriptcreatelinemap((const char*)filename))
|
||||
return 0;
|
||||
|
@ -421,7 +421,7 @@ void scriptunload()
|
|||
{
|
||||
GuiScriptClear();
|
||||
scriptIp=0;
|
||||
scriptbplist.clear(); //clear breakpoints
|
||||
std::vector<SCRIPTBP>().swap(scriptbplist); //clear breakpoints
|
||||
bAbort=false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,36 @@
|
|||
#include "debugger.h"
|
||||
#include "console.h"
|
||||
|
||||
static BOOL CALLBACK EnumSymProc(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
|
||||
static struct INTERNALSYMBOLMODULEINFO
|
||||
{
|
||||
uint base;
|
||||
char name[MAX_MODULE_SIZE];
|
||||
std::vector<SYMBOLINFO> symbols;
|
||||
};
|
||||
|
||||
static std::vector<INTERNALSYMBOLMODULEINFO> modList;
|
||||
|
||||
static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
static BOOL CALLBACK EnumModules(PCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext)
|
||||
#else
|
||||
static BOOL CALLBACK EnumModules(PCTSTR ModuleName, ULONG BaseOfDll, PVOID UserContext)
|
||||
#endif //_WIN64
|
||||
void symbolloadmodule(MODINFO* modinfo)
|
||||
{
|
||||
return TRUE;
|
||||
INTERNALSYMBOLMODULEINFO curModule;
|
||||
memset(&curModule, 0, sizeof(curModule));
|
||||
curModule.base=modinfo->base;
|
||||
sprintf(curModule.name, "%s%s", modinfo->name, modinfo->extension);
|
||||
modList.push_back(curModule);
|
||||
}
|
||||
|
||||
void symbolunloadmodule(uint base)
|
||||
{
|
||||
}
|
||||
|
||||
void symbolclear()
|
||||
{
|
||||
std::vector<INTERNALSYMBOLMODULEINFO>().swap(modList);
|
||||
}
|
||||
|
||||
void symbolupdategui()
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
#define _SYMBOLINFO_H
|
||||
|
||||
#include "_global.h"
|
||||
#include "addrinfo.h"
|
||||
|
||||
void symbolloadmodule(MODINFO* modinfo);
|
||||
void symbolunloadmodule(uint base);
|
||||
void symbolclear();
|
||||
void symbolupdategui();
|
||||
|
||||
#endif //_SYMBOLINFO_H
|
||||
|
|
|
@ -60,7 +60,8 @@ SymbolView::SymbolView(QWidget *parent) :
|
|||
connect(Bridge::getBridge(), SIGNAL(clearLog()), this, SLOT(clearSymbolLogSlot()));
|
||||
connect(Bridge::getBridge(), SIGNAL(clearSymbolLog()), this, SLOT(clearSymbolLogSlot()));
|
||||
connect(mModuleList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
|
||||
|
||||
connect(Bridge::getBridge(), SIGNAL(updateSymbolList(int,SYMBOLMODULEINFO*)), this, SLOT(updateSymbolList(int,SYMBOLMODULEINFO*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(setSymbolProgress(int)), ui->symbolProgress, SLOT(setValue(int)));
|
||||
emit mModuleList->selectionChangedSignal(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,21 @@ void Bridge::emitUpdateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
|
|||
emit updateSymbolList(module_count, modules);
|
||||
}
|
||||
|
||||
void Bridge::emitAddMsgToSymbolLog(QString msg)
|
||||
{
|
||||
emit addMsgToSymbolLog(msg);
|
||||
}
|
||||
|
||||
void Bridge::emitClearSymbolLog()
|
||||
{
|
||||
emit clearSymbolLog();
|
||||
}
|
||||
|
||||
void Bridge::emitSetSymbolProgress(int progress)
|
||||
{
|
||||
emit setSymbolProgress(progress);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
Static Functions
|
||||
|
@ -248,8 +263,7 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
|
|||
|
||||
case GUI_SCRIPT_SETIP:
|
||||
{
|
||||
int_t arg=(int_t)param1;
|
||||
Bridge::getBridge()->emitScriptSetIp((int)arg);
|
||||
Bridge::getBridge()->emitScriptSetIp((int)(int_t)param1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -289,6 +303,24 @@ __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* pa
|
|||
}
|
||||
break;
|
||||
|
||||
case GUI_SYMBOL_LOG_ADD:
|
||||
{
|
||||
Bridge::getBridge()->emitAddMsgToSymbolLog(QString(reinterpret_cast<const char*>(param1)));
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_SYMBOL_LOG_CLEAR:
|
||||
{
|
||||
Bridge::getBridge()->emitClearSymbolLog();
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_SYMBOL_SET_PROGRESS:
|
||||
{
|
||||
Bridge::getBridge()->emitSetSymbolProgress((int)(int_t)param1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ public:
|
|||
void emitScriptMessage(QString message);
|
||||
int emitScriptQuestion(QString message);
|
||||
void emitUpdateSymbolList(int module_count, SYMBOLMODULEINFO* modules);
|
||||
void emitAddMsgToSymbolLog(QString msg);
|
||||
void emitClearSymbolLog();
|
||||
void emitSetSymbolProgress(int progress);
|
||||
|
||||
void* winId;
|
||||
QWidget* scriptView;
|
||||
|
@ -60,8 +63,6 @@ signals:
|
|||
void updateCPUTitle(QString modname);
|
||||
void setInfoLine(int line, QString text);
|
||||
void dumpAt(int_t va);
|
||||
void addMsgToSymbolLog(QString msg);
|
||||
void clearSymbolLog();
|
||||
|
||||
void scriptAdd(int count, const char** lines);
|
||||
void scriptClear();
|
||||
|
@ -73,6 +74,9 @@ signals:
|
|||
void scriptQuestion(QString message);
|
||||
|
||||
void updateSymbolList(int module_count, SYMBOLMODULEINFO* modules);
|
||||
void addMsgToSymbolLog(QString msg);
|
||||
void clearSymbolLog();
|
||||
void setSymbolProgress(int progress);
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
Loading…
Reference in New Issue