[Lldb-commits] [PATCH] D136295: Fix exception description in lldb-vscode
jeffrey tan via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 19 14:46:26 PDT 2022
yinghuitan created this revision.
yinghuitan added reviewers: clayborg, labath, jingham, jdoerfert, JDevlieghere, aadsm, kusmour, fixathon.
Herald added a project: All.
yinghuitan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
There is a bug in lldb-vscode that only shows stop reason ("exception") in
stopped event without showing the stop description of thrown exception. This
causes VSCode UI to only show "Paused on Exception" general message in
callstack window UI.
This patch fixes the bug so that VSCode callstack will show the detailed
exceptioni description, like "signal SIGABRT" or "EXC_BAD_ACCESS..." which
aligns with command line lldb experience.
I use C++ exception in testcase because the hardware exception description is
platform dependent and hard to verify.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136295
Files:
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/test/API/tools/lldb-vscode/exception/Makefile
lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py
lldb/test/API/tools/lldb-vscode/exception/main.cpp
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
@@ -930,7 +930,7 @@
// If no description has been set, then set it to the default thread stopped
// description. If we have breakpoints that get hit and shouldn't be reported
// as breakpoints, then they will set the description above.
- if (ObjectContainsKey(body, "description")) {
+ if (!ObjectContainsKey(body, "description")) {
char description[1024];
if (thread.GetStopDescription(description, sizeof(description))) {
EmplaceSafeString(body, "description", std::string(description));
Index: lldb/test/API/tools/lldb-vscode/exception/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/exception/main.cpp
@@ -0,0 +1,6 @@
+#include <stdexcept>
+
+int main() {
+ throw std::runtime_error("runtime error message");
+ return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py
@@ -0,0 +1,23 @@
+"""
+Test stop hooks
+"""
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbvscode_testcase
+
+
+class TestVSCode_exception(lldbvscode_testcase.VSCodeTestCaseBase):
+
+ @skipIfRemote
+ def test_stopped_description(self):
+ '''
+ TODO
+ '''
+ program = self.getBuildArtifact("a.out")
+ print("test_stopped_description called", flush=True)
+ self.build_and_launch(program)
+
+ self.vscode.request_continue()
+ self.assertTrue(self.verify_stop_exception_info("signal SIGABRT"))
Index: lldb/test/API/tools/lldb-vscode/exception/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/exception/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -93,10 +93,10 @@
return
self.assertTrue(False, "breakpoint not hit")
- def verify_exception_breakpoint_hit(self, filter_label):
+ def verify_stop_exception_info(self, expected_description):
'''Wait for the process we are debugging to stop, and verify the stop
reason is 'exception' and that the description matches
- 'filter_label'
+ 'expected_description'
'''
stopped_events = self.vscode.wait_for_stopped()
for stopped_event in stopped_events:
@@ -109,7 +109,7 @@
if 'description' not in body:
continue
description = body['description']
- if filter_label == description:
+ if expected_description == description:
return True
return False
@@ -236,7 +236,7 @@
def continue_to_exception_breakpoint(self, filter_label):
self.vscode.request_continue()
- self.assertTrue(self.verify_exception_breakpoint_hit(filter_label),
+ self.assertTrue(self.verify_stop_exception_info(filter_label),
'verify we got "%s"' % (filter_label))
def continue_to_exit(self, exitCode=0):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136295.469053.patch
Type: text/x-patch
Size: 3692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221019/4e62afd8/attachment.bin>
More information about the lldb-commits
mailing list