yinghuitan created this revision. yinghuitan added reviewers: clayborg, labath, jingham, jdoerfert, JDevlieghere, kusmour, aadsm. Herald added a project: All. yinghuitan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
This fixes an issue that optimized variable error message is not shown to end users in lldb-vscode. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D126014 Files: lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py lldb/tools/lldb-vscode/JSONUtils.cpp Index: lldb/tools/lldb-vscode/JSONUtils.cpp =================================================================== --- lldb/tools/lldb-vscode/JSONUtils.cpp +++ lldb/tools/lldb-vscode/JSONUtils.cpp @@ -136,10 +136,13 @@ llvm::StringRef value = v.GetValue(); llvm::StringRef summary = v.GetSummary(); llvm::StringRef type_name = v.GetType().GetDisplayTypeName(); + lldb::SBError error = v.GetError(); std::string result; llvm::raw_string_ostream strm(result); - if (!value.empty()) { + if (!error.Success()) { + strm << "<error: " << error.GetCString() << ">"; + } else if (!value.empty()) { strm << value; if (!summary.empty()) strm << ' ' << summary; Index: lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py =================================================================== --- lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py +++ lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py @@ -33,3 +33,22 @@ self.assertTrue(leaf_frame['name'].endswith(' [opt]')) parent_frame = self.vscode.get_stackFrame(frameIndex=1) self.assertTrue(parent_frame['name'].endswith(' [opt]')) + + @skipIfWindows + @skipIfRemote + def test_optimized_variable(self): + ''' Test optimized variable value contains error. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = 'main.cpp' + breakpoint_line = line_number(source, '// breakpoint 2') + lines = [breakpoint_line] + # Set breakpoint in the thread function so we can step the threads + breakpoint_ids = self.set_source_breakpoints(source, lines) + 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') + + self.assertTrue(optimized_variable['value'].startswith('<error:'))
Index: lldb/tools/lldb-vscode/JSONUtils.cpp =================================================================== --- lldb/tools/lldb-vscode/JSONUtils.cpp +++ lldb/tools/lldb-vscode/JSONUtils.cpp @@ -136,10 +136,13 @@ llvm::StringRef value = v.GetValue(); llvm::StringRef summary = v.GetSummary(); llvm::StringRef type_name = v.GetType().GetDisplayTypeName(); + lldb::SBError error = v.GetError(); std::string result; llvm::raw_string_ostream strm(result); - if (!value.empty()) { + if (!error.Success()) { + strm << "<error: " << error.GetCString() << ">"; + } else if (!value.empty()) { strm << value; if (!summary.empty()) strm << ' ' << summary; Index: lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py =================================================================== --- lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py +++ lldb/test/API/tools/lldb-vscode/optimized/TestVSCode_optimized.py @@ -33,3 +33,22 @@ self.assertTrue(leaf_frame['name'].endswith(' [opt]')) parent_frame = self.vscode.get_stackFrame(frameIndex=1) self.assertTrue(parent_frame['name'].endswith(' [opt]')) + + @skipIfWindows + @skipIfRemote + def test_optimized_variable(self): + ''' Test optimized variable value contains error. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = 'main.cpp' + breakpoint_line = line_number(source, '// breakpoint 2') + lines = [breakpoint_line] + # Set breakpoint in the thread function so we can step the threads + breakpoint_ids = self.set_source_breakpoints(source, lines) + 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') + + self.assertTrue(optimized_variable['value'].startswith('<error:'))
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits