Skip to content

Commit

Permalink
DBG: move call to CB_STOPDEBUG to the very end of the debug loop
Browse files Browse the repository at this point in the history
close issue #1899
  • Loading branch information
mrexodia committed Feb 14, 2018
1 parent 2c284cd commit 16fdf57
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dbg/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static EXCEPTION_DEBUG_INFO lastExceptionInfo = { 0 };
static char szDebuggeeInitializationScript[MAX_PATH] = "";
static WString gInitExe, gInitCmd, gInitDir, gDllLoader;
static CookieQuery cookie;
static bool bDatabaseLoaded = false;
char szProgramDir[MAX_PATH] = "";
char szFileName[MAX_PATH] = "";
char szSymbolCachePath[MAX_PATH] = "";
Expand Down Expand Up @@ -1341,6 +1342,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)

// Init program database
DbLoad(DbLoadSaveType::DebugData);
bDatabaseLoaded = true;

SafeSymSetOptions(SYMOPT_IGNORE_CVREC | SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_FAVOR_COMPRESSED | SYMOPT_IGNORE_NT_SYMPATH);
GuiSymbolLogClear();
Expand Down Expand Up @@ -2549,6 +2551,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
bIsAttached = attach;
dbgsetskipexceptions(false);
bFreezeStack = false;
bDatabaseLoaded = false;

//prepare attach/createprocess
DWORD pid;
Expand Down Expand Up @@ -2716,6 +2719,9 @@ static void debugLoopFunction(void* lpParameter, bool attach)
DebugLoop();
}

if(bDatabaseLoaded) //fixes data loss when attach failed (https://github.com/x64dbg/x64dbg/issues/1899)
DbClose();

//call plugin callback
PLUG_CB_STOPDEBUG stopInfo;
stopInfo.reserved = 0;
Expand All @@ -2731,7 +2737,6 @@ static void debugLoopFunction(void* lpParameter, bool attach)
//cleanup
dbgcleartracestate();
dbgClearRtuBreakpoints();
DbClose();
ModClear();
ThreadClear();
WatchClear();
Expand Down

0 comments on commit 16fdf57

Please sign in to comment.