[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Closing this because I'm going to change my approach after talking to Greg.

https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg , the main issue is to allow users to use the regular initCommands 
and at the same time have another way for the vscode extension to issue their 
own initCommands and control the output of these specific commands without 
interfering with the initCommands provided by the user. 
Any sort of global setting that controls the output is not going to work 
because it would affect both the extension's initCommands as well as the 
user's. Like, we don't want to hide users' initCommands just because the 
extension wants to hide a few.
This makes me think that the cleanest approach is to have another set of 
initCommands for the extension, that runs totally independently from the ones 
provided by the user.
What do you think?

https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

Another idea would be to add a command that allows users to specify the console 
to log LLDB commands from `*Commands` settings by allowing them to specify a 
console. From the DAP spec we have:
```
/**
 * The output category. If not specified or if the category is not
 * understood by the client, `console` is assumed.
 * Values:
 * 'console': Show the output in the client's default message UI, e.g. a
 * 'debug console'. This category should only be used for informational
 * output from the debugger (as opposed to the debuggee).
 * 'important': A hint for the client to show the output in the client's UI
 * for important and highly visible information, e.g. as a popup
 * notification. This category should only be used for important messages
 * from the debugger (as opposed to the debuggee). Since this category value
 * is a hint, clients might ignore the hint and assume the `console`
 * category.
 * 'stdout': Show the output as normal program output from the debuggee.
 * 'stderr': Show the output as error program output from the debuggee.
 * 'telemetry': Send the output to telemetry instead of showing it to the
 * user.
 * etc.
 */
category?: 'console' | 'important' | 'stdout' | 'stderr' | 'telemetry' | 
string;
```
I was thinking:
```
   "lldbCommandsOutputDestination" = ['console' | 'important' | 'stdout' | 
'stderr' | 'telemetry' | 'none']
```
Note that I added one exrtra 'none' which would also be 'off' or 'quiet'

https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

I am not a fan of making a whole extra duplication of "initCommands" just to 
make these commands not show up in the debug console. Wouldn't a setting like:
```
  "showCommandsInDebugConsole": ["always", "error-only", "never"]
``` 
Would this achieve the same thing without needed to put these command elsewhere?

https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.


---
Full diff: https://github.com/llvm/llvm-project/pull/74748.diff


11 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+3) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+4) 
- (added) lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile (+2) 
- (added) 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 (+77) 
- (added) lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp (+1) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+30-3) 
- (modified) lldb/tools/lldb-dap/DAP.h (+27-2) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+11-6) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.h (+10-5) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+6-1) 
- (modified) lldb/tools/lldb-dap/package.json (+34) 


``diff
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 bb863bb8719176..4f2bff7ad5101d 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
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
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 4ccd6014e54be6..f1bf4decbe0779 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
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -470,4 +473,5 @@ def build_and_launch(
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
diff --git a/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
new file mode 100644
index 00..3d0b98f13f3d7b
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
new file mode 100644
index 00..0d930dcbc80e38
--- /dev/null
+++ 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
@@ -0,0 +1,77 @@
+"""
+Test lldb-dap stack trace respon

[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo ready_for_review 
https://github.com/llvm/llvm-project/pull/74748
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/74748

>From 07bd16ac9bbc4f9868d1b541e003aa95bf6ae8be Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 29 Nov 2023 18:12:54 -0500
Subject: [PATCH] [lldb-dap] Introduce the new privateConfiguration setting

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.
---
 .../test/tools/lldb-dap/dap_server.py |  3 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 +
 .../lldb-dap/privateConfiguration/Makefile|  2 +
 .../TestDAP_privateConfiguration.py   | 77 +++
 .../lldb-dap/privateConfiguration/main.cpp|  1 +
 lldb/tools/lldb-dap/DAP.cpp   | 33 +++-
 lldb/tools/lldb-dap/DAP.h | 29 ++-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 17 ++--
 lldb/tools/lldb-dap/LLDBUtils.h   | 15 ++--
 lldb/tools/lldb-dap/lldb-dap.cpp  |  7 +-
 lldb/tools/lldb-dap/package.json  | 34 
 11 files changed, 205 insertions(+), 17 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp

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 bb863bb8719176..4f2bff7ad5101d 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
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
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 4ccd6014e54be6..f1bf4decbe0779 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
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -470,4 +473,5 @@ def build_and_launch(
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
diff --git a/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
new file mode 100644
index 00..3d0b98f13f3d7b
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfigur

[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/74748

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.


>From c5817d7acf154798cff6ac0b8f24a80002ff202d Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 29 Nov 2023 18:12:54 -0500
Subject: [PATCH] [lldb-dap] Introduce the new privateConfiguration setting

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.
---
 .../test/tools/lldb-dap/dap_server.py |  3 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 +
 .../lldb-dap/privateConfiguration/Makefile|  2 +
 .../TestDAP_privateConfiguration.py   | 77 +++
 .../lldb-dap/privateConfiguration/main.cpp|  1 +
 lldb/tools/lldb-dap/DAP.cpp   | 33 +++-
 lldb/tools/lldb-dap/DAP.h | 30 +++-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 17 ++--
 lldb/tools/lldb-dap/LLDBUtils.h   |  7 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  7 +-
 lldb/tools/lldb-dap/package.json  | 17 
 11 files changed, 183 insertions(+), 15 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp

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 bb863bb8719176..4f2bff7ad5101d 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
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
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 4ccd6014e54be6..f1bf4decbe0779 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
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+private