Fix compilation errors
This commit is contained in:
parent
5d0f5da46c
commit
f9a038e566
|
|
@ -21,7 +21,6 @@ static void GuiAddLogMessageAsync(_In_z_ const char* msg)
|
|||
*/
|
||||
void dputs(_In_z_ const char* Text)
|
||||
{
|
||||
dprintf_untranslated("[%llu] ", (unsigned long long)time(nullptr));
|
||||
// Only append the newline if the caller didn't
|
||||
const char* TranslatedText = GuiTranslateText(Text);
|
||||
size_t textlen = strlen(TranslatedText);
|
||||
|
|
@ -59,29 +58,6 @@ void dprintf_untranslated(_In_z_ _Printf_format_string_ const char* Format, ...)
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
static double getTimeInMilliseconds()
|
||||
{
|
||||
static LARGE_INTEGER freq;
|
||||
static bool isInitialized = false;
|
||||
|
||||
if(isInitialized == false)
|
||||
{
|
||||
// Expensive crap.
|
||||
QueryPerformanceFrequency(&freq);
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
LARGE_INTEGER ct;
|
||||
QueryPerformanceCounter(&ct);
|
||||
|
||||
return ((double)ct.QuadPart * 1000.0) / (double)freq.QuadPart;
|
||||
}
|
||||
|
||||
static double getTimeInSeconds()
|
||||
{
|
||||
return getTimeInMilliseconds() / 1000.0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Print a formatted string to the console.
|
||||
\param format The printf format to use (see documentation of printf for more information).
|
||||
|
|
@ -89,15 +65,8 @@ static double getTimeInSeconds()
|
|||
*/
|
||||
void dprintf_args(_In_z_ _Printf_format_string_ const char* Format, va_list Args)
|
||||
{
|
||||
static double startupTime = getTimeInSeconds();
|
||||
double dElapsed = getTimeInSeconds() - startupTime;
|
||||
int64_t elapsed = (int64_t)dElapsed;
|
||||
int64_t minutes = elapsed / 60;
|
||||
int64_t ms = (int64_t)((dElapsed - elapsed) * 1000.0);
|
||||
|
||||
char buffer[16384];
|
||||
auto len = sprintf_s(buffer, "[%llu] ", (unsigned long long)time(nullptr));
|
||||
vsnprintf_s(buffer + len, _countof(buffer) - len, _TRUNCATE, GuiTranslateText(Format), Args);
|
||||
vsnprintf_s(buffer, _TRUNCATE, GuiTranslateText(Format), Args);
|
||||
|
||||
GuiAddLogMessageAsync(buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ static duint pCreateProcessBase = 0;
|
|||
static duint pDebuggedEntry = 0;
|
||||
static bool bRepeatIn = false;
|
||||
static duint stepRepeat = 0;
|
||||
static bool isDetachedByUser = false;
|
||||
static bool bIsAttached = false;
|
||||
static bool bSkipExceptions = false;
|
||||
static duint skipExceptionCount = 0;
|
||||
|
|
@ -326,6 +327,11 @@ void dbgsetsteprepeat(bool steppingIn, duint repeat)
|
|||
stepRepeat = repeat;
|
||||
}
|
||||
|
||||
void dbgsetisdetachedbyuser(bool b)
|
||||
{
|
||||
isDetachedByUser = b;
|
||||
}
|
||||
|
||||
void dbgsetfreezestack(bool freeze)
|
||||
{
|
||||
bFreezeStack = freeze;
|
||||
|
|
@ -1894,6 +1900,20 @@ static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString)
|
|||
}
|
||||
}
|
||||
|
||||
static bool dbgdetachDisableAllBreakpoints(const BREAKPOINT* bp)
|
||||
{
|
||||
if(bp->enabled)
|
||||
{
|
||||
if(bp->type == BPNORMAL)
|
||||
DeleteBPX(bp->addr);
|
||||
else if(bp->type == BPMEMORY)
|
||||
RemoveMemoryBPX(bp->addr, 0);
|
||||
else if(bp->type == BPHARDWARE && TITANDRXVALID(bp->titantype))
|
||||
DeleteHardwareBreakPoint(TITANGETDRX(bp->titantype));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
||||
{
|
||||
hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId);
|
||||
|
|
@ -1914,7 +1934,24 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(ExceptionData->ExceptionRecord.ExceptionCode == MS_VC_EXCEPTION) //SetThreadName exception
|
||||
if(ExceptionData->ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT)
|
||||
{
|
||||
if(isDetachedByUser)
|
||||
{
|
||||
PLUG_CB_DETACH detachInfo;
|
||||
detachInfo.fdProcessInfo = fdProcessInfo;
|
||||
plugincbcall(CB_DETACH, &detachInfo);
|
||||
BpEnumAll(dbgdetachDisableAllBreakpoints); // Disable all software breakpoints before detaching.
|
||||
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
|
||||
else
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
|
||||
isDetachedByUser = false;
|
||||
_dbg_animatestop(); // Stop animating
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(ExceptionData->ExceptionRecord.ExceptionCode == MS_VC_EXCEPTION) //SetThreadName exception
|
||||
{
|
||||
THREADNAME_INFO nameInfo; //has no valid local pointers
|
||||
memcpy(&nameInfo, ExceptionData->ExceptionRecord.ExceptionInformation, sizeof(THREADNAME_INFO));
|
||||
|
|
@ -1993,6 +2030,21 @@ static void cbAttachDebugger()
|
|||
varset("$pid", fdProcessInfo->dwProcessId, true);
|
||||
}
|
||||
|
||||
void cbDetach()
|
||||
{
|
||||
if(!isDetachedByUser)
|
||||
return;
|
||||
PLUG_CB_DETACH detachInfo;
|
||||
detachInfo.fdProcessInfo = fdProcessInfo;
|
||||
plugincbcall(CB_DETACH, &detachInfo);
|
||||
BpEnumAll(dbgdetachDisableAllBreakpoints); // Disable all software breakpoints before detaching.
|
||||
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
|
||||
else
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
|
||||
return;
|
||||
}
|
||||
|
||||
cmdline_qoutes_placement_t getqoutesplacement(const char* cmdline)
|
||||
{
|
||||
cmdline_qoutes_placement_t quotesPos;
|
||||
|
|
@ -2797,6 +2849,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
|
|||
pDebuggedEntry = 0;
|
||||
pDebuggedBase = 0;
|
||||
pCreateProcessBase = 0;
|
||||
isDetachedByUser = false;
|
||||
hActiveThread = nullptr;
|
||||
if(!gDllLoader.empty()) //Delete the DLL loader (#1496)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ void DebugSetBreakpoints();
|
|||
void GuiSetDebugStateAsync(DBGSTATE state);
|
||||
void dbgsetskipexceptions(bool skip);
|
||||
void dbgsetsteprepeat(bool steppingIn, duint repeat);
|
||||
void dbgsetisdetachedbyuser(bool b);
|
||||
void dbgsetfreezestack(bool freeze);
|
||||
void dbgclearignoredexceptions();
|
||||
void dbgaddignoredexception(ExceptionRange range);
|
||||
|
|
@ -99,6 +100,7 @@ void cbTraceIntoIntoTraceRecordStep();
|
|||
void cbTraceOverIntoTraceRecordStep();
|
||||
void cbRunToUserCodeBreakpoint(void* ExceptionAddress);
|
||||
DWORD WINAPI threadAttachLoop(void* lpParameter);
|
||||
void cbDetach();
|
||||
bool cbSetModuleBreakpoints(const BREAKPOINT* bp);
|
||||
EXCEPTION_DEBUG_INFO & getLastExceptionInfo();
|
||||
bool dbgrestartadmin();
|
||||
|
|
|
|||
Loading…
Reference in New Issue