[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-12 Thread via lldb-commits

Da-Viper wrote:

@JDevlieghere  was away for sometime could you please review this. 

thanks

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


[Lldb-commits] [lldb] [lldb] Fix Block::GetRangeIndexContainingAddress for discontinuous functions (PR #124931)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -6,15 +6,22 @@
 
 # CHECK: Found 1 function(s).
 # CHECK: foo: [input.o[0x0-0xe), input.o[0x14-0x1c)]
-# CHECK-NEXT: input.o[0x0]: cmpl   $0x0, %edi
-# CHECK-NEXT: input.o[0x3]: je 0x14
-# CHECK-NEXT: input.o[0x5]: jmp0x7
-# CHECK-NEXT: input.o[0x7]: callq  0xe
-# CHECK-NEXT: input.o[0xc]: jmp0x1b
+# CHECK-NEXT: input.o[0x0]: callq  0xe
+# CHECK-NEXT: input.o[0x5]: jmp0x1b
+# CHECK-NEXT: input.o[0x7]: cmpl   $0x0, %edi
+# CHECK-NEXT: input.o[0xa]: je 0x14
+# CHECK-NEXT: input.o[0xc]: jmp0x0
 # CHECK-EMPTY:
 # CHECK-NEXT: input.o[0x14]: callq  0x19
 # CHECK-NEXT: input.o[0x19]: jmp0x1b
 # CHECK-NEXT: input.o[0x1b]: retq
+# CHECK-NEXT: offset 0x00 => index 0
+# CHECK-NEXT: offset 0x0c => index 0
+# CHECK-NEXT: offset 0x0e => index 
+# CHECK-NEXT: offset 0x13 => index 
+# CHECK-NEXT: offset 0x14 => index 1
+# CHECK-NEXT: offset 0x1b => index 1
+# CHECK-NEXT: offset 0x1c => index 

labath wrote:

yep

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


[Lldb-commits] [lldb] [lldb] Fix Block::GetRangeIndexContainingAddress for discontinuous functions (PR #124931)

2025-02-12 Thread David Spickett via lldb-commits


@@ -6,15 +6,22 @@
 
 # CHECK: Found 1 function(s).
 # CHECK: foo: [input.o[0x0-0xe), input.o[0x14-0x1c)]
-# CHECK-NEXT: input.o[0x0]: cmpl   $0x0, %edi
-# CHECK-NEXT: input.o[0x3]: je 0x14
-# CHECK-NEXT: input.o[0x5]: jmp0x7
-# CHECK-NEXT: input.o[0x7]: callq  0xe
-# CHECK-NEXT: input.o[0xc]: jmp0x1b
+# CHECK-NEXT: input.o[0x0]: callq  0xe
+# CHECK-NEXT: input.o[0x5]: jmp0x1b
+# CHECK-NEXT: input.o[0x7]: cmpl   $0x0, %edi
+# CHECK-NEXT: input.o[0xa]: je 0x14
+# CHECK-NEXT: input.o[0xc]: jmp0x0
 # CHECK-EMPTY:
 # CHECK-NEXT: input.o[0x14]: callq  0x19
 # CHECK-NEXT: input.o[0x19]: jmp0x1b
 # CHECK-NEXT: input.o[0x1b]: retq
+# CHECK-NEXT: offset 0x00 => index 0
+# CHECK-NEXT: offset 0x0c => index 0
+# CHECK-NEXT: offset 0x0e => index 
+# CHECK-NEXT: offset 0x13 => index 
+# CHECK-NEXT: offset 0x14 => index 1
+# CHECK-NEXT: offset 0x1b => index 1
+# CHECK-NEXT: offset 0x1c => index 

DavidSpickett wrote:

 means that it's not part of a block, is that right?

So if I have a function that does not cover the offset I ask for, it would 
return this failure value.

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

2025-02-12 Thread via lldb-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,Yutong Zhu
 <115899167+yutongz...@users.noreply.github.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?=,
=?utf-8?q?Michał_Górny?= ,LLVM GN Syncbot
 ,Rahul Joshi ,David Sherwood
 ,Nick Sarnie ,Joseph Huber
 ,Vigneshwar Jayakumar ,Timm
 Baeder ,Hsiangkai Wang ,Keith
 Smiley ,Ivan Kosarev ,
=?utf-8?q?Michał_Górny?= ,Stanislav Mekhanoshin
 ,sitrin ,Florian
 Mayer ,Kazu Hirata ,Kazu Hirata
 ,Kazu Hirata ,Kazu Hirata 
 =?utf-8?q?,?=Kazu Hirata ,Kazu Hirata 
,Andreas
 Jonson ,Sharjeel Khan ,Razvan
 Lupusoru ,Ilia Kuklin 
,Aaron
 Siddhartha Mondal ,"S. Bharadwaj Yadavalli"
 ,Nick Desaulniers
 ,Wael Yehia ,Balazs Benics
 ,Aaron Siddhartha Mondal ,Jonas
 Devlieghere ,Ryosuke Niwa ,Vigneshwar
 Jayakumar ,Vigneshwar Jayakumar
 ,Elvin Wang ,Renaud
 Kauffmann ,Zahira Ammarguellat
 ,Tai Ly ,Ryosuke Niwa
 ,Mark de Wever ,quic-areg
 ,Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Nick
 Sarnie ,Kevin Gleason ,Kazu
 Hirata ,Philip Reames ,Joseph Huber
 ,David Green ,Florian Mayer
 ,Alireza Torabian ,Philip
 Reames ,Florian Mayer ,
Andrzej =?utf-8?q?Warzyński?= ,Alexey Bataev
 ,Florian Mayer ,vporpo
 ,Shoaib Meenai ,Nick Desaulniers
 ,Nathan Ridge ,lntue
 ,Brox Chen ,Michael Jones
 ,Philip Reames ,Lang Hames
 ,Shoaib Meenai ,Daniel Hoekwater
 ,lntue ,Florian Mayer
 ,Philip Reames ,Justin Fargnoli
 ,Philip Reames ,Arda Unal
 <3157490+ardau...@users.noreply.github.com>,Kazu Hirata ,Kazu
 Hirata ,Michael Jones ,Krzysztof
 Drewniak ,Christopher Ferris
 ,donald chen 
,lonely
 eagle <2020382...@qq.com>,c8ef ,Thurston Dang
 ,Jie Fu ,"Miguel A. Arroyo"
 ,Luke Lau ,Hongtao Yu
 ,LLVM GN Syncbot ,Jim Lin
 ,Abhishek Kaushik ,Kazu
 Hirata ,Ethan Luis McDonough 
,Vikram
 Hegde <115221833+vikra...@users.noreply.github.com>,Sam Elliott
 ,Haohai Wen ,Ethan Luis
 McDonough ,Matt Arsenault
 ,Vitaly Buka ,Owen Pan
 ,Craig Topper ,Amit Kumar
 Pandey <137622562+ampandey-1...@users.noreply.github.com>,Adam Siemieniuk
 ,Alex MacLean ,Nikita Popov
 ,Louis Dionne ,jeanPerier
 ,Fraser Cormack ,Timm Baeder
 ,Simon Pilgrim ,Nikita Popov
 ,Yeaseen ,Nikita Popov
 ,Pavel Labath ,
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID:
In-Reply-To: 


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 82bd148a3f25439d7f52a32422dc1bcd2da03803 
4892b2598adf37b848e321c6ed808e68b7c8fd97 --extensions cpp,h,c -- 
clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p4.cpp 
clang/test/Modules/malformed-constraint-template-non-type-parm-decl.cpp 
libc/src/math/generic/atan2f_float.h libclc/clc/include/clc/clc_convert.h 
libclc/clc/include/clc/float/definitions.h 
llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h 
llvm/lib/Target/RISCV/RISCVVMV0Elimination.cpp bolt/tools/driver/llvm-bolt.cpp 
clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/LangOptions.h 
clang/lib/AST/ASTContext.cpp clang/lib/AST/ByteCode/Interp.cpp 
clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/lib/AST/DeclTemplate.cpp 
clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp 
clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/ROCm.h 
clang/lib/Sema/HeuristicResolver.cpp clang/lib/Sema/JumpDiagnostics.cpp 
clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaOpenMP.cpp 
clang/lib/Serialization/ASTWriterDecl.cpp 
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
clang/test/AST/ByteCode/cxx26.cpp clang/test/AST/ByteCode/new-delete.cpp 
clang/test/Analysis/Checkers/WebKit/call-args-counted-const-member.cpp 
clang/test/Analysis/Checkers/WebKit/mock-types.h 
clang/test/Driver/amdgpu-openmp-sanitize-options.c 
clang/test/Driver/linker-wrapper.c clang/test/Driver/sycl-offload-jit.cpp 
clang/test/Tooling/clang-linker-wrapper-spirv-elf.cpp 
clang/tools/clang-installapi/Options.cpp 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
clang/unittests/Format/TokenAnnotatorTest.cpp 
clang/unittests/Sema/HeuristicResolverTest.cpp 
compiler-rt/lib/profile/InstrProfiling.h 
compiler-rt/lib/profile/InstrProfilingFile.c 
compiler-rt/lib/scudo/standalone/chunk.h 
compiler-rt/lib/scudo/standalone/report.cpp 
compiler-rt/lib/scudo/standalone/report.h 
compiler-rt/lib/scudo/standalone/tests/report_test.cpp 
flang/lib/Lower/OpenACC.cpp flang/lib/Optimizer/Analysis/AliasAnalysis.cpp 
flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/Dialect/FIROps.cpp 
libc/include/llvm-libc-macros/endian-macros.h 
libc/include/llvm-libc-types/struct_tm.h 
libc/src/__support/FPUtil/double_double.h 
libc/src/__support/macros/optimization.h libc/src/math/generic/atan2f.cpp 
libc/src/math/generic/pow.cp

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This patch adds a new API to `SBType` to retrieve the value of a template 
parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216

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


8 Files Affected:

- (modified) lldb/include/lldb/API/SBTarget.h (+1) 
- (modified) lldb/include/lldb/API/SBType.h (+7) 
- (modified) lldb/include/lldb/API/SBValue.h (+1) 
- (modified) lldb/source/API/SBType.cpp (+34) 
- (modified) 
lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
(+17-2) 
- (modified) lldb/test/API/lang/cpp/template-arguments/Makefile (+1) 
- (modified) 
lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py (+30-2) 
- (modified) lldb/test/API/lang/cpp/template-arguments/main.cpp (+5) 


``diff
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(target, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "breakpoint here", lldb.SBFileSpec("main.cpp"), 
exe_name="a.out"
 )
 frame = thread.GetSelectedFrame()
@@ -33,10 +33,25 @@ def test_template_argument_pack(self):
 self.assertEqual(
 only_pack.GetType().GetTemplateArgumentType(2).GetName(), "double"
 )
-# Access the C template par

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

Michael137 wrote:

We now have three APIs to query template parameters: 
`GetTemplateParameterType`/`GetTemplateParameterKind`/`GetTemplateParameterValue`.
 Perhaps we could just represent a template parameter as an `SBValue` instead? 
And return that via a `SBType::GetTemplateParameter`. Then the 
type/kind/name/value can be queried off of it?

I chose the simpler approach with this patch but happy to reconsider if others 
feel one way or the other

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits


@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;

Michael137 wrote:

These were only necessary to get access to `SBTarget::GetSP`

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 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 
e258bca9505f35e0a22cb213a305eea9b76d11ea...d69bd14f285f5508abc35b60172efc8839b7c0fd
 lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py
``





View the diff from darker here.


``diff
--- template-arguments/TestCppTemplateArguments.py  2025-02-12 
12:32:14.00 +
+++ template-arguments/TestCppTemplateArguments.py  2025-02-12 
12:36:03.909384 +
@@ -53,11 +53,11 @@
 
 value = self.expect_expr("temp3", result_type="Foo")
 template_param_value = 
value.GetType().GetTemplateArgumentValue(target, 1)
 self.assertTrue(template_param_value)
 self.assertEqual(template_param_value.GetTypeName(), "char")
-self.assertEqual(chr(template_param_value.GetValueAsSigned()), 'v')
+self.assertEqual(chr(template_param_value.GetValueAsSigned()), "v")
 
 # FIXME: type should be Foo
 # FIXME: double/float NTTP parameter values currently not supported.
 value = self.expect_expr("temp4", result_type="Foo")
 template_param_value = 
value.GetType().GetTemplateArgumentValue(target, 1)

``




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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

This is definitely better than what you had before, but I still think it's more 
complicated than it needs to be. For one, I'd like to understand why is there a 
need for separate `TelemetryManager` and `TelemetryConfig` fields. If the 
downstream implementation is going to be in charge of creating the telemetry 
manager, why does it need to bother with calling `SetTelemetryConfig`?

A good way to demonstrate how this is supposed to be used in practice (and also 
provide some test coverage) would be to write a unit test which creates a 
simple telemetry vendor plugin and goes through the motions of creating and 
registering it. It doesn't have to be big -- I'm only interested in the 
mechanics of registration here, not data collection -- but it should show how 
one goes about to create and then access the telemetry manager.

If we can reduce the size this class (which I'm 80% certain we can), then I am 
also thinking that maybe it doesn't need to exist at all, as the remaining 
(static) functions could be moved into the TelemetryManager class (so that 
TelemetryManager (not vendor) is *the* plugin). I think that would also be more 
consistent with the lldb plugin concept as e.g. ObjectFile instances are 
created and managed by ObjectFile subclasses -- there isn't a special 
ObjectFileVendor hierarchy to do that (the SymbolVendor, which you may be 
modelling this after, is a bit of an exception here, but I don't want to use it 
as a model precisely because it's so simple that it might not need to exist).

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);

labath wrote:

Could we make these protected (as they're only meant to be called by 
subclasses)?

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+//===-- TelemetryVendor.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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(std::make_shared(
+  /*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}

labath wrote:

Could we make it so that we don't need this method? So that the values of these 
two objects are initialized to this by default?

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+//===-- TelemetryVendor.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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(std::make_shared(
+  /*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+lldb::TelemetryConfigSP TelemetryVendor::GetTelemetryConfig() {
+  static lldb::TelemetryConfigSP g_config_sp;
+  return g_config_sp;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+const lldb::TelemetryConfigSP &config) {
+  GetTelemetryCOnfig() = config;
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;

labath wrote:

This doesn't actually work, as it assigns the copy of the pointer returned by 
`GetTelemetryManager`. Given that shared_ptr (and unique_ptr, which I think 
would be a better choice) are trivially constructible, the simplest way to 
implement this would be
```
static std::some_ptr g_manager_sp;
void TelemetryVendor::SetTelemetryManager(std::some_ptr 
manager_sp) { g_manager_sp = std::move(manager_sp); }
```

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;

labath wrote:

Why does this have to be a concrete class? You're saying that the no-op case 
will use a NULL telemetry manager, which makes me thing that we shouldn't need 
to be able to instantiate this class.

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();

labath wrote:

Does this have to be a shared pointer? AIUI, the telemetry manager should be 
valid for the entirety of the application lifetime, and it shouldn't change, 
which makes me thing this should just return a raw pointer.

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


[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)

2025-02-12 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] Addressed additional review comments from PR/119716. (PR #126757)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -44,21 +41,20 @@ void LLDBBaseTelemetryInfo::serialize(Serializer 
&serializer) const {
 serializer.write("end_time", ToNanosec(end_time.value()));
 }
 
-[[maybe_unused]] static std::string MakeUUID(lldb_private::Debugger *debugger) 
{
+[[maybe_unused]] static std::string MakeUUID(Debugger *debugger) {
   uint8_t random_bytes[16];
   if (auto ec = llvm::getRandomBytes(random_bytes, 16)) {
 LLDB_LOG(GetLog(LLDBLog::Object),
  "Failed to generate random bytes for UUID: {0}", ec.message());
-// fallback to using timestamp + debugger ID.
+// Fallback to using timestamp + debugger ID.
 return llvm::formatv(
 "{0}_{1}", std::chrono::steady_clock::now().time_since_epoch().count(),
 debugger->GetID());
   }
-  return lldb_private::UUID(random_bytes).GetAsString();
+  return MakeUUID(random_bytes).GetAsString();

labath wrote:

Are you sure about that?

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+import lldb
+import re
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class TestStatusline(PExpectTest):
+def do_setup(self):
+# Create a target and run to a breakpoint.
+exe = self.getBuildArtifact("a.out")
+self.expect(
+"target create {}".format(exe), substrs=["Current executable set 
to"]
+)
+self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
+self.expect("run", substrs=["stop reason"])
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test(self):
+"""Basic test for the statusline.
+
+PExpect was designed for line-oriented output so we're limited in what
+we can test.
+"""
+self.build()
+self.launch(timeout=3)
+self.do_setup()
+
+# Change the terminal dimensions.
+self.child.setwinsize(10, 60)
+
+# Enable the statusline and check that we can see the target, the
+# location and the stop reason.
+self.child.send("set set show-statusline true\n")

labath wrote:

Can we use self.expect for this? I'm not sure what's the order of things being 
printed. If the status line is printed before the prompt, then you can put it 
into the `substrs` argument of the `expect` call. Otherwise, you can keep this 
expect line after it.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+import lldb
+import re
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class TestStatusline(PExpectTest):
+def do_setup(self):
+# Create a target and run to a breakpoint.
+exe = self.getBuildArtifact("a.out")
+self.expect(
+"target create {}".format(exe), substrs=["Current executable set 
to"]
+)
+self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
+self.expect("run", substrs=["stop reason"])
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test(self):
+"""Basic test for the statusline.
+
+PExpect was designed for line-oriented output so we're limited in what
+we can test.
+"""
+self.build()
+self.launch(timeout=3)
+self.do_setup()
+
+# Change the terminal dimensions.
+self.child.setwinsize(10, 60)
+
+# Enable the statusline and check that we can see the target, the
+# location and the stop reason.
+self.child.send("set set show-statusline true\n")
+self.child.expect(
+re.escape("a.out | main.c:4:15 | breakpoint 1.1
")
+)
+
+# Change the terminal dimensions.
+self.child.setwinsize(10, 20)
+self.child.send("set set show-statusline false\n")
+self.child.send("set set show-statusline true\n")

labath wrote:

And the same here.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+import lldb
+import re
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class TestStatusline(PExpectTest):
+def do_setup(self):
+# Create a target and run to a breakpoint.
+exe = self.getBuildArtifact("a.out")
+self.expect(
+"target create {}".format(exe), substrs=["Current executable set 
to"]
+)
+self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
+self.expect("run", substrs=["stop reason"])
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test(self):
+"""Basic test for the statusline.
+
+PExpect was designed for line-oriented output so we're limited in what
+we can test.
+"""
+self.build()
+self.launch(timeout=3)

labath wrote:

remove short timeout

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+import lldb
+import re
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class TestStatusline(PExpectTest):
+def do_setup(self):
+# Create a target and run to a breakpoint.
+exe = self.getBuildArtifact("a.out")
+self.expect(
+"target create {}".format(exe), substrs=["Current executable set 
to"]
+)
+self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
+self.expect("run", substrs=["stop reason"])
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+def test(self):
+"""Basic test for the statusline.
+
+PExpect was designed for line-oriented output so we're limited in what

labath wrote:

You should still be able to check a fair number of things. This isn't like the 
curses GUI, where there's the curses library sitting between our code and the 
terminal. All of the escape codes we print are fully within our control.

For example, it should be possible to check that the right escape sequence for 
enabling/disabling the status line is printed in response to changing the 
setting value.

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


[Lldb-commits] [lldb] [lldb-dap] Fix: Could not find DAP in path (PR #126903)

2025-02-12 Thread via lldb-commits

https://github.com/Da-Viper created 
https://github.com/llvm/llvm-project/pull/126903

Fixes #120839

>From 253ce7d35c1500606391eb4242fe3b32734c Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Wed, 12 Feb 2025 12:38:31 +
Subject: [PATCH] [lldb-dap] Fix: compare with the string instead of promise.

---
 lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 55c2f3e9f7deb..7607053041c8c 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -50,13 +50,13 @@ async function findDAPExecutable(): Promise {
   const executable = process.platform === "win32" ? "lldb-dap.exe" : 
"lldb-dap";
 
   // Prefer lldb-dap from Xcode on Darwin.
-  const xcrun_dap = findWithXcrun(executable);
+  const xcrun_dap = await findWithXcrun(executable);
   if (xcrun_dap) {
 return xcrun_dap;
   }
 
   // Find lldb-dap in the user's path.
-  const path_dap = findInPath(executable);
+  const path_dap = await findInPath(executable);
   if (path_dap) {
 return path_dap;
   }

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits


@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;

Michael137 wrote:

This was necessary to get access to the SBValue constructor

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


[Lldb-commits] [lldb] [lldb/DWARF] Resolve type unit references in llvm DWARFDIE compatibility wrappers (PR #126902)

2025-02-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The llvm versions of these functions do that, so we must to so as well. 
Practically this meant that were were unable to correctly un-simplify the names 
of some types when using type units, which resulted in type lookup errors.

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


2 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (+2-2) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp 
(+17-3) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 1e2564cb22f25..0db230d0a8b56 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -622,12 +622,12 @@ std::optional DWARFDIE::getLanguage() const {
 }
 
 DWARFDIE DWARFDIE::resolveReferencedType(dw_attr_t attr) const {
-  return GetReferencedDIE(attr);
+  return GetReferencedDIE(attr).resolveTypeUnitReference();
 }
 
 DWARFDIE DWARFDIE::resolveReferencedType(DWARFFormValue v) const {
   if (IsValid())
-return v.Reference();
+return v.Reference().resolveTypeUnitReference();
   return {};
 }
 
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
index 328d6d2e16d59..ad5dfb6a6dded 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
@@ -11,12 +11,23 @@
 // Test that we following DW_AT_signature correctly. If not, lldb might 
confuse the types of v1 and v2.
 // RUN: %clangxx --target=x86_64-pc-linux -g -gsimple-template-names 
-fdebug-types-section %s -c -o %t2.o
 // RUN: ld.lld %t2.o -o %t2
-// RUN: %lldb %t2 -o "target variable v1 v2" -o exit | FileCheck %s 
--check-prefix=TYPE
+// RUN: %lldb %t2 -o "target variable v1 v2" \
+// RUN:   -o "type lookup t2" -o "type lookup 
t2" \
+// RUN:   -o exit | FileCheck %s --check-prefix=TYPE
 
 // LOG: unique name: t3 >::t4
 
-// TYPE:  (t2 >) v1 = {}
-// TYPE-NEXT: (t2 >) v2 = {}
+// TYPE-LABEL: target variable v1 v2
+// TYPE:   (t2 >) v1 = {}
+// TYPE:   (t2 >) v2 = {}
+
+// TYPE-LABEL: type lookup t2
+// TYPE:   template<> struct t2 {
+// TYPE-NEXT:  }
+
+// TYPE-LABEL: type lookup t2
+// TYPE:   template<> struct t2 {
+// TYPE-NEXT:  }
 
 struct outer_struct1 {
   template  struct t1 {};
@@ -30,6 +41,9 @@ template  struct t2 {};
 t2> v1;
 t2> v2;
 
+t2 v1_1;
+t2 v1_2;
+
 template  struct t3 {
   struct t4 {};
 };

``




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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Fix: Could not find DAP in path (PR #126903)

2025-02-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (Da-Viper)


Changes

Fixes #120839

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


1 Files Affected:

- (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+2-2) 


``diff
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 55c2f3e9f7deb..7607053041c8c 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -50,13 +50,13 @@ async function findDAPExecutable(): Promise {
   const executable = process.platform === "win32" ? "lldb-dap.exe" : 
"lldb-dap";
 
   // Prefer lldb-dap from Xcode on Darwin.
-  const xcrun_dap = findWithXcrun(executable);
+  const xcrun_dap = await findWithXcrun(executable);
   if (xcrun_dap) {
 return xcrun_dap;
   }
 
   // Find lldb-dap in the user's path.
-  const path_dap = findInPath(executable);
+  const path_dap = await findInPath(executable);
   if (path_dap) {
 return path_dap;
   }

``




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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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

This patch adds a new API to `SBType` to retrieve the value of a template 
parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216

>From d69bd14f285f5508abc35b60172efc8839b7c0fd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 12 Feb 2025 12:27:22 +
Subject: [PATCH] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API

This patch adds a new API to `SBType` to retrieve the value of a
template parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h|  7 
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/source/API/SBType.cpp| 34 +++
 .../TestTemplatePackArgs.py   | 19 +--
 .../API/lang/cpp/template-arguments/Makefile  |  1 +
 .../TestCppTemplateArguments.py   | 32 +++--
 .../API/lang/cpp/template-arguments/main.cpp  |  5 +++
 8 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(

[Lldb-commits] [lldb] [lldb/DWARF] Resolve type unit references in llvm DWARFDIE compatibility wrappers (PR #126902)

2025-02-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/126902

The llvm versions of these functions do that, so we must to so as well. 
Practically this meant that were were unable to correctly un-simplify the names 
of some types when using type units, which resulted in type lookup errors.

>From 2c8e19be624a2ce6687f92840a2e494075024754 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 12 Feb 2025 13:34:03 +0100
Subject: [PATCH] [lldb/DWARF] Resolve type unit references in llvm DWARFDIE
 compatibility wrappers

The llvm versions of these functions do that, so we must to so as well.
Practically this meant that were were unable to correctly un-simplify
the names of some types when using type units, which resulted in type
lookup errors.
---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp |  4 ++--
 .../DWARF/x86/simplified-template-names.cpp   | 20 ---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 1e2564cb22f25..0db230d0a8b56 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -622,12 +622,12 @@ std::optional DWARFDIE::getLanguage() const {
 }
 
 DWARFDIE DWARFDIE::resolveReferencedType(dw_attr_t attr) const {
-  return GetReferencedDIE(attr);
+  return GetReferencedDIE(attr).resolveTypeUnitReference();
 }
 
 DWARFDIE DWARFDIE::resolveReferencedType(DWARFFormValue v) const {
   if (IsValid())
-return v.Reference();
+return v.Reference().resolveTypeUnitReference();
   return {};
 }
 
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
index 328d6d2e16d59..ad5dfb6a6dded 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp
@@ -11,12 +11,23 @@
 // Test that we following DW_AT_signature correctly. If not, lldb might 
confuse the types of v1 and v2.
 // RUN: %clangxx --target=x86_64-pc-linux -g -gsimple-template-names 
-fdebug-types-section %s -c -o %t2.o
 // RUN: ld.lld %t2.o -o %t2
-// RUN: %lldb %t2 -o "target variable v1 v2" -o exit | FileCheck %s 
--check-prefix=TYPE
+// RUN: %lldb %t2 -o "target variable v1 v2" \
+// RUN:   -o "type lookup t2" -o "type lookup 
t2" \
+// RUN:   -o exit | FileCheck %s --check-prefix=TYPE
 
 // LOG: unique name: t3 >::t4
 
-// TYPE:  (t2 >) v1 = {}
-// TYPE-NEXT: (t2 >) v2 = {}
+// TYPE-LABEL: target variable v1 v2
+// TYPE:   (t2 >) v1 = {}
+// TYPE:   (t2 >) v2 = {}
+
+// TYPE-LABEL: type lookup t2
+// TYPE:   template<> struct t2 {
+// TYPE-NEXT:  }
+
+// TYPE-LABEL: type lookup t2
+// TYPE:   template<> struct t2 {
+// TYPE-NEXT:  }
 
 struct outer_struct1 {
   template  struct t1 {};
@@ -30,6 +41,9 @@ template  struct t2 {};
 t2> v1;
 t2> v2;
 
+t2 v1_1;
+t2 v1_2;
+
 template  struct t3 {
   struct t4 {};
 };

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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

>From d69bd14f285f5508abc35b60172efc8839b7c0fd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 12 Feb 2025 12:27:22 +
Subject: [PATCH 1/2] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue
 API

This patch adds a new API to `SBType` to retrieve the value of a
template parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h|  7 
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/source/API/SBType.cpp| 34 +++
 .../TestTemplatePackArgs.py   | 19 +--
 .../API/lang/cpp/template-arguments/Makefile  |  1 +
 .../TestCppTemplateArguments.py   | 32 +++--
 .../API/lang/cpp/template-arguments/main.cpp  |  5 +++
 8 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(target, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "breakpoint here", lldb.SBFileSpec("main.cpp"), 
exe_name="a.out"
 )
 frame = thread.GetSelectedFrame()
@@ -33,10 +33,25 @@ def test_template_argument_pack(self):
 self.assertEqual(
 only_pack

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;

labath wrote:

Okay, sorry, this is my bad. I didn't mean to imply that it should be done in 
this patch. I do like this idea, but I think that if we do that, it should be 
done in a more wider fashion rather than a one-off.

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits

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

This looks okay to me (modulo the friend messup). Given this is a public API 
and whatnot, it might be a good idea to wait if folks in the US have any 
thoughts on this.

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -687,6 +687,39 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return {};
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  return SBValue(ValueObjectConstResult::Create(target.GetSP().get(), 
arg->type,

labath wrote:

How about `ValueObject::CreateValueObjectFromData` ? It looks like it calls the 
same function underneath, but it seem more correct.

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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

>From d69bd14f285f5508abc35b60172efc8839b7c0fd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 12 Feb 2025 12:27:22 +
Subject: [PATCH 1/5] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue
 API

This patch adds a new API to `SBType` to retrieve the value of a
template parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h|  7 
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/source/API/SBType.cpp| 34 +++
 .../TestTemplatePackArgs.py   | 19 +--
 .../API/lang/cpp/template-arguments/Makefile  |  1 +
 .../TestCppTemplateArguments.py   | 32 +++--
 .../API/lang/cpp/template-arguments/main.cpp  |  5 +++
 8 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(target, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "breakpoint here", lldb.SBFileSpec("main.cpp"), 
exe_name="a.out"
 )
 frame = thread.GetSelectedFrame()
@@ -33,10 +33,25 @@ def test_template_argument_pack(self):
 self.assertEqual(
 only_pack

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;

oontvoo wrote:

>From my understanding, this class is the main (and only) way for the rest of 
>LLDB to obtain a `TelemetryManager` - that is, via 
>`TelemetryVendor::GetTelemetryManager()` function, without worrying about 
>picking the the right plugin class.

The downstream plugin will just call this class 
`TelemetryVendor::SetTelemetryManager` .



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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);

oontvoo wrote:

Yes

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb/DWARF] Resolve type unit references in llvm DWARFDIE compatibility wrappers (PR #126902)

2025-02-12 Thread Michael Buch via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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

>From d69bd14f285f5508abc35b60172efc8839b7c0fd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 12 Feb 2025 12:27:22 +
Subject: [PATCH 1/3] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue
 API

This patch adds a new API to `SBType` to retrieve the value of a
template parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h|  7 
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/source/API/SBType.cpp| 34 +++
 .../TestTemplatePackArgs.py   | 19 +--
 .../API/lang/cpp/template-arguments/Makefile  |  1 +
 .../TestCppTemplateArguments.py   | 32 +++--
 .../API/lang/cpp/template-arguments/main.cpp  |  5 +++
 8 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(target, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "breakpoint here", lldb.SBFileSpec("main.cpp"), 
exe_name="a.out"
 )
 frame = thread.GetSelectedFrame()
@@ -33,10 +33,25 @@ def test_template_argument_pack(self):
 self.assertEqual(
 only_pack

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

Michael137 wrote:

> > Perhaps we could just represent a template parameter as an SBValue instead?
> 
> I'm not sure I understand. Do you mean, even for type template template 
> parameters? How would that work? By creating an empty value of the given 
> type? And how would we pass the "kind" of the template parameter? I don't 
> think it makes sense adding it to the SBValue class..
> 
> The current implementation seems okay to me, but if we wanted to create 
> something fancier, then I think it'd be best to create a new SB class 
> (SBTypeTemplateParameter?)

Yea `SBTypeTemplateParameter` was more along the lines of what I was thinking, 
if we wanted to unify these APIs

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -687,6 +687,39 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return {};
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())

labath wrote:

Can this ever be not valid? What would that even mean?

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;

labath wrote:

This is completely optional, it just seemed like a good opportunity to 
advertise [my idea](https://godbolt.org/z/sG8GqYh5T) for avoiding these random 
criss-cross friend declarations.

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits


@@ -687,6 +687,39 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return {};
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())

Michael137 wrote:

Yea we don't need this

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


[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126746

>From 008537373cd928fea9ac04b1aed39c2ecafec65a Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:36:06 -0500
Subject: [PATCH 1/5] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (by
 users of Telemetry)

---
 llvm/lib/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index d0a2bc9294381..08e3d7ddb8c12 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -43,6 +43,7 @@ add_subdirectory(TargetParser)
 add_subdirectory(TextAPI)
 if (LLVM_BUILD_TELEMETRY)
   add_subdirectory(Telemetry)
+  add_definitions(-DLLDB_BUILD_TELEMETRY)
 endif()
 add_subdirectory(ToolDrivers)
 add_subdirectory(XRay)

>From f2a3822291d7153359286bd5efc4c080c21adedd Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 11:22:36 -0500
Subject: [PATCH 2/5] add macro def in llvm-config.h

---
 llvm/include/llvm/Config/llvm-config.h.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake 
b/llvm/include/llvm/Config/llvm-config.h.cmake
index 629977cc11d68..239f9dd3f38db 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -201,4 +201,7 @@
 /* Define if logf128 is available */
 #cmakedefine LLVM_HAS_LOGF128
 
+/* Define if building LLVM with LLVM_BUILD_TELEMETRY */
+#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY}
+
 #endif

>From 1bec761f06f79fac21a063a1e5c222e274dd3ddb Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 13:07:12 -0500
Subject: [PATCH 3/5] remove macro from lldb/soruce/Core/CMakeLists.txt

---
 lldb/source/Core/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index cf5f6ac9da489..82fb5f42f9f4b 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -18,7 +18,6 @@ endif()
 
 if (LLVM_BUILD_TELEMETRY)
set(TELEMETRY_DEPS Telemetry)
-   add_definitions(-DLLDB_BUILD_TELEMETRY)
 endif()
 
 # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore

>From 88cdb5ac5f7b6f8cb8bb539a7c1291a302632ec5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 13:08:12 -0500
Subject: [PATCH 4/5] remove macro from llvm/CMakeLists.txt

---
 llvm/lib/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 08e3d7ddb8c12..d0a2bc9294381 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -43,7 +43,6 @@ add_subdirectory(TargetParser)
 add_subdirectory(TextAPI)
 if (LLVM_BUILD_TELEMETRY)
   add_subdirectory(Telemetry)
-  add_definitions(-DLLDB_BUILD_TELEMETRY)
 endif()
 add_subdirectory(ToolDrivers)
 add_subdirectory(XRay)

>From fe6c66535eb5feb9060b0c450840c74ad49bcc1f Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 14:17:35 -0500
Subject: [PATCH 5/5] include config.h header and use new LLVM_BUILD_TELEMETRY
 macro

---
 lldb/source/Core/Telemetry.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 99f5d43ccbaf0..0d0d7c1df3bb9 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -6,7 +6,9 @@
 //
 
//===--===//
 
-#ifdef LLDB_BUILD_TELEMETRY
+#include "llvm/Config/llvm-config.h"
+
+#ifdef LLVM_BUILD_TELEMETRY
 
 #include "lldb/Core/Telemetry.h"
 #include "lldb/Core/Debugger.h"
@@ -71,4 +73,4 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo 
*entry) {
 } // namespace telemetry
 } // namespace lldb_private
 
-#endif // LLDB_BUILD_TELEMETRY
+#endif // LLVM_BUILD_TELEMETRY

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


[Lldb-commits] [lldb] fc4d871 - Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (#126746)

2025-02-12 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-02-12T09:33:52-05:00
New Revision: fc4d87100a01f08dbdf78b68e1a6a5c2584d840d

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

LOG: Define -DLLVM_BUILD_TELEMETRY to be used in ifdef  (#126746)

Background: 

Telemetry code isn't always built (controlled by this
LLVM_BUILD_TELEMETRY cmake flag)
This means users of the library may not have the library. So we're
definding the `-DLLVM_BUILD_TELEMETRY` to be used in ifdef.

Added: 


Modified: 
lldb/source/Core/CMakeLists.txt
lldb/source/Core/Telemetry.cpp
llvm/include/llvm/Config/llvm-config.h.cmake

Removed: 




diff  --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index cf5f6ac9da489..82fb5f42f9f4b 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -18,7 +18,6 @@ endif()
 
 if (LLVM_BUILD_TELEMETRY)
set(TELEMETRY_DEPS Telemetry)
-   add_definitions(-DLLDB_BUILD_TELEMETRY)
 endif()
 
 # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore

diff  --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 99f5d43ccbaf0..0d0d7c1df3bb9 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -6,7 +6,9 @@
 //
 
//===--===//
 
-#ifdef LLDB_BUILD_TELEMETRY
+#include "llvm/Config/llvm-config.h"
+
+#ifdef LLVM_BUILD_TELEMETRY
 
 #include "lldb/Core/Telemetry.h"
 #include "lldb/Core/Debugger.h"
@@ -71,4 +73,4 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo 
*entry) {
 } // namespace telemetry
 } // namespace lldb_private
 
-#endif // LLDB_BUILD_TELEMETRY
+#endif // LLVM_BUILD_TELEMETRY

diff  --git a/llvm/include/llvm/Config/llvm-config.h.cmake 
b/llvm/include/llvm/Config/llvm-config.h.cmake
index 629977cc11d68..239f9dd3f38db 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -201,4 +201,7 @@
 /* Define if logf128 is available */
 #cmakedefine LLVM_HAS_LOGF128
 
+/* Define if building LLVM with LLVM_BUILD_TELEMETRY */
+#cmakedefine LLVM_BUILD_TELEMETRY ${LLVM_BUILD_TELEMETRY}
+
 #endif



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


[Lldb-commits] [lldb] [llvm] Define -DLLVM_BUILD_TELEMETRY to be used in ifdef (PR #126746)

2025-02-12 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 1/5] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 2/5] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/lldb

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;

