[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to true.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.


>From 5b1250c20f34c0236e98f055af2547e5bdba0366 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH] [lldb-vscode] Make descriptive summaries and raw child for
 synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to true.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++---
 .../variables/TestVSCode_variables.py | 71 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 +++-
 lldb/tools/lldb-vscode/VSCode.cpp |  3 +-
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 ++
 9 files changed, 126 insertions(+), 30 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..1716920be1ad596 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=True,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+descriptiveSummaries=descriptiveSummaries,
+rawChildForSynthetics=rawChildForSynthetics,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=True,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+descriptiveSummaries=descriptiveSummaries,
+rawChildForSynthetics=rawChildForSynthetics,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..6df3609ae3abbc3 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"]

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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


@@ -240,6 +240,16 @@
"timeout": {
"type": 
"string",
"description": 
"The time in seconds to wait for a program to stop at entry point when 
launching with \"launchCommands\". Defaults to 30 seconds."
+   },
+   "descriptiveSummaries": 
{
+   "type": 
"boolean",
+   "description": 
"Show more descriptive variable summaries, which might incur in worse 
performance.",

walter-erquinigo wrote:

Thanks for the feedback.

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

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

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

>From fc0700e761db9761675c42826e8f5bfa5b510840 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH] [lldb-vscode] Make descriptive summaries and raw child for
 synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to true.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++---
 .../variables/TestVSCode_variables.py | 71 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 +++-
 lldb/tools/lldb-vscode/VSCode.cpp |  3 +-
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 ++
 9 files changed, 126 insertions(+), 30 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..1716920be1ad596 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=True,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+descriptiveSummaries=descriptiveSummaries,
+rawChildForSynthetics=rawChildForSynthetics,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=True,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+descriptiveSummaries=descriptiveSummaries,
+rawChildForSynthetics=rawChildForSynthetics,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..6df3609ae3abbc3 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+descriptiveSummaries=False,
+rawChildForSynthetics=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["descriptiveSummaries"] = descriptiveSummaries
+args_dict["rawChildForSynthetics"] = rawChildForSynthetics
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_e

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

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

>From 4d563d5542291c4b386caaad1f6f4c18f4c7bfd1 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH] [lldb-vscode] Make descriptive summaries and raw child for
 synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to false as well.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++---
 .../variables/TestVSCode_variables.py | 71 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 +++-
 lldb/tools/lldb-vscode/VSCode.cpp |  2 +
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 ++
 9 files changed, 126 insertions(+), 29 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 command_dict = {"command": "launch", "type": "reques

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-08 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg , do you get notifications when I update the PR? :) I'm still getting 
used to github for llvm.
In any case, this is ready for review.

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


[Lldb-commits] [lldb] c154ba8 - [LLDB][NFC] Add the mojo language to Language::GetPrimaryLanguage

2023-09-11 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-09-11T15:25:05-04:00
New Revision: c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c

URL: 
https://github.com/llvm/llvm-project/commit/c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c
DIFF: 
https://github.com/llvm/llvm-project/commit/c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c.diff

LOG: [LLDB][NFC] Add the mojo language to Language::GetPrimaryLanguage

This doesn't change the current behavior of the function, but the explicit 
declaration looks cleaner.

Added: 


Modified: 
lldb/source/Target/Language.cpp

Removed: 




diff  --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 78785352676da31..42c3350806d90f5 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -374,6 +374,7 @@ LanguageType Language::GetPrimaryLanguage(LanguageType 
language) {
   case eLanguageTypeJulia:
   case eLanguageTypeDylan:
   case eLanguageTypeMipsAssembler:
+  case eLanguageTypeMojo:
   case eLanguageTypeUnknown:
   default:
 return language;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

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

>From 6415738e5c359553212d4a04780694587a536a82 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH] [lldb-vscode] Make descriptive summaries and raw child for
 synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to false as well.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++--
 .../variables/TestVSCode_variables.py | 81 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 ++-
 lldb/tools/lldb-vscode/VSCode.cpp |  2 +
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 +
 9 files changed, 136 insertions(+), 29 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 command_dict = {"command": "launch", "type": "request",

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

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

>From 6415738e5c359553212d4a04780694587a536a82 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH 1/2] [lldb-vscode] Make descriptive summaries and raw child
 for synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to false as well.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++--
 .../variables/TestVSCode_variables.py | 81 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 ++-
 lldb/tools/lldb-vscode/VSCode.cpp |  2 +
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 +
 9 files changed, 136 insertions(+), 29 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 command_dict = {"command": "launch", "type": "reque

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 4a030f5 - [lldb-vscode][NFC] Access a pointee type in a simpler way

2023-09-15 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-09-15T12:26:04-04:00
New Revision: 4a030f5b245b63fe09c29686c50d40796c987d96

URL: 
https://github.com/llvm/llvm-project/commit/4a030f5b245b63fe09c29686c50d40796c987d96
DIFF: 
https://github.com/llvm/llvm-project/commit/4a030f5b245b63fe09c29686c50d40796c987d96.diff

LOG: [lldb-vscode][NFC] Access a pointee type in a simpler way

The new code is a bit simpler bit achieves the same goal. A small test was 
added just in case.

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
lldb/tools/lldb-vscode/JSONUtils.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index d0172ef9160fdd6..3cfe02ef6aa1576 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -62,6 +62,9 @@ def run_test_evaluate_expressions(
 self.assertEvaluate(
 "struct1", "{foo:15}" if enableAutoVariableSummaries else 
"my_struct @ 0x"
 )
+self.assertEvaluate(
+"struct2", "{foo:16}" if enableAutoVariableSummaries else "0x.*"
+)
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 0d149ff27fd3d3e..c6b422e4d7a02e6 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -203,10 +203,9 @@ static bool ShouldBeDereferencedForSummary(lldb::SBValue 
&v) {
   if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())
 return false;
 
-  // If it's a pointer to a pointer, we don't dereference to avoid confusing
+  // If we are referencing a pointer, we don't dereference to avoid confusing
   // the user with the addresses that could shown in the summary.
-  if (v.GetType().IsPointerType() &&
-  v.GetType().GetDereferencedType().IsPointerType())
+  if (v.Dereference().GetType().IsPointerType())
 return false;
 
   // If it's synthetic or a pointer to a basic type that provides a summary, we



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)
+
+To this aim, they are hooked into the ValueObjects model, in order to provide
+entry points through which such customization questions can be answered. For
+example what format should this number be printed as? How many child elements

walter-erquinigo wrote:

```suggestion
example: What format should this number be printed as? How many child elements
```

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


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)

walter-erquinigo wrote:

```suggestion
backed by LLDB).
```

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


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)
+
+To this aim, they are hooked into the ValueObjects model, in order to provide
+entry points through which such customization questions can be answered. For
+example what format should this number be printed as? How many child elements
+does this ``std::vector`` have?
+
+The architecture of the subsystem is layered, with the highest level layer
+being the user visible interaction features (e.g. the ``type ***`` commands,
+the SB classes, ...). Other layers of interest that will be analyzed in this
+document include
+
+* Classes implementing individual data formatter types
+* Classes implementing formatters navigation, discovery and categorization
+* The ``FormatManager`` layer
+* The ``DataVisualization`` layer
+* The SWIG <> LLDB communication layer
+
+Data Formatter Types
+
+
+As described in the user documentation, there are four types of formatters:
+
+* Formats
+* Summaries
+* Filters
+* Synthetic children
+
+Formatters have descriptor classes, ``Type*Impl``, which contain at least a
+"Flags" nested object, which contains both rules to be used by the matching
+algorithm (e.g. should the formatter for type Foo apply to a Foo*?) or rules to
+be used by the formatter itself (e.g. is this summary a oneliner?).
+
+Individual formatter descriptor classes then also contain data items useful to
+them for performing their functionality. For instance ``TypeFormatImpl``
+(backing formats) contains an ``lldb::Format`` that is the format to then be
+applied were this formatter to be selected. Upon issuing a ``type format add``
+a new ``TypeFormatImpl`` is created that wraps the user-specified format, and
+matching options:
+
+::
+
+  entry.reset(new TypeFormatImpl(
+  format, TypeFormatImpl::Flags()
+  .SetCascades(m_command_options.m_cascade)
+  .SetSkipPointers(m_command_options.m_skip_pointers)
+  .SetSkipReferences(m_command_options.m_skip_references)));
+
+
+While formats are fairly simple and only implemented by one class, the other
+formatter types are backed by a class hierarchy.
+
+Summaries, for instance, can exist in one of three "flavors":
+
+* Summary strings
+* Python script
+* Native C++
+
+The base class for summaries, ``TypeSummaryImpl``, is a pure virtual class that
+wraps, again, the Flags, and exports among others:
+
+::
+
+  virtual bool FormatObject (ValueObject *valobj, std::string& dest) = 0;
+
+
+This is the core entry point, which allows subclasses to specify their mode of
+operation.
+
+``StringSummaryFormat``, which is the class that implements summary strings,
+does a check as to whether the summary is a one-liner, and if not, then uses
+its stored summary string to call into ``Debugger::FormatPrompt``, and obtain a
+string back, which it returns in ``dest`` as the resulting summary.
+
+For a Python summary, implemented in ``ScriptSummaryFormat``,
+``FormatObject()`` calls into the ``ScriptInterpreter`` which is supposed to
+hold the knowledge on how to bridge back and forth with the scripting language
+(Python in the case of LLDB) in order to produce a valid string. Implementors
+of new ``ScriptInterpreters`` for other languages are expected to provide a
+``GetScriptedSummary()`` entrypoint for this purpose, if they desire to allow
+users to provide formatters in the new language
+
+Lastly, C++ summaries (``CXXFunctionSummaryFormat``), wrap a function pointer
+and call into it to execute their duty. It should be noted that there are no
+facilities for users to interact with C++ formatters, and as such they are
+extremely opaque, effectively being a thin wrapper between plain function
+pointers and the LLDB formatters subsystem.
+
+Also, dynamic loading of C++ formatters in LLDB is currently not implemented,
+and as such it is safe and reasonable for these formatters to deal with
+internal ``ValueObjects`` instances instead of public ``SBValue`` objects.
+
+An interesting data point is that summaries are expected to be stateless. While
+at the Python layer they are handed an ``SBValue`` (since nothing else could be
+visible for scripts), it is not expected that 

[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)
+
+To this aim, they are hooked into the ValueObjects model, in order to provide
+entry points through which such customization questions can be answered. For
+example what format should this number be printed as? How many child elements
+does this ``std::vector`` have?
+
+The architecture of the subsystem is layered, with the highest level layer
+being the user visible interaction features (e.g. the ``type ***`` commands,
+the SB classes, ...). Other layers of interest that will be analyzed in this
+document include
+
+* Classes implementing individual data formatter types
+* Classes implementing formatters navigation, discovery and categorization
+* The ``FormatManager`` layer
+* The ``DataVisualization`` layer
+* The SWIG <> LLDB communication layer
+
+Data Formatter Types
+
+
+As described in the user documentation, there are four types of formatters:
+
+* Formats
+* Summaries
+* Filters
+* Synthetic children
+
+Formatters have descriptor classes, ``Type*Impl``, which contain at least a
+"Flags" nested object, which contains both rules to be used by the matching
+algorithm (e.g. should the formatter for type Foo apply to a Foo*?) or rules to
+be used by the formatter itself (e.g. is this summary a oneliner?).
+
+Individual formatter descriptor classes then also contain data items useful to
+them for performing their functionality. For instance ``TypeFormatImpl``
+(backing formats) contains an ``lldb::Format`` that is the format to then be
+applied were this formatter to be selected. Upon issuing a ``type format add``
+a new ``TypeFormatImpl`` is created that wraps the user-specified format, and
+matching options:
+
+::
+
+  entry.reset(new TypeFormatImpl(
+  format, TypeFormatImpl::Flags()
+  .SetCascades(m_command_options.m_cascade)
+  .SetSkipPointers(m_command_options.m_skip_pointers)
+  .SetSkipReferences(m_command_options.m_skip_references)));
+
+
+While formats are fairly simple and only implemented by one class, the other
+formatter types are backed by a class hierarchy.
+
+Summaries, for instance, can exist in one of three "flavors":
+
+* Summary strings
+* Python script
+* Native C++
+
+The base class for summaries, ``TypeSummaryImpl``, is a pure virtual class that
+wraps, again, the Flags, and exports among others:
+
+::
+
+  virtual bool FormatObject (ValueObject *valobj, std::string& dest) = 0;
+
+
+This is the core entry point, which allows subclasses to specify their mode of
+operation.
+
+``StringSummaryFormat``, which is the class that implements summary strings,
+does a check as to whether the summary is a one-liner, and if not, then uses
+its stored summary string to call into ``Debugger::FormatPrompt``, and obtain a
+string back, which it returns in ``dest`` as the resulting summary.
+
+For a Python summary, implemented in ``ScriptSummaryFormat``,
+``FormatObject()`` calls into the ``ScriptInterpreter`` which is supposed to
+hold the knowledge on how to bridge back and forth with the scripting language
+(Python in the case of LLDB) in order to produce a valid string. Implementors
+of new ``ScriptInterpreters`` for other languages are expected to provide a
+``GetScriptedSummary()`` entrypoint for this purpose, if they desire to allow

walter-erquinigo wrote:

```suggestion
``GetScriptedSummary()`` entry point for this purpose, if they desire to allow
```

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


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)
+
+To this aim, they are hooked into the ValueObjects model, in order to provide
+entry points through which such customization questions can be answered. For
+example what format should this number be printed as? How many child elements
+does this ``std::vector`` have?
+
+The architecture of the subsystem is layered, with the highest level layer
+being the user visible interaction features (e.g. the ``type ***`` commands,
+the SB classes, ...). Other layers of interest that will be analyzed in this
+document include
+
+* Classes implementing individual data formatter types
+* Classes implementing formatters navigation, discovery and categorization
+* The ``FormatManager`` layer
+* The ``DataVisualization`` layer
+* The SWIG <> LLDB communication layer
+
+Data Formatter Types
+
+
+As described in the user documentation, there are four types of formatters:
+
+* Formats
+* Summaries
+* Filters
+* Synthetic children
+
+Formatters have descriptor classes, ``Type*Impl``, which contain at least a
+"Flags" nested object, which contains both rules to be used by the matching
+algorithm (e.g. should the formatter for type Foo apply to a Foo*?) or rules to
+be used by the formatter itself (e.g. is this summary a oneliner?).
+
+Individual formatter descriptor classes then also contain data items useful to
+them for performing their functionality. For instance ``TypeFormatImpl``
+(backing formats) contains an ``lldb::Format`` that is the format to then be
+applied were this formatter to be selected. Upon issuing a ``type format add``
+a new ``TypeFormatImpl`` is created that wraps the user-specified format, and
+matching options:
+
+::
+
+  entry.reset(new TypeFormatImpl(
+  format, TypeFormatImpl::Flags()
+  .SetCascades(m_command_options.m_cascade)
+  .SetSkipPointers(m_command_options.m_skip_pointers)
+  .SetSkipReferences(m_command_options.m_skip_references)));
+
+
+While formats are fairly simple and only implemented by one class, the other
+formatter types are backed by a class hierarchy.
+
+Summaries, for instance, can exist in one of three "flavors":
+
+* Summary strings
+* Python script
+* Native C++
+
+The base class for summaries, ``TypeSummaryImpl``, is a pure virtual class that
+wraps, again, the Flags, and exports among others:
+
+::
+
+  virtual bool FormatObject (ValueObject *valobj, std::string& dest) = 0;
+
+
+This is the core entry point, which allows subclasses to specify their mode of
+operation.
+
+``StringSummaryFormat``, which is the class that implements summary strings,
+does a check as to whether the summary is a one-liner, and if not, then uses
+its stored summary string to call into ``Debugger::FormatPrompt``, and obtain a
+string back, which it returns in ``dest`` as the resulting summary.
+
+For a Python summary, implemented in ``ScriptSummaryFormat``,
+``FormatObject()`` calls into the ``ScriptInterpreter`` which is supposed to
+hold the knowledge on how to bridge back and forth with the scripting language
+(Python in the case of LLDB) in order to produce a valid string. Implementors
+of new ``ScriptInterpreters`` for other languages are expected to provide a
+``GetScriptedSummary()`` entrypoint for this purpose, if they desire to allow
+users to provide formatters in the new language
+
+Lastly, C++ summaries (``CXXFunctionSummaryFormat``), wrap a function pointer
+and call into it to execute their duty. It should be noted that there are no
+facilities for users to interact with C++ formatters, and as such they are
+extremely opaque, effectively being a thin wrapper between plain function
+pointers and the LLDB formatters subsystem.
+
+Also, dynamic loading of C++ formatters in LLDB is currently not implemented,
+and as such it is safe and reasonable for these formatters to deal with
+internal ``ValueObjects`` instances instead of public ``SBValue`` objects.
+
+An interesting data point is that summaries are expected to be stateless. While
+at the Python layer they are handed an ``SBValue`` (since nothing else could be
+visible for scripts), it is not expected that 

