From cedb778ff50655332db0157d098a03689cb43879 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 25 Oct 2015 17:12:59 +0000 Subject: [PATCH] ide: Standard debugger improved git-svn-id: svn://ultimatepp.org/upp/trunk@9081 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Debuggers/Debuggers.h | 7 +++ uppsrc/ide/Debuggers/Gdb.cpp | 10 +++- uppsrc/ide/Debuggers/GdbData.cpp | 100 ++++++++++++++++++++++++++++++- uppsrc/ide/icon.ico | Bin 2862 -> 2862 bytes uppsrc/ide/ide.lay | 4 +- uppsrc/ide/idewin.cpp | 2 +- 6 files changed, 117 insertions(+), 6 deletions(-) diff --git a/uppsrc/ide/Debuggers/Debuggers.h b/uppsrc/ide/Debuggers/Debuggers.h index a601a4e66..eb30c7302 100644 --- a/uppsrc/ide/Debuggers/Debuggers.h +++ b/uppsrc/ide/Debuggers/Debuggers.h @@ -111,6 +111,7 @@ struct Gdb : Debugger, ParentCtrl { virtual bool Key(dword key, int count); virtual void Stop(); virtual bool IsFinished(); + virtual bool Tip(const String& exp, CodeEditor::MouseTip& mt); One host; One dbg; @@ -130,6 +131,8 @@ struct Gdb : Debugger, ParentCtrl { ArrayCtrl self; ColumnList cpu; Label dlock; + + VectorMap expression_cache; WithQuickwatchLayout quickwatch; @@ -174,13 +177,17 @@ struct Gdb : Debugger, ParentCtrl { void SwitchFrame(); void SwitchThread(); + static void ReadGdbValues(CParser& p, VectorMap& val); + static void ReadGdbValues(const String& h, VectorMap& val); + String Print0(const String& exp); String Print(const String& exp); void Locals(); void Watches(); void TryAuto(Index& tested, const String& exp); void Autos(); void Data(); + void Self(); void Cpu(); void QuickWatch(); diff --git a/uppsrc/ide/Debuggers/Gdb.cpp b/uppsrc/ide/Debuggers/Gdb.cpp index 4c5e77a9e..6b4adf8cb 100644 --- a/uppsrc/ide/Debuggers/Gdb.cpp +++ b/uppsrc/ide/Debuggers/Gdb.cpp @@ -178,6 +178,7 @@ void Gdb::CheckEnd(const char *s) String Gdb::Cmdp(const char *cmdline, bool fr) { + expression_cache.Clear(); String s = Cmd(cmdline); if(ParsePos(s, file, line, addr)) { IdeSetDebugPos(GetLocalPath(file), line - 1, fr ? DbgImg::FrameLinePtr() @@ -382,21 +383,28 @@ Gdb::Gdb() locals.NoHeader(); locals.AddColumn("", 1); locals.AddColumn("", 6); + locals.EvenRowColor(); watches.NoHeader(); watches.AddColumn("", 1).Edit(watchedit); watches.AddColumn("", 6); watches.Inserting().Removing(); + watches.EvenRowColor(); autos.NoHeader(); autos.AddColumn("", 1); autos.AddColumn("", 6); + autos.EvenRowColor(); + self.NoHeader(); + self.AddColumn("", 1); + self.AddColumn("", 6); + self.EvenRowColor(); cpu.Columns(3); cpu.ItemHeight(Courier(Ctrl::HorzLayoutZoom(12)).GetCy()); -// cpu.SetDisplay(Single()); Add(tab.SizePos()); tab.Add(autos.SizePos(), "Autos"); tab.Add(locals.SizePos(), "Locals"); tab.Add(watches.SizePos(), "Watches"); + tab.Add(self.SizePos(), "this"); tab.Add(cpu.SizePos(), "CPU"); Add(threads.LeftPosZ(300, 100).TopPos(2)); Add(frame.HSizePosZ(404, 0).TopPos(2)); diff --git a/uppsrc/ide/Debuggers/GdbData.cpp b/uppsrc/ide/Debuggers/GdbData.cpp index e912061ad..81ca3231d 100644 --- a/uppsrc/ide/Debuggers/GdbData.cpp +++ b/uppsrc/ide/Debuggers/GdbData.cpp @@ -1,5 +1,6 @@ #include "Debuggers.h" +#if 0 String DataClean(CParser& p) { String r; @@ -70,6 +71,13 @@ String DataClean(const char *s) catch(CParser::Error) {} return Null; } +#endif + +String DataClean(const String& exp) +{ + int q = exp.Find('{'); + return q >= 0 ? TrimBoth(exp.Mid(q)) : exp; +} void Gdb::Locals() { @@ -93,7 +101,7 @@ void Gdb::Locals() MarkChanged(prev, locals); } -String Gdb::Print(const String& exp) +String Gdb::Print0(const String& exp) { String q = FastCmd("print " + exp); StringStream ss(q); @@ -109,6 +117,16 @@ String Gdb::Print(const String& exp) return DataClean(ln); } +String Gdb::Print(const String& exp) +{ + int q = expression_cache.Find(exp); + if(q >= 0) + return expression_cache[q]; + String r = Print0(exp); + expression_cache.Add(exp, r); + return r; +} + void Gdb::Watches() { VectorMap prev = DataMap(watches); @@ -158,6 +176,65 @@ void Gdb::Autos() MarkChanged(prev, autos); } +void Gdb::ReadGdbValues(CParser& p, VectorMap& val) +{ + if(p.Char('{')) { + while(!p.Char('}') && !p.IsEof()) { + String id; + String value; + const char *b = p.GetPtr(); + while(!p.IsEof()) + if(p.IsChar('=')) { + id = TrimBoth(String(b, p.GetPtr())); + p.Char('='); + break; + } + else + p.SkipTerm(); + b = p.GetPtr(); + int lvl = 0; + while(!p.IsEof()) + if(p.IsChar(',') && lvl == 0) { + String v = TrimBoth(String(b, p.GetPtr())); + if(*id == '<') // Base class + ReadGdbValues(v, val); + else + val.Add(id, v); + p.Char(','); + break; + } + else + if(p.Char('{')) + lvl++; + else + if(p.Char('}')) + lvl--; + else + p.SkipTerm(); + } + } +} + +void Gdb::ReadGdbValues(const String& h, VectorMap& val) +{ + try { + CParser p(h); + ReadGdbValues(p, val); + } + catch(CParser::Error) {} +} + +void Gdb::Self() +{ + VectorMap prev = DataMap(locals); + self.Clear(); + VectorMap val; + ReadGdbValues(Print("*this"), val); + for(int i = 0; i < val.GetCount(); i++) + self.Add(val.GetKey(i), val[i]); + MarkChanged(prev, locals); +} + void Gdb::Cpu() { String s = FastCmd("info registers"); @@ -180,7 +257,8 @@ void Gdb::Data() case 0: Autos(); break; case 1: Locals(); break; case 2: Watches(); break; - case 3: Cpu(); break; + case 3: Self(); break; + case 4: Cpu(); break; } } @@ -206,3 +284,21 @@ void Gdb::QuickWatch() } quickwatch.Close(); } + +bool Gdb::Tip(const String& exp, CodeEditor::MouseTip& mt) +{ + if(IsNull(exp)) + return false; + String val = Print(exp); + if(!IsNull(val) && !val.EndsWith(")}") && !IsAlpha(*val)) { + if(val.GetCount() > 100) { + val.Trim(100); + val << "..."; + } + mt.display = &StdDisplay(); + mt.value = val; + mt.sz = mt.display->GetStdSize(String(mt.value) + "X"); + return true; + } + return false; +} diff --git a/uppsrc/ide/icon.ico b/uppsrc/ide/icon.ico index f93bbb7ae4fb8565d354c60e031ffac062dbdb6c..0602f9c904c82481d7cdb85b226a43a53f0c5957 100644 GIT binary patch literal 2862 zcmdT`y>8S%5FYsPDfKVh-L2(hKl_I+C>lhGxkWHMEl(L4^8t~p${D&_G&KZx~|1Xa7o{EI@NIW18+Hy`+IAIXc!}m z1B+G5A?I_&atC-hPkOlDM#tvW>|Pr=h`D<%-M3RCoOTb9QE+R$c~I4X`k_- z6>&=6K7XM?r*w7sor+jf&IFq4nrmj{A?p9mE0)hA`YjJ{tgo+SHki+#UtG9ze2%KB zhH*YGdKnDezKzxZtqg?w<}{q2lit}OZ8e2Cv~1FVeQ*G4`~7^A2LHZ&>rEQ^aJK$8 zHQ+tlbB1D%2D}&hj>g9D_u#+Vv1>KX$|P}(NffEFOcV#PBFj`>mMUv=6!W|^n@S~Y zD$a8(P&0YFoM&-t_XU?_vBfL!r|gzr^3=Q zuA?~t(rmq|uI`@pM+U4dsk*v8?{#&J)iTkD3OYU}kvApLQ{Dyt7SUIZnSVMWs_qb- zqK5T^btEfM!*w?(J)f29uH*CCo&$Z`wxWA*N!@%t@1dv%-Z1R*pis#yk#R2?m4(`>_#{(2g@j^$yPj9$vwDmPy^q@D$ho_uKxUuBTSib9DeZjSQ4)iVYFM@RsE~%Rnzh!E6mOz$3`Tk~8iM?DJNqRsg;S#SildN4RHxU*iDYa>+c5VvtMn(ib@X z4Uc)mo_C#}*2TTeGjhb7#Mlk8Hh(`lwD0@i*UW$0fQp-g;PvU#^K_2btB+hV+jz3> z2D9Q&_$G!&EKx;mUEO|C6-6j4Mk7~Mg<~U9H;tQBm213@;A~cD(z$}gjb}4#5L16V z^qcY6@`7ucvEd!~OIG6-zfAnPc12mbI=0AMWx(&;VCIK=XZ4R