labath wrote:

Yes, but `TelemetryVendor::GetTelemetryManager` is a static (non-member) 
function, which means this class doesn't need to be instantiatable, which means 
that you don't need to define/override the `GetPluginName` function. Most, if 
not all of our base classes for plugin hierarchies are abstract classes.

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


[Lldb-commits] [lldb] [lldb] Support disassembling discontinuous functions (PR #126505)

2025-02-12 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Remove Debugger::Get{Output, Error}Stream (NFC) (PR #126821)

2025-02-12 Thread Pavel Labath via lldb-commits

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

Makes sense. I suspect all of those uses of the method were candidates for 
corrupting the debugger output.

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


[Lldb-commits] [lldb] 37f36cb - [lldb] Support disassembling discontinuous functions (#126505)

2025-02-12 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-02-12T10:47:22+01:00
New Revision: 37f36cbffb890a0c144211dec0c3589bd17f2a36

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

LOG: [lldb] Support disassembling discontinuous functions (#126505)

The command already supported disassembling multiple ranges, among other
reasons because inline functions can be discontinuous. The main thing
that was missing was being able to retrieve the function ranges from the
top level function object.

The output of the command for the case where the function entry point is
not its lowest address is somewhat confusing (we're showing negative
offsets), but it is correct.

Added: 


Modified: 
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectDisassemble.h
lldb/source/Symbol/SymbolContext.cpp
lldb/test/Shell/Commands/command-disassemble.s

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 5b131fe86dedb..70e687e19ac6d 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
+#include 
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
@@ -236,25 +237,31 @@ CommandObjectDisassemble::CommandObjectDisassemble(
 
 CommandObjectDisassemble::~CommandObjectDisassemble() = default;
 
-llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
- llvm::StringRef what) {
+llvm::Expected>
+CommandObjectDisassemble::CheckRangeSize(std::vector ranges,
+ llvm::StringRef what) {
+  addr_t total_range_size = 0;
+  for (const AddressRange &r : ranges)
+total_range_size += r.GetByteSize();
+
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < GetDebugger().GetStopDisassemblyMaxSize())
-return llvm::Error::success();
+  total_range_size < GetDebugger().GetStopDisassemblyMaxSize())
+return ranges;
+
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";
-  range.Dump(&msg, &GetTarget(), Address::DumpStyleLoadAddress,
- Address::DumpStyleFileAddress);
+  for (const AddressRange &r : ranges)
+r.Dump(&msg, &GetTarget(), Address::DumpStyleLoadAddress,
+   Address::DumpStyleFileAddress);
   msg << ". To disassemble specify an instruction count limit, start/stop "
  "addresses or use the --force option.";
-  return llvm::createStringError(llvm::inconvertibleErrorCode(),
- msg.GetString());
+  return llvm::createStringError(msg.GetString());
 }
 
 llvm::Expected>
 CommandObjectDisassemble::GetContainingAddressRanges() {
   std::vector ranges;
-  const auto &get_range = [&](Address addr) {
+  const auto &get_ranges = [&](Address addr) {
 ModuleSP module_sp(addr.GetModule());
 SymbolContext sc;
 bool resolve_tail_call_address = true;
@@ -262,9 +269,11 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
 addr, eSymbolContextEverything, sc, resolve_tail_call_address);
 if (sc.function || sc.symbol) {
   AddressRange range;
-  sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
- false, range);
-  ranges.push_back(range);
+  for (uint32_t idx = 0;
+   sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol,
+  idx, false, range);
+   ++idx)
+ranges.push_back(range);
 }
   };
 
@@ -273,14 +282,14 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
 Address symbol_containing_address;
 if (target.ResolveLoadAddress(m_options.symbol_containing_addr,
   symbol_containing_address)) {
-  get_range(symbol_containing_address);
+  get_ranges(symbol_containing_address);
 }
   } else {
 for (lldb::ModuleSP module_sp : target.GetImages().Modules()) {
   Address file_address;
   if (module_sp->ResolveFileAddress(m_options.symbol_containing_addr,
 file_address)) {
-get_range(file_address);
+get_ranges(file_address);
   }
 }
   }
@@ -292,9 +301,7 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
 m_options.symbol_containing_addr);
   }
 