[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo commented:

Awesome doc!

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


[Lldb-commits] [lldb] [lldb] Revive internal data formatter documentation (PR #66527)

2023-09-15 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,436 @@
+Data Formatters
+===
+
+This page is an introduction to the design of the LLDB data formatters
+subsystem. The intended target audience are people interested in understanding
+or modifying the formatters themselves rather than writing a specific data
+formatter. For this latter purpose, the user documentation about formatters is
+the main relevant document which one should refer to.
+
+This page also highlights some open areas for improvement to the general
+subsystem, and more evolutions not anticipated here are certainly possible.
+
+Overview
+
+
+The LLDB data formatters subsystem is used to allow the debugger as well as the
+end-users to customize the way their variables look upon inspection in the user
+interface (be it the command line tool, or one of the several GUIs that are
+backed by LLDB)
+
+To this aim, they are hooked into the ValueObjects model, in order to provide
+entry points through which such customization questions can be answered. For
+example what format should this number be printed as? How many child elements
+does this ``std::vector`` have?
+
+The architecture of the subsystem is layered, with the highest level layer
+being the user visible interaction features (e.g. the ``type ***`` commands,
+the SB classes, ...). Other layers of interest that will be analyzed in this
+document include
+
+* Classes implementing individual data formatter types
+* Classes implementing formatters navigation, discovery and categorization
+* The ``FormatManager`` layer
+* The ``DataVisualization`` layer
+* The SWIG <> LLDB communication layer
+
+Data Formatter Types
+
+
+As described in the user documentation, there are four types of formatters:
+
+* Formats
+* Summaries
+* Filters
+* Synthetic children
+
+Formatters have descriptor classes, ``Type*Impl``, which contain at least a
+"Flags" nested object, which contains both rules to be used by the matching
+algorithm (e.g. should the formatter for type Foo apply to a Foo*?) or rules to
+be used by the formatter itself (e.g. is this summary a oneliner?).
+
+Individual formatter descriptor classes then also contain data items useful to
+them for performing their functionality. For instance ``TypeFormatImpl``
+(backing formats) contains an ``lldb::Format`` that is the format to then be
+applied were this formatter to be selected. Upon issuing a ``type format add``
+a new ``TypeFormatImpl`` is created that wraps the user-specified format, and
+matching options:
+
+::
+
+  entry.reset(new TypeFormatImpl(
+  format, TypeFormatImpl::Flags()
+  .SetCascades(m_command_options.m_cascade)
+  .SetSkipPointers(m_command_options.m_skip_pointers)
+  .SetSkipReferences(m_command_options.m_skip_references)));
+
+
+While formats are fairly simple and only implemented by one class, the other
+formatter types are backed by a class hierarchy.
+
+Summaries, for instance, can exist in one of three "flavors":
+
+* Summary strings
+* Python script
+* Native C++
+
+The base class for summaries, ``TypeSummaryImpl``, is a pure virtual class that
+wraps, again, the Flags, and exports among others:
+
+::
+
+  virtual bool FormatObject (ValueObject *valobj, std::string& dest) = 0;
+
+
+This is the core entry point, which allows subclasses to specify their mode of
+operation.
+
+``StringSummaryFormat``, which is the class that implements summary strings,
+does a check as to whether the summary is a one-liner, and if not, then uses
+its stored summary string to call into ``Debugger::FormatPrompt``, and obtain a
+string back, which it returns in ``dest`` as the resulting summary.
+
+For a Python summary, implemented in ``ScriptSummaryFormat``,
+``FormatObject()`` calls into the ``ScriptInterpreter`` which is supposed to
+hold the knowledge on how to bridge back and forth with the scripting language
+(Python in the case of LLDB) in order to produce a valid string. Implementors
+of new ``ScriptInterpreters`` for other languages are expected to provide a
+``GetScriptedSummary()`` entrypoint for this purpose, if they desire to allow
+users to provide formatters in the new language
+
+Lastly, C++ summaries (``CXXFunctionSummaryFormat``), wrap a function pointer
+and call into it to execute their duty. It should be noted that there are no
+facilities for users to interact with C++ formatters, and as such they are
+extremely opaque, effectively being a thin wrapper between plain function
+pointers and the LLDB formatters subsystem.
+
+Also, dynamic loading of C++ formatters in LLDB is currently not implemented,
+and as such it is safe and reasonable for these formatters to deal with
+internal ``ValueObjects`` instances instead of public ``SBValue`` objects.
+
+An interesting data point is that summaries are expected to be stateless. While
+at the Python layer they are handed an ``SBValue`` (since nothing else could be
+visible for scripts), it is not expected that 

[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

The variables pane on VSCode is very narrow by default, and lldb-vscode has 
been using the default formatter for addresses, which uses 18 characters for 
each address. That's a bit too much because it prints too many leading zeroes.
As a way to improve readability of variables, I'm adding some logic to format 
addresses manually using as few chars as possible. I don't want to mess with 
the default LLDB formatter because, if the user uses the debug console, they 
should see addresses formatted in the regular way.


>From 82a50d63e896bcce943370e12e14f442c2a140b7 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 12:40:33 -0400
Subject: [PATCH] [lldb-vscode] Show value addresses in a short format

The variables pane on VSCode is very narrow by default, and lldb-vscode has 
been using the default formatter for addresses, which uses 18 characters for 
each address. That's a bit too much because it prints too many leading zeroes.
As a way to improve readability of variables, I'm adding some logic to format 
addresses manually using as few chars as possible. I don't want to mess with 
the default LLDB formatter because, if the user uses the debug console, they 
should see addresses formatted in the regular way.
---
 lldb/include/lldb/API/SBType.h|   4 +
 lldb/source/API/SBType.cpp|   4 +
 .../API/tools/lldb-vscode/evaluate/main.cpp   |   2 +-
 .../variables/TestVSCode_variables.py | 107 +++---
 .../API/tools/lldb-vscode/variables/main.cpp  |   6 +
 lldb/tools/lldb-vscode/JSONUtils.cpp  |  21 +++-
 6 files changed, 127 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5962f0c50dee14f..c8fcb759dede6b2 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -121,6 +121,10 @@ class SBType {
 
   uint64_t GetByteSize();
 
+  /// \return
+  ///Whether the type is a pointer or a reference.
+  bool IsPointerOrReferenceType();
+
   bool IsPointerType();
 
   bool IsReferenceType();
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index ee5b6447428098e..38fcb54f5ea98dc 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -127,6 +127,10 @@ uint64_t SBType::GetByteSize() {
   return 0;
 }
 
+bool SBType::IsPointerOrReferenceType() {
+  return IsPointerType() || IsReferenceType();
+}
+
 bool SBType::IsPointerType() {
   LLDB_INSTRUMENT_VA(this);
 
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp 
b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
index 3a541b21b220828..bed853ba6e1433e 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
@@ -43,6 +43,6 @@ int main(int argc, char const *argv[]) {
   my_bool_vec.push_back(true);
   my_bool_vec.push_back(false); // breakpoint 6
   my_bool_vec.push_back(true); // breakpoint 7
-  
+
   return 0;
 }
diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index fc24b3b34e70283..efb5f3ec284589f 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -42,6 +42,17 @@ def verify_values(self, verify_dict, actual, 
varref_dict=None, expression=None):
 ('"%s" value "%s" doesn\'t start with' ' "%s")')
 % (key, actual_value, verify_value),
 )
+if "notstartswith" in verify_dict:
+verify = verify_dict["notstartswith"]
+for key in verify:
+verify_value = verify[key]
+actual_value = actual[key]
+startswith = actual_value.startswith(verify_value)
+self.assertFalse(
+startswith,
+('"%s" value "%s" starts with' ' "%s")')
+% (key, actual_value, verify_value),
+)
 if "contains" in verify_dict:
 verify = verify_dict["contains"]
 for key in verify:
@@ -155,6 +166,7 @@ def do_test_scopes_variables_setVariable_evaluate(
 "argv": {
 "equals": {"type": "const char **"},
 "startswith": {"value": "0x"},
+"notstartswith": {"value": "0x0"},
 "hasVariablesReference": True,
 },
 "pt": {
@@ -166,8 +178,53 @@ def do_test_scopes_variables_setVariable_evaluate(
 "buffer": {"children": buffer_children},
 },
 },
+"pt_ptr": {
+"equals": {"type": "PointType *"},
+"startswith": {"value": "0x"},
+"notstartswith": {"value": "0x0"},
+"hasVariablesReference": True,
+   

[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

>From d8060f818b18b3fe64641d9683fa49ffca0b3736 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 12:40:33 -0400
Subject: [PATCH] [lldb-vscode] Show value addresses in a short format

The variables pane on VSCode is very narrow by default, and lldb-vscode has 
been using the default formatter for addresses, which uses 18 characters for 
each address. That's a bit too much because it prints too many leading zeroes.
As a way to improve readability of variables, I'm adding some logic to format 
addresses manually using as few chars as possible. I don't want to mess with 
the default LLDB formatter because, if the user uses the debug console, they 
should see addresses formatted in the regular way.
---
 lldb/include/lldb/API/SBType.h|   4 +
 lldb/source/API/SBType.cpp|   4 +
 .../API/tools/lldb-vscode/evaluate/main.cpp   |   2 +-
 .../variables/TestVSCode_variables.py | 107 +++---
 .../API/tools/lldb-vscode/variables/main.cpp  |   6 +
 lldb/tools/lldb-vscode/JSONUtils.cpp  |  21 +++-
 6 files changed, 127 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5962f0c50dee14f..c8fcb759dede6b2 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -121,6 +121,10 @@ class SBType {
 
   uint64_t GetByteSize();
 
+  /// \return
+  ///Whether the type is a pointer or a reference.
+  bool IsPointerOrReferenceType();
+
   bool IsPointerType();
 
   bool IsReferenceType();
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index ee5b6447428098e..38fcb54f5ea98dc 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -127,6 +127,10 @@ uint64_t SBType::GetByteSize() {
   return 0;
 }
 
+bool SBType::IsPointerOrReferenceType() {
+  return IsPointerType() || IsReferenceType();
+}
+
 bool SBType::IsPointerType() {
   LLDB_INSTRUMENT_VA(this);
 
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp 
b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
index 3a541b21b220828..bed853ba6e1433e 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
@@ -43,6 +43,6 @@ int main(int argc, char const *argv[]) {
   my_bool_vec.push_back(true);
   my_bool_vec.push_back(false); // breakpoint 6
   my_bool_vec.push_back(true); // breakpoint 7
-  
+
   return 0;
 }
diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index fc24b3b34e70283..e54a42814f1e9d4 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -42,6 +42,17 @@ def verify_values(self, verify_dict, actual, 
varref_dict=None, expression=None):
 ('"%s" value "%s" doesn\'t start with' ' "%s")')
 % (key, actual_value, verify_value),
 )
+if "notstartswith" in verify_dict:
+verify = verify_dict["notstartswith"]
+for key in verify:
+verify_value = verify[key]
+actual_value = actual[key]
+startswith = actual_value.startswith(verify_value)
+self.assertFalse(
+startswith,
+('"%s" value "%s" starts with' ' "%s")')
+% (key, actual_value, verify_value),
+)
 if "contains" in verify_dict:
 verify = verify_dict["contains"]
 for key in verify:
@@ -155,6 +166,7 @@ def do_test_scopes_variables_setVariable_evaluate(
 "argv": {
 "equals": {"type": "const char **"},
 "startswith": {"value": "0x"},
+"notstartswith": {"value": "0x0"},
 "hasVariablesReference": True,
 },
 "pt": {
@@ -166,8 +178,53 @@ def do_test_scopes_variables_setVariable_evaluate(
 "buffer": {"children": buffer_children},
 },
 },
+"pt_ptr": {
+"equals": {"type": "PointType *"},
+"startswith": {"value": "0x"},
+"notstartswith": {"value": "0x0"},
+"hasVariablesReference": True,
+},
+"another_pt_ptr": {
+"equals": {"type": "PointType *"},
+"startswith": {"value": ""},
+"hasVariablesReference": True,
+},
 "x": {"equals": {"type": "int"}},
+"some_int": {
+"equals": {
+"type": "int",
+"value": "10",
+},
+},
+"some_int_ptr": {
+"equals": {"type": "int *"},
+"startswit

[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I initially didn't want to mess with global configurations, but after a second 
thought, I think your solution is better. I'll try that out

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


[Lldb-commits] [lldb] [lldb-vscode] Show value addresses in a short format (PR #66534)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add a setting for print hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

As suggested by Greg in https://github.com/llvm/llvm-project/pull/66534, I'm 
adding a setting at the Target level that controls whether to show leading 
zeroes in hex ValueObject values.

This has the benefit of reducing the amount of characters displayed in certain 
interfaces, like VSCode.


>From 750c8566bc31a359fe5a69ee5f10a79ccb78d9ce Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:41:23 -0400
Subject: [PATCH] [LLDB] Add a setting for print hex values without leading
 zeroes

As suggested by Greg in https://github.com/llvm/llvm-project/pull/66534, I'm 
adding a setting at the Target level that controls whether to show leading 
zeroes in hex ValueObject values.

This has the benefit of reducing the amount of characters displayed in certain 
interfaces, like VSCode.
---
 lldb/include/lldb/Target/Target.h  |  2 ++
 lldb/source/Core/DumpDataExtractor.cpp | 15 +++
 lldb/source/Target/Target.cpp  | 10 --
 lldb/source/Target/TargetProperties.td |  3 +++
 lldb/test/API/python_api/value/TestValueAPI.py | 17 -
 lldb/test/API/python_api/value/main.c  |  7 +--
 6 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index ed0ecbbddbf8149..b2dcd3b0b3d30a0 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -167,6 +167,8 @@ class TargetProperties : public Properties {
 
   bool GetEnableSyntheticValue() const;
 
+  bool ShouldShowHexValuesWithLeadingZeroes() const;
+
   uint32_t GetMaxZeroPaddingInFloatFormat() const;
 
   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
diff --git a/lldb/source/Core/DumpDataExtractor.cpp 
b/lldb/source/Core/DumpDataExtractor.cpp
index cb76b118325b7ef..fa9c5209ed490ff 100644
--- a/lldb/source/Core/DumpDataExtractor.cpp
+++ b/lldb/source/Core/DumpDataExtractor.cpp
@@ -620,10 +620,17 @@ lldb::offset_t lldb_private::DumpDataExtractor(
   case 2:
   case 4:
   case 8:
-s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
-  (int)(2 * item_byte_size), (int)(2 * item_byte_size),
-  DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
-   item_bit_offset));
+if (exe_scope->CalculateTarget()
+->ShouldShowHexValuesWithLeadingZeroes()) {
+  s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
+(int)(2 * item_byte_size), (int)(2 * item_byte_size),
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+} else {
+  s->Printf(wantsuppercase ? "0x%" PRIX64 : "0x%" PRIx64,
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+}
 break;
   default: {
 assert(item_bit_size == 0 && item_bit_offset == 0);
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 35f5ef324fde667..87746d7aa3c32aa 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4236,8 +4236,8 @@ bool 
TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
 }
 
 bool TargetProperties::GetPreloadSymbols() const {
-  if (INTERRUPT_REQUESTED(m_target->GetDebugger(), 
-  "Interrupted checking preload symbols")) {
+  if (INTERRUPT_REQUESTED(m_target->GetDebugger(),
+  "Interrupted checking preload symbols")) {
 return false;
   }
   const uint32_t idx = ePropertyPreloadSymbols;
@@ -4539,6 +4539,12 @@ bool TargetProperties::GetEnableSyntheticValue() const {
   idx, g_target_properties[idx].default_uint_value != 0);
 }
 
+bool TargetProperties::ShouldShowHexValuesWithLeadingZeroes() const {
+  const uint32_t idx = ePropertyShowHexValuesWithLeadingZeroes;
+  return GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
   const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
   return GetPropertyAtIndexAs(
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 3bfdfa8cfaa957f..9f639842a80841a 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -82,6 +82,9 @@ let Definition = "target" in {
   def SaveObjectsDir: Property<"save-jit-objects-dir", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"If specified, the directory to save intermediate object files 
generated by the LLVM JIT">;
+  def ShowHexValuesWithLeadingZeroes: 
Property<"show-hex-values-with-leading-zeroes", "Boolean">,
+DefaultTrue,
+Desc<"Whether to displa

[Lldb-commits] [lldb] [LLDB] Add a setting for print hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add a setting for print hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

>From 99b2a5e3663263fd1a92e350a3254fafbe9724c5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:41:23 -0400
Subject: [PATCH] [LLDB] Add a setting for print hex values without leading
 zeroes

As suggested by Greg in https://github.com/llvm/llvm-project/pull/66534, I'm 
adding a setting at the Target level that controls whether to show leading 
zeroes in hex ValueObject values.

This has the benefit of reducing the amount of characters displayed in certain 
interfaces, like VSCode.
---
 lldb/include/lldb/Target/Target.h  |  2 ++
 lldb/source/Core/DumpDataExtractor.cpp | 18 ++
 lldb/source/Target/Target.cpp  | 10 --
 lldb/source/Target/TargetProperties.td |  3 +++
 lldb/test/API/python_api/value/TestValueAPI.py | 17 -
 lldb/test/API/python_api/value/main.c  |  7 +--
 6 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index ed0ecbbddbf8149..b2dcd3b0b3d30a0 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -167,6 +167,8 @@ class TargetProperties : public Properties {
 
   bool GetEnableSyntheticValue() const;
 
+  bool ShouldShowHexValuesWithLeadingZeroes() const;
+
   uint32_t GetMaxZeroPaddingInFloatFormat() const;
 
   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
diff --git a/lldb/source/Core/DumpDataExtractor.cpp 
b/lldb/source/Core/DumpDataExtractor.cpp
index cb76b118325b7ef..3db751b6faa3ff9 100644
--- a/lldb/source/Core/DumpDataExtractor.cpp
+++ b/lldb/source/Core/DumpDataExtractor.cpp
@@ -620,10 +620,20 @@ lldb::offset_t lldb_private::DumpDataExtractor(
   case 2:
   case 4:
   case 8:
-s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
-  (int)(2 * item_byte_size), (int)(2 * item_byte_size),
-  DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
-   item_bit_offset));
+// If we don't have an ExecutionScope, we print with leading zeroes to
+// preserve behavior that LLDB had before the
+// show-hex-values-with-leading-zeroes setting was added.
+if (!exe_scope || exe_scope->CalculateTarget()
+  ->ShouldShowHexValuesWithLeadingZeroes()) {
+  s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
+(int)(2 * item_byte_size), (int)(2 * item_byte_size),
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+} else {
+  s->Printf(wantsuppercase ? "0x%" PRIX64 : "0x%" PRIx64,
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+}
 break;
   default: {
 assert(item_bit_size == 0 && item_bit_offset == 0);
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 35f5ef324fde667..87746d7aa3c32aa 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4236,8 +4236,8 @@ bool 
TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
 }
 
 bool TargetProperties::GetPreloadSymbols() const {
-  if (INTERRUPT_REQUESTED(m_target->GetDebugger(), 
-  "Interrupted checking preload symbols")) {
+  if (INTERRUPT_REQUESTED(m_target->GetDebugger(),
+  "Interrupted checking preload symbols")) {
 return false;
   }
   const uint32_t idx = ePropertyPreloadSymbols;
@@ -4539,6 +4539,12 @@ bool TargetProperties::GetEnableSyntheticValue() const {
   idx, g_target_properties[idx].default_uint_value != 0);
 }
 
+bool TargetProperties::ShouldShowHexValuesWithLeadingZeroes() const {
+  const uint32_t idx = ePropertyShowHexValuesWithLeadingZeroes;
+  return GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
   const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
   return GetPropertyAtIndexAs(
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 3bfdfa8cfaa957f..9f639842a80841a 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -82,6 +82,9 @@ let Definition = "target" in {
   def SaveObjectsDir: Property<"save-jit-objects-dir", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"If specified, the directory to save intermediate object files 
generated by the LLVM JIT">;
+  def ShowHexValuesWithLeadingZeroes: 
Property<"show-hex-values-with-leading-zeroes", "Boolean">,
+DefaultTrue,
+Desc<"Whether to display leading zeroes in hex ValueObject values.">;
   def MaxZeroPa

[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@jimingham , that's a good catch. Probably I should rename this because I want 
this setting to affect only SBValueObject::GetValue(), which is want ends up 
being sent to IDEs as a common interface. Trying to control all places that 
print as hex value is a bit too much and it'll be hard to enforce in the long 
term. Any particular suggestion? Because I can't really come up with a good 
name better than  `show-leading-zeroes-in-valueobject-values`.

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


[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I like Greg's proposal of naming it 
`show-hex-variable-values-with-leading-zeroes`. Seems very clear. I also like 
the idea of making it a global target config, which would simplify the code.

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


[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

enableAutoVariableSummaries is a setting that enhances the summaries of 
variables in the IDE. A shortcoming of this feature is that it wasn't showing 
the addresses of pointers, which is valuable information. This fixes it by 
adding it whenever applicable.


>From 776f589a3fdfd160ce449461d0d2936e52849bd2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:50:35 -0400
Subject: [PATCH] [lldb-vscode] Show addresses next to dereferenced summaries
 when using enableAutoVariableSummaries

enableAutoVariableSummaries is a setting that enhances the summaries of 
variables in the IDE. A shortcoming of this feature is that it wasn't showing 
the addresses of pointers, which is valuable information. This fixes it by 
adding it whenever applicable.
---
 .../evaluate/TestVSCode_evaluate.py   |  5 +-
 .../API/tools/lldb-vscode/evaluate/main.cpp   |  3 +-
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 51 +++
 3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index 3cfe02ef6aa1576..bf3b16067fed2fa 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -63,7 +63,10 @@ def run_test_evaluate_expressions(
 "struct1", "{foo:15}" if enableAutoVariableSummaries else 
"my_struct @ 0x"
 )
 self.assertEvaluate(
-"struct2", "{foo:16}" if enableAutoVariableSummaries else "0x.*"
+"struct2", "0x.* → {foo:16}" if enableAutoVariableSummaries else 
"0x.*"
+)
+self.assertEvaluate(
+"struct3", "0x.*0"
 )
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp 
b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
index 3a541b21b220828..f09d00e6444bb79 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
@@ -18,6 +18,7 @@ struct my_struct {
 int main(int argc, char const *argv[]) {
   my_struct struct1 = {15};
   my_struct *struct2 = new my_struct{16};
+  my_struct *struct3 = nullptr;
   int var1 = 20;
   int var2 = 21;
   int var3 = static_int; // breakpoint 1
@@ -43,6 +44,6 @@ int main(int argc, char const *argv[]) {
   my_bool_vec.push_back(true);
   my_bool_vec.push_back(false); // breakpoint 6
   my_bool_vec.push_back(true); // breakpoint 7
-  
+
   return 0;
 }
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index c6b422e4d7a02e6..d475f45bec459bb 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -203,10 +203,12 @@ static bool ShouldBeDereferencedForSummary(lldb::SBValue 
&v) {
   if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())
 return false;
 
-  // If we are referencing a pointer, we don't dereference to avoid confusing
-  // the user with the addresses that could shown in the summary.
-  if (v.Dereference().GetType().IsPointerType())
-return false;
+  // We don't want to dereference invalid data.
+  if (!v.IsSynthetic()) {
+lldb::addr_t address = v.GetValueAsUnsigned(0);
+if (address == 0 && address == LLDB_INVALID_ADDRESS)
+  return false;
+  }
 
   // If it's synthetic or a pointer to a basic type that provides a summary, we
   // don't dereference.
@@ -227,33 +229,40 @@ void SetValueForKey(lldb::SBValue &v, llvm::json::Object 
&object,
   if (!error.Success()) {
 strm << "";
   } else {
-auto tryDumpSummaryAndValue = [&strm](lldb::SBValue value) {
+auto tryDumpSummaryAndValue =
+[](lldb::SBValue value) -> std::optional {
   llvm::StringRef val = value.GetValue();
   llvm::StringRef summary = value.GetSummary();
   if (!val.empty()) {
-strm << val;
+std::string dump;
+llvm::raw_string_ostream os(dump);
+os << val;
 if (!summary.empty())
-  strm << ' ' << summary;
-return true;
+  os << ' ' << summary;
+return dump;
   }
-  if (!summary.empty()) {
-strm << ' ' << summary;
-return true;
-  }
-  if (auto container_summary = GetSyntheticSummaryForContainer(value)) {
-strm << *container_summary;
-return true;
-  }
-  return false;
+  if (!summary.empty())
+return summary.str();
+  return GetSyntheticSummaryForContainer(value);
 };
 
+bool done = false;
 // We first try to get the summary from its dereferenced value.
-bool done = ShouldBeDereferencedForSummary(v) &&
-tryDumpSummaryAndValue(v.Dereference());
+if (ShouldBeDereferencedForSummary(v)) {
+  if (std::optio

[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

>From 31236a70c8d1736563a253dc3a2582366220cb8f Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:50:35 -0400
Subject: [PATCH] [lldb-vscode] Show addresses next to dereferenced summaries
 when using enableAutoVariableSummaries

enableAutoVariableSummaries is a setting that enhances the summaries of 
variables in the IDE. A shortcoming of this feature is that it wasn't showing 
the addresses of pointers, which is valuable information. This fixes it by 
adding it whenever applicable.
---
 .../evaluate/TestVSCode_evaluate.py   |  3 +-
 .../API/tools/lldb-vscode/evaluate/main.cpp   |  3 +-
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 51 +++
 3 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index 3cfe02ef6aa1576..5632f33ae910724 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -63,8 +63,9 @@ def run_test_evaluate_expressions(
 "struct1", "{foo:15}" if enableAutoVariableSummaries else 
"my_struct @ 0x"
 )
 self.assertEvaluate(
-"struct2", "{foo:16}" if enableAutoVariableSummaries else "0x.*"
+"struct2", "0x.* → {foo:16}" if enableAutoVariableSummaries else 
"0x.*"
 )
+self.assertEvaluate("struct3", "0x.*0")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp 
b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
index 3a541b21b220828..f09d00e6444bb79 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
@@ -18,6 +18,7 @@ struct my_struct {
 int main(int argc, char const *argv[]) {
   my_struct struct1 = {15};
   my_struct *struct2 = new my_struct{16};
+  my_struct *struct3 = nullptr;
   int var1 = 20;
   int var2 = 21;
   int var3 = static_int; // breakpoint 1
@@ -43,6 +44,6 @@ int main(int argc, char const *argv[]) {
   my_bool_vec.push_back(true);
   my_bool_vec.push_back(false); // breakpoint 6
   my_bool_vec.push_back(true); // breakpoint 7
-  
+
   return 0;
 }
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index c6b422e4d7a02e6..d475f45bec459bb 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -203,10 +203,12 @@ static bool ShouldBeDereferencedForSummary(lldb::SBValue 
&v) {
   if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())
 return false;
 
-  // If we are referencing a pointer, we don't dereference to avoid confusing
-  // the user with the addresses that could shown in the summary.
-  if (v.Dereference().GetType().IsPointerType())
-return false;
+  // We don't want to dereference invalid data.
+  if (!v.IsSynthetic()) {
+lldb::addr_t address = v.GetValueAsUnsigned(0);
+if (address == 0 && address == LLDB_INVALID_ADDRESS)
+  return false;
+  }
 
   // If it's synthetic or a pointer to a basic type that provides a summary, we
   // don't dereference.
@@ -227,33 +229,40 @@ void SetValueForKey(lldb::SBValue &v, llvm::json::Object 
&object,
   if (!error.Success()) {
 strm << "";
   } else {
-auto tryDumpSummaryAndValue = [&strm](lldb::SBValue value) {
+auto tryDumpSummaryAndValue =
+[](lldb::SBValue value) -> std::optional {
   llvm::StringRef val = value.GetValue();
   llvm::StringRef summary = value.GetSummary();
   if (!val.empty()) {
-strm << val;
+std::string dump;
+llvm::raw_string_ostream os(dump);
+os << val;
 if (!summary.empty())
-  strm << ' ' << summary;
-return true;
+  os << ' ' << summary;
+return dump;
   }
-  if (!summary.empty()) {
-strm << ' ' << summary;
-return true;
-  }
-  if (auto container_summary = GetSyntheticSummaryForContainer(value)) {
-strm << *container_summary;
-return true;
-  }
-  return false;
+  if (!summary.empty())
+return summary.str();
+  return GetSyntheticSummaryForContainer(value);
 };
 
+bool done = false;
 // We first try to get the summary from its dereferenced value.
-bool done = ShouldBeDereferencedForSummary(v) &&
-tryDumpSummaryAndValue(v.Dereference());
+if (ShouldBeDereferencedForSummary(v)) {
+  if (std::optional text =
+  tryDumpSummaryAndValue(v.Dereference())) {
+strm << v.GetValue() << " → " << *text;
+done = true;
+  }
+}
 
 // We then try to get it from the current value itself.
-if (!done)
-  done = tryDumpSummaryAndValue(v);
+if 

[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

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

>From 3bddb5d5f813d5eac165be1a73b9058f5ee0510d Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:41:23 -0400
Subject: [PATCH] [LLDB] Add a setting for print hex variable values without
 leading zeroes

As suggested by Greg in https://github.com/llvm/llvm-project/pull/66534, I'm 
adding a setting at the Target level that controls whether to show leading 
zeroes in hex ValueObject values.

This has the benefit of reducing the amount of characters displayed in certain 
interfaces, like VSCode.
---
 lldb/include/lldb/Target/Target.h  |  2 ++
 lldb/source/Core/DumpDataExtractor.cpp | 15 +++
 lldb/source/Target/Target.cpp  | 10 --
 lldb/source/Target/TargetProperties.td |  4 
 lldb/test/API/python_api/value/TestValueAPI.py | 17 -
 lldb/test/API/python_api/value/main.c  |  7 +--
 6 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index ed0ecbbddbf8149..e9e531d0e12640a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -167,6 +167,8 @@ class TargetProperties : public Properties {
 
   bool GetEnableSyntheticValue() const;
 
+  bool ShowHexVariableValuesWithLeadingZeroes() const;
+
   uint32_t GetMaxZeroPaddingInFloatFormat() const;
 
   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
diff --git a/lldb/source/Core/DumpDataExtractor.cpp 
b/lldb/source/Core/DumpDataExtractor.cpp
index cb76b118325b7ef..986c9a181919ee0 100644
--- a/lldb/source/Core/DumpDataExtractor.cpp
+++ b/lldb/source/Core/DumpDataExtractor.cpp
@@ -620,10 +620,17 @@ lldb::offset_t lldb_private::DumpDataExtractor(
   case 2:
   case 4:
   case 8:
-s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
-  (int)(2 * item_byte_size), (int)(2 * item_byte_size),
-  DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
-   item_bit_offset));
+if (Target::GetGlobalProperties()
+.ShowHexVariableValuesWithLeadingZeroes()) {
+  s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
+(int)(2 * item_byte_size), (int)(2 * item_byte_size),
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+} else {
+  s->Printf(wantsuppercase ? "0x%" PRIX64 : "0x%" PRIx64,
+DE.GetMaxU64Bitfield(&offset, item_byte_size, 
item_bit_size,
+ item_bit_offset));
+}
 break;
   default: {
 assert(item_bit_size == 0 && item_bit_offset == 0);
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 35f5ef324fde667..8de4fd033ec8785 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -4236,8 +4236,8 @@ bool 
TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) {
 }
 
 bool TargetProperties::GetPreloadSymbols() const {
-  if (INTERRUPT_REQUESTED(m_target->GetDebugger(), 
-  "Interrupted checking preload symbols")) {
+  if (INTERRUPT_REQUESTED(m_target->GetDebugger(),
+  "Interrupted checking preload symbols")) {
 return false;
   }
   const uint32_t idx = ePropertyPreloadSymbols;
@@ -4539,6 +4539,12 @@ bool TargetProperties::GetEnableSyntheticValue() const {
   idx, g_target_properties[idx].default_uint_value != 0);
 }
 
+bool TargetProperties::ShowHexVariableValuesWithLeadingZeroes() const {
+  const uint32_t idx = ePropertyShowHexVariableValuesWithLeadingZeroes;
+  return GetPropertyAtIndexAs(
+  idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const {
   const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
   return GetPropertyAtIndexAs(
diff --git a/lldb/source/Target/TargetProperties.td 
b/lldb/source/Target/TargetProperties.td
index 3bfdfa8cfaa957f..154a6e5919ab0cd 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -82,6 +82,10 @@ let Definition = "target" in {
   def SaveObjectsDir: Property<"save-jit-objects-dir", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"If specified, the directory to save intermediate object files 
generated by the LLVM JIT">;
+  def ShowHexVariableValuesWithLeadingZeroes: 
Property<"show-hex-variable-values-with-leading-zeroes", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Whether to display leading zeroes when printing variable values in 
hex format.">;
   def MaxZeroPaddingInFloatFormat: 
Property<"max-zero-padding-in-float-format", "UInt64">,
 DefaultUnsignedValue<6>,
 Desc<"The maximum number of zeroes to insert wh

[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-15 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I've updated the PR following Greg's suggestions.

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


[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-18 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Thanks Jim and Greg!

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


[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-18 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 9389b05 - [lldb] Fix the TestValueAPI test

2023-09-18 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-09-18T13:57:25-04:00
New Revision: 9389b056a604b7da9478bb40125d6a1ad379823a

URL: 
https://github.com/llvm/llvm-project/commit/9389b056a604b7da9478bb40125d6a1ad379823a
DIFF: 
https://github.com/llvm/llvm-project/commit/9389b056a604b7da9478bb40125d6a1ad379823a.diff

LOG: [lldb] Fix the TestValueAPI test

This test was reported as failing by 
https://lab.llvm.org/buildbot/#/builders/68/builds/60172. The fix is very 
simple. We need to invoke the correct setting.

Added: 


Modified: 
lldb/test/API/python_api/value/TestValueAPI.py

Removed: 




diff  --git a/lldb/test/API/python_api/value/TestValueAPI.py 
b/lldb/test/API/python_api/value/TestValueAPI.py
index 05670b8db9bb77a..3855c67c8d37257 100644
--- a/lldb/test/API/python_api/value/TestValueAPI.py
+++ b/lldb/test/API/python_api/value/TestValueAPI.py
@@ -212,7 +212,7 @@ def test(self):
 frame0.FindVariable("fixed_int_ptr").GetValue(),
 "0x00aa",
 )
-self.runCmd("settings set target.show-hex-values-with-leading-zeroes 
false")
+self.runCmd("settings set 
target.show-hex-variable-values-with-leading-zeroes false")
 self.assertEqual(
 frame0.FindVariable("another_fixed_int_ptr").GetValue(),
 "0xaa",



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-18 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> if it doesn't have a summary and we auto generate one, then we can append the 
> generated summary string

That makes a ton of sense. I'll try that approach. Thanks

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


[Lldb-commits] [lldb] 014c41d - [LLDB] Attempt to fix DumpDataExtractorTest

2023-09-18 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-18T21:30:42Z
New Revision: 014c41d688f961cdb81cf92e6ba97100a49766a6

URL: 
https://github.com/llvm/llvm-project/commit/014c41d688f961cdb81cf92e6ba97100a49766a6
DIFF: 
https://github.com/llvm/llvm-project/commit/014c41d688f961cdb81cf92e6ba97100a49766a6.diff

LOG: [LLDB] Attempt to fix DumpDataExtractorTest

This test was broken by 710276a2505514634a7cc805461b1219dcef9337 because
DumpDataExtractor now accesses the Target properties, which someone ends
up relying on the file system.

This is an instance of this error 
https://lab.llvm.org/buildbot/#/builders/96/builds/45607/steps/6/logs/stdio

I cannot reproduce this locally, but it seems that the error happens
because we are not initializing the FileSystem and the Host as part of
the test setup.

Added: 


Modified: 
lldb/unittests/Core/DumpDataExtractorTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/DumpDataExtractorTest.cpp 
b/lldb/unittests/Core/DumpDataExtractorTest.cpp
index bbe5e9e5ed9e299..3332cf6f07fd180 100644
--- a/lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ b/lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -7,6 +7,8 @@
 
//===--===//
 
 #include "lldb/Core/DumpDataExtractor.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Endian.h"
@@ -18,6 +20,20 @@
 using namespace lldb;
 using namespace lldb_private;
 
+// This is needed for the tests because they rely on the Target global
+// properties.
+class DumpDataExtractorTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+  }
+  void TearDown() override {
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+
 static void TestDumpWithAddress(uint64_t base_addr, size_t item_count,
 llvm::StringRef expected) {
   std::vector data{0x11, 0x22};



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 266630c - [LLDB] Attempt to fix DumpDataExtractorTest

2023-09-18 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-18T22:02:05Z
New Revision: 266630cffceefbe3b00f34ba8efcfba62259335e

URL: 
https://github.com/llvm/llvm-project/commit/266630cffceefbe3b00f34ba8efcfba62259335e
DIFF: 
https://github.com/llvm/llvm-project/commit/266630cffceefbe3b00f34ba8efcfba62259335e.diff

LOG: [LLDB] Attempt to fix DumpDataExtractorTest

In 014c41d688f961cdb81cf92e6ba97100a49766a6 I tried to fix these tests,
but it seems that I needed to change TEST for TEST_F to make that work.
It's a pain that these failures don't repro on any of my machines, but I
verified thta the initialization code for the tests is invoked.

Added: 


Modified: 
lldb/unittests/Core/DumpDataExtractorTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/DumpDataExtractorTest.cpp 
b/lldb/unittests/Core/DumpDataExtractorTest.cpp
index 3332cf6f07fd180..8c58fecfee29cbe 100644
--- a/lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ b/lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -48,7 +48,7 @@ static void TestDumpWithAddress(uint64_t base_addr, size_t 
item_count,
   ASSERT_EQ(expected, result.GetString());
 }
 
-TEST(DumpDataExtractorTest, BaseAddress) {
+TEST_F(DumpDataExtractorTest, BaseAddress) {
   TestDumpWithAddress(0x12341234, 1, "0x12341234: 0x11");
   TestDumpWithAddress(LLDB_INVALID_ADDRESS, 1, "0x11");
   TestDumpWithAddress(0x12341234, 2, "0x12341234: 0x11\n0x12341235: 0x22");
@@ -69,7 +69,7 @@ static void TestDumpWithOffset(offset_t start_offset,
   ASSERT_EQ(expected, result.GetString());
 }
 
-TEST(DumpDataExtractorTest, StartOffset) {
+TEST_F(DumpDataExtractorTest, StartOffset) {
   TestDumpWithOffset(0, "0x: 0x11 0x22 0x33");
   // The offset applies to the DataExtractor, not the address used when
   // formatting.
@@ -78,7 +78,7 @@ TEST(DumpDataExtractorTest, StartOffset) {
   TestDumpWithOffset(3, "");
 }
 
-TEST(DumpDataExtractorTest, NullStream) {
+TEST_F(DumpDataExtractorTest, NullStream) {
   // We don't do any work if there is no output stream.
   uint8_t c = 0x11;
   StreamString result;
@@ -128,7 +128,7 @@ static void TestDump(const std::vector data, 
lldb::Format format,
LLDB_INVALID_ADDRESS, format, expected);
 }
 
-TEST(DumpDataExtractorTest, Formats) {
+TEST_F(DumpDataExtractorTest, Formats) {
   TestDump(1, lldb::eFormatDefault, "0x01");
   TestDump(1, lldb::eFormatBoolean, "true");
   TestDump(0xAA, lldb::eFormatBinary, "0b10101010");
@@ -274,7 +274,7 @@ TEST(DumpDataExtractorTest, Formats) {
   TestDump(99, lldb::Format::eFormatVoid, "0x0063");
 }
 
-TEST(DumpDataExtractorTest, FormatCharArray) {
+TEST_F(DumpDataExtractorTest, FormatCharArray) {
   // Unlike the other formats, charArray isn't 1 array of N chars.
   // It must be passed as N chars of 1 byte each.
   // (eFormatVectorOfChar does this swap for you)
@@ -315,7 +315,7 @@ void TestDumpMultiLine(const T *data, size_t num_items, 
lldb::Format format,
0x8000, format, expected);
 }
 
-TEST(DumpDataExtractorTest, MultiLine) {
+TEST_F(DumpDataExtractorTest, MultiLine) {
   // A vector counts as 1 item regardless of size.
   TestDumpMultiLine(std::vector{0x11},
 lldb::Format::eFormatVectorOfUInt8, 1,
@@ -370,7 +370,7 @@ void TestDumpWithItemByteSize(size_t item_byte_size, 
lldb::Format format,
expected);
 }
 
-TEST(DumpDataExtractorTest, ItemByteSizeErrors) {
+TEST_F(DumpDataExtractorTest, ItemByteSizeErrors) {
   TestDumpWithItemByteSize(
   16, lldb::Format::eFormatBoolean,
   "error: unsupported byte size (16) for boolean format");



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add a setting for printing ValueObject hex values without leading zeroes (PR #66548)

2023-09-19 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Thanks, man!

On Tue, Sep 19, 2023, 4:53 AM David Spickett ***@***.***>
wrote:

> 9568601
> 
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you modified the open/close state.Message
> ID: ***@***.***>
>


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


[Lldb-commits] [lldb] [lldb-vscode] Show addresses next to dereferenced summaries when using enableAutoVariableSummaries (PR #66551)

2023-09-19 Thread Walter Erquinigo via lldb-commits

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

>From 4c9d8d3f5be34d5ffec502a8fa891b603549b2cc Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 15 Sep 2023 16:50:35 -0400
Subject: [PATCH] [lldb-vscode] Use auto summaries when variables have values

Auto summaries were only being used when non-pointer/reference variables didn't 
have values nor summaries. Greg pointed out that it should be better to simply 
use auto summaries when the variable doesn't have a summary of its own, 
regardless of other conditions.
This led to code simplification and correct visualization of auto summaries for 
pointer/reference types.
---
 .../evaluate/TestVSCode_evaluate.py   |  3 +-
 .../API/tools/lldb-vscode/evaluate/main.cpp   |  3 +-
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 80 +++
 3 files changed, 31 insertions(+), 55 deletions(-)

diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index 3cfe02ef6aa1576..d1b73e1a057e1da 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -63,8 +63,9 @@ def run_test_evaluate_expressions(
 "struct1", "{foo:15}" if enableAutoVariableSummaries else 
"my_struct @ 0x"
 )
 self.assertEvaluate(
-"struct2", "{foo:16}" if enableAutoVariableSummaries else "0x.*"
+"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else 
"0x.*"
 )
+self.assertEvaluate("struct3", "0x.*0")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp 
b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
index 3a541b21b220828..f09d00e6444bb79 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp
@@ -18,6 +18,7 @@ struct my_struct {
 int main(int argc, char const *argv[]) {
   my_struct struct1 = {15};
   my_struct *struct2 = new my_struct{16};
+  my_struct *struct3 = nullptr;
   int var1 = 20;
   int var2 = 21;
   int var3 = static_int; // breakpoint 1
@@ -43,6 +44,6 @@ int main(int argc, char const *argv[]) {
   my_bool_vec.push_back(true);
   my_bool_vec.push_back(false); // breakpoint 6
   my_bool_vec.push_back(true); // breakpoint 7
-  
+
   return 0;
 }
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index c6b422e4d7a02e6..6cf753170d8429f 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -136,14 +136,14 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
 /// first children, so that the user can get a glimpse of its contents at a
 /// glance.
 static std::optional
-GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+TryCreateAutoSummaryForContainer(lldb::SBValue &v) {
   // We gate this feature because it performs GetNumChildren(), which can
   // cause performance issues because LLDB needs to complete possibly huge
   // types.
   if (!g_vsc.enable_auto_variable_summaries)
 return std::nullopt;
 
-  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+  if (!v.MightHaveChildren())
 return std::nullopt;
   /// As this operation can be potentially slow, we limit the total time spent
   /// fetching children to a few ms.
@@ -194,28 +194,18 @@ GetSyntheticSummaryForContainer(lldb::SBValue &v) {
   return summary;
 }
 
-/// Return whether we should dereference an SBValue in order to generate a more
-/// meaningful summary string.
-static bool ShouldBeDereferencedForSummary(lldb::SBValue &v) {
+/// Try to create a summary string for the given value that doesn't have a
+/// summary of its own.
+static std::optional TryCreateAutoSummary(lldb::SBValue value) {
   if (!g_vsc.enable_auto_variable_summaries)
-return false;
-
-  if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())
-return false;
-
-  // If we are referencing a pointer, we don't dereference to avoid confusing
-  // the user with the addresses that could shown in the summary.
-  if (v.Dereference().GetType().IsPointerType())
-return false;
-
-  // If it's synthetic or a pointer to a basic type that provides a summary, we
-  // don't dereference.
-  if ((v.IsSynthetic() || v.GetType().GetPointeeType().GetBasicType() !=
-  lldb::eBasicTypeInvalid) &&
-  !llvm::StringRef(v.GetSummary()).empty()) {
-return false;
-  }
-  return true;
+return std::nullopt;
+
+  // We use the dereferenced value for generating the summary.
+  if (value.GetType().IsPointerType() || value.GetType().IsReferenceType())
+value = value.Dereference();
+
+  // We only support auto summaries for containers.
+  return TryCreateAutoSummaryForContainer(value);
 }
 
 void SetValueForKey(lldb::SBValue &v, llvm::jso

[Lldb-commits] [lldb] [lldb-vscode] Use auto summaries whenever variables don't have a summary (PR #66551)

2023-09-19 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Use auto summaries whenever variables don't have a summary (PR #66551)

2023-09-19 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Use auto summaries whenever variables don't have a summary (PR #66551)

2023-09-19 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Use auto summaries whenever variables don't have a summary (PR #66551)

2023-09-20 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix stdcpp type summary mistakenly marked as regex (NFC) (PR #66949)

2023-09-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Good catch! I think I have suffered because of this at some point.

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


[Lldb-commits] [lldb] Lazy deference underlying object for shared/weak/unique_ptr synthetic… (PR #67069)

2023-09-21 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@jimingham , IIRC from old experiments regarding the synthetic formatter code, 
`true` is returned when you want to avoid caching the results of the `Update`, 
which means that if you want to persist the success or the failure, you just 
return `false`. I might be wrong but that's the behavior I recall I observed a 
while ago.

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


[Lldb-commits] [lldb] [lldb] Require paused process and frame for "register info" command (PR #67124)

2023-09-22 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Require paused process and frame for "register info" command (PR #67124)

2023-09-22 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Require paused process and frame for "register info" command (PR #67124)

2023-09-22 Thread Walter Erquinigo via lldb-commits


@@ -659,3 +659,16 @@ def test_fs_gs_base(self):
 pthread_self_val.GetValueAsUnsigned(0),
 "fs_base does not equal to pthread_self() value.",
 )
+
+def test_process_must_be_stopped(self):
+"""Check that all register commands error when the process is not 
stopped."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+pid = self.spawnSubprocess(exe, ["wait_for_attach"]).pid
+self.setAsync(True)
+self.runCmd("process attach --continue -p %d" % pid)

walter-erquinigo wrote:

shouldn't these lines be swapped? Other than that, this LGTM

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


[Lldb-commits] [lldb] Lazy deference underlying object for shared/weak/unique_ptr synthetic… (PR #67069)

2023-09-22 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

Do you think it would be a good idea to provide aliases for the return values 
of the Update method with better names that match the behavior you just 
discovered? I'm not a fan of true/false in this case, because it confuses 
synthetic type developers, but I'm just trying to think of ways to improve this 
without breaking any existing code.

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


[Lldb-commits] [lldb] [lldb] Require paused process and frame for "register info" command (PR #67124)

2023-09-22 Thread Walter Erquinigo via lldb-commits


@@ -659,3 +659,16 @@ def test_fs_gs_base(self):
 pthread_self_val.GetValueAsUnsigned(0),
 "fs_base does not equal to pthread_self() value.",
 )
+
+def test_process_must_be_stopped(self):
+"""Check that all register commands error when the process is not 
stopped."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+pid = self.spawnSubprocess(exe, ["wait_for_attach"]).pid
+self.setAsync(True)
+self.runCmd("process attach --continue -p %d" % pid)

walter-erquinigo wrote:

All good then!

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-22 Thread Walter Erquinigo via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


walter-erquinigo wrote:

Btw, I'm building support for the mojo language, and very likely the `main` 
method will not have the symbol `main`, so building an abstraction around this, 
for every language, would be very convenient.

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


[Lldb-commits] [lldb] [lldb][NFC] Move some ctors and tors to cpp files (PR #67165)

2023-09-22 Thread Walter Erquinigo via lldb-commits

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

This prevents undefined vtable errors when linking these libraries from 
out-of-tree. I'm facing this issue as I work on my new language plugin.


>From 68818ce0376ba717157edaffd5ae2101cf26d4e2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 22 Sep 2023 12:29:46 -0400
Subject: [PATCH] [lldb][NFC] Move some ctors and tors to cpp files

This prevents undefined vtable errors when linking these libraries from 
out-of-tree. I'm facing this issue as I work on my new language plugin.
---
 .../lldb/Core/UserSettingsController.h|  7 +++---
 lldb/include/lldb/Symbol/Function.h   | 22 +---
 lldb/source/Core/UserSettingsController.cpp   |  7 ++
 lldb/source/Symbol/Function.cpp   | 25 +++
 4 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/lldb/include/lldb/Core/UserSettingsController.h 
b/lldb/include/lldb/Core/UserSettingsController.h
index ea60467c9afe5c0..32da7e05f7040f7 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -32,12 +32,11 @@ namespace lldb_private {
 
 class Properties {
 public:
-  Properties() = default;
+  Properties();
 
-  Properties(const lldb::OptionValuePropertiesSP &collection_sp)
-  : m_collection_sp(collection_sp) {}
+  Properties(const lldb::OptionValuePropertiesSP &collection_sp);
 
-  virtual ~Properties() = default;
+  virtual ~Properties();
 
   virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
 // This function is virtual in case subclasses want to lazily implement
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 2da13f878a7992c..0c1afd0ceb6f1f5 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -267,7 +267,7 @@ using CallSiteParameterArray = 
llvm::SmallVector;
 class CallEdge {
 public:
   enum class AddrType : uint8_t { Call, AfterCall };
-  virtual ~CallEdge() = default;
+  ~CallEdge();
 
   /// Get the callee's definition.
   ///
@@ -305,10 +305,7 @@ class CallEdge {
 
 protected:
   CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
-   bool is_tail_call, CallSiteParameterArray &¶meters)
-  : caller_address(caller_address),
-caller_address_type(caller_address_type), is_tail_call(is_tail_call),
-parameters(std::move(parameters)) {}
+   bool is_tail_call, CallSiteParameterArray &¶meters);
 
   /// Helper that finds the load address of \p unresolved_pc, a file address
   /// which refers to an instruction within \p caller.
@@ -339,11 +336,7 @@ class DirectCallEdge : public CallEdge {
   /// return PC within the calling function to identify a specific call site.
   DirectCallEdge(const char *symbol_name, AddrType caller_address_type,
  lldb::addr_t caller_address, bool is_tail_call,
- CallSiteParameterArray &¶meters)
-  : CallEdge(caller_address_type, caller_address, is_tail_call,
- std::move(parameters)) {
-lazy_callee.symbol_name = symbol_name;
-  }
+ CallSiteParameterArray &¶meters);
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
 
@@ -370,12 +363,9 @@ class IndirectCallEdge : public CallEdge {
 public:
   /// Construct a call edge using a DWARFExpression to identify the callee, and
   /// a return PC within the calling function to identify a specific call site.
-  IndirectCallEdge(DWARFExpressionList call_target, AddrType 
caller_address_type,
-   lldb::addr_t caller_address, bool is_tail_call,
-   CallSiteParameterArray &¶meters)
-  : CallEdge(caller_address_type, caller_address, is_tail_call,
- std::move(parameters)),
-call_target(std::move(call_target)) {}
+  IndirectCallEdge(DWARFExpressionList call_target,
+   AddrType caller_address_type, lldb::addr_t caller_address,
+   bool is_tail_call, CallSiteParameterArray &¶meters);
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
 
diff --git a/lldb/source/Core/UserSettingsController.cpp 
b/lldb/source/Core/UserSettingsController.cpp
index f5dd926cf0500b9..72217117557ffdc 100644
--- a/lldb/source/Core/UserSettingsController.cpp
+++ b/lldb/source/Core/UserSettingsController.cpp
@@ -30,6 +30,13 @@ class Property;
 using namespace lldb;
 using namespace lldb_private;
 
+Properties::Properties() = default;
+
+Properties::Properties(const lldb::OptionValuePropertiesSP &collection_sp)
+: m_collection_sp(collection_sp) {}
+
+Properties::~Properties() = default;
+
 lldb::OptionValueSP
 Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
  llvm::StringRef path, Status &error) const {
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index

[Lldb-commits] [lldb] [lldb][NFC] Move some ctors and tors to cpp files (PR #67165)

2023-09-22 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFC] Move some ctors and tors to cpp files (PR #67165)

2023-09-22 Thread Walter Erquinigo via lldb-commits

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

>From 0f7b275c5fa608dce8b345c81794514abda017f3 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 22 Sep 2023 12:29:46 -0400
Subject: [PATCH] [lldb][NFC] Move some ctors and tors to cpp files

This prevents undefined vtable errors when linking these libraries from 
out-of-tree. I'm facing this issue as I work on my new language plugin.
---
 .../lldb/Core/UserSettingsController.h|  7 +++---
 lldb/include/lldb/Symbol/Function.h   | 22 +---
 lldb/source/Core/UserSettingsController.cpp   |  7 ++
 lldb/source/Symbol/Function.cpp   | 25 +++
 4 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/lldb/include/lldb/Core/UserSettingsController.h 
b/lldb/include/lldb/Core/UserSettingsController.h
index ea60467c9afe5c0..32da7e05f7040f7 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -32,12 +32,11 @@ namespace lldb_private {
 
 class Properties {
 public:
-  Properties() = default;
+  Properties();
 
-  Properties(const lldb::OptionValuePropertiesSP &collection_sp)
-  : m_collection_sp(collection_sp) {}
+  Properties(const lldb::OptionValuePropertiesSP &collection_sp);
 
-  virtual ~Properties() = default;
+  virtual ~Properties();
 
   virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
 // This function is virtual in case subclasses want to lazily implement
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 2da13f878a7992c..0c1afd0ceb6f1f5 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -267,7 +267,7 @@ using CallSiteParameterArray = 
llvm::SmallVector;
 class CallEdge {
 public:
   enum class AddrType : uint8_t { Call, AfterCall };
-  virtual ~CallEdge() = default;
+  ~CallEdge();
 
   /// Get the callee's definition.
   ///
@@ -305,10 +305,7 @@ class CallEdge {
 
 protected:
   CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
-   bool is_tail_call, CallSiteParameterArray &¶meters)
-  : caller_address(caller_address),
-caller_address_type(caller_address_type), is_tail_call(is_tail_call),
-parameters(std::move(parameters)) {}
+   bool is_tail_call, CallSiteParameterArray &¶meters);
 
   /// Helper that finds the load address of \p unresolved_pc, a file address
   /// which refers to an instruction within \p caller.
@@ -339,11 +336,7 @@ class DirectCallEdge : public CallEdge {
   /// return PC within the calling function to identify a specific call site.
   DirectCallEdge(const char *symbol_name, AddrType caller_address_type,
  lldb::addr_t caller_address, bool is_tail_call,
- CallSiteParameterArray &¶meters)
-  : CallEdge(caller_address_type, caller_address, is_tail_call,
- std::move(parameters)) {
-lazy_callee.symbol_name = symbol_name;
-  }
+ CallSiteParameterArray &¶meters);
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
 
@@ -370,12 +363,9 @@ class IndirectCallEdge : public CallEdge {
 public:
   /// Construct a call edge using a DWARFExpression to identify the callee, and
   /// a return PC within the calling function to identify a specific call site.
-  IndirectCallEdge(DWARFExpressionList call_target, AddrType 
caller_address_type,
-   lldb::addr_t caller_address, bool is_tail_call,
-   CallSiteParameterArray &¶meters)
-  : CallEdge(caller_address_type, caller_address, is_tail_call,
- std::move(parameters)),
-call_target(std::move(call_target)) {}
+  IndirectCallEdge(DWARFExpressionList call_target,
+   AddrType caller_address_type, lldb::addr_t caller_address,
+   bool is_tail_call, CallSiteParameterArray &¶meters);
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
 
diff --git a/lldb/source/Core/UserSettingsController.cpp 
b/lldb/source/Core/UserSettingsController.cpp
index f5dd926cf0500b9..72217117557ffdc 100644
--- a/lldb/source/Core/UserSettingsController.cpp
+++ b/lldb/source/Core/UserSettingsController.cpp
@@ -30,6 +30,13 @@ class Property;
 using namespace lldb;
 using namespace lldb_private;
 
+Properties::Properties() = default;
+
+Properties::Properties(const lldb::OptionValuePropertiesSP &collection_sp)
+: m_collection_sp(collection_sp) {}
+
+Properties::~Properties() = default;
+
 lldb::OptionValueSP
 Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
  llvm::StringRef path, Status &error) const {
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 5ed0e66bdacbd57..c651e4573854108 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -122,6 +122,13 @@ size_t In

[Lldb-commits] [lldb] [lldb][NFC] Move some ctors and tors to cpp files (PR #67165)

2023-09-22 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add command start (PR #67019)

2023-09-22 Thread Walter Erquinigo via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


walter-erquinigo wrote:

That's file. You can have multiple commits in the same PR, because when it gets 
approved and merged, github will squash all your commits into a single one.

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


[Lldb-commits] [lldb] [lldb] Add windows support for LLDB_EXPORT_ALL_SYMBOLS (PR #67628)

2023-09-27 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Other than a few nits, this is awesome!

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


[Lldb-commits] [lldb] [lldb] Add windows support for LLDB_EXPORT_ALL_SYMBOLS (PR #67628)

2023-09-27 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add windows support for LLDB_EXPORT_ALL_SYMBOLS (PR #67628)

2023-09-27 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,100 @@
+"""A tool for extracting a list of private lldb symbols to export for MSVC.
+
+When exporting symbols from a dll or exe we either need to mark the symbols in
+the source code as __declspec(dllexport) or supply a list of symbols to the
+linker. Private symbols in LLDB don't explicitly specific dllexport, so we
+automate that by examining the symbol table.
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def extract_symbols(nm_path: str, lib: str):
+"""Extract all of the private lldb symbols from the given path to llvm-nm 
and
+library to extract from."""
+
+# Matches mangled symbols containing 'lldb_private'.
+lldb_sym_re = r"0* [BT] (?P[?]+[^?].*lldb_private.*)"
+
+# '-g' means we only get global symbols.
+# '-p' do not waste time sorting the symbols.
+process = subprocess.Popen(
+[nm_path, "-g", "-p", lib],
+bufsize=1,
+stdout=subprocess.PIPE,
+stdin=subprocess.PIPE,
+universal_newlines=True,
+)
+process.stdin.close()
+
+lldb_symbols = set()
+for line in process.stdout:
+match = re.match(lldb_sym_re, line)
+if match:
+symbol = match.group("symbol")
+assert symbol.count(" ") == 0, (
+"Regex matched too much, probably got undecorated name as well"
+)
+# Deleting destructors start with ?_G or ?_E and can be discarded
+# because link.exe gives you a warning telling you they can't be
+# exported if you don't.
+if symbol.startswith("??_G") or symbol.startswith("??_E"):
+continue
+lldb_symbols.add(symbol)
+
+return lldb_symbols
+
+
+def main():
+parser = argparse.ArgumentParser(description="Generate LLDB dll exports")
+parser.add_argument(
+"-o", metavar="file", type=str, help="The name of the resultant export 
file."
+)
+parser.add_argument("--nm", help="Path to the llvm-nm executable.")
+parser.add_argument(
+"libs",
+metavar="lib",
+type=str,
+nargs="+",
+help="The libraries to extract symbols from.",
+)
+args = parser.parse_args()
+
+# Get the list of libraries to extract symbols from
+libs = list()
+for lib in args.libs:
+# When invoked by cmake the arguments are the cmake target names of the
+# libraries, so we need to add .lib/.a to the end and maybe lib to the
+# start to get the filename. Also allow objects.
+suffixes = [".lib", ".a", ".obj", ".o"]
+if not any([lib.endswith(s) for s in suffixes]):
+for s in suffixes:
+if os.path.exists(lib + s):
+lib = lib + s
+break
+if os.path.exists("lib" + lib + s):
+lib = "lib" + lib + s
+break

walter-erquinigo wrote:

I'd rewrite this like 
```suggestion
for suffix in suffixes:
   for path in [lib + suffix, "lib" + lib + suffix]:
 if os.path.exists(path):
   lib = path
   break
```

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


[Lldb-commits] [lldb] [lldb] Add windows support for LLDB_EXPORT_ALL_SYMBOLS (PR #67628)

2023-09-27 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,100 @@
+"""A tool for extracting a list of private lldb symbols to export for MSVC.
+
+When exporting symbols from a dll or exe we either need to mark the symbols in
+the source code as __declspec(dllexport) or supply a list of symbols to the
+linker. Private symbols in LLDB don't explicitly specific dllexport, so we
+automate that by examining the symbol table.
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def extract_symbols(nm_path: str, lib: str):
+"""Extract all of the private lldb symbols from the given path to llvm-nm 
and
+library to extract from."""
+
+# Matches mangled symbols containing 'lldb_private'.
+lldb_sym_re = r"0* [BT] (?P[?]+[^?].*lldb_private.*)"
+
+# '-g' means we only get global symbols.
+# '-p' do not waste time sorting the symbols.
+process = subprocess.Popen(
+[nm_path, "-g", "-p", lib],
+bufsize=1,
+stdout=subprocess.PIPE,
+stdin=subprocess.PIPE,
+universal_newlines=True,
+)
+process.stdin.close()
+
+lldb_symbols = set()
+for line in process.stdout:
+match = re.match(lldb_sym_re, line)
+if match:
+symbol = match.group("symbol")
+assert symbol.count(" ") == 0, (
+"Regex matched too much, probably got undecorated name as well"
+)
+# Deleting destructors start with ?_G or ?_E and can be discarded
+# because link.exe gives you a warning telling you they can't be
+# exported if you don't.
+if symbol.startswith("??_G") or symbol.startswith("??_E"):
+continue
+lldb_symbols.add(symbol)
+
+return lldb_symbols
+
+
+def main():
+parser = argparse.ArgumentParser(description="Generate LLDB dll exports")
+parser.add_argument(
+"-o", metavar="file", type=str, help="The name of the resultant export 
file."
+)
+parser.add_argument("--nm", help="Path to the llvm-nm executable.")
+parser.add_argument(
+"libs",
+metavar="lib",
+type=str,
+nargs="+",
+help="The libraries to extract symbols from.",
+)
+args = parser.parse_args()
+
+# Get the list of libraries to extract symbols from
+libs = list()
+for lib in args.libs:
+# When invoked by cmake the arguments are the cmake target names of the
+# libraries, so we need to add .lib/.a to the end and maybe lib to the
+# start to get the filename. Also allow objects.
+suffixes = [".lib", ".a", ".obj", ".o"]
+if not any([lib.endswith(s) for s in suffixes]):
+for s in suffixes:
+if os.path.exists(lib + s):
+lib = lib + s
+break
+if os.path.exists("lib" + lib + s):
+lib = "lib" + lib + s
+break
+if not any([lib.endswith(s) for s in suffixes]):
+print("Don't know what to do with argument " + lib, 
file=sys.stderr)

walter-erquinigo wrote:

you could make this error more precise

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

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

None

>From 78edde6c7b6294c0e1a78b18cdf81d156c636a38 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 29 Sep 2023 15:44:05 -0400
Subject: [PATCH] [LLDB] Export DWARF Parser symbols for external language
 plugins

---
 .../include/lldb/Expression/DWARFExpression.h |   5 +-
 .../lldb/Expression/DWARFExpressionList.h |   3 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   7 +-
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   4 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 146 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugAbbrev.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   4 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   4 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  14 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |   2 +-
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  64 
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   2 +
 .../DWARF/SymbolFileDWARFDebugMap.h   |  16 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   9 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |   1 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |   5 +-
 33 files changed, 197 insertions(+), 135 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 380910ba0ea3d61..128c3637e9c24a3 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -18,9 +18,8 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
-class DWARFUnit;
-
 namespace lldb_private {
+class DWARFUnit;
 
 /// \class DWARFExpression DWARFExpression.h
 /// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
@@ -45,7 +44,7 @@ class DWARFExpression {
   DWARFExpression(const DataExtractor &data);
 
   /// Destructor
-  virtual ~DWARFExpression();
+  ~DWARFExpression();
 
   /// Return true if the location expression contains data
   bool IsValid() const;
diff --git a/lldb/include/lldb/Expression/DWARFExpressionList.h 
b/lldb/include/lldb/Expression/DWARFExpressionList.h
index c0939647056dcbf..63c772e51dfcba6 100644
--- a/lldb/include/lldb/Expression/DWARFExpressionList.h
+++ b/lldb/include/lldb/Expression/DWARFExpressionList.h
@@ -13,9 +13,8 @@
 #include "lldb/Utility/RangeMap.h"
 #include "lldb/lldb-private.h"
 
-class DWARFUnit;
-
 namespace lldb_private {
+class DWARFUnit;
 
 /// \class DWARFExpressionList DWARFExpressionList.h
 /// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..4cb12f8ca8632e1 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -28,11 +28,12 @@
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/lldb-private.h"
 
-class DWARFDIE;
-class DWARFASTParser;
 class PDBASTParser;
 
 namespace lldb_private {
+class DWARFDIE;
+class DWARFASTParser;
+
 namespace npdb {
   class PdbAstBuilder;
 } // namespace npdb
@@ -581,6 +582,6 @@ class TypeSystemMap {
   std::optional create_callback = std::nullopt);
   };
 
-} // namespace lldb_private
+  } // namespace lldb_private
 
 #endif // LLDB_SYMBOL_TYPESYSTEM_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index b5a5cfe263f7804..7864189503a9666 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+namespace lldb_private {
 /// Identifies a DWARF debug info entry within a given Module. It contains 
three
 /// "coordinates":
 /// - file_index: identifies the separate stand alone debug info file
@@ -131,10 +132,12 @@ class DIERef {
 static_assert(sizeof(DIERef) == 8);
 
 typedef std::vector DIEArray;
+} // namespace lldb_private
 
 namespace llvm {
-template<> struct format_provider {

[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

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

>From 616b08f7c9e30b501d5f0fe2ff8d6fbf3ecb9582 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 29 Sep 2023 15:44:05 -0400
Subject: [PATCH] [LLDB] Export DWARF Parser symbols for external language
 plugins

---
 .../include/lldb/Expression/DWARFExpression.h |   6 +-
 .../lldb/Expression/DWARFExpressionList.h |   4 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   8 +-
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   4 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 146 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugAbbrev.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   4 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   4 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  14 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |   2 +-
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   5 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   2 +
 .../DWARF/SymbolFileDWARFDebugMap.h   |  16 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   9 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |   1 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |   5 +-
 33 files changed, 171 insertions(+), 105 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 380910ba0ea3d61..c9d747c4a82ad88 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -18,10 +18,10 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
-class DWARFUnit;
-
 namespace lldb_private {
 
+class DWARFUnit;
+
 /// \class DWARFExpression DWARFExpression.h
 /// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
 /// expression and interprets it.
@@ -45,7 +45,7 @@ class DWARFExpression {
   DWARFExpression(const DataExtractor &data);
 
   /// Destructor
-  virtual ~DWARFExpression();
+  ~DWARFExpression();
 
   /// Return true if the location expression contains data
   bool IsValid() const;
diff --git a/lldb/include/lldb/Expression/DWARFExpressionList.h 
b/lldb/include/lldb/Expression/DWARFExpressionList.h
index c0939647056dcbf..2bb83e05c8f304e 100644
--- a/lldb/include/lldb/Expression/DWARFExpressionList.h
+++ b/lldb/include/lldb/Expression/DWARFExpressionList.h
@@ -13,10 +13,10 @@
 #include "lldb/Utility/RangeMap.h"
 #include "lldb/lldb-private.h"
 
-class DWARFUnit;
-
 namespace lldb_private {
 
+class DWARFUnit;
+
 /// \class DWARFExpressionList DWARFExpressionList.h
 /// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
 /// address range to a single DWARF location expression.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..377fc51000b89cd 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -28,11 +28,13 @@
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/lldb-private.h"
 
-class DWARFDIE;
-class DWARFASTParser;
 class PDBASTParser;
 
 namespace lldb_private {
+
+class DWARFDIE;
+class DWARFASTParser;
+
 namespace npdb {
   class PdbAstBuilder;
 } // namespace npdb
@@ -579,7 +581,7 @@ class TypeSystemMap {
   llvm::Expected GetTypeSystemForLanguage(
   lldb::LanguageType language,
   std::optional create_callback = std::nullopt);
-  };
+};
 
 } // namespace lldb_private
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index b5a5cfe263f7804..7864189503a9666 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+namespace lldb_private {
 /// Identifies a DWARF debug info entry within a given Module. It contains 
three
 /// "coordinates":
 /// - file_index: identifies the separate stand alone debug info file
@@ -131,10 +132,12 @@ class DIERef {
 static_assert(sizeof(DIERef) == 8);
 
 typedef

[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

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

>From b5cfeaad26ecd29f15aadaad408ff30899a8a16d Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 29 Sep 2023 15:44:05 -0400
Subject: [PATCH] [LLDB] Export DWARF Parser symbols for external language
 plugins

---
 .../include/lldb/Expression/DWARFExpression.h |   6 +-
 .../lldb/Expression/DWARFExpressionList.h |   4 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   8 +-
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   4 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 146 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugAbbrev.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   4 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   4 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  14 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |   2 +-
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   5 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   2 +
 .../DWARF/SymbolFileDWARFDebugMap.h   |  16 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   9 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |   1 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |   5 +-
 33 files changed, 171 insertions(+), 105 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 380910ba0ea3d61..c9d747c4a82ad88 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -18,10 +18,10 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
-class DWARFUnit;
-
 namespace lldb_private {
 
+class DWARFUnit;
+
 /// \class DWARFExpression DWARFExpression.h
 /// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
 /// expression and interprets it.
@@ -45,7 +45,7 @@ class DWARFExpression {
   DWARFExpression(const DataExtractor &data);
 
   /// Destructor
-  virtual ~DWARFExpression();
+  ~DWARFExpression();
 
   /// Return true if the location expression contains data
   bool IsValid() const;
diff --git a/lldb/include/lldb/Expression/DWARFExpressionList.h 
b/lldb/include/lldb/Expression/DWARFExpressionList.h
index c0939647056dcbf..2bb83e05c8f304e 100644
--- a/lldb/include/lldb/Expression/DWARFExpressionList.h
+++ b/lldb/include/lldb/Expression/DWARFExpressionList.h
@@ -13,10 +13,10 @@
 #include "lldb/Utility/RangeMap.h"
 #include "lldb/lldb-private.h"
 
-class DWARFUnit;
-
 namespace lldb_private {
 
+class DWARFUnit;
+
 /// \class DWARFExpressionList DWARFExpressionList.h
 /// "lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file
 /// address range to a single DWARF location expression.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index eb6e453e1aec0d0..377fc51000b89cd 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -28,11 +28,13 @@
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/lldb-private.h"
 
-class DWARFDIE;
-class DWARFASTParser;
 class PDBASTParser;
 
 namespace lldb_private {
+
+class DWARFDIE;
+class DWARFASTParser;
+
 namespace npdb {
   class PdbAstBuilder;
 } // namespace npdb
@@ -579,7 +581,7 @@ class TypeSystemMap {
   llvm::Expected GetTypeSystemForLanguage(
   lldb::LanguageType language,
   std::optional create_callback = std::nullopt);
-  };
+};
 
 } // namespace lldb_private
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index b5a5cfe263f7804..7864189503a9666 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+namespace lldb_private {
 /// Identifies a DWARF debug info entry within a given Module. It contains 
three
 /// "coordinates":
 /// - file_index: identifies the separate stand alone debug info file
@@ -131,10 +132,12 @@ class DIERef {
 static_assert(sizeof(DIERef) == 8);
 
 typedef

[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg , LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` (see 
https://github.com/llvm/llvm-project/blob/main/lldb/cmake/modules/AddLLDB.cmake#L177)
 that is used to export `lldb_private` as well as `lldb` symbols. This shows 
that there's been a precedent for this kind of features and it seems to be well 
maintained.

Besides that, I do like your idea of exporting specific namespaces for plugins, 
however for this specific case, I do think that lldb_private is the namespace 
to use. The main reason is that `lldb_private::TypeSystem` forces to implement 
`DWARFASTParser`, which is a base class with its implementation in the plugin 
folder. A cleaner API would have all of the necessary bits to implement the 
`DWARFASTParser` child in the lldb_private namespace outside of a plugin, 
because `lldb_private::TypeSystem` is already outside of any plugin folder, 
just like other DWARF-related classes like `DWARFExpression` are outside of 
plugin folders. I chatted with @bulbazord about moving some DWARF files from 
the symbol plugin to be at the same level as the type system, but that's 
particularly challenging because of heavy coupling between the DWARF parser 
code and clang/clang typesystem. So this patch at least puts some code in the 
correct namespace, so to speak.


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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

After chatting with @clayborg , I'm going to try a different approach:
- putting all of these dwarf-related files from the plugin in a 
`lldb_plugins::dwarf` namespace.
- adding a new cmake flag that operates along with `LLDB_EXPORT_ALL_SYMBOLS` to 
specify a custom exports file, which would default to 
`lldb/source/API/liblldb-private.exports`. That way external plugins would have 
the option to decide what gets exported and what not.

In the meantime, I'm open to more feedback

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-09-29 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> Perhaps instead of lldb_plugin we can name it something like 
> lldb_private::plugin instead? 

Well, that would definitely work for me, as these symbols would be 
automatically exported alongside all the other `lldb_private` symbols. What I'm 
not completely sure about is if we want to go that route for plugins because 
then all of their symbols would be exported with this flag. @clayborg what do 
you think?

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-10-02 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@jimingham , indeed, I don't want to have a plugin that could be loadable by 
any build of lldb. The Mojo SDK is distributing already its own build of 
vanilla lldb along with the mojo plugin that is loaded at runtime and that 
links correctly with that lldb.
I initially tried linking the .a files, but that lead to a not short list of 
dependencies that included clang and other libraries that I also needed to link 
against, which was not very clean and could lead to potential issues on 
windows, where the exports file has a limited size. In the end after all the 
discussion, I think that the cleanest solution that could benefit other plugin 
developers is to allow specifying a custom exports file that can be used 
instead of `third-party/llvm-project/lldb/source/API/liblldb-private.exports` 
offering more control on what to export.

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


[Lldb-commits] [lldb] [LLDB] Export DWARF Parser symbols for external language plugins (PR #67851)

2023-10-02 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-02 Thread Walter Erquinigo via lldb-commits

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

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851


>From 4abd9478422cdf471103ff01d7994d2e7ffc1500 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 13:56:00 -0400
Subject: [PATCH] [LLDB] Allow specifying a custom exports file

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851
---
 lldb/cmake/modules/LLDBConfig.cmake | 3 +++
 lldb/source/API/CMakeLists.txt  | 6 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..264eed1ad82012f 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -125,6 +125,9 @@ endif()
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
   "Causes lldb to export all symbols when building liblldb.")
 
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..45e3b7a91034006 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,15 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
 # from working on some systems but limits the liblldb size.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb 
namespace")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
 # Don't use an explicit export.  Instead, tell the linker to
 # export all symbols.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the 
exports "
+" file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-02 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 3674a06 - [NFC][LLDB] Remove an unnecessary virtual destructor

2023-10-03 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-10-03T15:43:22-04:00
New Revision: 3674a0610a71becc54eab715905c4017d65471c4

URL: 
https://github.com/llvm/llvm-project/commit/3674a0610a71becc54eab715905c4017d65471c4
DIFF: 
https://github.com/llvm/llvm-project/commit/3674a0610a71becc54eab715905c4017d65471c4.diff

LOG: [NFC][LLDB] Remove an unnecessary virtual destructor

DWARFExpression has a virtual destructor but no other virtual methods, so we 
can safely remove the virtual keyword.

Added: 


Modified: 
lldb/include/lldb/Expression/DWARFExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 380910ba0ea3d61..5e03f539a272cac 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -45,7 +45,7 @@ class DWARFExpression {
   DWARFExpression(const DataExtractor &data);
 
   /// Destructor
-  virtual ~DWARFExpression();
+  ~DWARFExpression();
 
   /// Return true if the location expression contains data
   bool IsValid() const;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-03 Thread Walter Erquinigo via lldb-commits

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

As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining 
a new namespace `lldb_plugin::dwarf` for the classes in this 
Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with 
exporting the necessary symbols for my out-of-tree language plugin. The only 
two classes that I didn't change are DWARFDataExtractor, because that's being 
explicitly exported as part of lldb_private in `lldb-forward.h` , and the 
ClangDWARFASTParser, because that shouldn't be in the same namespace as the 
generic language-agnostic dwarf parser, but I'm okay with changing that. In any 
case, even if I didn't need this for my work, adding this namespace could be 
considered a good practice.


>From c8886aa7bf978ef35a7bedd1dc34dda7d8f840b3 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 16:56:16 -0400
Subject: [PATCH] [LLDB][NFC] Create a namespace for the DWARF plugin

As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining 
a new namespace `lldb_plugin::dwarf` for the classes in this 
Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with 
exporting the necessary symbols for my out-of-tree language plugin. The only 
two classes that I didn't change are DWARFDataExtractor, because that's being 
explicitly exported as part of lldb_private in `lldb-forward.h` , and the 
ClangDWARFASTParser, because that shouldn't be in the same namespace as the 
generic language-agnostic dwarf parser, but I'm okay with changing that. In any 
case, even if I didn't need this for my work, adding this namespace could be 
considered a good practice.
---
 .../include/lldb/Expression/DWARFExpression.h |  24 ++-
 .../lldb/Expression/DWARFExpressionList.h |   9 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   8 +-
 lldb/source/Expression/DWARFExpression.cpp|   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.cpp  |   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.h|  35 ++--
 .../Plugins/SymbolFile/DWARF/DIERef.cpp   |   1 +
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../SymbolFile/DWARF/DWARFASTParser.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   5 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |   2 +
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 158 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp |   1 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFContext.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFContext.h   |  48 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDataExtractor.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugAbbrev.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDebugAbbrev.h   |   2 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.cpp|   1 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  12 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   6 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   6 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDefines.cpp |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDefines.h   |   4 +-
 .../SymbolFile/DWARF/DWARFFormValue.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  43 ++---
 .../SymbolFile/DWARF/DWARFTypeUnit.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  17 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp |   3 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  39 ++---
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |   1 +
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |  37 ++--
 .../Plugins/SymbolFile/DWARF/NameToDIE.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  10 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  12 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   3 +
 .../DWARF/SymbolF

[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-03 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-03 Thread Walter Erquinigo via lldb-commits

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

>From 98c009c5f33b81d579fd11d11a660026f33836ae Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 16:56:16 -0400
Subject: [PATCH] [LLDB][NFC] Create a namespace for the DWARF plugin

As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining 
a new namespace `lldb_plugin::dwarf` for the classes in this 
Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with 
exporting the necessary symbols for my out-of-tree language plugin. The only 
two classes that I didn't change are DWARFDataExtractor, because that's being 
explicitly exported as part of lldb_private in `lldb-forward.h` , and the 
ClangDWARFASTParser, because that shouldn't be in the same namespace as the 
generic language-agnostic dwarf parser, but I'm okay with changing that. In any 
case, even if I didn't need this for my work, adding this namespace could be 
considered a good practice.
---
 .../include/lldb/Expression/DWARFExpression.h |  24 ++-
 .../lldb/Expression/DWARFExpressionList.h |   9 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   8 +-
 lldb/source/Expression/DWARFExpression.cpp|   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.cpp  |   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.h|  35 ++--
 .../Plugins/SymbolFile/DWARF/DIERef.cpp   |   1 +
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../SymbolFile/DWARF/DWARFASTParser.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   5 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |   2 +
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 158 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp |   1 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFContext.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFContext.h   |  48 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDataExtractor.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugArangeSet.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.cpp|   1 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  12 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   6 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   6 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDefines.cpp |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDefines.h   |   4 +-
 .../SymbolFile/DWARF/DWARFFormValue.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  43 ++---
 .../SymbolFile/DWARF/DWARFTypeUnit.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  21 ++-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  17 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp |   3 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  39 ++---
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |   1 +
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |  37 ++--
 .../Plugins/SymbolFile/DWARF/NameToDIE.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  10 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  12 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   3 +
 .../DWARF/SymbolFileDWARFDebugMap.h   |  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   1 +
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   9 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |   1 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |   5 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   1 +
 .../TypeSystem/Clang/TypeSystemClang.h|   2 +-
 63 files changed, 364 insertions(+), 243 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 5e03f539a272cac..4ed3881eb513c99 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -18,7 +18,9 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
+namespace lldb_plugin::dwarf {
 class DWARFU

[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-03 Thread Walter Erquinigo via lldb-commits

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

>From 92dc652698d7de826e28ce1563fa804366bab5c0 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 16:56:16 -0400
Subject: [PATCH] [LLDB][NFC] Create a namespace for the DWARF plugin

As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining 
a new namespace `lldb_plugin::dwarf` for the classes in this 
Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with 
exporting the necessary symbols for my out-of-tree language plugin. The only 
two classes that I didn't change are DWARFDataExtractor, because that's being 
explicitly exported as part of lldb_private in `lldb-forward.h` , and the 
ClangDWARFASTParser, because that shouldn't be in the same namespace as the 
generic language-agnostic dwarf parser, but I'm okay with changing that. In any 
case, even if I didn't need this for my work, adding this namespace could be 
considered a good practice.
---
 .../include/lldb/Expression/DWARFExpression.h |  24 ++-
 .../lldb/Expression/DWARFExpressionList.h |   9 +-
 lldb/include/lldb/Symbol/TypeSystem.h |   8 +-
 lldb/source/Expression/DWARFExpression.cpp|   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.cpp  |   1 +
 .../SymbolFile/DWARF/AppleDWARFIndex.h|  35 ++--
 .../Plugins/SymbolFile/DWARF/DIERef.cpp   |   1 +
 lldb/source/Plugins/SymbolFile/DWARF/DIERef.h |   7 +-
 .../SymbolFile/DWARF/DWARFASTParser.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |   5 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |   2 +
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 158 ++
 .../SymbolFile/DWARF/DWARFAttribute.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFAttribute.h |   3 +
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp |   5 +-
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFCompileUnit.cpp |   1 +
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFContext.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFContext.h   |  48 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |   2 +
 .../SymbolFile/DWARF/DWARFDataExtractor.h |   2 +-
 .../SymbolFile/DWARF/DWARFDebugArangeSet.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugArangeSet.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugAranges.cpp|   1 +
 .../SymbolFile/DWARF/DWARFDebugAranges.h  |   2 +
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  12 +-
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.h|   2 +
 .../SymbolFile/DWARF/DWARFDebugMacro.cpp  |   1 +
 .../SymbolFile/DWARF/DWARFDebugMacro.h|   6 +-
 .../SymbolFile/DWARF/DWARFDebugRanges.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDebugRanges.h   |   6 +-
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   1 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   2 +
 .../Plugins/SymbolFile/DWARF/DWARFDefines.cpp |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFDefines.h   |   4 +-
 .../SymbolFile/DWARF/DWARFFormValue.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |   1 +
 .../Plugins/SymbolFile/DWARF/DWARFIndex.h |  43 ++---
 .../SymbolFile/DWARF/DWARFTypeUnit.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   4 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  28 ++--
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  17 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp |   3 +-
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.h   |  39 ++---
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp |   1 +
 .../SymbolFile/DWARF/ManualDWARFIndex.h   |  37 ++--
 .../Plugins/SymbolFile/DWARF/NameToDIE.cpp|   1 +
 .../Plugins/SymbolFile/DWARF/NameToDIE.h  |   5 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  10 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  20 ++-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   3 +
 .../DWARF/SymbolFileDWARFDebugMap.h   |  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   1 +
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   9 +-
 .../SymbolFile/DWARF/UniqueDWARFASTType.cpp   |   1 +
 .../SymbolFile/DWARF/UniqueDWARFASTType.h |   5 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   1 +
 .../TypeSystem/Clang/TypeSystemClang.h|   2 +-
 63 files changed, 372 insertions(+), 250 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 5e03f539a272cac..4ed3881eb513c99 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -18,7 +18,9 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
+namespace lldb_plugin::dwarf {
 class DWAR

[Lldb-commits] [lldb] [lldb-vscode] Update installation instructions (PR #68234)

2023-10-04 Thread Walter Erquinigo via lldb-commits

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

lldb-vscode had installation instructions based on creating a folder inside 
~/.vscode/extensions, which no longer works. A different installation mechanism 
is needed based on a VSCode command. More can be read in the contents of this 
patch.

Closes https://github.com/llvm/llvm-project/issues/63655


>From 8eafc95bc1a3804557adab55db997cb6ac3d37e5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 4 Oct 2023 12:55:16 -0400
Subject: [PATCH] [lldb-vscode] Update installation instructions

lldb-vscode had installation instructions based on creating a folder inside 
~/.vscode/extensions, which no longer works. A different installation mechanism 
is needed based on a VSCode command. More can be read in the contents of this 
patch.

Closes https://github.com/llvm/llvm-project/issues/63655
---
 lldb/tools/lldb-vscode/README.md | 115 ---
 1 file changed, 60 insertions(+), 55 deletions(-)

diff --git a/lldb/tools/lldb-vscode/README.md b/lldb/tools/lldb-vscode/README.md
index 154ccefc5f59798..6f930293126d53e 100644
--- a/lldb/tools/lldb-vscode/README.md
+++ b/lldb/tools/lldb-vscode/README.md
@@ -1,18 +1,20 @@
 
 # Table of Contents
 
-- [Introduction](#Introduction)
-- [Installation](#Installation-Visual-Studio-Code)
+- [Table of Contents](#table-of-contents)
+- [Introduction](#introduction)
+- [Installation for Visual Studio Code](#installation-for-visual-studio-code)
 - [Configurations](#configurations)
-   - [Launch Configuration Settings](#launch-configuration-settings)
-   - [Attach Configuration Settings](#attach-configuration-settings)
-   - [Example configurations](#example-configurations)
-   - [Launching](#launching)
-   - [Attach to process using process ID](#attach-using-pid)
-   - [Attach to process by name](#attach-by-name)
-   - [Loading a core file](#loading-a-core-file)
-- [Custom Debugger Commands](#custom-debugger-commands)
-  - [startDebugging](#startDebugging)
+  - [Launch Configuration Settings](#launch-configuration-settings)
+  - [Attaching Settings](#attaching-settings)
+  - [Example configurations](#example-configurations)
+- [Launching](#launching)
+- [Attach using PID](#attach-using-pid)
+- [Attach by Name](#attach-by-name)
+- [Loading a Core File](#loading-a-core-file)
+- [Custom debugger commands](#custom-debugger-commands)
+  - [startDebugging](#startdebugging)
+  - [repl-mode](#repl-mode)
 
 # Introduction
 
@@ -24,52 +26,57 @@ get a full featured debugger with a well defined protocol.
 
 # Installation for Visual Studio Code
 
-Installing the plug-in involves creating a directory in the 
`~/.vscode/extensions` folder and copying the package.json file that is in the 
same directory as this
-documentation into it, and copying to symlinking a lldb-vscode binary into
-the `bin` directory inside the plug-in directory.
-
-If you want to make a stand alone plug-in that you can send to others on unix 
systems:
-
-```
-$ mkdir -p ~/.vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
-$ cp package.json ~/.vscode/extensions/llvm-org.lldb-vscode-0.1.0
-$ cd ~/.vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
-$ cp /path/to/a/built/lldb-vscode .
-$ cp /path/to/a/built/liblldb.so .
+Installing the plug-in involves creating a directory in any location outside of
+`~/.vscode/extensions`. For example, `~/vscode-lldb` is a valid one. You'll 
also
+need a subfolder `bin`, e.g. `~/vscode-lldb/bin`. Then copy the `package.json`
+file that is in the same directory as this documentation into it, and symlink
+the `lldb-vscode` binary into the `bin` directory inside the plug-in directory.
+
+Finally, on VS Code, execute the command
+`Developer: Install Extension from Location` and pick the folder you just
+created, which would be `~/vscode-lldb` following the example above.
+
+If you want to make a stand alone plug-in that you can send to others on UNIX
+systems:
+
+```bash
+mkdir -p ~/llvm-org.lldb-vscode-0.1.0/bin
+cp package.json ~/llvm-org.lldb-vscode-0.1.0
+cd ~/llvm-org.lldb-vscode-0.1.0/bin
+cp /path/to/a/built/lldb-vscode .
+cp /path/to/a/built/liblldb.so .
 ```
 
-It is important to note that the directory `~/.vscode/extensions` works for 
users logged in locally to the machine. If you are remoting into the box using 
Visual Studio Code's Remote plugins (SSH, WSL, Docker) it will look for 
extensions on `~/.vscode-server/extensions` only and you will not see your just 
installed lldb-vscode plug-in. If you want this plugin to be visible to 
remoting users, you will need to either repeat the process above for the 
`~/.vscode-server` folder or create a symbolic link from it to 
`~/.vscode/extensions`:
+If you want to make a stand alone plug-in that you can send to others on macOS
+systems:
 
-```
-$ cd ~/.vscode-server/extensions
-$ ln -s ~/.vscode/extensions/llvm-org.lldb-vscode-0.1.0  
llvm-org.l

[Lldb-commits] [lldb] [lldb-vscode] Update installation instructions (PR #68234)

2023-10-04 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-04 Thread Walter Erquinigo via lldb-commits


@@ -18,7 +18,9 @@
 #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
 #include 
 
+namespace lldb_plugin::dwarf {

walter-erquinigo wrote:

This is possible after the switch to c++17, and that's probably why no one else 
is using it in LLDB. There's no explicit llvm coding convention for this. I'm 
fine with splitting it into two lines if you want.

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


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-04 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I'll add the warning as you guys mention. That'll set clear expectations on 
what users will be getting.

Besides that, @bulbazord , the current symbols getting exported by 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports` are not all 
the symbols, but just some. Some folks like me need access to symbols from 
specific plugins that don't use the lldb_private namespace, so being able to 
replace the list that the file mentioned above exports is fundamental.

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


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-04 Thread Walter Erquinigo via lldb-commits

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

>From d557ea59b9c24387244280566260c33ac6bb9367 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 13:56:00 -0400
Subject: [PATCH] [LLDB] Allow specifying a custom exports file

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851
---
 lldb/cmake/modules/LLDBConfig.cmake |  3 +++
 lldb/source/API/CMakeLists.txt  | 13 ++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..264eed1ad82012f 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -125,6 +125,9 @@ endif()
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
   "Causes lldb to export all symbols when building liblldb.")
 
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..a574a461d4920ae 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,18 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
 # from working on some systems but limits the liblldb size.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb 
namespace")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
-# Don't use an explicit export.  Instead, tell the linker to
-# export all symbols.
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
+# Don't use an explicit export. Instead, tell the linker to export all 
symbols.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
+MESSAGE(WARNING "Private LLDB symbols frequently change and no API 
stability is guaranteed. "
+"Only the SB API is guaranteed to be stable.")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the 
exports "
+" file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+MESSAGE(WARNING "Private LLDB symbols frequently change and no API 
stability is guaranteed. "
+"Only the SB API is guaranteed to be stable.")
+add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-04 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Allow specifying a custom exports file (PR #68013)

2023-10-04 Thread Walter Erquinigo via lldb-commits

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

>From a472a16e6032ce0cef0acae6957f690f7e6cc4a3 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 2 Oct 2023 13:56:00 -0400
Subject: [PATCH] [LLDB] Allow specifying a custom exports file

LLDB has the cmake flag `LLDB_EXPORT_ALL_SYMBOLS` that exports the lldb, 
lldb_private namespaces, as well as other symbols like python and lua (see 
`third-party/llvm-project/lldb/source/API/liblldb-private.exports`). However, 
not all symbols in lldb fall into these categories and in order to get access 
to some symbols that live in plugin folders (like dwarf parsing symbols), it's 
useful to be able to specify a custom exports file giving more control to the 
developer using lldb as a library.

This adds the new cmake flag `LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE` that is 
used when `LLDB_EXPORT_ALL_SYMBOLS` is enabled to specify that custom exports 
file.

This is a follow up of https://github.com/llvm/llvm-project/pull/67851
---
 lldb/cmake/modules/LLDBConfig.cmake |  5 -
 lldb/source/API/CMakeLists.txt  | 13 ++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 380016ce48015fa..ce5e666a6f5e1ac 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -123,7 +123,10 @@ if(APPLE AND CMAKE_GENERATOR STREQUAL Xcode)
 endif()
 
 set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
-  "Causes lldb to export all symbols when building liblldb.")
+  "Causes lldb to export some private symbols when building liblldb. See 
lldb/source/API/liblldb-private.exports for the full list of symbols that get 
exported.")
+
+set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
+  "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
 
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7cfa3aaafdae188..a574a461d4920ae 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -177,11 +177,18 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
 # from working on some systems but limits the liblldb size.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb 
namespace")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
-  else()
-# Don't use an explicit export.  Instead, tell the linker to
-# export all symbols.
+  elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
+# Don't use an explicit export. Instead, tell the linker to export all 
symbols.
 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
+MESSAGE(WARNING "Private LLDB symbols frequently change and no API 
stability is guaranteed. "
+"Only the SB API is guaranteed to be stable.")
 add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
+  else ()
+MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the 
exports "
+" file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
+MESSAGE(WARNING "Private LLDB symbols frequently change and no API 
stability is guaranteed. "
+"Only the SB API is guaranteed to be stable.")
+add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
   endif()
   set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
 elseif (LLDB_EXPORT_ALL_SYMBOLS)

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] Remove use of ConstString from FilterRule in StructuredDataDarwinLog (PR #68347)

2023-10-05 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


<    1   2   3   4   5   6   7   8   9   >