- resolved issue #34 (no more random crashes)
- added step until return (thanks to RaMMicHaeL for the suggestion)
This commit is contained in:
parent
e5a6871ab3
commit
7841d1c1b3
|
@ -52,3 +52,4 @@ x64_dbg_gui/Project/Src/Bridge/libx64_bridge.a
|
|||
x64_dbg_gui/Project/Src/Bridge/x32_bridge.lib
|
||||
x64_dbg_gui/Project/Src/Bridge/x64_bridge.lib
|
||||
help/output/*
|
||||
*.autosave
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "memory.h"
|
||||
#include "sqlhelper.h"
|
||||
#include "breakpoint.h"
|
||||
#include "threading.h"
|
||||
|
||||
sqlite3* userdb;
|
||||
static std::vector<MODINFO> modinfo;
|
||||
|
@ -12,11 +13,14 @@ static std::vector<MODINFO> modinfo;
|
|||
void dbinit()
|
||||
{
|
||||
//initialize user database
|
||||
lock(WAITID_USERDB);
|
||||
if(sqlite3_open(":memory:", &userdb))
|
||||
{
|
||||
unlock(WAITID_USERDB);
|
||||
dputs("failed to open database!");
|
||||
return;
|
||||
}
|
||||
unlock(WAITID_USERDB);
|
||||
sqlloadsavedb(userdb, dbpath, false);
|
||||
if(!sqlexec(userdb, "CREATE TABLE IF NOT EXISTS labels (id INTEGER PRIMARY KEY AUTOINCREMENT, mod TEXT, addr INT64 NOT NULL, text TEXT NOT NULL)"))
|
||||
dprintf("SQL Error: %s\n", sqllasterror());
|
||||
|
@ -55,8 +59,11 @@ void dbclose()
|
|||
if(!sqlexec(userdb, "DELETE FROM breakpoints WHERE mod IS NULL"))
|
||||
dprintf("SQL Error: %s\n", sqllasterror());
|
||||
dbsave();
|
||||
wait(WAITID_USERDB); //wait for the SQLite operation to complete before closing
|
||||
lock(WAITID_USERDB);
|
||||
sqlite3_db_release_memory(userdb);
|
||||
sqlite3_close(userdb); //close user database
|
||||
unlock(WAITID_USERDB);
|
||||
}
|
||||
|
||||
///module functions
|
||||
|
@ -369,14 +376,17 @@ bool labelfromstring(const char* text, uint* addr)
|
|||
char sql[deflen]="";
|
||||
sprintf(sql, "SELECT addr,mod FROM labels WHERE text='%s'", labeltext);
|
||||
sqlite3_stmt* stmt;
|
||||
lock(WAITID_USERDB);
|
||||
if(sqlite3_prepare_v2(userdb, sql, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
#ifdef _WIN64
|
||||
|
@ -388,11 +398,13 @@ bool labelfromstring(const char* text, uint* addr)
|
|||
if(!modname)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
//TODO: fix this
|
||||
*addr+=modbasefromname(modname);
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -545,14 +557,17 @@ bool functionget(duint addr, duint* start, duint* end)
|
|||
sprintf(sql, "SELECT start,end FROM functions WHERE mod='%s' AND start<=%"fext"d AND end>=%"fext"d", modname, rva, rva);
|
||||
}
|
||||
sqlite3_stmt* stmt;
|
||||
lock(WAITID_USERDB);
|
||||
if(sqlite3_prepare_v2(userdb, sql, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
#ifdef _WIN64
|
||||
|
@ -567,6 +582,7 @@ bool functionget(duint addr, duint* start, duint* end)
|
|||
*start=dbstart;
|
||||
if(end)
|
||||
*end=dbend;
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "sqlhelper.h"
|
||||
#include "console.h"
|
||||
#include "memory.h"
|
||||
#include "threading.h"
|
||||
|
||||
static BREAKPOINT bpall[1000]; //TODO: fix this size
|
||||
static int bpcount=0;
|
||||
|
@ -86,19 +87,23 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
|
|||
sprintf(sql, "SELECT addr,enabled,singleshoot,oldbytes,type,titantype,mod,name FROM breakpoints WHERE (addr=%"fext"d AND type=%d AND mod='%s')", addr-modbase, type, modname);
|
||||
}
|
||||
sqlite3_stmt* stmt;
|
||||
lock(WAITID_USERDB);
|
||||
if(sqlite3_prepare_v2(userdb, sql, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(!bp) //just check if a breakpoint exists
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
memset(bp, 0, sizeof(BREAKPOINT));
|
||||
|
@ -133,6 +138,7 @@ bool bpget(uint addr, BP_TYPE type, const char* name, BREAKPOINT* bp)
|
|||
if(memisvalidreadptr(fdProcessInfo->hProcess, bp->addr))
|
||||
bp->active=true;
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -214,14 +220,17 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
|
|||
else
|
||||
sprintf(sql, "SELECT addr,enabled,singleshoot,oldbytes,type,titantype,mod,name FROM breakpoints WHERE mod='%s'", module);
|
||||
sqlite3_stmt* stmt;
|
||||
lock(WAITID_USERDB);
|
||||
if(sqlite3_prepare_v2(userdb, sql, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
BREAKPOINT curbp;
|
||||
|
@ -270,6 +279,7 @@ bool bpenumall(BPENUMCALLBACK cbEnum, const char* module)
|
|||
}
|
||||
while(sqlite3_step(stmt)==SQLITE_ROW);
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,6 +549,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
|||
|
||||
static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
||||
{
|
||||
lock(WAITID_STOP); //we are running
|
||||
//initialize
|
||||
bIsAttached=false;
|
||||
bSkipExceptions=false;
|
||||
|
@ -565,6 +566,7 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
|||
{
|
||||
fdProcessInfo=&g_pi;
|
||||
dputs("error starting process (invalid pe?)!");
|
||||
unlock(WAITID_STOP);
|
||||
return 0;
|
||||
}
|
||||
BOOL wow64=false, mewow64=false;
|
||||
|
@ -572,19 +574,19 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
|||
{
|
||||
dputs("IsWow64Process failed!");
|
||||
StopDebug();
|
||||
unlock(WAITID_STOP);
|
||||
return 0;
|
||||
}
|
||||
if((mewow64 and !wow64) or (!mewow64 and wow64))
|
||||
{
|
||||
#ifdef _WIN64
|
||||
dputs("Use x32_dbg to debug this process!");
|
||||
return 0;
|
||||
#else
|
||||
dputs("Use x64_dbg to debug this process!");
|
||||
#endif // _WIN64
|
||||
unlock(WAITID_STOP);
|
||||
return 0;
|
||||
}
|
||||
lock(WAITID_STOP);
|
||||
BridgeSettingSet("Recent Files", "path", szFileName);
|
||||
varset("$hp", (uint)fdProcessInfo->hProcess, true);
|
||||
varset("$pid", fdProcessInfo->dwProcessId, true);
|
||||
|
@ -631,8 +633,7 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
|
|||
dputs("debugging stopped!");
|
||||
varset("$hp", 0, true);
|
||||
varset("$pid", 0, true);
|
||||
unlock(WAITID_STOP);
|
||||
waitclear();
|
||||
unlock(WAITID_STOP); //we are done
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -685,7 +686,8 @@ CMDRESULT cbDebugInit(int argc, char* argv[])
|
|||
if(*currentfolder)
|
||||
init->currentfolder=currentfolder;
|
||||
//initialize
|
||||
waitclear(); //clear waiting flags
|
||||
wait(WAITID_STOP); //wait for the debugger to stop
|
||||
waitclear(); //clear waiting flags NOTE: thread-unsafe
|
||||
if(!CreateThread(0, 0, threadDebugLoop, init, 0, 0))
|
||||
{
|
||||
dputs("failed creating debug thread!");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "sqlhelper.h"
|
||||
#include "console.h"
|
||||
#include "threading.h"
|
||||
|
||||
static char lasterror[deflen]="";
|
||||
|
||||
|
@ -10,31 +11,39 @@ const char* sqllasterror()
|
|||
|
||||
bool sqlexec(sqlite3* db, const char* query)
|
||||
{
|
||||
lock(WAITID_USERDB);
|
||||
char* errorText=0;
|
||||
if(sqlite3_exec(db, query, 0, 0, &errorText)!=SQLITE_OK) //error
|
||||
{
|
||||
strcpy(lasterror, errorText);
|
||||
if(errorText)
|
||||
strcpy(lasterror, errorText);
|
||||
sqlite3_free(errorText);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
*lasterror=0;
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sqlhasresult(sqlite3* db, const char* query)
|
||||
{
|
||||
lock(WAITID_USERDB);
|
||||
sqlite3_stmt* stmt;
|
||||
if(sqlite3_prepare_v2(db, query, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,19 +51,23 @@ bool sqlgettext(sqlite3* db, const char* query, char* result)
|
|||
{
|
||||
if(!result)
|
||||
return false;
|
||||
lock(WAITID_USERDB);
|
||||
sqlite3_stmt* stmt;
|
||||
if(sqlite3_prepare_v2(db, query, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
strcpy(result, (const char*)sqlite3_column_text(stmt, 0));
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,19 +75,23 @@ bool sqlgetint(sqlite3* db, const char* query, int* result)
|
|||
{
|
||||
if(!result)
|
||||
return false;
|
||||
lock(WAITID_USERDB);
|
||||
sqlite3_stmt* stmt;
|
||||
if(sqlite3_prepare_v2(db, query, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
*result=sqlite3_column_int(stmt, 0);
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -82,15 +99,18 @@ bool sqlgetuint(sqlite3* db, const char* query, uint* result)
|
|||
{
|
||||
if(!result)
|
||||
return false;
|
||||
lock(WAITID_USERDB);
|
||||
sqlite3_stmt* stmt;
|
||||
if(sqlite3_prepare_v2(db, query, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
if(sqlite3_step(stmt)!=SQLITE_ROW)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
#ifdef _WIN64
|
||||
|
@ -99,6 +119,7 @@ bool sqlgetuint(sqlite3* db, const char* query, uint* result)
|
|||
*result=sqlite3_column_int(stmt, 0);
|
||||
#endif // _WIN64
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -119,6 +140,7 @@ void sqlstringescape(const char* string, char* escaped_string)
|
|||
|
||||
bool sqlloadsavedb(sqlite3* memory, const char* file, bool save)
|
||||
{
|
||||
lock(WAITID_USERDB);
|
||||
//CREDIT: http://www.sqlite.org/backup.html
|
||||
int rc;
|
||||
sqlite3* pFile;
|
||||
|
@ -139,19 +161,23 @@ bool sqlloadsavedb(sqlite3* memory, const char* file, bool save)
|
|||
rc=sqlite3_errcode(pTo);
|
||||
}
|
||||
sqlite3_close(pFile);
|
||||
unlock(WAITID_USERDB);
|
||||
return (rc==SQLITE_OK);
|
||||
}
|
||||
|
||||
int sqlrowcount(sqlite3* db, const char* query)
|
||||
{
|
||||
lock(WAITID_USERDB);
|
||||
int rowcount=0;
|
||||
sqlite3_stmt* stmt;
|
||||
if(sqlite3_prepare_v2(db, query, -1, &stmt, 0)!=SQLITE_OK)
|
||||
{
|
||||
sqlite3_finalize(stmt);
|
||||
unlock(WAITID_USERDB);
|
||||
return false;
|
||||
}
|
||||
while(sqlite3_step(stmt)==SQLITE_ROW)
|
||||
rowcount++;
|
||||
unlock(WAITID_USERDB);
|
||||
return rowcount;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "threading.h"
|
||||
|
||||
static bool waitarray[16];
|
||||
static volatile bool waitarray[16];
|
||||
|
||||
void waitclear()
|
||||
{
|
||||
memset(waitarray, 0, sizeof(waitarray));
|
||||
memset((void*)waitarray, 0, sizeof(waitarray));
|
||||
}
|
||||
|
||||
void wait(WAIT_ID id)
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
enum WAIT_ID
|
||||
{
|
||||
WAITID_RUN,
|
||||
WAITID_STOP
|
||||
WAITID_STOP,
|
||||
WAITID_USERDB
|
||||
};
|
||||
|
||||
//functions
|
||||
|
|
|
@ -4,7 +4,6 @@ CPUDisassembly::CPUDisassembly(QWidget *parent) : Disassembly(parent)
|
|||
{
|
||||
// Create the action list for the right click context menu
|
||||
setupRightClickContextMenu();
|
||||
|
||||
}
|
||||
|
||||
void CPUDisassembly::CopyToClipboard(const char* text)
|
||||
|
|
|
@ -87,3 +87,12 @@ QVBoxLayout* CPUWidget::getBotRightWidget(void)
|
|||
{
|
||||
return ui->mBotRightFrameLayout;
|
||||
}
|
||||
|
||||
void CPUWidget::runSelection()
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
QString command = "bp " + QString("%1").arg(mDisas->rvaToVa(mDisas->getInitialSelection()), sizeof(int_t)*2, 16, QChar('0')).toUpper() + ", ss";
|
||||
if(DbgCmdExecDirect(command.toUtf8().constData()))
|
||||
DbgCmdExecDirect("run");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ public:
|
|||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void runSelection();
|
||||
|
||||
private:
|
||||
Ui::CPUWidget *ui;
|
||||
Disassembly* mDisas;
|
||||
|
|
|
@ -108,12 +108,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
connect(ui->actionScylla,SIGNAL(triggered()),this,SLOT(startScylla()));
|
||||
connect(ui->actionRestart,SIGNAL(triggered()),this,SLOT(restartDebugging()));
|
||||
connect(ui->actionBreakpoints,SIGNAL(triggered()),this,SLOT(displayBreakpointWidget()));
|
||||
|
||||
connect(ui->actioneStepOver,SIGNAL(triggered()),this,SLOT(execeStepOver()));
|
||||
connect(ui->actioneStepInto,SIGNAL(triggered()),this,SLOT(execeStepInto()));
|
||||
connect(ui->actioneRun,SIGNAL(triggered()),this,SLOT(execeRun()));
|
||||
connect(ui->actioneRtr,SIGNAL(triggered()),this,SLOT(execeRtr()));
|
||||
connect(ui->actionScript,SIGNAL(triggered()),this,SLOT(displayScriptWidget()));
|
||||
connect(ui->actionRunSelection,SIGNAL(triggered()),mCpuWin,SLOT(runSelection()));
|
||||
|
||||
connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateCPUTitle(QString)), this, SLOT(updateCPUTitleSlot(QString)));
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
</property>
|
||||
<addaction name="actionRun"/>
|
||||
<addaction name="actioneRun"/>
|
||||
<addaction name="actionRunSelection"/>
|
||||
<addaction name="actionPause"/>
|
||||
<addaction name="actionRestart"/>
|
||||
<addaction name="actionClose"/>
|
||||
|
@ -383,6 +384,21 @@
|
|||
<string>Alt+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRunSelection">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resource.qrc">
|
||||
<normaloff>:/icons/images/arrow-run-cursor.png</normaloff>:/icons/images/arrow-run-cursor.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run until selection</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Run until selection</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F4</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 665 B |
|
@ -25,5 +25,6 @@
|
|||
<file>images/script-error.png</file>
|
||||
<file>images/information.png</file>
|
||||
<file>images/question.png</file>
|
||||
<file>images/arrow-run-cursor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in New Issue