-  if (llvm::Error err = CheckRangeSize(ranges[0], "the function"))
-return std::move(err);
-  return ranges;
+  return CheckRangeSize(std::move(ranges), "the function");
 }
 
 llv

[Lldb-commits] [lldb] [lldb] Support disassembling discontinuous functions (PR #126505)

2025-02-12 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits


@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;

Michael137 wrote:

Ah fair enough, reverted that for now

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


[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)

2025-02-12 Thread Matthew Bastien via lldb-commits

https://github.com/matthewbastien updated 
https://github.com/llvm/llvm-project/pull/126803

>From a07148100b02fa109cd3131d2d7742cdc0ae2bfa Mon Sep 17 00:00:00 2001
From: Matthew Bastien 
Date: Tue, 11 Feb 2025 16:38:43 -0500
Subject: [PATCH 1/2] add `debugAdapterExecutable` property to launch
 configuration

---
 lldb/tools/lldb-dap/package.json| 10 +-
 lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts |  9 +++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index e866af0602d70..d45c78432fa23 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -86,7 +86,7 @@
   "default": {},
   "description": "The environment of the lldb-dap process.",
   "additionalProperties": {
- "type": "string"
+"type": "string"
   }
 }
   }
@@ -152,6 +152,10 @@
   "program"
 ],
 "properties": {
+  "debugAdapterExecutable": {
+"type": "string",
+"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."
+  },
   "program": {
 "type": "string",
 "description": "Path to the program to debug."
@@ -338,6 +342,10 @@
   },
   "attach": {
 "properties": {
+  "debugAdapterExecutable": {
+"type": "string",
+"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."
+  },
   "program": {
 "type": "string",
 "description": "Path to the program to attach to."
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 55c2f3e9f7deb..e1c6bd4fd4300 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise {
 async function getDAPExecutable(
   session: vscode.DebugSession,
 ): Promise {
+  // Check if the executable was provided in the launch configuration.
+  const launchConfigPath = session.configuration["debugAdapterExecutable"];
+  if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) {
+return launchConfigPath;
+  }
+
+  // Check if the executable was provided in the extension's configuration.
   const config = vscode.workspace.getConfiguration(
 "lldb-dap",
 session.workspaceFolder,
   );
-
-  // Prefer the explicitly specified path in the extension's configuration.
   const configPath = config.get("executable-path");
   if (configPath && configPath.length !== 0) {
 return configPath;

>From 28b9097c12de0b3ef5fe4f083c54ff5d0963c6c7 Mon Sep 17 00:00:00 2001
From: Matthew Bastien 
Date: Wed, 12 Feb 2025 10:32:36 -0500
Subject: [PATCH 2/2] reword description of debugAdapterExecutable

---
 lldb/tools/lldb-dap/package.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index d45c78432fa23..edcae59867b53 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -154,7 +154,7 @@
 "properties": {
   "debugAdapterExecutable": {
 "type": "string",
-"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."
+"markdownDescription": "The absolute path to the LLDB debug 
adapter executable to use."
   },
   "program": {
 "type": "string",
@@ -344,7 +344,7 @@
 "properties": {
   "debugAdapterExecutable": {
 "type": "string",
-"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."
+"markdownDescription": "The absolute path to the LLDB debug 
adapter executable to use."
   },
   "program": {
 "type": "string",

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


[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)

2025-02-12 Thread Matthew Bastien via lldb-commits


@@ -152,6 +152,10 @@
   "program"
 ],
 "properties": {
+  "debugAdapterExecutable": {
+"type": "string",
+"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."

matthewbastien wrote:

Good catch. I changed the wording to make it clear that this must be an 
absolute path to the executable.

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


[Lldb-commits] [lldb] [lldb] Correctly resolve (discontinuous) function offsets when disassembling (PR #126925)

2025-02-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/126925

We need to iterate through the all symbol context ranges returned by (since 
#126505) SymbolContext::GetAddressRange. This also includes a fix to print the 
function offsets as signed values.

I've also wanted to check that the addresses which are in the middle of the 
function do *not* resolve to the function, but that's not entirely the case 
right now. This appears to be a separate issue though, so I've just left a TODO 
for now.

>From 7d01821bbf930005e7bf026f3c436616178718a2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 12 Feb 2025 16:07:50 +0100
Subject: [PATCH] [lldb] Correctly resolve (discontinuous) function offsets
 when disassembling

We need to iterate through the all symbol context ranges returned by
(since #126505) SymbolContext::GetAddressRange. This also includes a fix
to print the function offsets as signed values.

I've also wanted to check that the addresses which are in the middle of
the function do *not* resolve to the function, but that's not entirely
the case right now. This appears to be a separate issue though, so I've
just left a TODO for now.
---
 .../Disassembler/LLVMC/DisassemblerLLVMC.cpp   | 12 
 lldb/source/Symbol/SymbolContext.cpp   | 14 +-
 lldb/test/Shell/Commands/command-disassemble.s | 13 -
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 76f2db086476f..a77155f6bf41e 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -31,6 +31,7 @@
 
 #include "lldb/Core/Address.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
@@ -1806,10 +1807,13 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t 
value, uint64_t *type_ptr,
 bool format_omitting_current_func_name = false;
 if (sym_ctx.symbol || sym_ctx.function) {
   AddressRange range;
-  if (sym_ctx.GetAddressRange(resolve_scope, 0, false, range) &&
-  range.GetBaseAddress().IsValid() &&
-  range.ContainsLoadAddress(value_so_addr, target)) {
-format_omitting_current_func_name = true;
+  for (uint32_t idx = 0;
+   sym_ctx.GetAddressRange(resolve_scope, idx, false, range);
+   ++idx) {
+if (range.ContainsLoadAddress(value_so_addr, target)) {
+  format_omitting_current_func_name = true;
+  break;
+}
   }
 }
 
diff --git a/lldb/source/Symbol/SymbolContext.cpp 
b/lldb/source/Symbol/SymbolContext.cpp
index 4725df52ff559..183947a694363 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -104,15 +104,19 @@ bool SymbolContext::DumpStopContext(
 
 if (addr_t file_addr = addr.GetFileAddress();
 file_addr != LLDB_INVALID_ADDRESS) {
-  const addr_t function_offset =
-  file_addr - function->GetAddress().GetFileAddress();
+  // Avoiding signed arithmetic due to UB in -INT_MAX.
+  const char sign =
+  file_addr >= function->GetAddress().GetFileAddress() ? '+' : '-';
+  addr_t offset = file_addr - function->GetAddress().GetFileAddress();
+  if (sign == '-')
+offset = -offset;
   if (!show_function_name) {
 // Print +offset even if offset is 0
 dumped_something = true;
-s->Printf("+%" PRIu64 ">", function_offset);
-  } else if (function_offset) {
+s->Format("{0}{1}>", sign, offset);
+  } else if (offset) {
 dumped_something = true;
-s->Printf(" + %" PRIu64, function_offset);
+s->Format(" {0} {1}", sign, offset);
   }
 }
 
diff --git a/lldb/test/Shell/Commands/command-disassemble.s 
b/lldb/test/Shell/Commands/command-disassemble.s
index 951d96cefd4b9..eb84a9ce39d4a 100644
--- a/lldb/test/Shell/Commands/command-disassemble.s
+++ b/lldb/test/Shell/Commands/command-disassemble.s
@@ -84,7 +84,7 @@
 # CHECK-NEXT: command-disassemble.s.tmp[0x2044] <+0>: int$0x32
 # CHECK-NEXT: warning: Not disassembling a function because it is very large 
[0x2046-0x4046). To disassemble specify an instruction 
count limit, start/stop addresses or use the --force option.
 # CHECK-NEXT: (lldb) disassemble --name case3
-# CHECK-NEXT: error: Not disassembling a function because it is very large 
[0x6046-0x7046)[0x9046-0xa046). 
To disassemble specify an instruction count limit, start/stop addresses or use 
the --force option.
+# CHECK-NEXT: error: Not disassembling a function because it is very large 
[0x6046-0x7046)[0x0

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;

oontvoo wrote:

Ah, ok. gotcha. done

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,46 @@
+//===-- TelemetryVendor.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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(std::make_shared(
+  /*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}

labath wrote:

That's better, but can we now remove the method altogether (instead of just 
leaving it empty)? There should be no need to "initialize" the base class if 
it's not doing anything. Ideally, only the concrete vendor subclasses should 
need initialization (that is also how (most) our other plugins work, though it 
may not be the case with SymbolVendor, which I suspect you're drawing 
inspiration from))

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 1/8] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 2/8] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/lldb

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;

oontvoo wrote:

(done)

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 1/9] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 2/9] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/lldb

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Michael Buch via lldb-commits

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

>From d69bd14f285f5508abc35b60172efc8839b7c0fd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 12 Feb 2025 12:27:22 +
Subject: [PATCH 1/3] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue
 API

This patch adds a new API to `SBType` to retrieve the value of a
template parameter given an index. We re-use the
`TypeSystemClang::GetIntegralTemplateArgument` for this and thus currently only 
supports integral non-type template parameters. Types like float/double are not 
supported yet.

rdar://144395216
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h|  7 
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/source/API/SBType.cpp| 34 +++
 .../TestTemplatePackArgs.py   | 19 +--
 .../API/lang/cpp/template-arguments/Makefile  |  1 +
 .../TestCppTemplateArguments.py   | 32 +++--
 .../API/lang/cpp/template-arguments/main.cpp  |  5 +++
 8 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 9b97359d49cf9..bb912ab41d0fe 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -964,6 +964,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 63ba91082d576..9ad3244686328 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -221,6 +221,13 @@ class SBType {
 
   lldb::SBType GetTemplateArgumentType(uint32_t idx);
 
+  /// Returns the value of the non-type template parameter at index \c idx.
+  /// If \c idx is out-of-bounds or the template parameter doesn't have
+  /// a value, returns an empty SBValue.
+  ///
+  /// This function will expand parameter packs.
+  lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
+
   /// Return the TemplateArgumentKind of the template argument at index idx.
   /// Variadic argument packs are automatically expanded.
   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9090cece80f7c..46ef6daa95264 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -446,6 +446,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBType;
   friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 4cc16c64e4756..8d04e9650b781 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -687,6 +687,40 @@ lldb::TemplateArgumentKind 
SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+   uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+return SBValue();
+
+  std::optional arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+idx, expand_pack);
+break;
+  default:
+break;
+  }
+
+  if (!arg)
+return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  auto value_obj_sp = ValueObjectConstResult::Create(
+  target.GetSP().get(), arg->type, ConstString("value"), data);
+  return SBValue(std::move(value_obj_sp));
+}
+
 SBType SBType::FindDirectNestedType(const char *name) {
   LLDB_INSTRUMENT_VA(this, name);
 
diff --git 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
index c571357ff6720..f2467cbea9439 100644
--- 
a/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
+++ 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
@@ -11,7 +11,7 @@
 class TemplatePackArgsTestCase(TestBase):
 def test_template_argument_pack(self):
 self.build()
-(_, _, thread, _) = lldbutil.run_to_source_breakpoint(
+(target, _, thread, _) = lldbutil.run_to_source_breakpoint(
 self, "breakpoint here", lldb.SBFileSpec("main.cpp"), 
exe_name="a.out"
 )
 frame = thread.GetSelectedFrame()
@@ -33,10 +33,25 @@ def test_template_argument_pack(self):
 self.assertEqual(
 only_pack

[Lldb-commits] [lldb] [lldb] Correctly resolve (discontinuous) function offsets when disassembling (PR #126925)

2025-02-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

We need to iterate through the all symbol context ranges returned by (since 
#126505) SymbolContext::GetAddressRange. This also includes a fix to 
print the function offsets as signed values.

I've also wanted to check that the addresses which are in the middle of the 
function do *not* resolve to the function, but that's not entirely the case 
right now. This appears to be a separate issue though, so I've just left a TODO 
for now.

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


3 Files Affected:

- (modified) lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
(+8-4) 
- (modified) lldb/source/Symbol/SymbolContext.cpp (+9-5) 
- (modified) lldb/test/Shell/Commands/command-disassemble.s (+8-5) 


``diff
diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 76f2db086476f..a77155f6bf41e 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -31,6 +31,7 @@
 
 #include "lldb/Core/Address.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
@@ -1806,10 +1807,13 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t 
value, uint64_t *type_ptr,
 bool format_omitting_current_func_name = false;
 if (sym_ctx.symbol || sym_ctx.function) {
   AddressRange range;
-  if (sym_ctx.GetAddressRange(resolve_scope, 0, false, range) &&
-  range.GetBaseAddress().IsValid() &&
-  range.ContainsLoadAddress(value_so_addr, target)) {
-format_omitting_current_func_name = true;
+  for (uint32_t idx = 0;
+   sym_ctx.GetAddressRange(resolve_scope, idx, false, range);
+   ++idx) {
+if (range.ContainsLoadAddress(value_so_addr, target)) {
+  format_omitting_current_func_name = true;
+  break;
+}
   }
 }
 
diff --git a/lldb/source/Symbol/SymbolContext.cpp 
b/lldb/source/Symbol/SymbolContext.cpp
index 4725df52ff559..183947a694363 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -104,15 +104,19 @@ bool SymbolContext::DumpStopContext(
 
 if (addr_t file_addr = addr.GetFileAddress();
 file_addr != LLDB_INVALID_ADDRESS) {
-  const addr_t function_offset =
-  file_addr - function->GetAddress().GetFileAddress();
+  // Avoiding signed arithmetic due to UB in -INT_MAX.
+  const char sign =
+  file_addr >= function->GetAddress().GetFileAddress() ? '+' : '-';
+  addr_t offset = file_addr - function->GetAddress().GetFileAddress();
+  if (sign == '-')
+offset = -offset;
   if (!show_function_name) {
 // Print +offset even if offset is 0
 dumped_something = true;
-s->Printf("+%" PRIu64 ">", function_offset);
-  } else if (function_offset) {
+s->Format("{0}{1}>", sign, offset);
+  } else if (offset) {
 dumped_something = true;
-s->Printf(" + %" PRIu64, function_offset);
+s->Format(" {0} {1}", sign, offset);
   }
 }
 
diff --git a/lldb/test/Shell/Commands/command-disassemble.s 
b/lldb/test/Shell/Commands/command-disassemble.s
index 951d96cefd4b9..eb84a9ce39d4a 100644
--- a/lldb/test/Shell/Commands/command-disassemble.s
+++ b/lldb/test/Shell/Commands/command-disassemble.s
@@ -84,7 +84,7 @@
 # CHECK-NEXT: command-disassemble.s.tmp[0x2044] <+0>: int$0x32
 # CHECK-NEXT: warning: Not disassembling a function because it is very large 
[0x2046-0x4046). To disassemble specify an instruction 
count limit, start/stop addresses or use the --force option.
 # CHECK-NEXT: (lldb) disassemble --name case3
-# CHECK-NEXT: error: Not disassembling a function because it is very large 
[0x6046-0x7046)[0x9046-0xa046). 
To disassemble specify an instruction count limit, start/stop addresses or use 
the --force option.
+# CHECK-NEXT: error: Not disassembling a function because it is very large 
[0x6046-0x7046)[0x9046-0xa050). 
To disassemble specify an instruction count limit, start/stop addresses or use 
the --force option.
 # CHECK-NEXT: Not disassembling a function because it is very large 
[0x4046-0x6046). To disassemble specify an instruction 
count limit, start/stop addresses or use the --force option.
 # CHECK-NEXT: (lldb) disassemble --name case3 --count 3
 # CHECK-NEXT: command-disassemble.s.tmp`n2::case3:
@@ -93,9 +93,10 @@
 # CHECK-NEXT: command-disassemble.s.tmp[0x604a] <-12284>: int$0x2a
 # CHECK-EMPTY:
 # CHECK-NEXT: command-disassemble.s.tmp`n2::

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 1/7] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 2/7] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/lldb

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,46 @@
+//===-- TelemetryVendor.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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(std::make_shared(
+  /*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}

oontvoo wrote:

done

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,46 @@
+//===-- TelemetryVendor.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
+//
+//===--===//
+#ifdef LLDB_BUILD_TELEMETRY
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(std::make_shared(
+  /*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+lldb::TelemetryConfigSP TelemetryVendor::GetTelemetryConfig() {
+  static lldb::TelemetryConfigSP g_config_sp;
+  return g_config_sp;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+const lldb::TelemetryConfigSP &config) {
+  GetTelemetryCOnfig() = config;
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;

oontvoo wrote:

done (will use unique_ptr)

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


[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits


@@ -152,6 +152,10 @@
   "program"
 ],
 "properties": {
+  "debugAdapterExecutable": {
+"type": "string",
+"markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."

vogelsgesang wrote:

Thanks, looks good to me :)

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


[Lldb-commits] [lldb] [lldb-dap] Fix: Could not find DAP in path (PR #126903)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits

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

good find! LGTM

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


[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits

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


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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/10] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/10] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> This is definitely better than what you had before, but I still think it's 
> more complicated than it needs to be. For one, I'd like to understand why is 
> there a need for separate `TelemetryManager` and `TelemetryConfig` fields. If 
> the downstream implementation is going to be in charge of creating the 
> telemetry manager, why does it need to bother with calling 
> `SetTelemetryConfig`?

Sorry, missed this comment some how. 
Yeah, that's a good point. I've removed the new class and just define the 
static TelemetryManager::getInstance  

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/11] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/11] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

2025-02-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/126935

Currently we're creating inheritable (`~FD_CLOEXEC`) file descriptors in the 
(few) cases where we need to pass an FD to a subprocess. The problem with these 
is that, in a multithreaded application such as lldb, there's essentially no 
way to prevent them from being leaked into processes other than the intended 
one.

A safer (though still not completely safe) approach is to mark the descriptors 
as FD_CLOEXEC and only clear this flag in the subprocess. We currently have 
something that almost does that, which is the ability to add a 
`DuplicateFileAction` to our `ProcessLaunchInfo` struct (the duplicated file 
descriptor will be created with the flag cleared). The problem with *that* is 
that this approach is completely incompatible with Windows.

Windows equivalents of file descriptors are `HANDLE`s, but these do not have 
user controlled values -- applications are expected to work with whatever 
HANDLE values are assigned by the OS. In unix terms, there is no equivalent to 
the `dup2` syscall (only `dup`).

To find a way out of this conundrum, and create a miniscule API surface that 
works uniformly across platforms, this PR proposes to extend the 
`DuplicateFileAction` API to support duplicating a file descriptor onto itself. 
Currently, this operation does nothing (it leaves the FD_CLOEXEC flag set), 
because that's how `dup2(fd, fd)` behaves, but I think it's not completely 
unreasonable to say that this operation should clear the FD_CLOEXEC flag, just 
like it would do if one was using different fd values. This would enable us to 
pass a windows HANDLE as itself through the ProcessLaunchInfo API.

This PR implements the unix portion of this idea. Macos and non-macos launchers 
are updated to clear FD_CLOEXEC flag when duplicating a file descriptor onto 
itself, and I've created a test which enables passing a FD_CLOEXEC file 
descritor to the subprocess. For the windows portion, please see the follow-up 
PR.

>From 75e6dd4f81a9fe4bd303ba4e3b0301b69d47b523 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Sun, 20 Oct 2024 02:55:02 +0200
Subject: [PATCH] [lldb/Host] Enable inheriting "non-inheritable" FDs

Currently we're creating inheritable (`~FD_CLOEXEC`) file descriptors in
the (few) cases where we need to pass an FD to a subprocess. The problem
with these is that, in a multithreaded application such as lldb, there's
essentially no way to prevent them from being leaked into processes
other than the intended one.

A safer (though still not completely safe) approach is to mark the
descriptors as FD_CLOEXEC and only clear this flag in the subprocess. We
currently have something that almost does that, which is the ability to
add a `DuplicateFileAction` to our `ProcessLaunchInfo` struct (the
duplicated file descriptor will be created with the flag cleared). The
problem with *that* is that this approach is completely incompatible
with Windows.

Windows equivalents of file descriptors are `HANDLE`s, but these do not
have user controlled values -- applications are expected to work with
whatever HANDLE values are assigned by the OS. In unix terms, there is
no equivalent to the `dup2` syscall (only `dup`).

To find a way out of this conundrum, and create a miniscule API surface
that works uniformly across platforms, this PR proposes to extend the
`DuplicateFileAction` API to support duplicating a file descriptor onto
itself. Currently, this operation does nothing (it leaves the FD_CLOEXEC
flag set), because that's how `dup2(fd, fd)` behaves, but I think it's
not completely unreasonable to say that this operation should clear the
FD_CLOEXEC flag, just like it would do if one was using different fd
values. This would enable us to pass a windows HANDLE as itself through
the ProcessLaunchInfo API.

This PR implements the unix portion of this idea. Macos and non-macos
launchers are updated to clear FD_CLOEXEC flag when duplicating a file
descriptor onto itself, and I've created a test which enables passing a
FD_CLOEXEC file descritor to the subprocess. For the windows portion,
please see the follow-up PR.
---
 lldb/source/Host/macosx/objcxx/Host.mm| 11 +++-
 .../Host/posix/ProcessLauncherPosixFork.cpp   | 11 +++-
 lldb/unittests/Host/HostTest.cpp  | 55 ++-
 3 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 5b3d04a6b587b..38edac45dedbd 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -1100,7 +1100,7 @@ static bool AddPosixSpawnFileAction(void *_file_actions, 
const FileAction *info,
 else if (info->GetActionArgument() == -1)
   error = Status::FromErrorString(
   "invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");
-else {
+else if (info->GetFD() != info->GetActionArgument()) {
   error =
   St

[Lldb-commits] [lldb] [lldb-dap] Ensure we do not print the close sentinel when closing stdout. (PR #126833)

2025-02-12 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Ensure we do not print the close sentinel when closing stdout. (PR #126833)

2025-02-12 Thread Pavel Labath via lldb-commits


@@ -58,16 +56,19 @@ Error 
OutputRedirector::RedirectTo(std::function callback) {
 char buffer[OutputBufferSize];
 while (!m_stopped) {
   ssize_t bytes_count = ::read(read_fd, &buffer, sizeof(buffer));
-  // EOF detected.
-  if (bytes_count == 0)
-break;
   if (bytes_count == -1) {
 // Skip non-fatal errors.
 if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)
   continue;
 break;
   }
 
+  StringRef data(buffer, bytes_count);
+  if (m_stopped)
+data.consume_back(kCloseSentinel);
+  if (data.empty())
+break;
+
   callback(StringRef(buffer, bytes_count));

labath wrote:

```suggestion
  callback(data);
```

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


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] 73ab0c0 - [lldb-dap] Upgrade @types/node to fix TS2386 in node/module.d.ts (#126994)

2025-02-12 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-02-12T19:09:09-08:00
New Revision: 73ab0c076215125a249eee117f51f2ce4f5f9b50

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

LOG: [lldb-dap] Upgrade @types/node to fix TS2386 in node/module.d.ts (#126994)

Upgrade @types/node to work around an issue in TypeScript [1] that
caused our "publish to VSCode Marketplace" github action [2] to fail:

```
node_modules/@types/node/module.d.ts:290:13 - error TS2386: Overload signatures 
must all be optional or required.

290 resolve?(specified: string, parent?: string | URL): 
Promise;
```

[1] https://github.com/microsoft/TypeScript/pull/59259#issuecomment-2228833941
[2] https://github.com/llvm/vscode-lldb/actions/runs/13298213337/job/37134713009

Added: 


Modified: 
lldb/tools/lldb-dap/package-lock.json
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/tools/lldb-dap/package-lock.json 
b/lldb/tools/lldb-dap/package-lock.json
index 4c18474241421..ab5c7dc33a8e5 100644
--- a/lldb/tools/lldb-dap/package-lock.json
+++ b/lldb/tools/lldb-dap/package-lock.json
@@ -1,15 +1,15 @@
 {
   "name": "lldb-dap",
-  "version": "0.2.9",
+  "version": "0.2.10",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
 "": {
   "name": "lldb-dap",
-  "version": "0.2.9",
+  "version": "0.2.10",
   "license": "Apache 2.0 License with LLVM exceptions",
   "devDependencies": {
-"@types/node": "^18.11.18",
+"@types/node": "^18.19.41",
 "@types/vscode": "1.75.0",
 "@vscode/vsce": "^3.2.2",
 "prettier": "^3.4.2",
@@ -389,10 +389,11 @@
   }
 },
 "node_modules/@types/node": {
-  "version": "18.19.6",
-  "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.6.tgz";,
-  "integrity": 
"sha512-X36s5CXMrrJOs2lQCdDF68apW4Rfx9ixYMawlepwmE4Anezv/AV2LSpKD1Ub8DAc+urp5bk0BGZ6NtmBitfnsg==",
+  "version": "18.19.75",
+  "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.75.tgz";,
+  "integrity": 
"sha512-UIksWtThob6ZVSyxcOqCLOUNg/dyO1Qvx4McgeuhrEtHTLFTf7BBhEazaE4K806FGTPtzd/2sE90qn4fVr7cyw==",
   "dev": true,
+  "license": "MIT",
   "dependencies": {
 "undici-types": "~5.26.4"
   }

diff  --git a/lldb/tools/lldb-dap/package.json 
b/lldb/tools/lldb-dap/package.json
index 12d143babfd73..31d808eda4c35 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -27,7 +27,7 @@
 "Debuggers"
   ],
   "devDependencies": {
-"@types/node": "^18.11.18",
+"@types/node": "^18.19.41",
 "@types/vscode": "1.75.0",
 "@vscode/vsce": "^3.2.2",
 "prettier-plugin-curly": "^0.3.1",



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


[Lldb-commits] [lldb] [lldb-dap] Upgrade @types/node to fix TS2386 in node/module.d.ts (PR #126994)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits


@@ -3801,6 +3801,23 @@ void request_variables(const llvm::json::Object 
&request) {
   variable_name_counts[GetNonNullVariableName(variable)]++;
 }
 
+// Show return value if there is any ( in the top frame )

vogelsgesang wrote:

should we add a release not for this?

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


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits


@@ -3801,6 +3801,23 @@ void request_variables(const llvm::json::Object 
&request) {
   variable_name_counts[GetNonNullVariableName(variable)]++;
 }
 
+// Show return value if there is any ( in the top frame )
+auto process = g_dap.target.GetProcess();
+auto selected_thread = process.GetSelectedThread();
+lldb::SBValue stop_return_value = selected_thread.GetStopReturnValue();
+if (stop_return_value.IsValid() &&
+(selected_thread.GetSelectedFrame().GetFrameID() == 0)) {
+  auto renamed_return_value = stop_return_value.Clone("(Return Value)");
+  int64_t return_ref = 0;
+  if (stop_return_value.MightHaveChildren() ||
+  stop_return_value.IsSynthetic()) {
+return_ref = g_dap.variables.InsertExpandableVariable(
+stop_return_value, /*is_permanent=*/false);
+  }
+  variables.emplace_back(CreateVariable(renamed_return_value, return_ref,
+UINT64_MAX, hex, false));

vogelsgesang wrote:

aren't we also adding the return value to the "globals" and the "registers" 
group here? I assume it should only be part of "Locals"?

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


[Lldb-commits] [lldb] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-12 Thread Adrian Vogelsgesang via lldb-commits


@@ -663,6 +663,41 @@ def do_test_indexedVariables(self, 
enableSyntheticChildDebugging: bool):
 ]["variables"]
 self.verify_variables(verify_children, children)
 
+def test_return_variables(self):
+"""
+Test the stepping out of a function with return value show the 
variable correctly.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+verify_locals = {
+"(Return Value)": {"equals": {"type": "int", "value": "300"}},
+"argc": {},
+"argv": {},
+"pt": {},
+"x": {},
+"return_result": {"equals": {"type": "int"}},
+}
+
+function_name = "test_return_variable"
+breakpoint_ids = self.set_function_breakpoints([function_name])
+
+self.assertEqual(len(breakpoint_ids), 1)
+self.continue_to_breakpoints(breakpoint_ids)
+
+threads = self.dap_server.get_threads()
+for thread in threads:
+if thread.get("reason") == "breakpoint":
+# We have a thread that

vogelsgesang wrote:

incomplete sentence

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


[Lldb-commits] [lldb] [lldb-dap] add `debugAdapterExecutable` property to launch configuration (PR #126803)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

LGTM!

> @tedwoodward does this PR also address your request in #123842, or did you 
> have something else in mind?

I was thinking the same thing. I'm pretty sure this is doing exactly what Ted's 
asking for. 


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


[Lldb-commits] [lldb] [lldb-dap] Fix: Could not find DAP in path (PR #126903)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

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

Thank you!

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


[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> I understand the issue in point two--this patch may unnecessarily require a 
> separate tinfo library even when the headers and objects are available via 
> ncurses. But could you explain more on your recommended solutions, 
> particularly on why we would need to set an optional variable?
> 
> If we're going to require a CMAKE flag anyways to show a warning, why not 
> just guard it on a `LLDB_USE_SEPARATE_TERMINFO=ON` flag and not worry about 
> autodetection? It's already breaking with a link time error, surely that's a 
> louder signal than a configure-time warning.

Yes, you could do that, but then platforms that have a separate `terminfo` 
library need to remember to turn this on. If they don't they'll hit the link 
time warning you mentioned and then need to remember or find the appropriate 
variable. The advantage of the auto detection is that it works out of the box: 
if CMake can find the library, we'll link against it, if not then we won't. 
Anyway, doing that means adding a module to find it, and maybe that's overkill 
for `terminfo` as it presumably only affects a small subset of platforms. So 
I'm fine with either. 

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


[Lldb-commits] [lldb] [lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC) (PR #126972)

2025-02-12 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/126972

None

>From 3a8b692f3dffc280c2e4cbbbd4041a9cd334c5f7 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Wed, 12 Feb 2025 12:56:34 -0800
Subject: [PATCH] [lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC)

---
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp| 33 +++
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 6d92a204b86cc..609968bf0bde2 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -861,14 +861,9 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
   for (const auto &entry : m_binary->export_directories()) {
 llvm::StringRef sym_name;
 if (auto err = entry.getSymbolName(sym_name)) {
-  if (log)
-log->Format(
-__FILE__, __func__,
-"ObjectFilePECOFF::AppendFromExportTable - failed to get export "
-"table entry name: {0}",
-llvm::fmt_consume(std::move(err)));
-  else
-llvm::consumeError(std::move(err));
+  LLDB_LOG_ERROR(log, std::move(err),
+ "ObjectFilePECOFF::AppendFromExportTable - failed to get "
+ "export table entry name: {0}");
   continue;
 }
 Symbol symbol;
@@ -886,13 +881,10 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
   // it in symtab and make a note using the symbol name.
   llvm::StringRef forwarder_name;
   if (auto err = entry.getForwardTo(forwarder_name)) {
-if (log)
-  log->Format(__FILE__, __func__,
-  "ObjectFilePECOFF::AppendFromExportTable - failed to get 
"
-  "forwarder name of forwarder export '{0}': {1}",
-  sym_name, llvm::fmt_consume(std::move(err)));
-else
-  llvm::consumeError(std::move(err));
+LLDB_LOG_ERROR(log, std::move(err),
+   "ObjectFilePECOFF::AppendFromExportTable - failed to "
+   "get forwarder name of forwarder export '{1}': {0}",
+   sym_name);
 continue;
   }
   llvm::SmallString<256> new_name = 
{symbol.GetDisplayName().GetStringRef(),
@@ -904,13 +896,10 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
 
 uint32_t function_rva;
 if (auto err = entry.getExportRVA(function_rva)) {
-  if (log)
-log->Format(__FILE__, __func__,
-"ObjectFilePECOFF::AppendFromExportTable - failed to get "
-"address of export entry '{0}': {1}",
-sym_name, llvm::fmt_consume(std::move(err)));
-  else
-llvm::consumeError(std::move(err));
+  LLDB_LOG_ERROR(log, std::move(err),
+ "ObjectFilePECOFF::AppendFromExportTable - failed to get "
+ "address of export entry '{1}': {0}",
+ sym_name);
   continue;
 }
 // Skip the symbol if it doesn't look valid.

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


[Lldb-commits] [lldb] [lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC) (PR #126972)

2025-02-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes



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


1 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
(+11-22) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 6d92a204b86cc..609968bf0bde2 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -861,14 +861,9 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
   for (const auto &entry : m_binary->export_directories()) {
 llvm::StringRef sym_name;
 if (auto err = entry.getSymbolName(sym_name)) {
-  if (log)
-log->Format(
-__FILE__, __func__,
-"ObjectFilePECOFF::AppendFromExportTable - failed to get export "
-"table entry name: {0}",
-llvm::fmt_consume(std::move(err)));
-  else
-llvm::consumeError(std::move(err));
+  LLDB_LOG_ERROR(log, std::move(err),
+ "ObjectFilePECOFF::AppendFromExportTable - failed to get "
+ "export table entry name: {0}");
   continue;
 }
 Symbol symbol;
@@ -886,13 +881,10 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
   // it in symtab and make a note using the symbol name.
   llvm::StringRef forwarder_name;
   if (auto err = entry.getForwardTo(forwarder_name)) {
-if (log)
-  log->Format(__FILE__, __func__,
-  "ObjectFilePECOFF::AppendFromExportTable - failed to get 
"
-  "forwarder name of forwarder export '{0}': {1}",
-  sym_name, llvm::fmt_consume(std::move(err)));
-else
-  llvm::consumeError(std::move(err));
+LLDB_LOG_ERROR(log, std::move(err),
+   "ObjectFilePECOFF::AppendFromExportTable - failed to "
+   "get forwarder name of forwarder export '{1}': {0}",
+   sym_name);
 continue;
   }
   llvm::SmallString<256> new_name = 
{symbol.GetDisplayName().GetStringRef(),
@@ -904,13 +896,10 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList 
*sect_list,
 
 uint32_t function_rva;
 if (auto err = entry.getExportRVA(function_rva)) {
-  if (log)
-log->Format(__FILE__, __func__,
-"ObjectFilePECOFF::AppendFromExportTable - failed to get "
-"address of export entry '{0}': {1}",
-sym_name, llvm::fmt_consume(std::move(err)));
-  else
-llvm::consumeError(std::move(err));
+  LLDB_LOG_ERROR(log, std::move(err),
+ "ObjectFilePECOFF::AppendFromExportTable - failed to get "
+ "address of export entry '{1}': {0}",
+ sym_name);
   continue;
 }
 // Skip the symbol if it doesn't look valid.

``




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


[Lldb-commits] [lldb] [lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC) (PR #126972)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use LLDB_LOG_ERROR in ObjectFilePECOFF.cpp (NFC) (PR #126972)

2025-02-12 Thread Saleem Abdulrasool via lldb-commits

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

Thanks for cleaning this up!

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


[Lldb-commits] [lldb] [lldb] Remove Debugger::Get{Output, Error}Stream (NFC) (PR #126821)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] eff3c34 - [lldb] Remove Debugger::Get{Output, Error}Stream (NFC) (#126821)

2025-02-12 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-02-12T08:29:06-08:00
New Revision: eff3c343b08cfc46016708b3182ac062d45b3e21

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

LOG: [lldb] Remove Debugger::Get{Output,Error}Stream (NFC) (#126821)

Remove Debugger::GetOutputStream and Debugger::GetErrorStream in
preparation for replacing both with a new variant that needs to be
locked and hence can't be handed out like we do right now.

The patch replaces most uses with GetAsyncOutputStream and
GetAsyncErrorStream respectively. There methods return new StreamSP
objects that automatically get flushed on destruction.

See #126630 for more details.

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/source/API/SBDebugger.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Core/DynamicLoader.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/ThreadPlanTracer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 70f4c4216221c..d7751ca045bb2 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -143,10 +143,6 @@ class Debugger : public 
std::enable_shared_from_this,
 
   File &GetErrorFile() { return m_error_stream_sp->GetFile(); }
 
-  StreamFile &GetOutputStream() { return *m_output_stream_sp; }
-
-  StreamFile &GetErrorStream() { return *m_error_stream_sp; }
-
   repro::DataRecorder *GetInputRecorder();
 
   Status SetInputString(const char *data);

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index bdb8e538b99f8..bf19d2ff8333c 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -508,39 +508,31 @@ SBFile SBDebugger::GetInputFile() {
 
 FILE *SBDebugger::GetOutputFileHandle() {
   LLDB_INSTRUMENT_VA(this);
-  if (m_opaque_sp) {
-StreamFile &stream_file = m_opaque_sp->GetOutputStream();
-return stream_file.GetFile().GetStream();
-  }
+  if (m_opaque_sp)
+return m_opaque_sp->GetOutputStreamSP()->GetFile().GetStream();
   return nullptr;
 }
 
 SBFile SBDebugger::GetOutputFile() {
   LLDB_INSTRUMENT_VA(this);
-  if (m_opaque_sp) {
-SBFile file(m_opaque_sp->GetOutputStream().GetFileSP());
-return file;
-  }
+  if (m_opaque_sp)
+return SBFile(m_opaque_sp->GetOutputStreamSP()->GetFileSP());
   return SBFile();
 }
 
 FILE *SBDebugger::GetErrorFileHandle() {
   LLDB_INSTRUMENT_VA(this);
 
-  if (m_opaque_sp) {
-StreamFile &stream_file = m_opaque_sp->GetErrorStream();
-return stream_file.GetFile().GetStream();
-  }
+  if (m_opaque_sp)
+return m_opaque_sp->GetErrorStreamSP()->GetFile().GetStream();
   return nullptr;
 }
 
 SBFile SBDebugger::GetErrorFile() {
   LLDB_INSTRUMENT_VA(this);
   SBFile file;
-  if (m_opaque_sp) {
-SBFile file(m_opaque_sp->GetErrorStream().GetFileSP());
-return file;
-  }
+  if (m_opaque_sp)
+return SBFile(m_opaque_sp->GetErrorStreamSP()->GetFileSP());
   return SBFile();
 }
 
@@ -581,8 +573,8 @@ void SBDebugger::HandleCommand(const char *command) {
 
 sb_interpreter.HandleCommand(command, result, false);
 
-result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
-result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
+result.PutError(m_opaque_sp->GetErrorStreamSP()->GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStreamSP()->GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 2df2aeb20aa26..18569e155b517 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -257,12 +257,11 @@ Status Debugger::SetPropertyValue(const ExecutionContext 
*exe_ctx,
 std::list errors;
 StreamString feedback_stream;
 if (!target_sp->LoadScriptingResources(errors, feedback_stream)) {
-  Stream &s = GetErrorStream();
-  for (auto &error : errors) {
-s.Printf("%s\n", error.AsCString());
-  }
+  lldb::StreamSP s = GetAsyncErrorStream();
+  for (auto &e

[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

2025-02-12 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)

2025-02-12 Thread Jordan R AW via lldb-commits

ajordanr-google wrote:

> This isn't using TINFO_LIBRARIES anywhere. Presumably you'll need to add it 
> to LLDB_CURSES_LIBS like the original spack patch.

Hmm. This patch does seem to work locally, so it's not _required_. I would have 
thought the logic is entirely in the `find_package` invocation, and the 
variables are just for the `if` check. But no issue adding it to the 
`LLDB_CURSES_LIBS`, will do that now!

---

I understand the issue in point two--this patch may unnecessarily require a 
separate tinfo library even when the headers and objects are available via 
ncurses. But could you explain more on your recommended solutions, particularly 
on why we would need to set an optional variable? 

If we're going to require a CMAKE flag anyways to show a warning, why not just 
guard it on a `LLDB_USE_SEPARATE_TERMINFO=ON` flag and not worry about 
autodetection? It's already breaking with a link time error, surely that's a 
louder signal than a configure-time warning.

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/15] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/15] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/16] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/16] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)

2025-02-12 Thread Jordan R AW via lldb-commits

ajordanr-google wrote:

Thanks, this does clear it up! Yeah I'd rather have it work out of the bod.

I'll see what I can do for doing the autodetection ergonomically, and get back 
to you. If not, I'll add a flag.

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


[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/17] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/17] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] Define Telemetry plugin for LLDB. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Define Telemetry plugin. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Define Telemetry plugin for LLDB. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/126588

>From c7734011094995c64137de6f8122033d2a981610 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 10 Feb 2025 14:44:11 -0500
Subject: [PATCH 01/17] Define TelemetryVendor plugin.

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a 
default Config and NULL TelemetryManager.
Downstream vendors can extend this to provide a vendor-specific Config along 
with a functional TelemetryManager instance.
---
 lldb/include/lldb/Core/TelemetryVendor.h | 39 +
 lldb/source/Core/TelemetryVendor.cpp | 43 
 2 files changed, 82 insertions(+)
 create mode 100644 lldb/include/lldb/Core/TelemetryVendor.h
 create mode 100644 lldb/source/Core/TelemetryVendor.cpp

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 0..a2ab3b69fde42
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include 
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp 
b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 0..520a01b9b1c7a
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.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/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+  std::make_unique(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr current_config;
+std::unique_ptr TelemetryVendor::GetTelemetryConfig() 
{
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+std::unique_ptr config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

>From 5f6a04de76a5bf633ca9d14d9907d535301c5c59 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Feb 2025 10:31:00 -0500
Subject: [PATCH 02/17] use shared ptr

---
 lldb/include/lldb/Core/TelemetryVendor.h |  7 ---
 lldb/include/lldb/lldb-forward.h |  5 +
 lldb/source/Core/TelemetryVendor.cpp | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Core/TelemetryVendor.h 
b/lldb/include/lldb/Core/TelemetryVendor.h
index a2ab3b69fde42..a55f06fb9141f 100644
--- a/lldb/include/lldb/Core/TelemetryVendor.h
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -27,11 +27,12 @@ class TelemetryVendor : public PluginInterface {
 
   static void Terminate();
 
-  static std::unique_ptr GetTelemetryConfig();
-  static void
-  SetTelemetryConfig(std::unique_ptr config);
+  static lldb::TelemetryConfig GetTelemetryConfig();
+
+  static void SetTelemetryConfig(const lldb::TelemetryConfigSP &config);
 
   static lldb::TelemetryManagerSP GetTelemetryManager();
+
   static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
 };
 
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index fc7456a4b9a32..2f2a4ec86a1fb 100644
--- a/lldb/include/lldb/

[Lldb-commits] [lldb] Define Telemetry plugin for LLDB. (PR #126588)

2025-02-12 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add terminfo dependency for ncurses support (PR #126810)

2025-02-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

- This isn't using `TINFO_LIBRARIES` anywhere. Presumably you'll need to add it 
to `LLDB_CURSES_LIBS` like the original spack patch.
- This doesn't work on systems that have `ncruses` and `panel`, but no separate 
`terminfo` library.  The purpose of the CMake module is to find `ncurses` and 
`panel` as a unit, and we don't want to fail if `terminfo` is part of 
`ncurses`, which is what happens with the current patch. I don't know if 
there's a way to set optional variables through (at least not at first glance), 
in which case we might need to auto-detect it with `add_optional_dependency` 
and a separate module for finding it. The auto-detection should make that work 
out of the box on all platforms and platforms that know they need `terminfo` 
can set the CMake flag to "on" to force a configuration time warning if it's 
not found.  


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


  1   2   >