mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Debugger improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@11857 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
8fb4a54fbe
commit
a511e3a67b
3 changed files with 67 additions and 32 deletions
|
|
@ -203,6 +203,7 @@ public:
|
|||
void TreeExpand(int node);
|
||||
|
||||
void CopyStack();
|
||||
void CopyStackAll();
|
||||
void CopyDisas();
|
||||
|
||||
bool Create(One<Host>&& host, const String& exefile, const String& cmdline, bool console);
|
||||
|
|
|
|||
|
|
@ -27,9 +27,41 @@ void Gdb::DebugBar(Bar& bar)
|
|||
bar.Add(b, AK_CPU, THISBACK1(SetTab, 4));
|
||||
bar.MenuSeparator();
|
||||
bar.Add(b, "Copy backtrace", THISBACK(CopyStack));
|
||||
bar.Add(b, "Copy backtrace of all threads", THISBACK(CopyStackAll));
|
||||
bar.Add(b, "Copy dissassembly", THISBACK(CopyDisas));
|
||||
}
|
||||
|
||||
String FormatFrame(const char *s)
|
||||
{
|
||||
if(*s++ != '#')
|
||||
return Null;
|
||||
while(IsDigit(*s))
|
||||
s++;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
if(s[0] == '0' && ToUpper(s[1]) == 'X') {
|
||||
s += 2;
|
||||
while(IsXDigit(*s))
|
||||
s++;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
if(s[0] != 'i' && s[1] != 'n')
|
||||
return Null;
|
||||
s += 2;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
}
|
||||
if(!IsAlpha(*s))
|
||||
return Null;
|
||||
const char *w = strchr(s, '\r');
|
||||
if(w)
|
||||
return String(s, w);
|
||||
w = strchr(s, '\n');
|
||||
if(w)
|
||||
return String(s, w);
|
||||
return s;
|
||||
}
|
||||
|
||||
void Gdb::CopyStack()
|
||||
{
|
||||
if(IdeIsDebugLock())
|
||||
|
|
@ -41,6 +73,40 @@ void Gdb::CopyStack()
|
|||
WriteClipboardText(s);
|
||||
}
|
||||
|
||||
void Gdb::CopyStackAll()
|
||||
{
|
||||
String s = FastCmd("info threads");
|
||||
StringStream ss(s);
|
||||
String r;
|
||||
while(!ss.IsEof()) {
|
||||
String s = ss.GetLine();
|
||||
CParser p(s);
|
||||
try {
|
||||
bool active = p.Char('*');
|
||||
if(p.IsNumber()) {
|
||||
int id = p.ReadInt();
|
||||
r << "----------------------------------\r\n"
|
||||
<< "Thread: " << id << "\r\n\r\n";
|
||||
|
||||
FastCmd(Sprintf("thread %d", id));
|
||||
|
||||
int i = 0;
|
||||
int q = ~frame;
|
||||
frame.Clear();
|
||||
for(;;) {
|
||||
String s = FormatFrame(FastCmd("frame " + AsString(i++)));
|
||||
if(IsNull(s)) break;
|
||||
r << s << "\r\n";
|
||||
}
|
||||
r << "\r\n";
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
FastCmd(Sprintf("thread %d", ~threads));
|
||||
WriteClipboardText(r);
|
||||
}
|
||||
|
||||
void Gdb::CopyDisas()
|
||||
{
|
||||
if(IdeIsDebugLock())
|
||||
|
|
@ -116,37 +182,6 @@ void Gdb::SyncDisas(bool fr)
|
|||
disas.SetIp(addr, fr ? DbgImg::FrameLinePtr() : DbgImg::IpLinePtr());
|
||||
}
|
||||
|
||||
String FormatFrame(const char *s)
|
||||
{
|
||||
if(*s++ != '#')
|
||||
return Null;
|
||||
while(IsDigit(*s))
|
||||
s++;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
if(s[0] == '0' && ToUpper(s[1]) == 'X') {
|
||||
s += 2;
|
||||
while(IsXDigit(*s))
|
||||
s++;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
if(s[0] != 'i' && s[1] != 'n')
|
||||
return Null;
|
||||
s += 2;
|
||||
while(*s == ' ')
|
||||
s++;
|
||||
}
|
||||
if(!IsAlpha(*s))
|
||||
return Null;
|
||||
const char *w = strchr(s, '\r');
|
||||
if(w)
|
||||
return String(s, w);
|
||||
w = strchr(s, '\n');
|
||||
if(w)
|
||||
return String(s, w);
|
||||
return s;
|
||||
}
|
||||
|
||||
bool ParsePos(const String& s, String& fn, int& line, adr_t & adr)
|
||||
{
|
||||
const char *q = FindTag(s, "\x1a\x1a");
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ String Gdb::FastCmd(const char *command)
|
|||
if(!dbg || !dbg->IsRunning() || IdeIsDebugLock()) return Null;
|
||||
bool lock = false;
|
||||
if(command) {
|
||||
LLOG("FastCmd: " << command);
|
||||
dbg->Write(String(command) + "\n");
|
||||
PutVerbose(command);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue