wallace created this revision. wallace requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The variable.rst documentation says: If it returns a value, and that value is True, LLDB will be allowed to cache the children and the children count it previously obtained, and will not return to the provider class to ask. If nothing, None, or anything other than True is returned, LLDB will discard the cached information and ask. Regardless, whenever necessary LLDB will call update. However, several update methods in gnu_libstdcpp.py were returning True, which made lldb unaware of any changes in the corresponding objects. This problem was visible by lldb-vscode in the following way: - If a breakpoint is hit and there's a vector with the contents {1, 2}, it'll be displayed correctly. - Then the user steps and the next stop contains the vector modified. The program changed it to {1, 2, 3} - frame var then displays {1, 2} incorrectly, due to the caching caused by the update method It's worth mentioning that none of libcxx.py'd update methods return True. Same for LibCxxVector.cpp, which returns false. Added a very simple test that fails without this fix. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103209 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
Index: lldb/test/API/tools/lldb-vscode/evaluate/main.cpp =================================================================== --- lldb/test/API/tools/lldb-vscode/evaluate/main.cpp +++ lldb/test/API/tools/lldb-vscode/evaluate/main.cpp @@ -1,5 +1,8 @@ #include "foo.h" +#include <vector> +#include <map> + static int static_int = 42; int non_static_int = 43; @@ -25,5 +28,21 @@ } a_function(var3); foo_func(); + + std::vector<int> my_vec; + my_vec.push_back(1); + my_vec.push_back(2); + my_vec.push_back(3); // breakpoint 4 + + std::map<int, int> my_map; + my_map[1] = 2; + my_map[2] = 3; + my_map[3] = 4; // breakpoint 5 + + std::vector<bool> my_bool_vec; + my_bool_vec.push_back(true); + my_bool_vec.push_back(false); // breakpoint 6 + my_bool_vec.push_back(true); // breakpoint 7 + return 0; } Index: lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py =================================================================== --- lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py +++ lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py @@ -39,7 +39,11 @@ [ line_number(source, "// breakpoint 1"), line_number(source, "// breakpoint 2"), - line_number(source, "// breakpoint 3") + line_number(source, "// breakpoint 3"), + line_number(source, "// breakpoint 4"), + line_number(source, "// breakpoint 5"), + line_number(source, "// breakpoint 6"), + line_number(source, "// breakpoint 7"), ] ) self.continue_to_next_stop() @@ -132,6 +136,20 @@ self.assertEvaluateFailure("foo_func") self.assertEvaluateFailure("foo_var") + # Now we check that values are updated after stepping + self.continue_to_next_stop() + self.assertEvaluate("my_vec", "size=2") + self.continue_to_next_stop() + self.assertEvaluate("my_vec", "size=3") + + self.assertEvaluate("my_map", "size=2") + self.continue_to_next_stop() + self.assertEvaluate("my_map", "size=3") + + self.assertEvaluate("my_bool_vec", "size=1") + self.continue_to_next_stop() + self.assertEvaluate("my_bool_vec", "size=2") + @skipIfWindows @skipIfRemote def test_generic_evaluate_expressions(self): Index: lldb/examples/synthetic/gnu_libstdcpp.py =================================================================== --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -148,6 +148,7 @@ self.data_size = self.data_type.GetByteSize() except: pass + return False def has_children(self): return True @@ -235,7 +236,7 @@ self.count = 0 except: pass - return True + return False class StdVBoolImplementation(object): @@ -282,7 +283,7 @@ self.valid = True except: self.valid = False - return True + return False def __init__(self, valobj, dict): logger = lldb.formatters.Logger.Logger() @@ -378,6 +379,7 @@ self.skip_size = self.Mheader.GetType().GetByteSize() except: pass + return False def num_children(self): logger = lldb.formatters.Logger.Logger()
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits