Author: jeffreytan81 Date: 2023-11-20T15:57:14-08:00 New Revision: 85ee3fc7ec15f432430ee0c73fe81f3d6382d9df
URL: https://github.com/llvm/llvm-project/commit/85ee3fc7ec15f432430ee0c73fe81f3d6382d9df DIFF: https://github.com/llvm/llvm-project/commit/85ee3fc7ec15f432430ee0c73fe81f3d6382d9df.diff LOG: Fix command escape bug in lldb-dap (#72902) https://github.com/llvm/llvm-project/pull/69238 caused breakage in VSCode debug console usage -- the user's input is always treated as commands instead of expressions (the same behavior as if empty command escape prefix is specified). The bug is in one overload of `GetString()` which did not respect the default value of "\`". But more important, I am puzzled to find out why the regression is not caught by lldb test (testdap_evaluate). Turns out https://github.com/llvm/llvm-project/pull/69238 specifies commandEscapePrefix default value in test framework to be "\`" while VSCode will default not specify any commandEscapePrefix at all. Changing it to None will fail `testdap_evaluate`. We should align the default behavior between DAP client and testcase. This patches fixes the bug in `GetString()` and changed the default value of commandEscapePrefix in testcases to be None (be consistent with IDE). Co-authored-by: jeffreytan81 <jeffrey...@fb.com> Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py lldb/tools/lldb-dap/JSONUtils.cpp Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 518e3b9cf5bab33..bb863bb87191763 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -731,7 +731,7 @@ def request_launch( postRunCommands=None, enableAutoVariableSummaries=False, enableSyntheticChildDebugging=False, - commandEscapePrefix="`", + commandEscapePrefix=None, customFrameFormat=None, customThreadFormat=None, ): diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 0cf9d4fde49488f..4ccd6014e54be6a 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -354,7 +354,7 @@ def launch( postRunCommands=None, enableAutoVariableSummaries=False, enableSyntheticChildDebugging=False, - commandEscapePrefix="`", + commandEscapePrefix=None, customFrameFormat=None, customThreadFormat=None, ): @@ -434,7 +434,7 @@ def build_and_launch( lldbDAPEnv=None, enableAutoVariableSummaries=False, enableSyntheticChildDebugging=False, - commandEscapePrefix="`", + commandEscapePrefix=None, customFrameFormat=None, customThreadFormat=None, ): diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 50ade02801529c3..03a43f9da87f241 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -57,7 +57,7 @@ llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key, llvm::StringRef defaultValue) { if (obj == nullptr) return defaultValue; - return GetString(*obj, key); + return GetString(*obj, key, defaultValue); } // Gets an unsigned integer from a JSON object using the key, or returns the _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits