[Lldb-commits] [lldb] Debuginfod Testing & fixes: 3rd times the charm? (PR #87676)

2024-04-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

When I tried these on Arm, `.note.gnu.build-id` was not the issue, it was 
failures like those seen in the Fuschia logs.
`/bin/sh: 1: ifeq: not found` and `/bin/sh: 1: 
/b/s/w/ir/x/w/llvm_build/bin/dwp: not found` (plus some other tools).

Leave the tests disabled on Arm and I'll try them again once the current issues 
are resolved.

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-05 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

Why don't we just remove the enum from SBDebugger and use the one from Debugger 
instead, this will ensure the offsets are always the same. 

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


[Lldb-commits] [lldb] [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (PR #87657)

2024-04-05 Thread Michael Buch via lldb-commits


@@ -669,15 +670,8 @@ bool ClangUserExpression::Parse(DiagnosticManager 
&diagnostic_manager,
   // Parse the expression
   //
 
-  Process *process = exe_ctx.GetProcessPtr();
-  ExecutionContextScope *exe_scope = process;
-
-  if (!exe_scope)
-exe_scope = exe_ctx.GetTargetPtr();
-
-  bool parse_success = TryParse(diagnostic_manager, exe_scope, exe_ctx,
-execution_policy, keep_result_in_memory,
-generate_debug_info);
+  bool parse_success = TryParse(diagnostic_manager, exe_ctx, execution_policy,
+keep_result_in_memory, generate_debug_info);

Michael137 wrote:

Removing `exe_ctx` in favour of `exe_scope` is trickier because we store away 
the `exe_ctx` for use in `ClangExpressionDeclMap`. I'd prefer sticking with 
this approach unless people are strongly opposed to it

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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/87767

This patch attempts to decouple C++ expression evaluation from Objective-C 
support. We've previously enabled it by default (if a runtime existed), but 
that meant we're opting into extra work we only need to do for Objective-C, 
which complicates/slows down C++ expression evaluation. Of course there's a 
valid use-case for this, which is calling Objective-C APIs when stopped in C++ 
frames (which Objective-C++ developers might want to do). In those case we 
should really prompt the user to add the `expr --language objc++` flag. To 
accomodate a likely frequent use-case where a user breaks in a system C++ 
library (without debug-symbols) but their application is actually an 
Objective-C app, we allow Objective-C support in C++ expressions if the current 
frame doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and allows us to 
add more `LangOpts.ObjC` guards around the expression evaluator in the future 
(e.g., we could avoid looking into the Objective-C runtime during C++ 
expression evaluation, which we currently do unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657

>From f27a547ab85463f182ab63949bb6f11140a2f33f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 5 Apr 2024 11:51:47 +0100
Subject: [PATCH] [lldb][ClangExpressionParser] Don't by default enable
 Objecitve-C support when evaluating C++ expressions

This patch attempts to decouple C++ expression evaluation from
Objective-C support. We've previously enabled it by default
(if a runtime existed), but that meant we're opting into extra
work we only need to do for Objective-C, which complicates/slows down
C++ expression evaluation. Of course there's a valid use-case for this,
which is calling Objective-C APIs when stopped in C++ frames (which
Objective-C++ developers might want to do). In those case we should
really prompt the user to add the `expr --language objc++` flag.
To accomodate a likely frequent use-case where a user breaks in a system
C++ library (without debug-symbols) but their application is actually
an Objective-C app, we allow Objective-C support in C++ expressions
if the current frame doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and
allows us to add more `LangOpts.ObjC` guards around the expression
evaluator in the future (e.g., we could avoid looking into the
Objective-C runtime during C++ expression evaluation, which we
currently do unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657
---
 .../Clang/ClangExpressionParser.cpp |  5 -
 .../diagnostics/TestExprDiagnostics.py  |  2 +-
 .../expression/options/TestExprOptions.py   |  1 -
 .../objc-builtin-types/TestObjCBuiltinTypes.py  |  2 +-
 .../Makefile|  4 
 .../TestObjCFromCppFramesWithoutDebugInfo.py| 17 +
 .../main.cpp|  1 +
 7 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 822d286cd6c3c4..f48bdc730d9160 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser(
 [[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_03:
 lang_opts.CPlusPlus = true;
-if (process_sp)
+if (process_sp
+// We're stopped in a frame without debug-info. The user probably
+// intends to make global queries (which should include Objective-C).
+&& !(frame_sp && frame_sp->HasDebugInformation()))
   lang_opts.ObjC =
   process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
 break;
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index d64e9897a844f1..ddc1c3598480cf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self):
 
 # Import foundation so that the Obj-C module is loaded (which contains 
source locations
 # that can be used by LLDB).
-self.runCmd("expr @import Foundation")
+self.runCmd("expr --language objective-c++ -- @import Foundation")
 value

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This patch attempts to decouple C++ expression evaluation from Objective-C 
support. We've previously enabled it by default (if a runtime existed), but 
that meant we're opting into extra work we only need to do for Objective-C, 
which complicates/slows down C++ expression evaluation. Of course there's a 
valid use-case for this, which is calling Objective-C APIs when stopped in C++ 
frames (which Objective-C++ developers might want to do). In those case we 
should really prompt the user to add the `expr --language objc++` flag. To 
accomodate a likely frequent use-case where a user breaks in a system C++ 
library (without debug-symbols) but their application is actually an 
Objective-C app, we allow Objective-C support in C++ expressions if the current 
frame doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and allows us to 
add more `LangOpts.ObjC` guards around the expression evaluator in the future 
(e.g., we could avoid looking into the Objective-C runtime during C++ 
expression evaluation, which we currently do unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657

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


7 Files Affected:

- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+4-1) 
- (modified) 
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py (+1-1) 
- (modified) lldb/test/API/commands/expression/options/TestExprOptions.py (-1) 
- (modified) 
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+1-1) 
- (added) 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile (+4) 
- (added) 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 (+17) 
- (added) 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp (+1) 


``diff
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 822d286cd6c3c4..f48bdc730d9160 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser(
 [[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_03:
 lang_opts.CPlusPlus = true;
-if (process_sp)
+if (process_sp
+// We're stopped in a frame without debug-info. The user probably
+// intends to make global queries (which should include Objective-C).
+&& !(frame_sp && frame_sp->HasDebugInformation()))
   lang_opts.ObjC =
   process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
 break;
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index d64e9897a844f1..ddc1c3598480cf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self):
 
 # Import foundation so that the Obj-C module is loaded (which contains 
source locations
 # that can be used by LLDB).
-self.runCmd("expr @import Foundation")
+self.runCmd("expr --language objective-c++ -- @import Foundation")
 value = frame.EvaluateExpression("NSLog(1);")
 self.assertFalse(value.GetError().Success())
 # LLDB should print the source line that defines NSLog. To not rely on 
any
diff --git a/lldb/test/API/commands/expression/options/TestExprOptions.py 
b/lldb/test/API/commands/expression/options/TestExprOptions.py
index 6652c71083a958..01899f3b97cf44 100644
--- a/lldb/test/API/commands/expression/options/TestExprOptions.py
+++ b/lldb/test/API/commands/expression/options/TestExprOptions.py
@@ -59,7 +59,6 @@ def test_expr_options(self):
 self.assertTrue(val.IsValid())
 self.assertFalse(val.GetError().Success())
 
-@skipIfDarwin
 def test_expr_options_lang(self):
 """These expression language options should work as expected."""
 self.build()
diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..280994fbde71ab 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -53,5 +53,5 @@ def test_with_python_api(self):
 )
 self.expect(
 "expr --language C++ -- id my_id = 0; my_id",
-patterns=["\(id\) \$.* = nullptr"],
+error=True
 )
diff --git 
a/lldb/test/API/lang/objcxx/objc-

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
a1f4ac7704255627ac33ad67a22be5ac030f6179...f27a547ab85463f182ab63949bb6f11140a2f33f
 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
lldb/test/API/commands/expression/options/TestExprOptions.py 
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
``





View the diff from darker here.


``diff
--- lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py  2024-04-05 
10:58:48.00 +
+++ lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py  2024-04-05 
11:02:23.523228 +
@@ -49,9 +49,6 @@
 
 self.expect(
 "expr --language Objective-C++ -- id my_id = 0; my_id",
 patterns=["\(id\) \$.* = nil"],
 )
-self.expect(
-"expr --language C++ -- id my_id = 0; my_id",
-error=True
-)
+self.expect("expr --language C++ -- id my_id = 0; my_id", error=True)
--- 
lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 2024-04-05 10:58:48.00 +
+++ 
lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 2024-04-05 11:02:23.536024 +
@@ -6,10 +6,11 @@
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+
 class TestObjCFromCppFramesWithoutDebugInfo(TestBase):
 def test(self):
 self.build()
 (_, process, _, _) = lldbutil.run_to_name_breakpoint(self, "main")
 

``




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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/87767

>From f27a547ab85463f182ab63949bb6f11140a2f33f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 5 Apr 2024 11:51:47 +0100
Subject: [PATCH 1/2] [lldb][ClangExpressionParser] Don't by default enable
 Objecitve-C support when evaluating C++ expressions

This patch attempts to decouple C++ expression evaluation from
Objective-C support. We've previously enabled it by default
(if a runtime existed), but that meant we're opting into extra
work we only need to do for Objective-C, which complicates/slows down
C++ expression evaluation. Of course there's a valid use-case for this,
which is calling Objective-C APIs when stopped in C++ frames (which
Objective-C++ developers might want to do). In those case we should
really prompt the user to add the `expr --language objc++` flag.
To accomodate a likely frequent use-case where a user breaks in a system
C++ library (without debug-symbols) but their application is actually
an Objective-C app, we allow Objective-C support in C++ expressions
if the current frame doesn't have debug-info.

This fixes https://github.com/llvm/llvm-project/issues/75443 and
allows us to add more `LangOpts.ObjC` guards around the expression
evaluator in the future (e.g., we could avoid looking into the
Objective-C runtime during C++ expression evaluation, which we
currently do unconditionally).

Depends on https://github.com/llvm/llvm-project/pull/87657
---
 .../Clang/ClangExpressionParser.cpp |  5 -
 .../diagnostics/TestExprDiagnostics.py  |  2 +-
 .../expression/options/TestExprOptions.py   |  1 -
 .../objc-builtin-types/TestObjCBuiltinTypes.py  |  2 +-
 .../Makefile|  4 
 .../TestObjCFromCppFramesWithoutDebugInfo.py| 17 +
 .../main.cpp|  1 +
 7 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
 create mode 100644 
lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 822d286cd6c3c4..f48bdc730d9160 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser(
 [[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_03:
 lang_opts.CPlusPlus = true;
-if (process_sp)
+if (process_sp
+// We're stopped in a frame without debug-info. The user probably
+// intends to make global queries (which should include Objective-C).
+&& !(frame_sp && frame_sp->HasDebugInformation()))
   lang_opts.ObjC =
   process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
 break;
diff --git 
a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py 
b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index d64e9897a844f1..ddc1c3598480cf 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self):
 
 # Import foundation so that the Obj-C module is loaded (which contains 
source locations
 # that can be used by LLDB).
-self.runCmd("expr @import Foundation")
+self.runCmd("expr --language objective-c++ -- @import Foundation")
 value = frame.EvaluateExpression("NSLog(1);")
 self.assertFalse(value.GetError().Success())
 # LLDB should print the source line that defines NSLog. To not rely on 
any
diff --git a/lldb/test/API/commands/expression/options/TestExprOptions.py 
b/lldb/test/API/commands/expression/options/TestExprOptions.py
index 6652c71083a958..01899f3b97cf44 100644
--- a/lldb/test/API/commands/expression/options/TestExprOptions.py
+++ b/lldb/test/API/commands/expression/options/TestExprOptions.py
@@ -59,7 +59,6 @@ def test_expr_options(self):
 self.assertTrue(val.IsValid())
 self.assertFalse(val.GetError().Success())
 
-@skipIfDarwin
 def test_expr_options_lang(self):
 """These expression language options should work as expected."""
 self.build()
diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..280994fbde71ab 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -53

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (PR #87657)

2024-04-05 Thread via lldb-commits


@@ -669,15 +670,8 @@ bool ClangUserExpression::Parse(DiagnosticManager 
&diagnostic_manager,
   // Parse the expression
   //
 
-  Process *process = exe_ctx.GetProcessPtr();
-  ExecutionContextScope *exe_scope = process;
-
-  if (!exe_scope)
-exe_scope = exe_ctx.GetTargetPtr();
-
-  bool parse_success = TryParse(diagnostic_manager, exe_scope, exe_ctx,
-execution_policy, keep_result_in_memory,
-generate_debug_info);
+  bool parse_success = TryParse(diagnostic_manager, exe_ctx, execution_policy,
+keep_result_in_memory, generate_debug_info);

jimingham wrote:

At some point we should go through and rationalize the use of ExecutionContext 
vrs. ExecutionContextScope, but this patch doesn't seem the place to do that.  
Instead, going with whatever is locally most convenient seems the right choice 
here.

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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions (PR #87767)

2024-04-05 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

LGTM.  This is a reasonable strategy to limit opting in to all the ObjC runtime 
work, and should be understandable by users.

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


[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)

2024-04-05 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere requested changes to this pull request.


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


[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)

2024-04-05 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -25,19 +25,25 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
 }
 
 void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) {
-  std::lock_guard guard(m_map_mutex);
-  m_map[name] = entry;
+  {
+std::lock_guard guard(m_map_mutex);
+m_map[name] = entry;
+  }
+  // The lock is now released for the eventual call to Changed.

JDevlieghere wrote:

This comment explains _what_ you're doing, which the code already tells me, but 
not _why_.

I'd expect something like this, although it doesn't need to be quite so verbose:

```
// Release the mutex to avoid a potential deadlock between 
TypeCategoryMap::m_map_mutex and FormatManager::m_language_categories_mutex 
which can be acquired in reverse order when calling FormatManager::Changed.
``` 

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:

Thanks for the detailed suggestions! Makes sense!

For ObjC, just to clarify, the intention of hiding the filters was NOT because 
the debugger didn't support it - the intention was to avoid 
clustering/confusing users - that is, if they're not debugging ObjC, there's no 
reason to show the objc filters. (And we infer this by checking if they're 
debugging on a mac - it's theoretically possible they're cross debugging objc 
from a non-mac but in practice I don't think it's likely )
Does this seem reasonable?

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

jimingham wrote:

The ObjC Language runtime is able to detect whether ObjC is loaded into the 
program.  It runs that detector on each library load, so it keeps an accurate 
notion of this.  Ditto for the swift language runtime.  It would be better to 
consult that than guess based on platform.  There may not currently be a way to 
ask that from the SB API's but we can certainly make one...

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


[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)

2024-04-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/87807

Depends on https://github.com/llvm/llvm-project/pull/87767

>From a0dfe20ca4d6c544d00ca4b3791fc3dff70b465e Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 5 Apr 2024 12:10:09 +0100
Subject: [PATCH] [lldb][test] Add tests for evaluating local variables whose
 name clashes with Objective-C types

Depends on https://github.com/llvm/llvm-project/pull/87767
---
 .../objc-builtin-types/TestObjCBuiltinTypes.py  | 13 +
 .../API/lang/objcxx/objc-builtin-types/main.cpp |  8 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..2aa4784cd764e2 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -13,6 +13,7 @@ def setUp(self):
 # Find the line numbers to break inside main().
 self.main_source = "main.cpp"
 self.break_line = line_number(self.main_source, "// Set breakpoint 
here.")
+self.bar_break_line = line_number(self.main_source, "return id + 
Class")
 
 @add_test_categories(["pyapi"])
 def test_with_python_api(self):
@@ -26,6 +27,11 @@ def test_with_python_api(self):
 bpt = target.BreakpointCreateByLocation(self.main_source, 
self.break_line)
 self.assertTrue(bpt, VALID_BREAKPOINT)
 
+bar_bpt = target.BreakpointCreateByLocation(
+self.main_source, self.bar_break_line
+)
+self.assertTrue(bar_bpt, VALID_BREAKPOINT)
+
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 
@@ -55,3 +61,10 @@ def test_with_python_api(self):
 "expr --language C++ -- id my_id = 0; my_id",
 patterns=["\(id\) \$.* = nullptr"],
 )
+
+lldbutil.continue_to_breakpoint(process, bar_bpt)
+
+self.expect_expr("id", result_value="12", result_type="int")
+self.expect_expr("Class", result_value="15", result_type="int")
+self.expect("expr --language Objective-C++ -- id", error=True)
+self.expect("expr --language Objective-C++ -- Class", error=True)
diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp 
b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
@@ -2,8 +2,14 @@ namespace ns {
   typedef int id;
 };
 
+int bar() {
+  int id = 12;
+  int Class = 15;
+  return id + Class;
+}
+
 int main()
 {
   ns::id foo = 0;
-  return foo; // Set breakpoint here.
+  return foo + bar(); // Set breakpoint here.
 }

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


[Lldb-commits] [lldb] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (PR #87807)

2024-04-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

Depends on https://github.com/llvm/llvm-project/pull/87767

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


2 Files Affected:

- (modified) 
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+13) 
- (modified) lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp (+7-1) 


``diff
diff --git 
a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py 
b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 1eb7205f1bb465..2aa4784cd764e2 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -13,6 +13,7 @@ def setUp(self):
 # Find the line numbers to break inside main().
 self.main_source = "main.cpp"
 self.break_line = line_number(self.main_source, "// Set breakpoint 
here.")
+self.bar_break_line = line_number(self.main_source, "return id + 
Class")
 
 @add_test_categories(["pyapi"])
 def test_with_python_api(self):
@@ -26,6 +27,11 @@ def test_with_python_api(self):
 bpt = target.BreakpointCreateByLocation(self.main_source, 
self.break_line)
 self.assertTrue(bpt, VALID_BREAKPOINT)
 
+bar_bpt = target.BreakpointCreateByLocation(
+self.main_source, self.bar_break_line
+)
+self.assertTrue(bar_bpt, VALID_BREAKPOINT)
+
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 
@@ -55,3 +61,10 @@ def test_with_python_api(self):
 "expr --language C++ -- id my_id = 0; my_id",
 patterns=["\(id\) \$.* = nullptr"],
 )
+
+lldbutil.continue_to_breakpoint(process, bar_bpt)
+
+self.expect_expr("id", result_value="12", result_type="int")
+self.expect_expr("Class", result_value="15", result_type="int")
+self.expect("expr --language Objective-C++ -- id", error=True)
+self.expect("expr --language Objective-C++ -- Class", error=True)
diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp 
b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp
@@ -2,8 +2,14 @@ namespace ns {
   typedef int id;
 };
 
+int bar() {
+  int id = 12;
+  int Class = 15;
+  return id + Class;
+}
+
 int main()
 {
   ns::id foo = 0;
-  return foo; // Set breakpoint here.
+  return foo + bar(); // Set breakpoint here.
 }

``




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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

danliew-apple wrote:

I'm fine with that. You could also do 
`LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES` which is ever so slightly shorter 
🤷‍♂️

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

delcypher wrote:

> "tools" has a pretty specific meaning for LLVM so I think that will actually 
> cause more confusion (i.e. I would expect that option to apply to 
> llvm-dwarfdump, but not to clang). I'm personally fine with the current 
> concise name.

I'm not exactly sure what that "specific meaning" is but I'm happy to go with 
something else. I think using the name "EXECUTABLE" as @cyndyishida is 
suggesting is consistent with the option being used in `add_llvm_executable()`.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

delcypher wrote:

@JDevlieghere 
> "tools" has a pretty specific meaning for LLVM so I think that will actually 
> cause more confusion (i.e. I would expect that option to apply to 
> llvm-dwarfdump, but not to clang). I'm personally fine with the current 
> concise name.

I'm not exactly sure what that "specific meaning" is but I'm happy to go with 
something else. I think using the name "EXECUTABLE" as @cyndyishida is 
suggesting is consistent with the option being used in the 
`add_llvm_executable()` macro.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -654,6 +654,11 @@ enabled sub-projects. Nearly all of these variable names 
begin with
   Generate dSYM files and strip executables and libraries (Darwin Only).
   Defaults to OFF.
 
+**LLVM_ENABLE_EXPORTED_SYMBOLS**:BOOL
+  When building executables, preserve symbol exports. Defaults to ON. 
+  You can use this option to disable exported symbols on all executable build

delcypher wrote:

Well if there's precedent I guess you can go either way. I'm personally not a 
fan but you should go with whatever you prefer.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/87815

Implement telemetry in LLDB.

(See previous discussions at 
https://discourse.llvm.org/t/rfc-lldb-telemetry-metrics/64588)

>From cdee622a6646ba5c16a3c8156a5a50a938a14b57 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 5 Apr 2024 14:14:30 -0400
Subject: [PATCH 1/2] [lldb]POC implementation for telemetry in LLDB

---
 lldb/include/lldb/API/SBDebugger.h|   4 +
 lldb/include/lldb/Core/Debugger.h |  10 +
 lldb/include/lldb/Core/Telemetry.h| 206 ++
 lldb/include/lldb/Target/Process.h|   3 +
 lldb/source/API/SBDebugger.cpp|   9 +
 lldb/source/Core/CMakeLists.txt   |   1 +
 lldb/source/Core/Debugger.cpp |  32 +-
 lldb/source/Core/Telemetry.cpp| 620 ++
 .../source/Interpreter/CommandInterpreter.cpp |  44 +-
 lldb/source/Target/Process.cpp|   7 +-
 lldb/source/Target/Target.cpp |  17 +-
 lldb/tools/lldb-dap/DAP.cpp   |  18 +-
 12 files changed, 953 insertions(+), 18 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..c4b51fc925f094 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..a3ecb7e4724374 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -38,6 +39,7 @@
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "lldb/lldb-types.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/Utility/StructuredData.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -145,6 +147,12 @@ class Debugger : public 
std::enable_shared_from_this,
 
   lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
 
+  std::shared_ptr GetTelemetryLogger() {
+return m_telemetry_logger;
+  }
+
+  void SendClientTelemetry(lldb_private::StructuredData::Object *entry);
+
   File &GetInputFile() { return *m_input_file_sp; }
 
   File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
@@ -737,6 +745,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemetry_logger;
   // Events for m_sync_broadcaster
   enum {
 eBroadcastBitEventThreadIsListening = (1 << 0),
@@ -749,6 +758,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   Debugger(const Debugger &) = delete;
   const Debugger &operator=(const Debugger &) = delete;
+  TelemetryEventStats stats;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 00..1c7b030bb2a49c
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,206 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  retu

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes

Implement telemetry in LLDB.

(See previous discussions at 
https://discourse.llvm.org/t/rfc-lldb-telemetry-metrics/64588)

---

Patch is 48.73 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/87815.diff


12 Files Affected:

- (modified) lldb/include/lldb/API/SBDebugger.h (+4) 
- (modified) lldb/include/lldb/Core/Debugger.h (+10) 
- (added) lldb/include/lldb/Core/Telemetry.h (+237) 
- (modified) lldb/include/lldb/Target/Process.h (+3) 
- (modified) lldb/source/API/SBDebugger.cpp (+9) 
- (modified) lldb/source/Core/CMakeLists.txt (+1) 
- (modified) lldb/source/Core/Debugger.cpp (+31-1) 
- (added) lldb/source/Core/Telemetry.cpp (+620) 
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+34-10) 
- (modified) lldb/source/Target/Process.cpp (+6-1) 
- (modified) lldb/source/Target/Target.cpp (+16-1) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+13-5) 


``diff
diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..c4b51fc925f094 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..a3ecb7e4724374 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -38,6 +39,7 @@
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "lldb/lldb-types.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/Utility/StructuredData.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -145,6 +147,12 @@ class Debugger : public 
std::enable_shared_from_this,
 
   lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
 
+  std::shared_ptr GetTelemetryLogger() {
+return m_telemetry_logger;
+  }
+
+  void SendClientTelemetry(lldb_private::StructuredData::Object *entry);
+
   File &GetInputFile() { return *m_input_file_sp; }
 
   File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
@@ -737,6 +745,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemetry_logger;
   // Events for m_sync_broadcaster
   enum {
 eBroadcastBitEventThreadIsListening = (1 << 0),
@@ -749,6 +758,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   Debugger(const Debugger &) = delete;
   const Debugger &operator=(const Debugger &) = delete;
+  TelemetryEventStats stats;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 00..f021437772aa09
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: thes

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 2606c87788153bf33d854fa5c3a03e16d544c5d7 
7321a9073f1ec326f53ada9f40e258c038037af2 -- lldb/include/lldb/Core/Telemetry.h 
lldb/source/Core/Telemetry.cpp lldb/include/lldb/API/SBDebugger.h 
lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Target/Process.h 
lldb/source/API/SBDebugger.cpp lldb/source/Core/Debugger.cpp 
lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Target/Process.cpp 
lldb/source/Target/Target.cpp lldb/tools/lldb-dap/DAP.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index f021437772..4b9dc87d58 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -215,12 +215,12 @@ destination:/path/to/some/file
 
 The allowed field_name values are:
  * enable_logging
-   If the fields are specified more than once, the last line will take 
precedence
-   If enable_logging is set to false, no logging will occur.
+   If the fields are specified more than once, the last line will take
+precedence If enable_logging is set to false, no logging will occur.
  * destination.
-  This is allowed to be specified multiple times - it will add to the 
default
-  (ie, specified by vendor) list of destinations.
-  The value can be either of
+  This is allowed to be specified multiple times - it will add to the
+default (ie, specified by vendor) list of destinations. The value can be either
+of
  + one of the two magic values "stdout" or "stderr".
  + a path to a local file
 

``




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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

JDevlieghere wrote:

@delcypher I was referring to the tools in `/llvm-project/llvm/tools`, which 
use `add_llvm_tool_subdirectory` and `add_llvm_tool` but maybe the distinction 
is more murky than I think it is. I'm also fine with `EXECUTABLE` in the name 👍

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via lldb-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87684

>From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 12:08:28 -0700
Subject: [PATCH 1/3] [cmake] Build executables with -no_exported_symbols when
 building Apple toolchain

Building the Apple way turns off plugin support, meaning we don't need to be 
exporting unloadable symbols from all executables.
While deadstripping effects aren't expected to change, enabling this across all 
tools prevents the creation of export tries. This saves us ~3.5 MB's in just 
the universal build of `clang`.
---
 clang/cmake/caches/Apple-stage2.cmake   |  1 +
 lldb/cmake/caches/Apple-lldb-base.cmake |  1 +
 llvm/CMakeLists.txt |  3 +++
 llvm/cmake/modules/AddLLVM.cmake| 30 ++---
 llvm/docs/CMake.rst |  4 
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..faf61fd1fe9ecb 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..021538896b2346 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 6f5647d70d8bc1..7e393acacb80d8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS
+  "When building executables, disable any symbol exports (Darwin Only)" OFF)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..141a97c852e24f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+set_property(TARGET ${name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,-no_exported_symbols")
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
 set(USE_SHARED USE_SHARED)
   end

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:


> The ObjC Language runtime is able to detect whether ObjC is loaded into the 
> program. It runs that detector on each library load, so it keeps an accurate 
> notion of this. Ditto for the swift language runtime. It would be better to 
> consult that than guess based on platform.

This code runs before the runtimes (objc/swift) so it probably won't be able to 
query that, though?


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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

A bunch of time has passed since the original RFC. It would be great, and help 
with reviewing the PR, to have an overview of the currently proposed 
architecture, the different pieces and how it all fits together. I left some 
inline comments, but I'm not sure if it's worth fixing those before we're all 
on the same page about the higher level stuff. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);

JDevlieghere wrote:

It seems odd to allow clients to send their own telemetry. I'd expect all 
telemetry you'd want to collect to originate from within LLDB. This also seems 
like a pretty privacy concern because now you're opening the door to report 
arbitrary data on behalf of LLDB. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {

JDevlieghere wrote:

It would be great to have comments explaining the purpose of these classes. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;

JDevlieghere wrote:

These need comments to explain what they are. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;

JDevlieghere wrote:

Does every telemetry entry need a start and end time? I think we discussed this 
in the RFC, but I think there's a lot of telemetry that doesn't have to be time 
based. For example, `TargetInfoEntry` does that really need a start and stop 
time?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/API/SBStructuredData.h"

JDevlieghere wrote:

I guess this was added by your IDE. There's a few instances of these. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;
+
+  std::string ToString() const override;
+};
+
+struct TargetInfoEntry : public BaseTelemetryEntry {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  // The process(target) exit info. Not populated of this entry was emitted for
+  // startup event.
+  std::optional process_exit;
+
+  std::string ToString() const override;
+};
+
+// Entry from client (eg., SB-API)
+struct ClientTelemetryEntry : public BaseTelemetryEntry {
+  std::string request_name;
+  std::string error_msg;
+  std::string ToString() const override;
+};
+
+struct CommandInfoEntry : public BaseTelemetryEntry {
+  // If the command is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+  std::string command_uuid;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!!: The following fields may be omitted due to PII risk.
+  // (Configurable via the LoggerConfig struct)
+  std::string original_command;
+  std::string args;
+
+  ExitDescription exit_description;
+
+  std::string ToString() const override;
+};
+
+// The "catch-all" entry to store a set of custom/non-standard
+// data.
+struct MiscInfoEntry : public BaseTelemetryEntry {
+  // If the event is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+
+  // Set of key-value pairs for any optional (or impl-specific) data
+  std::unordered_map meta_data;
+
+  std::string ToString() const override;
+};
+
+// Where/how to send the logged entries.
+class TelemetryDestination {
+public:
+  virtual ~TelemetryDestination() = default;
+  virtual Status EmitEntry(const BaseTelemetryEntry *entry) = 0;
+  virtual std::string name() const = 0;
+};
+
+// The logger itself!
+class TelemetryLogger {

JDevlieghere wrote:

`TelemetryEmitter`? 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {

JDevlieghere wrote:

How does this class differ from the existing `Timer` class?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {

JDevlieghere wrote:

Is there supposed to be one `DebuggerInfoEntry` per debugger instance, or one 
per process instance?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;
+
+  std::string ToString() const override;
+};
+
+struct TargetInfoEntry : public BaseTelemetryEntry {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  // The process(target) exit info. Not populated of this entry was emitted for
+  // startup event.
+  std::optional process_exit;
+
+  std::string ToString() const override;
+};
+
+// Entry from client (eg., SB-API)
+struct ClientTelemetryEntry : public BaseTelemetryEntry {
+  std::string request_name;
+  std::string error_msg;
+  std::string ToString() const override;
+};
+
+struct CommandInfoEntry : public BaseTelemetryEntry {
+  // If the command is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+  std::string command_uuid;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!!: The following fields may be omitted due to PII risk.
+  // (Configurable via the LoggerConfig struct)
+  std::string original_command;
+  std::string args;
+
+  ExitDescription exit_description;
+
+  std::string ToString() const override;
+};
+
+// The "catch-all" entry to store a set of custom/non-standard
+// data.
+struct MiscInfoEntry : public BaseTelemetryEntry {
+  // If the event is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+
+  // Set of key-value pairs for any optional (or impl-specific) data
+  std::unordered_map meta_data;
+
+  std::string ToString() const override;
+};
+
+// Where/how to send the logged entries.
+class TelemetryDestination {
+public:
+  virtual ~TelemetryDestination() = default;
+  virtual Status EmitEntry(const BaseTelemetryEntry *entry) = 0;
+  virtual std::string name() const = 0;
+};
+
+// The logger itself!

JDevlieghere wrote:

This doesn't add much. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;

JDevlieghere wrote:

I'm confused as to what this means. A process has an exist code. Is this the 
LLDB process exit code or the process belonging to a `Debugger` instance? 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -1868,8 +1874,28 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
LazyBool lazy_add_to_history,
CommandReturnObject &result,
bool force_repeat_command) {
+  std::cout << "HandleCommand: " << command_line << "\n";

JDevlieghere wrote:

Stray debug line?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {

JDevlieghere wrote:

Logging is a pretty overloaded term. Unless this is actually related to the 
existing Log infrastructure, this should have a different name, something like 
`TelemetryConfig`? 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;
+
+  std::string ToString() const override;
+};
+
+struct TargetInfoEntry : public BaseTelemetryEntry {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  // The process(target) exit info. Not populated of this entry was emitted for
+  // startup event.
+  std::optional process_exit;
+
+  std::string ToString() const override;
+};
+
+// Entry from client (eg., SB-API)
+struct ClientTelemetryEntry : public BaseTelemetryEntry {
+  std::string request_name;
+  std::string error_msg;
+  std::string ToString() const override;
+};
+
+struct CommandInfoEntry : public BaseTelemetryEntry {
+  // If the command is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+  std::string command_uuid;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!!: The following fields may be omitted due to PII risk.
+  // (Configurable via the LoggerConfig struct)
+  std::string original_command;
+  std::string args;
+
+  ExitDescription exit_description;
+
+  std::string ToString() const override;
+};
+
+// The "catch-all" entry to store a set of custom/non-standard
+// data.
+struct MiscInfoEntry : public BaseTelemetryEntry {
+  // If the event is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+
+  // Set of key-value pairs for any optional (or impl-specific) data
+  std::unordered_map meta_data;
+
+  std::string ToString() const override;
+};
+
+// Where/how to send the logged entries.
+class TelemetryDestination {
+public:
+  virtual ~TelemetryDestination() = default;
+  virtual Status EmitEntry(const BaseTelemetryEntry *entry) = 0;
+  virtual std::string name() const = 0;
+};
+
+// The logger itself!
+class TelemetryLogger {
+public:
+  static std::shared_ptr CreateInstance(Debugger *);
+
+  virtual ~TelemetryLogger() = default;
+
+  // Invoked upon lldb startup
+  virtual void LogStartup(llvm::StringRef lldb_path,
+  TelemetryEventStats stats) = 0;
+
+  // Invoked upon lldb exit.
+  virtual void LogExit(llvm::StringRef lldb_path,

JDevlieghere wrote:

Instead of having separate methods for the different events, which all take a 
`TelemetryEventStats`, it seems like it would be simpler to have a generic 
`Emit` method and then the individual events know how to emit themselves? 

https://github.com/llvm/llvm-project/pull/87815
__

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;
+
+  std::string ToString() const override;
+};
+
+struct TargetInfoEntry : public BaseTelemetryEntry {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  // The process(target) exit info. Not populated of this entry was emitted for
+  // startup event.
+  std::optional process_exit;
+
+  std::string ToString() const override;
+};
+
+// Entry from client (eg., SB-API)
+struct ClientTelemetryEntry : public BaseTelemetryEntry {
+  std::string request_name;
+  std::string error_msg;
+  std::string ToString() const override;
+};
+
+struct CommandInfoEntry : public BaseTelemetryEntry {
+  // If the command is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+  std::string command_uuid;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!!: The following fields may be omitted due to PII risk.
+  // (Configurable via the LoggerConfig struct)
+  std::string original_command;
+  std::string args;
+
+  ExitDescription exit_description;
+
+  std::string ToString() const override;
+};
+
+// The "catch-all" entry to store a set of custom/non-standard
+// data.
+struct MiscInfoEntry : public BaseTelemetryEntry {
+  // If the event is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+
+  // Set of key-value pairs for any optional (or impl-specific) data
+  std::unordered_map meta_data;
+
+  std::string ToString() const override;
+};
+
+// Where/how to send the logged entries.
+class TelemetryDestination {
+public:
+  virtual ~TelemetryDestination() = default;
+  virtual Status EmitEntry(const BaseTelemetryEntry *entry) = 0;
+  virtual std::string name() const = 0;
+};
+
+// The logger itself!
+class TelemetryLogger {
+public:
+  static std::shared_ptr CreateInstance(Debugger *);
+
+  virtual ~TelemetryLogger() = default;
+
+  // Invoked upon lldb startup

JDevlieghere wrote:

Missing period. A few more instances of that below. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event

adrian-prantl wrote:

Can you convert all the comments in header files to Doxygen comments?
`///`

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {

adrian-prantl wrote:

And add top-level doxygen comments to each new datatype?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additional destinations to send the logged entries.
+  // Could be stdout, stderr, or some local paths.
+  // Note: these are destinations are __in addition to__ whatever the default
+  // destination(s) are, as implemented by vendors.
+  std::vector additional_destinations;
+};
+
+// The base class contains the basic set of data.
+// Downstream implementations can add more fields as needed.
+struct BaseTelemetryEntry {
+  // A "session" corresponds to every time lldb starts.
+  // All entries emitted for the same session will have
+  // the same session_uuid
+  std::string session_uuid;
+
+  TelemetryEventStats stats;
+
+  // Counting number of entries.
+  // (For each set of entries with the same session_uuid, this value should
+  // be unique for each entry)
+  size_t counter;
+
+  virtual ~BaseTelemetryEntry() = default;
+  virtual std::string ToString() const;
+};
+
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerInfoEntry : public BaseTelemetryEntry {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  // The debugger exit info. Not populated if this entry was emitted for 
startup
+  // event.
+  std::optional lldb_exit;
+
+  std::string ToString() const override;
+};
+
+struct TargetInfoEntry : public BaseTelemetryEntry {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  // The process(target) exit info. Not populated of this entry was emitted for
+  // startup event.
+  std::optional process_exit;
+
+  std::string ToString() const override;
+};
+
+// Entry from client (eg., SB-API)
+struct ClientTelemetryEntry : public BaseTelemetryEntry {
+  std::string request_name;
+  std::string error_msg;
+  std::string ToString() const override;
+};
+
+struct CommandInfoEntry : public BaseTelemetryEntry {
+  // If the command is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+  std::string command_uuid;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!!: The following fields may be omitted due to PII risk.
+  // (Configurable via the LoggerConfig struct)
+  std::string original_command;
+  std::string args;
+
+  ExitDescription exit_description;
+
+  std::string ToString() const override;
+};
+
+// The "catch-all" entry to store a set of custom/non-standard
+// data.
+struct MiscInfoEntry : public BaseTelemetryEntry {
+  // If the event is/can be associated with a target entry,
+  // this field contains that target's UUID.
+  //  otherwise.
+  std::string target_uuid;
+
+  // Set of key-value pairs for any optional (or impl-specific) data
+  std::unordered_map meta_data;
+
+  std::string ToString() const override;
+};
+
+// Where/how to send the logged entries.
+class TelemetryDestination {
+public:
+  virtual ~TelemetryDestination() = default;
+  virtual Status EmitEntry(const BaseTelemetryEntry *entry) = 0;
+  virtual std::string name() const = 0;
+};
+
+// The logger itself!
+class TelemetryLogger {
+public:
+  static std::shared_ptr CreateInstance(Debugger *);
+
+  virtual ~TelemetryLogger() = default;
+
+  // Invoked upon lldb startup
+  virtual void LogStartup(llvm::StringRef lldb_path,
+  TelemetryEventStats stats) = 0;
+
+  // Invoked upon lldb exit.
+  virtual void LogExit(llvm::StringRef lldb_path,
+   TelemetryEventStats stats) = 0;
+
+  // Invoked upon process exit
+  virtual void LogProcessExit(int status, llvm::StringRef exit_string,
+  TelemetryEventStats stats,
+  Target *target_ptr) = 0;
+
+  // Invoked upon loading the main executable module

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =

adrian-prantl wrote:

It would be more efficient to use an llvm stream 
https://llvm.org/doxygen/classllvm_1_1raw__string__ostream.html for all these 
string concatenations, throughout the file

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)

delcypher wrote:

Currently we silently ignore `LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES` if 
the linker doesn't support the flag. It would probably better to produce a 
fatal error to avoid an invalid configuration being used.

```cmake
if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
  if (LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
  set_property(TARGET ${name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,-no_exported_symbols")
  else()
message(FATAL_ERROR "LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be 
disabled when linker does not support  \" -Wl,-no_exported_symbols\""
  endif()
endif()
```

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via lldb-commits

https://github.com/cyndyishida updated 
https://github.com/llvm/llvm-project/pull/87684

>From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Thu, 4 Apr 2024 12:08:28 -0700
Subject: [PATCH 1/4] [cmake] Build executables with -no_exported_symbols when
 building Apple toolchain

Building the Apple way turns off plugin support, meaning we don't need to be 
exporting unloadable symbols from all executables.
While deadstripping effects aren't expected to change, enabling this across all 
tools prevents the creation of export tries. This saves us ~3.5 MB's in just 
the universal build of `clang`.
---
 clang/cmake/caches/Apple-stage2.cmake   |  1 +
 lldb/cmake/caches/Apple-lldb-base.cmake |  1 +
 llvm/CMakeLists.txt |  3 +++
 llvm/cmake/modules/AddLLVM.cmake| 30 ++---
 llvm/docs/CMake.rst |  4 
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..faf61fd1fe9ecb 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..021538896b2346 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 6f5647d70d8bc1..7e393acacb80d8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS
+  "When building executables, disable any symbol exports (Darwin Only)" OFF)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..141a97c852e24f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,11 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+set_property(TARGET ${name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,-no_exported_symbols")
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
 set(USE_SHARED USE_SHARED)
   end

[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")

delcypher wrote:

Nit: This won't do anything if 
`LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES` is already set in the cache 
(e.g. from a previous configure). You can use `FORCE` to always set the value.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")

delcypher wrote:

Same here. Consider using `FORCE`

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits

https://github.com/delcypher approved this pull request.

LGTM. Other than the nit about not using `FORCE` to set the CMake cache 
variable.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")

delcypher wrote:

Oh wait. Ignore me. Using `INTERNAL` implies `FORCE`.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits


@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")

delcypher wrote:

Ignore this suggestion. `INTERNAL` implies `FORCE`.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dan Liew via lldb-commits

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


[Lldb-commits] [lldb] [lldb][sbdebugger] Match progress category enum bit in Debugger.h (PR #87409)

2024-04-05 Thread Alex Langford via lldb-commits

bulbazord wrote:

> Why don't we just remove the enum from SBDebugger and use the one from 
> Debugger instead, this will ensure the offsets are always the same.

SBDebugger is public and Debugger is private, so I'm not sure how you can do 
this? Maybe I'm misunderstanding your suggestion...

It would be nice if we could move the enum into `lldb-enumerations` so we 
didn't have to worry about keeping this in sync though.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);

oontvoo wrote:

Can you clarify your privacy model?

We need this  API because we want to be able to collect performance stats for 
our IDE debugging  layer (eg., how long each DAP packet takes, success vs 
failed vs timedout counts, etc).  While it's possible that the clients could 
have their own telemetry  outside of LLDB, it is helpful to be able to combine 
both client(s)' and server's telemetry data for each session 

As for privacy concerns, at least, from our POV, we ensure that the collected 
data is stored with restricted and auditable access. The `Destination` class, 
which takes care of forwarding the collected telemetry entries to its final 
destination, is vendor-specific. So you could choose to ignore client telemetry 
if it does not fit your privacy model. 

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:

P.S: it was pointed out to me that changed capabilities can be pushed as an 
event. So I guess we could init the list of filters based on whether the 
languages are supported. Then when the runtime(s) become available, we can 
update the list after querying for which language is being debugged. WDYT?

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> I would be nice if we can detect if we support Swift dynamically. Internally 
> in LLDB, we can ask for a TypeSystem by language using:

See also how lldb/test/Shell/Process/UnsupportedLanguage.test works


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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -273,6 +301,44 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
 if (!isType(entry.tag()))
   continue;
 
+
+DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry);
+if (foreign_tu) {

bulbazord wrote:

nit: Merge these two lines
```
if (DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry)) {
```

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -273,6 +301,44 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
 if (!isType(entry.tag()))
   continue;
 
+
+DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry);
+if (foreign_tu) {
+  // If this entry represents a foreign type unit, we need to verify that
+  // the type unit that ended up in the final .dwp file is the right type
+  // unit. Type units have signatures which are the same across multiple
+  // .dwo files, but only one of those type units will end up in the .dwp
+  // file. The contents of type units for the same type can be different
+  // in different .dwo file, which means the DIE offsets might not be the
+  // same between two different type units. So we need to determine if this
+  // accelerator table matches the type unit in the .dwp file. If it 
doesn't
+  // match, then we need to ignore this accelerator table entry as the type
+  // unit that is in the .dwp file will have its own index.
+  const llvm::DWARFDebugNames::NameIndex *name_index = 
entry.getNameIndex();
+  if (name_index == nullptr)
+continue;
+  // In order to determine if the type unit that ended up in a .dwp file
+  // is valid, we need to grab the type unit and check the attribute on the
+  // type unit matches the .dwo file. For this to happen we rely on each
+  // .dwo file having its own .debug_names table with a single compile unit
+  // and multiple type units. This is the only way we can tell if a type
+  // unit came from a specific .dwo file.
+  if (name_index->getCUCount() == 1) {
+dw_offset_t cu_offset = name_index->getCUOffset(0);
+DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::DebugInfo,
+ cu_offset);
+if (cu) {

bulbazord wrote:

nit: Merge these two lines

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -34,6 +34,18 @@ DebugNamesDWARFIndex::Create(Module &module, 
DWARFDataExtractor debug_names,
   module, std::move(index_up), debug_names, debug_str, dwarf));
 }
 
+
+llvm::DenseSet
+DebugNamesDWARFIndex::GetTypeUnitSigs(const DebugNames &debug_names) {

bulbazord wrote:

nit: Type out the full word `GetTypeUnitSignatures` for consistency. 
DebugNames::NameIndex::getForeignTUSignature does this.

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -693,7 +693,6 @@ llvm::DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
   if (debug_abbrev_data.GetByteSize() == 0)
 return nullptr;
 
-  ElapsedTime elapsed(m_parse_time);

bulbazord wrote:

Why remove this `ElapsedTime`?

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -273,6 +301,44 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
 if (!isType(entry.tag()))
   continue;
 
+
+DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry);
+if (foreign_tu) {
+  // If this entry represents a foreign type unit, we need to verify that
+  // the type unit that ended up in the final .dwp file is the right type
+  // unit. Type units have signatures which are the same across multiple
+  // .dwo files, but only one of those type units will end up in the .dwp
+  // file. The contents of type units for the same type can be different
+  // in different .dwo file, which means the DIE offsets might not be the
+  // same between two different type units. So we need to determine if this
+  // accelerator table matches the type unit in the .dwp file. If it 
doesn't
+  // match, then we need to ignore this accelerator table entry as the type
+  // unit that is in the .dwp file will have its own index.
+  const llvm::DWARFDebugNames::NameIndex *name_index = 
entry.getNameIndex();
+  if (name_index == nullptr)
+continue;
+  // In order to determine if the type unit that ended up in a .dwp file
+  // is valid, we need to grab the type unit and check the attribute on the
+  // type unit matches the .dwo file. For this to happen we rely on each
+  // .dwo file having its own .debug_names table with a single compile unit
+  // and multiple type units. This is the only way we can tell if a type
+  // unit came from a specific .dwo file.
+  if (name_index->getCUCount() == 1) {
+dw_offset_t cu_offset = name_index->getCUOffset(0);
+DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::DebugInfo,
+ cu_offset);
+if (cu) {
+  DWARFBaseDIE cu_die = cu->GetUnitDIEOnly();
+  DWARFBaseDIE tu_die = foreign_tu->GetUnitDIEOnly();
+  llvm::StringRef cu_dwo_name =
+  cu_die.GetAttributeValueAsString(DW_AT_dwo_name, nullptr);
+  llvm::StringRef tu_dwo_name =
+  tu_die.GetAttributeValueAsString(DW_AT_dwo_name, nullptr);
+  if (cu_dwo_name != tu_dwo_name)

bulbazord wrote:

Is it possible for `cu_dwo_name` and `tu_dwo_name` to both be empty/invalid?

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -2717,7 +2731,6 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   die_context = die.GetDeclContext();
 else
   die_context = die.GetTypeLookupContext();
-assert(!die_context.empty());

bulbazord wrote:

Why remove the assertion? Not saying we should keep it, but why doesn't this 
hold?

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -48,15 +60,31 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames 
&debug_names) {
   return result;
 }
 
+DWARFTypeUnit *
+DebugNamesDWARFIndex::GetForeignTypeUnit(const DebugNames::Entry &entry) const 
{
+  std::optional type_sig = entry.getForeignTUTypeSignature();
+  if (type_sig)

bulbazord wrote:

nit: You can merge these lines:
```
if (std::optional type_sig = entry.getForeignTUTypeSignature())
```

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -21,9 +21,11 @@ class SymbolFileDWARFDwo;
 class ManualDWARFIndex : public DWARFIndex {
 public:
   ManualDWARFIndex(Module &module, SymbolFileDWARF &dwarf,
-   llvm::DenseSet units_to_avoid = {})
+   llvm::DenseSet units_to_avoid = {},
+   llvm::DenseSet type_sigs_to_avoid = {})
   : DWARFIndex(module), m_dwarf(&dwarf),
-m_units_to_avoid(std::move(units_to_avoid)) {}
+m_units_to_avoid(std::move(units_to_avoid)),
+m_type_sigs_to_avoid(type_sigs_to_avoid) {}

bulbazord wrote:

nit: If we are going to std::move `units_to_avoid`, we should do the same for 
`m_type_sigs_to_avoid`. It's the same situation.

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -1726,44 +1725,59 @@ lldb::ModuleSP 
SymbolFileDWARF::GetExternalModule(ConstString name) {
   return pos->second;
 }
 
-DWARFDIE
-SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
-  // This method can be called without going through the symbol vendor so we
-  // need to lock the module.
-  std::lock_guard guard(GetModuleMutex());
-
-  SymbolFileDWARF *symbol_file = nullptr;
-
+SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
   // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we
   // must make sure we use the correct DWARF file when resolving things. On
   // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple
   // SymbolFileDWARF classes, one for each .o file. We can often end up with
   // references to other DWARF objects and we must be ready to receive a
   // "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
   // instance.
+
   std::optional file_index = die_ref.file_index();
+
+  // If the file index matches, then we have the right SymbolFileDWARF already.
+  // This will work for both .dwo file and DWARF in .o files for mac. Also if
+  // both the file indexes are invalid, then we have a match.
+  if (GetFileIndex() == file_index)
+return this;
+
+  // If we are currently in a .dwo file and our file index doesn't match we 
need
+  // to let the base symbol file handle this.
+  SymbolFileDWARFDwo *dwo = llvm::dyn_cast_or_null(this);
+  if (dwo)

bulbazord wrote:

nit: Merge these two lines

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -1726,44 +1725,59 @@ lldb::ModuleSP 
SymbolFileDWARF::GetExternalModule(ConstString name) {
   return pos->second;
 }
 
-DWARFDIE
-SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
-  // This method can be called without going through the symbol vendor so we
-  // need to lock the module.
-  std::lock_guard guard(GetModuleMutex());
-
-  SymbolFileDWARF *symbol_file = nullptr;
-
+SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
   // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we
   // must make sure we use the correct DWARF file when resolving things. On
   // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple
   // SymbolFileDWARF classes, one for each .o file. We can often end up with
   // references to other DWARF objects and we must be ready to receive a
   // "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
   // instance.
+
   std::optional file_index = die_ref.file_index();
+
+  // If the file index matches, then we have the right SymbolFileDWARF already.
+  // This will work for both .dwo file and DWARF in .o files for mac. Also if
+  // both the file indexes are invalid, then we have a match.
+  if (GetFileIndex() == file_index)
+return this;
+
+  // If we are currently in a .dwo file and our file index doesn't match we 
need
+  // to let the base symbol file handle this.
+  SymbolFileDWARFDwo *dwo = llvm::dyn_cast_or_null(this);
+  if (dwo)
+return dwo->GetBaseSymbolFile().GetDIERefSymbolFile(die_ref);
+
   if (file_index) {
-if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
-  symbol_file = debug_map->GetSymbolFileByOSOIndex(*file_index); // OSO 
case
-  if (symbol_file)
-return symbol_file->DebugInfo().GetDIE(die_ref);
-  return DWARFDIE();
-}
+SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile();
+if (debug_map) {

bulbazord wrote:

nit: Merge these

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,91 @@
+// REQUIRES: lld
+
+// This test will make a type that will be compiled differently into two
+// different .dwo files in a type unit with the same type hash, but with
+// differing contents. I have discovered that the hash for the type unit is
+// simply based off of the typename and doesn't seem to differ when the 
contents
+// differ, so that will help us test foreign type units in the .debug_names
+// section of the main executable. When a DWP file is made, only one type unit
+// will be kept and the type unit that is kept has the .dwo file name that it
+// came from. When LLDB loads the foreign type units, it needs to verify that
+// any entries from foreign type units come from the right .dwo file. We test
+// this since the contents of type units are not always the same even though
+// they have the same type hash. We don't want invalid accelerator table 
entries
+// to come from one .dwo file and be used on a type unit from another since 
this
+// could cause invalid lookups to happen. LLDB knows how to track down which
+// .dwo file a type unit comes from by looking at the DW_AT_dwo_name attribute
+// in the DW_TAG_type_unit.
+
+// Now test with DWARF5
+// RUN: %clang -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf \
+// RUN:   -fdebug-types-section -gpubnames -c %s -o %t.main.o
+// RUN: %clang -target x86_64-pc-linux -gdwarf-5 -gsplit-dwarf -DVARIANT \
+// RUN:   -fdebug-types-section -gpubnames -c %s -o %t.foo.o
+// RUN: ld.lld %t.main.o %t.foo.o -o %t
+
+// First we check when we make the .dwp file with %t.main.dwo first so it will
+// pick the type unit from %t.main.dwo. Verify we find only the types from
+// %t.main.dwo's type unit.
+// RUN: llvm-dwp %t.main.dwo %t.foo.dwo -o %t.dwp
+// RUN: %lldb \
+// RUN:   -o "type lookup IntegerType" \
+// RUN:   -o "type lookup FloatType" \
+// RUN:   -o "type lookup IntegerType" \

bulbazord wrote:

Why look up IntegerType twice? 

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


[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -60,8 +60,10 @@ void ManualDWARFIndex::Index() {
   }
   if (dwp_info && dwp_info->ContainsTypeUnits()) {
 for (size_t U = 0; U < dwp_info->GetNumUnits(); ++U) {
-  if (auto *tu = 
llvm::dyn_cast(dwp_info->GetUnitAtIndex(U)))
-units_to_index.push_back(tu);
+  if (auto *tu = 
llvm::dyn_cast(dwp_info->GetUnitAtIndex(U))) {
+if (m_type_sigs_to_avoid.count(tu->GetTypeHash()) == 0)

bulbazord wrote:

Suggestion: It might be clearer to use `contains` directly instead of 
`count(...) == 0`

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


[Lldb-commits] [lldb] 25cf279 - [cmake] Build executables with -no_exported_symbols when building Apple toolchain (#87684)

2024-04-05 Thread via lldb-commits

Author: Cyndy Ishida
Date: 2024-04-05T14:41:20-07:00
New Revision: 25cf27910c3a58e71e37c3d5391235730aa7c488

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

LOG: [cmake] Build executables with -no_exported_symbols when building Apple 
toolchain (#87684)

Building the Apple way turns off plugin support, meaning we don't need
to export unloadable symbols from all executables. While deadstripping
effects aren't expected to change, enabling this across all tools
prevents the creation of export tries. This saves us ~3.5 MB in just the
universal build of `clang`.

Added: 


Modified: 
clang/cmake/caches/Apple-stage2.cmake
lldb/cmake/caches/Apple-lldb-base.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/docs/CMake.rst

Removed: 




diff  --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index 72cdedd611bc96..ede256a2da6b8f 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")

diff  --git a/lldb/cmake/caches/Apple-lldb-base.cmake 
b/lldb/cmake/caches/Apple-lldb-base.cmake
index 4d4f02bfae95bd..6c3fa4346d7e8a 100644
--- a/lldb/cmake/caches/Apple-lldb-base.cmake
+++ b/lldb/cmake/caches/Apple-lldb-base.cmake
@@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES OFF CACHE BOOL "")
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 88cf2d7ff099c9..d511376e18ba5e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES
+  "Preserve exported symbols in executables" ON)
+
 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
   "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 745935f1405170..f8a17f645e25ba 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
 endif()
   endif()
 
-  # Apple's linker complains about duplicate libraries, which CMake likes to do
-  # to support ELF platforms. To silence that warning, we can use
-  # -no_warn_duplicate_libraries, but only in versions of the linker that
-  # support that flag.
-  if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 include(CheckLinkerFlag)
-check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
-  else()
-set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
+# Linkers that support Darwin allow a setting to internalize all symbol 
exports, 
+# aiding in reducing binary size and often is applicable for executables.
+check_linker_flag(C "-Wl,-no_exported_symbols" 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+
+if (NOT LLVM_USE_LINKER) 
+  # Apple's linker complains about duplicate libraries, which CMake likes 
to do
+  # to support ELF platforms. To silence that warning, we can use
+  # -no_warn_duplicate_libraries, but only in versions of the linker that
+  # support that flag.
+  check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" 
LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
+else()
+  set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL 
"")
+endif()
+  
+  else() 
+set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "")
   endif()
 endif()
 
@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) 
+if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+  set_property(TARGET ${name} APPEND_STRING PROPERTY
+LINK_FLAGS " -Wl,-no_exported_symbols")
+else()
+  message(FATAL_ERROR 
+

[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Dave Lee via lldb-commits


@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) 
+if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+  set_property(TARGET ${name} APPEND_STRING PROPERTY
+LINK_FLAGS " -Wl,-no_exported_symbols")
+else()
+  message(FATAL_ERROR 
+"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when 
linker does not support \"-no_exported_symbols\"")

kastiglione wrote:

Prior to the addition of `-no_exported_symbols`, I used to use 
`-Wl,-exported_symbols_list,/dev/null` to achieve the same thing. That could be 
a fallback, if anyone is motivated.

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Slava Zakharin via lldb-commits

vzakhari wrote:

FYI, it looks like this change broke `compiler-rt` build, e.g. in 
https://lab.llvm.org/buildbot/#/builders/270/builds/12485

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via lldb-commits


@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
+  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) 
+if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+  set_property(TARGET ${name} APPEND_STRING PROPERTY
+LINK_FLAGS " -Wl,-no_exported_symbols")
+else()
+  message(FATAL_ERROR 
+"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when 
linker does not support \"-no_exported_symbols\"")

cyndyishida wrote:

Yea, theres more platform-friendly and older ways to achieve the same thing. I 
opted not to because AFAIK, our toolchain only builds with linkers that support 
the straightforward flag, and wasn't sure how useful this would be for other 
platforms. 

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


[Lldb-commits] [clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Cyndy Ishida via lldb-commits

cyndyishida wrote:

> FYI, it looks like this change broke `compiler-rt` build, e.g. in 
> https://lab.llvm.org/buildbot/#/builders/270/builds/12485

Should be resolved by: 
https://github.com/llvm/llvm-project/commit/fe45029dbdee6b3df2dbeaed17c9dd598ec511f2
 
I suspect compiler-rt may be relying on defaults set by Apple* cmake caches on 
unrelated environments.

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


[Lldb-commits] [lldb] [lldb][ClangUserExpression][NFCI] Pass the most specific ExecutionContextScope possible into ClangExpressionParser (PR #87657)

2024-04-05 Thread Michael Buch via lldb-commits


@@ -669,15 +670,8 @@ bool ClangUserExpression::Parse(DiagnosticManager 
&diagnostic_manager,
   // Parse the expression
   //
 
-  Process *process = exe_ctx.GetProcessPtr();
-  ExecutionContextScope *exe_scope = process;
-
-  if (!exe_scope)
-exe_scope = exe_ctx.GetTargetPtr();
-
-  bool parse_success = TryParse(diagnostic_manager, exe_scope, exe_ctx,
-execution_policy, keep_result_in_memory,
-generate_debug_info);
+  bool parse_success = TryParse(diagnostic_manager, exe_ctx, execution_policy,
+keep_result_in_memory, generate_debug_info);

Michael137 wrote:

@clayborg Any remaining concerns with landing this as-is? It seems like we want 
to have a separate discussion around which one of `ExecutionContextScope` or 
`ExecutionContext` to use in APIs, orthogonal to this patch.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -965,6 +966,14 @@ SBTarget SBDebugger::GetDummyTarget() {
   return sb_target;
 }
 
+void SBDebugger::SendTelemetry(SBStructuredData *entry) {
+  if (lldb_private::Debugger *debugger = this->get()) {

bulbazord wrote:

We have a convention to check for `m_opaque_sp`, look at the other methods for 
examples.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

I read through the RFC briefly and skimmed the PR. Left some comments, but I'm 
sure this PR will change over time.

+1 to all of Jonas's and Adrian's comments.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 

bulbazord wrote:

auxv is not available on every platform, you'll have to go through the host 
layer for whatever you're trying to do with it.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -965,6 +966,14 @@ SBTarget SBDebugger::GetDummyTarget() {
   return sb_target;
 }
 
+void SBDebugger::SendTelemetry(SBStructuredData *entry) {
+  if (lldb_private::Debugger *debugger = this->get()) {
+debugger->SendClientTelemetry(entry->m_impl_up->GetObjectSP().get());
+  } else {
+std::cerr << " --- cannot log dap request - debugger is null\n";

bulbazord wrote:

std::cerr is not the right place to write this, please log it instead. LLDB is 
often used as a library and there would be no way for clients to opt-out of 
this behavior.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {

bulbazord wrote:

`llvm::StringSwitch` might be a good idea here.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 

bulbazord wrote:

Don't include this if you don't actually need it in the header. Clients 
shouldn't need to pay the cost of including the chrono header if it's not 
actually needed.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"

bulbazord wrote:

Please don't include clang headers here directly. Try using the lldb version 
header for getting version information.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?

bulbazord wrote:

Please add more detail to this comment or remove it. As-is, this comment isn't 
actionable. Future contributors (yourself included) may not know what "some 
memory stats" actually means. 

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);

bulbazord wrote:

If you want to combine telemetry from LLDB and clients together, why not invert 
the relationship? Instead of having LLDB ingest client telemetry data and 
report them together, we could instead have LLDB hand its telemetry over to 
clients and have the client combine them.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,237 @@
+#ifndef LLDB_CORE_TELEMETRY_H

bulbazord wrote:

This file needs a copyright header.

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -0,0 +1,620 @@
+
+//===-- Telemetry.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "lldb/Core/Telemetry.h"
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "third_party/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+
+#include "clang/Basic/Version.h"
+
+namespace lldb_private {
+
+std::string BaseTelemetryEntry::ToString() const {
+  return "[BaseTelemetryEntry]\n" + ("  session_uuid:" + session_uuid + "\n") +
+ ("  start timestamp: " +
+  std::to_string(stats.m_start.time_since_epoch().count()) + "\n") +
+ (" counter: " + std::to_string(counter));
+}
+
+std::string DebuggerInfoEntry::ToString() const {
+  auto duration = stats.Duration();
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DebuggerInfoEntry]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ ("  lldb startup/session duration: " +
+  (duration.has_value() ? std::to_string(duration->count())
+: "") +
+  "(nanosec)\n") +
+ (lldb_exit.has_value()
+  ? ("lldb_exit_code: " + std::to_string(lldb_exit->exit_code) +
+ ", lldb_exit_description: " + lldb_exit->description + "\n  ")
+  : (""));
+}
+
+std::string ClientTelemetryEntry::ToString() const {
+  return BaseTelemetryEntry::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + std::to_string(stats.Duration()->count()) +
+  "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetInfoEntry::ToString() const {
+  std::string exit_or_load_desc;
+  if (process_exit.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc =
+"  process_duration: " + std::to_string(stats.Duration()->count()) +
+"(nanosec)" +
+"\n"
+"  exit_code: " +
+std::to_string(process_exit->exit_code) +
+", exit description: " + process_exit->description + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc = "  startup_init_duration: " +
+  std::to_string(stats.Duration()->count()) +
+  "(nanosec)" + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return BaseTelemetryEntry::ToString() + "\n" + ("[TargetInfoEntry]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  // TODO:  surely there's a better way to translate status to text???
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+m

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Alex Langford via lldb-commits


@@ -1628,7 +1628,14 @@ void request_initialize(const llvm::json::Object 
&request) {
   body.try_emplace("supportsEvaluateForHovers", true);
   // Available filters or options for the setExceptionBreakpoints request.
   llvm::json::Array filters;
+  std::string triple =
+  std::string(g_dap.debugger.GetSelectedPlatform().GetTriple());
   for (const auto &exc_bp : g_dap.exception_breakpoints) {
+// Skipping objc breakpoint filters if not working on macos.
+if (exc_bp.language == lldb::eLanguageTypeObjC &&
+triple.find("macos") == std::string::npos) {

bulbazord wrote:

In addition to what Jim said above, this might not always work. For example, 
there are more apple triples (e.g. `arm64-apple-ios`)

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


[Lldb-commits] [lldb] [llvm] [cmake] Prevent implicitly passing `-no_exported_symbols` (PR #87846)

2024-04-05 Thread Cyndy Ishida via lldb-commits

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/87846

* It is possible to setup llvm-project builds without going through 
`llvm/CMakeList.txt` so the fatal error handling should be smarter.
* Disable option on Apple style lldb-linux builds.

>From 75949b4fae9634a032dd97a34bd3546367dbab5a Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 5 Apr 2024 17:08:46 -0700
Subject: [PATCH] [cmake] Prevent implicitly passing `-no_exported_symbols`

* Its possible to setup llvm-project builds without going through
  `llvm/CMakeList.txt` so the fatal error handling should be smarter.
* Disable option on Apple style lldb-linux builds.
---
 lldb/cmake/caches/Apple-lldb-Linux.cmake | 1 +
 llvm/cmake/modules/AddLLVM.cmake | 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lldb/cmake/caches/Apple-lldb-Linux.cmake 
b/lldb/cmake/caches/Apple-lldb-Linux.cmake
index b2d3cf595fe18d..9258f01e2ec26a 100644
--- a/lldb/cmake/caches/Apple-lldb-Linux.cmake
+++ b/lldb/cmake/caches/Apple-lldb-Linux.cmake
@@ -1,4 +1,5 @@
 include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake)
+set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES ON CACHE BOOL "")
 
 set(LLVM_DISTRIBUTION_COMPONENTS
   lldb
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 81398ddb5c92e3..693fd5669f63f9 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1038,9 +1038,15 @@ macro(add_llvm_executable name)
 add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
-  if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND 
LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
+  if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND 
+  NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
+if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
   set_property(TARGET ${name} APPEND_STRING PROPERTY
 LINK_FLAGS " -Wl,-no_exported_symbols")
+else()
+  message(FATAL_ERROR
+"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when 
linker does not support \"-no_exported_symbols\"")
+endif()
   endif()
 
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)

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


  1   2   >