From e705db2e5272ecb7d08525821c5cc04e642432ab Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 28 Nov 2019 11:35:12 +0000 Subject: [PATCH] ide: PDB debugger expressions now support high-level types git-svn-id: svn://ultimatepp.org/upp/trunk@13721 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Debuggers/Data.cpp | 26 +++++----- uppsrc/ide/Debuggers/Exp.cpp | 47 +++++++++++++++++-- uppsrc/ide/Debuggers/Pdb.lay | 4 +- uppsrc/ide/Debuggers/Pretty.cpp | 2 +- uppsrc/ide/Debuggers/Sym.cpp | 1 + uppsrc/ide/Debuggers/Visualise.cpp | 2 +- .../app.tpp/PDBExpressions_en-us.tpp | 19 ++++++-- .../app.tpp/PDBExpressions_en-us.tppi | 9 ++-- 8 files changed, 78 insertions(+), 32 deletions(-) diff --git a/uppsrc/ide/Debuggers/Data.cpp b/uppsrc/ide/Debuggers/Data.cpp index 415a49c97..84539faaa 100644 --- a/uppsrc/ide/Debuggers/Data.cpp +++ b/uppsrc/ide/Debuggers/Data.cpp @@ -276,27 +276,25 @@ void Pdb::ExploreKey(ArrayCtrl *a) bool Pdb::Tip(const String& exp, CodeEditor::MouseTip& mt) { -/* mt.display = &StdDisplay(); - mt.value = exp; - mt.sz = Size(100, 20); - return true;*/ DR_LOG("Pdb::Tip"); Visual r; try { CParser p(exp); Val v = Exp(p); - Visualise(r, v, 2); - if(r.part.GetCount()) { - mt.sz = r.GetSize() + Size(4, 4); - mt.value = RawPickToValue(pick(r)); - mt.display = &Single(); - DR_LOG("Pdb::Tip true"); - return true; - } + Visualise(r, v, 0); } catch(LengthLimit) {} - catch(CParser::Error) {} - DR_LOG("Pdb::Tip false"); + catch(CParser::Error) { + DR_LOG("Pdb::Tip false"); + return false; + } + if(r.part.GetCount()) { + mt.sz = r.GetSize() + Size(4, 4); + mt.value = RawPickToValue(pick(r)); + mt.display = &Single(); + DR_LOG("Pdb::Tip true"); + return true; + } return false; } diff --git a/uppsrc/ide/Debuggers/Exp.cpp b/uppsrc/ide/Debuggers/Exp.cpp index 49d67294a..b47e25f01 100644 --- a/uppsrc/ide/Debuggers/Exp.cpp +++ b/uppsrc/ide/Debuggers/Exp.cpp @@ -444,17 +444,48 @@ Pdb::Val Pdb::Post(CParser& p) Val v = Term(p); LLOG("Post: " << v); for(;;) { + auto DoIndex = [&](bool key) { + int ech = key ? ')' : ']'; + int64 i = Null; + if(!p.Char(ech)) + i = (int)GetInt64(Exp0(p)); + p.Char(ech); + Pretty p; + if(PrettyVal(v, 0, 0, p) && p.kind != SINGLE_VALUE && p.data_type.GetCount() && + (IsNull(i) && p.data_count || abs(i) < p.data_count)) { + if(IsNull(i)) + i = p.data_count - 1; + else + if(i < 0) + i = p.data_count + i; + Pretty p; + PrettyVal(v, i, 1, p); + Val item; + int q = 0; + if(p.data_type.GetCount() > 1) { + if(!key) + q = 1; + } + (TypeInfo &)item = GetTypeInfo(p.data_type[q]); + item.context = v.context; + item.address = q < p.data_ptr.GetCount() ? p.data_ptr[q] : 0; + v = item; + } + else + v = DeRef(Compute(v, RValue(Nvl(i)), '+')); + }; + if(p.Char(':')) v = Field(v.ref ? DeRef(v) : v, ReadType(p)); else if(p.Char('.') || p.Char2(':', ':') || p.Char2('-', '>')) v = Field(v.ref ? DeRef(v) : v, p.ReadId()); else - if(p.Char('[')) { - int i = (int)GetInt64(Exp0(p)); - p.Char(']'); - v = DeRef(Compute(v, RValue(i), '+')); - } + if(p.Char('[')) + DoIndex(false); + else + if(p.Char('(')) + DoIndex(true); else break; } @@ -467,6 +498,12 @@ Pdb::Val Pdb::Unary(CParser& p) return Compute(RValue(0), Unary(p), '-'); if(p.Char('+')) return GetRVal(Unary(p)); + if(p.Char('#')) { + Pretty pp; + if(PrettyVal(Unary(p), 0, 0, pp)) + return RValue((int)pp.data_count); + ThrowError("Value not recognized as high-level type"); + } if(p.Char('*')) return DeRef(Unary(p)); if(p.Char('&')) diff --git a/uppsrc/ide/Debuggers/Pdb.lay b/uppsrc/ide/Debuggers/Pdb.lay index 2ab3ffbfe..9d451947d 100644 --- a/uppsrc/ide/Debuggers/Pdb.lay +++ b/uppsrc/ide/Debuggers/Pdb.lay @@ -1,10 +1,10 @@ -LAYOUT(EditPDBExpressionLayout, 604, 356) +LAYOUT(EditPDBExpressionLayout, 604, 484) ITEM(Label, lbl, SetLabel(t_("Expression")).LeftPosZ(4, 64).TopPosZ(8, 19)) ITEM(EditString, text, HSizePosZ(72, 8).TopPosZ(8, 19)) ITEM(Label, value_lbl, SetLabel(t_(" current value")).LeftPosZ(4, 80).TopPosZ(32, 19)) ITEM(DataPusher, value, SetEditable(false).HSizePosZ(88, 8).TopPosZ(32, 19)) ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(64, 190).BottomPosZ(6, 22)) ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(6, 22)) - ITEM(RichTextCtrl, help, LeftPosZ(4, 592).TopPosZ(52, 268)) + ITEM(RichTextCtrl, help, LeftPosZ(4, 592).TopPosZ(52, 396)) END_LAYOUT diff --git a/uppsrc/ide/Debuggers/Pretty.cpp b/uppsrc/ide/Debuggers/Pretty.cpp index 15280646d..469af368d 100644 --- a/uppsrc/ide/Debuggers/Pretty.cpp +++ b/uppsrc/ide/Debuggers/Pretty.cpp @@ -281,7 +281,7 @@ bool Pdb::PrettyVal(Pdb::Val val, int64 from, int count, Pretty& p) pretty.Add("std::vector", { 1, THISFN(PrettyStdVector) }); pretty.Add("std::basic_string", { 1, THISFN(PrettyStdString) }); } - + int ii = pretty.Find(type); if(ii >= 0) { const auto& pr = pretty[ii]; diff --git a/uppsrc/ide/Debuggers/Sym.cpp b/uppsrc/ide/Debuggers/Sym.cpp index 41b00c24c..a9d5407ec 100644 --- a/uppsrc/ide/Debuggers/Sym.cpp +++ b/uppsrc/ide/Debuggers/Sym.cpp @@ -380,6 +380,7 @@ int Pdb::FindType(adr_t modbase, const String& name) { "unsigned char", UINT1 }, { "short", SINT2 }, { "unsigned short", UINT2 }, + { "wchar_t", UINT2 }, { "int", SINT4 }, { "unsigned int", UINT4 }, { "float", FLT }, diff --git a/uppsrc/ide/Debuggers/Visualise.cpp b/uppsrc/ide/Debuggers/Visualise.cpp index c3fe1e5e1..f139ef64d 100644 --- a/uppsrc/ide/Debuggers/Visualise.cpp +++ b/uppsrc/ide/Debuggers/Visualise.cpp @@ -215,7 +215,7 @@ void Pdb::Visualise(Visual& result, Pdb::Val val, dword flags) if(VisualisePretty(result, val, flags)) return; } - catch(CParser::Error e) { DDUMP(e); } // if failed, display as raw data + catch(CParser::Error e) {} // if failed, display as raw data result.Cat("{ ", SColorMark); bool cm = false; diff --git a/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tpp b/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tpp index 2cd931211..c9caa21b5 100644 --- a/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tpp +++ b/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tpp @@ -1,5 +1,4 @@ topic "Supported operators"; -[2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,2#27521748481378242620020725143825:desc] [0 $$3,0#96390100711032703541132217272105:end] @@ -9,6 +8,7 @@ topic "Supported operators"; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] +[2 $$0,0#00000000000000000000000000000000:Default] [{_}%EN-US [s0; [* Debugger expressions syntax]&] [s0;@(0.0.255)1 &] @@ -20,11 +20,20 @@ topic "Supported operators"; [s0;1 &] [ {{2165:7835^@7 [s0; [1 Operator (by priority)]] :: [s0; [1 Note]] -::@2 [s0; [*@(0.0.255)1 . `-> `[`]]] +::@2 [s0; [*@(0.0.255)1 . `-> `[`] ()]] :: [s0; [1 Postfix operators. `'.`' and `'`->`' are synonyms (work based -on actual context).]] -:: [s0; [*@(0.0.255)1 `- `+ `* `& !]] -:: [s0; [1 Unary operators.]] +on actual context). ][*@(0.0.255)1 ()][1 has the same meaning as +][*@(0.0.255)1 `[`]][1 unless the value is recognized high`-level +map type (e.g. VectorMap) `- in that case it returns the key +while ][*@(0.0.255)1 `[`]][1 returns the value. For recognized high`-level +types, omitting argument of ][*@(0.0.255)1 `[`] ()][1 references +the last item in the list, while negative argument is addressing +elements from the last element; `-1 is the last element, `-2 +second last element etc...]] +:: [s0; [*@(0.0.255)1 `- `+ `* `& ! #]] +:: [s0; [1 Unary operators. Operator ][*@(0.0.255)1 #][1 represents a count +of elements in recognized high`-level type (e.g. Vector`::GetCount() +or std`::vector`::size()).]] :: [s0; [*@(0.0.255)1 `* / %]] :: [s0; [1 Binary operators.]] :: [s0; [*@(0.0.255)1 `+ `-]] diff --git a/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tppi b/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tppi index 5f3412228..86101c9a9 100644 --- a/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tppi +++ b/uppsrc/ide/Debuggers/app.tpp/PDBExpressions_en-us.tppi @@ -1,7 +1,8 @@ TITLE("Supported operators") COMPRESSED -120,156,157,148,123,111,219,54,20,197,191,202,45,220,230,53,219,227,83,212,163,9,210,45,3,22,108,72,134,21,253,75,211,38,90,166,109,162,182,232,137,116,107,35,77,62,251,46,29,183,139,55,7,29,102,200,38,65,233,119,121,206,185,148,75,6,47,95,146,62,233,145,175,124,242,43,51,209,171,121,168,74,43,68,90,104,38,139,247,63,221,102,69,228,41,242,92,81,158,74,78,5,75,240,135,114,202,36,227,130,166,44,19,41,231,41,201,155,185,246,190,42,231,44,77,183,16,235,179,30,83,146,81,37,82,145,82,174,82,134,44,35,132,17,197,36,21,60,101,50,31,27,223,84,37,193,199,57,238,145,37,60,35,148,16,69,41,225,76,17,46,5,165,156,97,9,166,24,37,50,55,237,184,42,127,76,138,8,136,104,74,38,40,61,193,106,66,16,172,30,49,193,41,39,140,75,154,201,36,31,153,169,109,15,89,146,95,181,164,72,110,131,89,236,28,105,81,156,93,202,130,34,154,244,147,158,194,109,133,196,205,178,232,136,35,198,88,34,51,42,5,74,18,132,229,157, -249,115,101,59,179,48,109,216,85,176,148,50,90,140,168,42,80,194,195,195,195,144,10,242,152,148,66,45,148,160,110,70,113,13,125,40,42,51,146,201,148,166,132,43,193,164,66,235,75,221,233,197,206,201,72,176,98,231,35,237,167,189,132,38,152,40,73,81,191,204,176,0,65,19,56,98,144,18,47,158,230,97,7,71,46,66,89,63,235,97,72,92,18,149,17,37,148,20,232,132,209,132,98,144,36,250,199,54,228,173,235,22,122,94,149,119,127,220,191,250,225,102,240,238,45,148,158,20,80,158,193,149,25,173,166,83,211,129,89,47,59,227,189,117,173,7,191,105,131,94,87,71,85,124,234,242,132,12,201,16,229,156,82,120,92,65,238,233,34,89,87,37,5,64,124,98,215,48,113,29,204,204,26,78,204,112,58,196,123,19,115,90,29,198,254,73,185,38,232,57,180,171,197,200,116,254,51,143,189,251,155,127,138,215,199,120,109,75,188,121,251,253,245,53,52,110,108,182,101,154,25,6,212,4,180,244,88,162,62,214,245,113,31,135,250,183,182,62,126,70,76,157,231,219,90,141, -110,97,100,96,229,205,24,130,3,191,52,141,157,108,192,55,110,105,14,147,97,102,253,22,253,160,59,171,71,115,131,73,90,31,60,216,22,22,38,204,220,216,239,192,109,124,112,119,135,205,145,185,74,185,252,253,82,237,250,64,225,118,105,58,29,80,254,201,104,131,161,88,215,217,176,57,173,170,60,255,242,200,141,11,38,46,92,50,56,160,3,141,14,46,160,46,235,106,15,250,197,249,16,3,118,187,250,62,6,50,196,240,116,59,142,153,12,46,226,188,51,177,231,174,221,44,48,248,143,174,123,15,35,29,35,112,45,96,148,43,108,75,227,218,96,214,225,116,248,164,250,126,130,3,168,191,129,250,12,234,35,120,177,39,225,93,171,187,205,19,1,207,86,56,131,111,225,213,30,250,157,253,175,44,110,61,248,159,232,121,125,14,47,240,251,26,46,224,53,142,23,245,249,191,114,199,54,235,0,122,62,7,55,193,185,241,6,102,250,67,92,198,228,244,194,124,105,217,16,174,3,88,15,75,135,239,82,60,13,120,138,198,248,231,209,132,249,6,67,92,44,99,214,75,103,219, -120,64,63,218,48,131,56,197,23,240,121,125,71,245,209,158,158,159,221,212,54,216,146,55,55,87,207,67,159,234,79,7,161,219,95,171,234,254,254,243,129,172,170,191,0,190,3,183,88, +120,156,157,85,107,115,226,54,20,253,43,119,135,221,4,82,112,37,217,242,139,77,38,187,155,62,50,109,147,78,119,182,95,168,91,11,35,64,19,63,168,37,8,52,155,252,246,94,25,231,65,54,116,103,202,24,236,145,117,238,61,231,220,171,203,72,121,94,56,20,140,15,175,126,186,140,134,12,94,191,166,125,210,113,3,234,134,220,165,30,243,241,135,186,148,113,230,122,52,100,145,23,186,110,72,226,44,23,90,39,163,156,133,97,3,98,125,214,97,1,103,52,240,66,47,164,110,16,50,196,50,66,24,9,24,167,158,27,50,30,79,164,206,146,17,193,237,46,230,136,124,55,34,148,144,128,82,226,178,128,184,220,163,212,101,24,130,5,140,18,30,203,114,146,140,126,244,135,22,224,33,128,112,159,16,226,99,52,207,35,24,221,194,60,151,186,132,185,156,70,220,143,199,114,166,202,100,244,165,36,254,85,73,1,137,149,145,69,171,72,120,195,163,83,62,164,8,245,251,126,39,192,180,30,199,100,145,85,228,34,140,49,159,71,148,123,72,201,35,44,174,229,223,75,85,203, +66,150,166,141,160,40,101,116,56,166,193,16,41,220,221,221,57,212,35,91,167,2,228,66,9,242,102,20,215,80,71,64,121,68,34,30,210,144,184,129,199,120,128,210,23,162,22,69,171,100,236,177,97,171,35,236,135,29,159,250,232,40,9,145,63,143,48,0,65,17,120,71,35,57,94,110,24,155,22,108,113,22,20,245,163,14,154,228,114,18,68,36,240,2,238,161,18,70,125,138,70,18,171,31,203,16,151,85,93,136,60,25,89,0,177,94,127,229,19,159,201,169,88,230,40,247,230,175,219,55,223,93,12,62,125,132,145,38,67,24,29,193,153,28,47,103,51,89,131,92,47,106,169,181,170,74,13,122,83,26,177,78,14,18,187,235,180,75,28,226,160,128,30,133,237,10,226,158,46,146,117,50,162,0,8,159,170,53,76,171,26,230,114,13,93,233,204,28,124,55,149,189,228,101,216,115,84,149,25,145,67,185,44,198,178,214,247,120,172,246,35,254,41,60,61,196,171,9,241,238,227,135,243,115,200,170,137,108,194,100,115,180,52,51,40,105,27,34,61,20,233,97,31,111,233,31, +101,122,184,135,76,26,199,77,172,76,148,48,150,176,212,114,2,166,2,189,144,153,154,110,64,103,213,66,190,140,52,115,165,27,232,74,212,74,140,115,137,78,42,109,52,168,18,10,105,230,213,68,183,192,198,62,184,185,193,114,242,56,8,93,254,231,105,208,214,129,194,229,66,214,194,32,253,238,120,131,166,168,170,86,102,211,75,146,56,126,216,114,81,25,105,23,78,25,188,192,3,133,14,78,32,29,165,9,116,119,113,191,86,218,88,143,171,54,133,182,158,56,232,159,40,39,214,150,193,137,125,174,165,45,123,85,110,10,244,254,186,170,175,96,44,172,11,85,9,232,230,18,43,147,85,165,145,107,211,115,32,217,77,141,249,172,1,115,161,209,13,12,35,10,137,210,69,169,202,25,224,218,179,221,150,98,179,127,89,230,216,112,13,100,37,242,165,4,165,161,150,89,53,43,213,63,152,120,174,102,243,116,144,203,149,204,161,16,11,48,155,133,108,75,250,187,204,80,199,47,98,209,67,209,214,104,51,23,6,107,167,49,134,193,24,102,89,151,219,192,87,114,3,215,115,133, +85,217,199,226,233,238,134,134,3,223,99,25,246,16,177,36,116,31,170,66,25,211,200,171,103,75,59,73,160,154,190,148,225,222,26,108,114,89,203,50,147,219,60,56,143,13,216,17,182,229,142,11,216,49,253,150,104,41,103,194,168,149,124,140,141,190,136,201,164,57,157,152,82,230,205,236,210,48,173,171,226,49,92,187,60,68,71,168,69,60,127,129,39,96,192,64,163,44,172,250,211,23,32,77,230,56,206,147,150,217,149,49,128,244,27,72,143,32,61,128,87,208,217,233,172,79,165,168,55,79,251,234,161,139,159,121,209,105,93,176,35,166,225,46,176,155,150,91,219,30,244,160,23,255,225,250,78,233,241,184,254,32,205,7,27,162,219,3,204,167,205,4,215,86,247,47,53,134,232,246,122,251,69,29,193,183,240,102,71,203,123,245,76,204,94,44,186,49,248,159,208,227,244,24,94,225,247,45,156,192,91,188,159,164,199,95,28,241,109,51,139,60,183,230,96,21,177,169,231,98,37,31,143,214,253,116,112,224,188,233,141,69,133,141,97,7,15,14,172,9,254,179,101,38,223,160, +189,197,194,158,233,69,165,74,59,11,175,149,153,131,125,196,89,191,159,223,65,122,176,195,231,231,106,166,50,60,250,239,46,206,246,131,62,167,159,95,4,93,254,150,36,183,183,247,179,47,73,254,5,80,42,131,251,