Author: Pavel Labath Date: 2023-02-02T11:24:47+01:00 New Revision: 88ac9138f4eb7b8c06154dd6e3f801d9882b66d7
URL: https://github.com/llvm/llvm-project/commit/88ac9138f4eb7b8c06154dd6e3f801d9882b66d7 DIFF: https://github.com/llvm/llvm-project/commit/88ac9138f4eb7b8c06154dd6e3f801d9882b66d7.diff LOG: [lldb] Try harder to optimize away a test variable The test was checking that we can print an error message when a variable is optimized away, but the optimizer got smarter (D140404) in tracking the variable's value (so that we were not able to recover its value). Using a value in an argument registers (argc) makes it more likely to be overwritten by subsequent function calls (and permanently lost). Added: Modified: lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py lldb/test/API/tools/lldb-vscode/optimized/main.cpp Removed: ################################################################################ diff --git a/lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py b/lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py index 3f7ac7cdc77a..5dfc35a927f2 100644 --- a/lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py +++ b/lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py @@ -45,6 +45,6 @@ def test_optimized_variable(self): self.assertEqual(len(breakpoint_ids), len(lines), "expect correct number of breakpoints") self.continue_to_breakpoints(breakpoint_ids) - optimized_variable = self.vscode.get_local_variable('optimized') + optimized_variable = self.vscode.get_local_variable('argc') self.assertTrue(optimized_variable['value'].startswith('<error:')) diff --git a/lldb/test/API/tools/lldb-vscode/optimized/main.cpp b/lldb/test/API/tools/lldb-vscode/optimized/main.cpp index 24ace4e4196f..cf94bc3e3ea2 100644 --- a/lldb/test/API/tools/lldb-vscode/optimized/main.cpp +++ b/lldb/test/API/tools/lldb-vscode/optimized/main.cpp @@ -7,10 +7,8 @@ int foo(int x, int y) { } int main(int argc, char const *argv[]) { - int optimized = argc > 1 ? std::stoi(argv[1]) : 0; - - printf("argc: %d, optimized: %d\n", argc, optimized); - int result = foo(argc, 20); + printf("argc: %d\n", argc); + int result = foo(20, argv[0][0]); printf("result: %d\n", result); // breakpoint 2 return 0; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits