ide: Fixed freezes with active debugger

git-svn-id: svn://ultimatepp.org/upp/trunk@7886 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-11-12 14:24:15 +00:00
parent 3f1c0d28f0
commit dc9ec7d974
6 changed files with 31 additions and 3 deletions

View file

@ -340,6 +340,7 @@ bool Ide::EditorTip(CodeEditor::MouseTip& mt)
{
if(!debugger)
return false;
DR_LOG("EditorTip");
int pos = mt.pos;
String e;
String sep;
@ -350,7 +351,7 @@ bool Ide::EditorTip(CodeEditor::MouseTip& mt)
e = b + sep + e;
sep = ".";
while(pos > 0 && editor.GetChar(pos - 1) == ' ')
pos++;
pos--;
if(pos > 0 && editor.GetChar(pos - 1) == '.')
--pos;
else
@ -364,7 +365,8 @@ bool Ide::EditorTip(CodeEditor::MouseTip& mt)
else
break;
while(pos > 0 && editor.GetChar(pos - 1) == ' ')
pos++;
pos--;
}
DR_LOG("debugger->Tip");
return debugger->Tip(e, mt);
}

View file

@ -278,6 +278,7 @@ bool Pdb::Tip(const String& exp, CodeEditor::MouseTip& mt)
mt.value = exp;
mt.sz = Size(100, 20);
return true;*/
DR_LOG("Pdb::Tip");
Visual r;
try {
CParser p(exp);
@ -287,10 +288,12 @@ bool Pdb::Tip(const String& exp, CodeEditor::MouseTip& mt)
mt.sz = r.GetSize() + Size(4, 4);
mt.value = RawPickToValue(r);
mt.display = &Single<VisualDisplay>();
DR_LOG("Pdb::Tip true");
return true;
}
}
catch(CParser::Error) {}
DR_LOG("Pdb::Tip false");
return false;
}

View file

@ -173,6 +173,7 @@ void Pdb::Unlock()
Pdb::Context Pdb::ReadContext(HANDLE hThread)
{
DR_LOG("ReadContext");
Context r;
#ifdef CPU_64
if(win64) {
@ -201,6 +202,7 @@ Pdb::Context Pdb::ReadContext(HANDLE hThread)
void Pdb::WriteContext(HANDLE hThread, Context& context)
{
DR_LOG("WriteContext");
#ifdef CPU_64
if(win64) {
CONTEXT ctx;
@ -229,6 +231,7 @@ void Pdb::AddThread(dword dwThreadId, HANDLE hThread)
{
if(threads.Find(dwThreadId) >= 0)
return;
DR_LOG("AddThread");
Thread& f = threads.GetAdd(dwThreadId);
// Retrive "base-level" stack-pointer, to have limit for stackwalks:
Context c = ReadContext(hThread);
@ -312,6 +315,7 @@ void Pdb::ToForeground()
bool Pdb::RunToException()
{
DR_LOG("RunToException");
LLOG("RUN TO EXCEPTION");
TimeStop ts;
bool disasfocus = disas.HasFocus();
@ -327,12 +331,15 @@ bool Pdb::RunToException()
return false;
}
opn++;
DR_LOG("WaitForDebugEvent");
if(WaitForDebugEvent(&event, 0)) {
DR_LOG("WaitForDebugEvent ended");
debug_threadid = event.dwThreadId;
opn = 0;
running = false;
switch(event.dwDebugEventCode) {
case EXCEPTION_DEBUG_EVENT: {
DR_LOG("EXCEPTION_DEBUG_EVENT");
LLOG("Exception: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionCode) <<
" at: " << FormatIntHex(event.u.Exception.ExceptionRecord.ExceptionAddress) <<
" first: " << event.u.Exception.dwFirstChance);
@ -399,14 +406,17 @@ bool Pdb::RunToException()
return true;
}
case CREATE_THREAD_DEBUG_EVENT:
DR_LOG("CREATE_THREAD_DEBUG_EVENT");
LLOG("Create thread: " << event.dwThreadId);
AddThread(event.dwThreadId, event.u.CreateThread.hThread);
break;
case EXIT_THREAD_DEBUG_EVENT:
DR_LOG("EXIT_THREAD_DEBUG_EVENT");
LLOG("Exit thread: " << event.dwThreadId);
RemoveThread(event.dwThreadId);
break;
case CREATE_PROCESS_DEBUG_EVENT:
DR_LOG("CREATE_PROCESS_DEBUG_EVENT");
LLOG("Create process: " << event.dwProcessId);
processid = event.dwProcessId;
AddThread(event.dwThreadId, event.u.CreateProcessInfo.hThread);
@ -414,22 +424,26 @@ bool Pdb::RunToException()
CloseHandle(event.u.CreateProcessInfo.hProcess);
break;
case EXIT_PROCESS_DEBUG_EVENT:
DR_LOG("EXIT_PROCESS_DEBUG_EVENT");
LLOG("Exit process: " << event.dwProcessId);
if(locked)
Unlock();
terminated = true;
return false;
case LOAD_DLL_DEBUG_EVENT: {
DR_LOG("LOAD_DLL_DEBUG_EVENT");
LLOG("Load dll: " << event.u.LoadDll.lpBaseOfDll);
CloseHandle(event.u.LoadDll.hFile);
refreshmodules = true;
break;
}
case UNLOAD_DLL_DEBUG_EVENT:
DR_LOG("UNLOAD_DLL_DEBUG_EVENT");
LLOG("UnLoad dll: " << event.u.UnloadDll.lpBaseOfDll);
refreshmodules = true;
break;
case RIP_EVENT:
DR_LOG("RIP_EVENT");
LLOG("RIP!");
Exclamation("Process being debugged died unexpectedly!");
terminated = true;
@ -437,10 +451,12 @@ bool Pdb::RunToException()
Unlock();
return false;
}
DR_LOG("ContinueDebugEvent");
ContinueDebugEvent(event.dwProcessId, event.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
running = true;
}
if(ts.Elapsed() > 200) {
DR_LOG("ts.Elpsed() > 200");
if(!lock) {
Lock();
locked = true;
@ -451,11 +467,14 @@ bool Pdb::RunToException()
}
}
if(lock) {
DR_LOG("GuiSleep");
GuiSleep(opn < 1000 ? 0 : 100);
Ctrl::ProcessEvents();
}
else
else {
DR_LOG("Sleep");
Sleep(opn < 1000 ? 0 : 100);
}
}
}

View file

@ -1,6 +1,8 @@
#ifndef __Debuggers__
#define __Debuggers__
#define DR_LOG(x) // RLOG(x)
#include <ide/Common/Common.h>
#include <HexView/HexView.h>

View file

@ -550,6 +550,7 @@ Pdb::Val Pdb::LogOr(CParser& p)
Pdb::Val Pdb::Exp0(CParser& p)
{
DR_LOG("Evaluating Expression: " << p.GetPtr());
LLOG("Evaluating Expression: " << p.GetPtr());
return LogOr(p);
}

View file

@ -55,6 +55,7 @@ void Pdb::CatInt(Visual& result, int64 val)
void Pdb::Visualise(Visual& result, Pdb::Val val, int expandptr, int slen)
{
DR_LOG("Visualise");
const int maxlen = 300;
if(result.length > maxlen)
return;