mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
Gdb: Debugger now remembers the last selected position in stack trace + minor GDB creation improvement.
git-svn-id: svn://ultimatepp.org/upp/trunk@12031 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7cefd91456
commit
33ba3dd2d4
2 changed files with 28 additions and 8 deletions
|
|
@ -152,6 +152,8 @@ public:
|
|||
String autoline;
|
||||
bool firstrun;
|
||||
|
||||
int frame_idx;
|
||||
|
||||
int pid = 0; // debugee pid
|
||||
|
||||
String DoRun();
|
||||
|
|
@ -226,6 +228,8 @@ public:
|
|||
Gdb();
|
||||
|
||||
private:
|
||||
void RestoreFramePos();
|
||||
|
||||
bool CreateDbg(One<Host>& host, const String& exeFile, bool console);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ void Gdb::DisasFocus()
|
|||
void Gdb::DropFrames()
|
||||
{
|
||||
int i = 0;
|
||||
int q = ~frame;
|
||||
|
||||
frame.Clear();
|
||||
while(i <= max_stack_trace_size) {
|
||||
auto s = ObtainFrame(i);
|
||||
|
|
@ -407,7 +407,11 @@ void Gdb::DropFrames()
|
|||
frame.Add(i++, s);
|
||||
}
|
||||
|
||||
frame <<= q;
|
||||
if (frame_idx == -1 && frame.GetCount() >= 0) {
|
||||
frame_idx = 0;
|
||||
}
|
||||
|
||||
RestoreFramePos();
|
||||
}
|
||||
|
||||
String Gdb::ObtainFrame(int frame_idx)
|
||||
|
|
@ -419,15 +423,20 @@ void Gdb::SwitchFrame()
|
|||
{
|
||||
auto i = static_cast<int>(~frame);
|
||||
if (i == max_stack_trace_size) {
|
||||
i = 0;
|
||||
RestoreFramePos();
|
||||
return;
|
||||
}
|
||||
|
||||
frame_idx = i;
|
||||
|
||||
Cmdp(Sprintf("frame %d", i), i);
|
||||
}
|
||||
|
||||
void Gdb::SwitchThread()
|
||||
{
|
||||
int i = (int)~threads;
|
||||
frame_idx = -1;
|
||||
|
||||
int i = static_cast<int>(~threads);
|
||||
Cmdp(Sprintf("thread %d", i), i);
|
||||
}
|
||||
|
||||
|
|
@ -443,6 +452,13 @@ bool Gdb::Key(dword key, int count)
|
|||
return Ctrl::Key(key, count);
|
||||
}
|
||||
|
||||
void Gdb::RestoreFramePos()
|
||||
{
|
||||
if (frame_idx >= 0 && frame_idx < frame.GetCount()) {
|
||||
frame <<= frame_idx;
|
||||
}
|
||||
}
|
||||
|
||||
bool Gdb::Create(One<Host>&& _host, const String& exefile, const String& cmdline, bool console)
|
||||
{
|
||||
host = pick(_host);
|
||||
|
|
@ -512,7 +528,8 @@ void Gdb::Periodic()
|
|||
}
|
||||
|
||||
Gdb::Gdb()
|
||||
: max_stack_trace_size(200)
|
||||
: frame_idx(-1)
|
||||
, max_stack_trace_size(200)
|
||||
{
|
||||
locals.NoHeader();
|
||||
locals.AddColumn("", 1);
|
||||
|
|
@ -573,10 +590,9 @@ Gdb::Gdb()
|
|||
|
||||
One<Debugger> GdbCreate(One<Host>&& host, const String& exefile, const String& cmdline, bool console)
|
||||
{
|
||||
Gdb *dbg = new Gdb;
|
||||
One<Gdb> dbg = MakeOne<Gdb>();
|
||||
if(!dbg->Create(pick(host), exefile, cmdline, console)) {
|
||||
delete dbg;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return dbg;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue