diff --git a/uppsrc/ide/Debuggers/Pdb.h b/uppsrc/ide/Debuggers/Pdb.h index 19ef2d876..693adf308 100644 --- a/uppsrc/ide/Debuggers/Pdb.h +++ b/uppsrc/ide/Debuggers/Pdb.h @@ -451,13 +451,14 @@ struct Pdb : Debugger, ParentCtrl { void PrettyStdVector(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void PrettyStdString(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void TraverseTree(bool set, Val head, Val node, int64& from, int& count, Pdb::Pretty& p, int depth); - void TraverseTreeClang(bool set, int nodet, Val node, int64& from, int& count, Pdb::Pretty& p, int depth); + void TraverseTreeClang(bool set, int nodet, Val node, int64& from, int& count, Pdb::Pretty& p, int depth, int key_size); void PrettyStdTree(Pdb::Val val, bool set, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void PrettyStdListM(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p, bool map = false); void PrettyStdList(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void PrettyStdForwardList(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void PrettyStdDeque(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void PrettyStdUnordered(Pdb::Val val, bool set, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); + void PrettyStdAtomic(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p); void LoadPrettyScripts(); void SetVal(EscValue& v, Pdb::Val val); diff --git a/uppsrc/ide/Debuggers/Pretty.cpp b/uppsrc/ide/Debuggers/Pretty.cpp index 427cc8f37..08aa413c6 100644 --- a/uppsrc/ide/Debuggers/Pretty.cpp +++ b/uppsrc/ide/Debuggers/Pretty.cpp @@ -89,6 +89,7 @@ bool Pdb::PrettyVal(Pdb::Val val, int64 from, int count, Pretty& p) pretty.Add("std::unordered_multiset", { 1, [=](Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) { PrettyStdUnordered(val, true, tparam, from, count, p); }}); pretty.Add("std::unordered_map", { 2, [=](Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) { PrettyStdUnordered(val, false, tparam, from, count, p); }}); pretty.Add("std::unordered_multimap", { 2, [=](Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) { PrettyStdUnordered(val, false, tparam, from, count, p); }}); + pretty.Add("std::atomic", { 1, [=](Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) { PrettyStdAtomic(val, tparam, from, count, p); }}); } type = Filter(type, [](int c) { return c != ' ' ? c : 0; }); diff --git a/uppsrc/ide/Debuggers/PrettyStd.cpp b/uppsrc/ide/Debuggers/PrettyStd.cpp index 597d5614d..8e6ae0c49 100644 --- a/uppsrc/ide/Debuggers/PrettyStd.cpp +++ b/uppsrc/ide/Debuggers/PrettyStd.cpp @@ -77,25 +77,21 @@ void Pdb::TraverseTree(bool set, Pdb::Val head, Val node, int64& from, int& coun TraverseTree(set, head, DeRef(GetAttr(node, "_Right")), from, count, p, depth + 1); } -void Pdb::TraverseTreeClang(bool set, int nodet, Val node, int64& from, int& count, Pdb::Pretty& p, int depth) +void Pdb::TraverseTreeClang(bool set, int nodet, Val node, int64& from, int& count, Pdb::Pretty& p, int depth, int key_size) { if(depth > 40 || count <= 0) // avoid problems if tree is damaged return; Val left = DeRef(GetAttr(node, "__left_")); if(left.address) - TraverseTreeClang(set, nodet, left, from, count, p, depth + 1); + TraverseTreeClang(set, nodet, left, from, count, p, depth + 1, key_size); node.type = nodet; Val data = GetAttr(node, "__value_"); if(from == 0) { - if(set) - p.data_ptr.Add(data.address); - else { - Val cc = GetAttr(data, "__cc"); - p.data_ptr.Add(GetAttr(cc, "first").address); - p.data_ptr.Add(GetAttr(cc, "second").address); - } + p.data_ptr.Add(data.address); + if(!set) + p.data_ptr.Add((data.address + key_size + 7) & ~7); count--; } else @@ -103,7 +99,7 @@ void Pdb::TraverseTreeClang(bool set, int nodet, Val node, int64& from, int& cou Val right = DeRef(GetAttr(node, "__right_")); if(right.address) - TraverseTreeClang(set, nodet, right, from, count, p, depth + 1); + TraverseTreeClang(set, nodet, right, from, count, p, depth + 1, key_size); } void Pdb::PrettyStdTree(Pdb::Val val, bool set, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) @@ -122,7 +118,7 @@ void Pdb::PrettyStdTree(Pdb::Val val, bool set, const Vector& tparam, in Val value = GetAttr(GetAttr(tree, "__pair1_"), "__value_"); p.data_count = GetIntAttr(GetAttr(tree, "__pair3_"), "__value_"); Val node = DeRef(GetAttr(value, "__left_")); - TraverseTreeClang(set, GetTypeInfo(nodet).type, node, from, count, p, 0); + TraverseTreeClang(set, GetTypeInfo(nodet).type, node, from, count, p, 0, SizeOfType(tparam[0])); } else { val = GetAttr(GetAttr(GetAttr(val, "_Mypair"), "_Myval2"), "_Myval2"); @@ -251,19 +247,16 @@ void Pdb::PrettyStdUnordered(Pdb::Val val, bool set, const Vector& tpara << tparam[0] << "," << tparam[1] << " >,void *>"; int ntype = GetTypeInfo(nodet).type; adr_t next = DeRef(GetAttr(GetAttr(GetAttr(val, "__p1_"), "__value_"), "__next_")).address; + int key_size = SizeOfType(tparam[0]); while(next && count > 0) { Val v = val; v.type = ntype; v.address = next; if(from == 0) { Val vl = GetAttr(v, "__value_"); - if(set) - p.data_ptr.Add(vl.address); - else { - vl = GetAttr(vl, "__cc"); - p.data_ptr.Add(GetAttr(vl, "first").address); - p.data_ptr.Add(GetAttr(vl, "second").address); - } + p.data_ptr.Add(vl.address); + if(!set) + p.data_ptr.Add((vl.address + key_size + 7) & ~7); } else from--; @@ -274,4 +267,11 @@ void Pdb::PrettyStdUnordered(Pdb::Val val, bool set, const Vector& tpara PrettyStdListM(GetAttr(val, "_List"), tparam, from, count, p, !set); } +void Pdb::PrettyStdAtomic(Pdb::Val val, const Vector& tparam, int64 from, int count, Pdb::Pretty& p) +{ + p.data_ptr << val.address; + p.data_type << tparam[0]; + p.kind = SINGLE_VALUE; +} + #endif diff --git a/upptst/PdbAll/PdbAll.cpp b/upptst/PdbAll/PdbAll.cpp index a7e496965..90d8102fb 100644 --- a/upptst/PdbAll/PdbAll.cpp +++ b/upptst/PdbAll/PdbAll.cpp @@ -11,7 +11,7 @@ using namespace Upp; -GUI_APP_MAIN +void UppTypes() { Date date = GetSysDate(); Time time = GetSysTime(); @@ -21,9 +21,28 @@ GUI_APP_MAIN Image img = CtrlImg::exclamation(); ImageBuffer ib(img); img = CtrlImg::exclamation(); - Value img_value = img; String string = "Hello world!"; WString wstring = "Hello world!"; + + DLOG("BREAKPOINT HERE"); +} + +void UppValue() +{ + ValueArray valuearray { "I", "II", "III", "IV", "V" }; + ValueMap valuemap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; + + Value img_value = CtrlImg::exclamation(); + Value value = valuemap; + Value text_value = "Test"; + Value error_value = ErrorValue("Test"); + Value void_value; + + DLOG("BREAKPOINT HERE"); +} + +void UppContainers() +{ Vector vector { "I", "II", "III", "IV", "V" }; BiVector bivector { "I", "II", "III", "IV", "V" }; Array array { "I", "II", "III", "IV", "V" }; @@ -31,15 +50,27 @@ GUI_APP_MAIN Index index { "I", "II", "III", "IV", "V" }; VectorMap vectormap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; ArrayMap arraymap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; - ValueArray valuearray { "I", "II", "III", "IV", "V" }; - ValueMap valuemap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; - Value value = valuemap; - Value text_value = "Test"; - Value error_value = ErrorValue("Test"); - Value void_value; + DLOG("BREAKPOINT HERE"); +} + +void StdTypes() +{ + WString wstring = "Hello world!"; std::string std_string = "Hello world!"; std::wstring std_wstring = wstring.ToStd(); + + std::atomic atomic_int; + atomic_int.store(12345); + std::atomic atomic_ptr; + int x = 54321; + atomic_ptr.store(&x); + + DLOG("BREAKPOINT HERE"); +} + +void StdContainers() +{ std::vector std_vector { "I", "II", "III", "IV", "V" }; std::deque std_deqeue { "I", "II", "III", "IV", "V" }; std::list std_list { "I", "II", "III", "IV", "V" }; @@ -48,11 +79,24 @@ GUI_APP_MAIN std::multiset std_multiset { "I", "II", "III", "IV", "V" }; std::map std_map { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; std::multimap std_multimap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; + std::map std_map2 { { "I", 1 }, { "II", 2 }, { "III", 3 }}; + std::multimap std_multimap2 { { "I", 1 }, { "II", 2 }, { "III", 3 }}; std::unordered_set std_unordered_set { "I", "II", "III", "IV", "V" }; std::unordered_multiset std_unordered_multiset { "I", "II", "III", "IV", "V" }; std::unordered_map std_unordered_map { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; std::unordered_multimap std_unordered_multimap { { 1 , "I"}, { 2, "II" }, { 3, "III"}, { 4, "IV"}, { 5, "V" } }; + DLOG("BREAKPOINT HERE"); +} + +GUI_APP_MAIN +{ + UppTypes(); + UppValue(); + UppContainers(); + + StdTypes(); + StdContainers(); for(String h : { "Hello world!", "Very very very very very very very long hello world!" }) { std::string sh = h.ToStd();