[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/112895

>From cc3a4a94e9e2eb8b4cf763d4c8c477c71776ee93 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 16 Oct 2024 17:34:53 +0200
Subject: [PATCH 1/2] [lldb] Add timed callbacks to the MainLoop class

The motivating use case is being able to "time out" certain operations
(by adding a timed callback which will force the termination of the
loop), but the design is flexible enough to accomodate other use cases
as well (e.g. running a periodic task in the background).

The implementation builds on the existing "pending callback" mechanism,
by associating a time point with each callback -- every time the loop
wakes up, it runs all of the callbacks which are past their point, and
it also makes sure to sleep only until the next callback is scheduled to
run.

I've done some renaming as names like "TriggerPendingCallbacks" were
no longer accurate -- the function may no longer cause any callbacks to be
called (it may just cause the main loop thread to recalculate the time
it wants to sleep).
---
 lldb/include/lldb/Host/MainLoopBase.h | 33 --
 lldb/include/lldb/Host/posix/MainLoopPosix.h  |  6 +-
 .../lldb/Host/windows/MainLoopWindows.h   |  4 +-
 lldb/source/Host/common/MainLoopBase.cpp  | 40 
 lldb/source/Host/posix/MainLoopPosix.cpp  | 63 +-
 lldb/source/Host/windows/MainLoopWindows.cpp  | 37 +++
 lldb/unittests/Host/MainLoopTest.cpp  | 64 +--
 7 files changed, 191 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Host/MainLoopBase.h 
b/lldb/include/lldb/Host/MainLoopBase.h
index 7365ee7a65ee64..0b79c52a358f4b 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -13,8 +13,10 @@
 #include "lldb/Utility/Status.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 
@@ -38,6 +40,9 @@ class MainLoopBase {
   class ReadHandle;
 
 public:
+  using TimePoint = std::chrono::time_point;
+
   MainLoopBase() : m_terminate_request(false) {}
   virtual ~MainLoopBase() = default;
 
@@ -52,7 +57,19 @@ class MainLoopBase {
   // Add a pending callback that will be executed once after all the pending
   // events are processed. The callback will be executed even if termination
   // was requested.
-  void AddPendingCallback(const Callback &callback);
+  void AddPendingCallback(const Callback &callback) {
+AddCallback(callback, std::chrono::steady_clock::time_point());
+  }
+
+  // Add a callback that will be executed after a certain amount of time has
+  // passed.
+  void AddCallback(const Callback &callback,
+   std::chrono::nanoseconds delay) {
+AddCallback(callback, std::chrono::steady_clock::now() + delay);
+  }
+
+  // Add a callback that will be executed after a given point in time.
+  void AddCallback(const Callback &callback, TimePoint point);
 
   // Waits for registered events and invoke the proper callbacks. Returns when
   // all callbacks deregister themselves or when someone requests termination.
@@ -69,14 +86,18 @@ class MainLoopBase {
 
   virtual void UnregisterReadObject(IOObject::WaitableHandle handle) = 0;
 
-  // Interrupt the loop that is currently waiting for events and execute
-  // the current pending callbacks immediately.
-  virtual void TriggerPendingCallbacks() = 0;
+  // Interrupt the loop that is currently waiting for events.
+  virtual void Interrupt() = 0;
+
+  void ProcessCallbacks();
 
-  void ProcessPendingCallbacks();
+  std::optional GetNextWakeupTime();
 
   std::mutex m_callback_mutex;
-  std::vector m_pending_callbacks;
+  std::priority_queue,
+  std::vector>,
+  llvm::on_first>>
+  m_callbacks;
   bool m_terminate_request : 1;
 
 private:
diff --git a/lldb/include/lldb/Host/posix/MainLoopPosix.h 
b/lldb/include/lldb/Host/posix/MainLoopPosix.h
index 07497b7b8c259a..bff96583bf5424 100644
--- a/lldb/include/lldb/Host/posix/MainLoopPosix.h
+++ b/lldb/include/lldb/Host/posix/MainLoopPosix.h
@@ -54,7 +54,7 @@ class MainLoopPosix : public MainLoopBase {
   void UnregisterReadObject(IOObject::WaitableHandle handle) override;
   void UnregisterSignal(int signo, std::list::iterator callback_it);
 
-  void TriggerPendingCallbacks() override;
+  void Interrupt() override;
 
 private:
   void ProcessReadObject(IOObject::WaitableHandle handle);
@@ -87,8 +87,8 @@ class MainLoopPosix : public MainLoopBase {
 
   llvm::DenseMap m_read_fds;
   llvm::DenseMap m_signals;
-  Pipe m_trigger_pipe;
-  std::atomic m_triggering;
+  Pipe m_interrupt_pipe;
+  std::atomic m_interrupting = false;
 #if HAVE_SYS_EVENT_H
   int m_kqueue;
 #endif
diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h 
b/lldb/include/lldb/Host/windows/MainLoopWindows.h
index 33e179e6c1286c..3937a24645d955 100644
--- a/lldb/include/lldb/Host/windo

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

This seems to have broken precommit CI on Windows: 
https://buildkite.com/llvm-project/github-pull-requests/builds/65#0192a01b-d3ac-44ad-abff-e53ac4a206ab
 all of the failures look related to line endings, and I noticed that I got a 
ton of command line messages of the form:
```
warning: in the working copy of 'clang/include/clang/Basic/Attr.td', LF will be 
replaced by CRLF the next time Git touches it
```

> Can we revert this until we figure out these bits?

Yes, please.

> Do we really want checkouts to default to having the majority of files with 
> CRLF on Windows? I would expect that most people working on Windows don't 
> really want this (this wasn't the case so far anyway)?

It certainly came as a surprise to me; my editors handle LF line endings just 
fine on Windows; it was very jarring to get hundreds of warnings from git that 
all seemed unactionable.


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


[Lldb-commits] [lldb] 3bc765d - [lldb][test] Add test for ASTImporter's name conflict resolution (#112566)

2024-10-18 Thread via lldb-commits

Author: Michael Buch
Date: 2024-10-18T14:19:42+01:00
New Revision: 3bc765dbbf9bf0eceab1c9679b9f761b3f760d56

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

LOG: [lldb][test] Add test for ASTImporter's name conflict resolution (#112566)

This is a reduced test case from a crash we've observed in the past. The
assertion that this test triggers is:
```
Assertion failed: ((Pos == ImportedDecls.end() || Pos->second == To) && "Try to 
import an already imported Decl"), function MapImported, file ASTImporter.cpp, 
line 10494.
```

In a non-asserts build we crash later on in the ASTImporter. The root
cause is, as the assertion above points out, that we erroneously replace
an existing `From->To` decl mapping with a `To` decl that isn't
complete. Then we try to complete it but it has no definition and we
dereference a nullptr.

The reason this happens is basically what's been described in
https://reviews.llvm.org/D67803?id=220956#1676588

The dylib contains a definition of `Service` which is different to the
one in the main executable. When we start dumping the children of the
variable we're printing, we start completing it's members,
`ASTImport`ing fields in the process. When the ASTImporter realizes
there's been a name conflict (i.e., a structural mismatch on the
`Service` type) it would usually report back an error. However, LLDB
uses `ODRHandlingType::Liberal`, which means we create a new decl for
the ODR'd type instead of re-using the previously mapped decl.
Eventually this leads us to crash.

Ideally we'd be using `ODRHandlingType::Conservative` and warn/error,
though LLDB relies on this in some cases (particularly for
distinguishing template specializations, though maybe there's better a
way to deal with those).

We should really warn the user when this happens and not crash. To avoid
the crash we'd need to know to not create a decl for the ODR violation,
and instead re-use the definition we've previously seen. Though I'm not
yet sure that's viable for all of LLDB's use-cases (where ODR violations
might legimiately occur in a program, e.g., with opaque definitions,
etc.).

Added: 
lldb/test/API/lang/cpp/odr-handling-with-dylib/Makefile
lldb/test/API/lang/cpp/odr-handling-with-dylib/TestOdrHandlingWithDylib.py
lldb/test/API/lang/cpp/odr-handling-with-dylib/main.cpp
lldb/test/API/lang/cpp/odr-handling-with-dylib/plugin.cpp
lldb/test/API/lang/cpp/odr-handling-with-dylib/plugin.h
lldb/test/API/lang/cpp/odr-handling-with-dylib/service.cpp
lldb/test/API/lang/cpp/odr-handling-with-dylib/service.h

Modified: 


Removed: 




diff  --git a/lldb/test/API/lang/cpp/odr-handling-with-dylib/Makefile 
b/lldb/test/API/lang/cpp/odr-handling-with-dylib/Makefile
new file mode 100644
index 00..91eadaa37282ee
--- /dev/null
+++ b/lldb/test/API/lang/cpp/odr-handling-with-dylib/Makefile
@@ -0,0 +1,6 @@
+CXX_SOURCES := main.cpp service.cpp
+
+DYLIB_CXX_SOURCES := plugin.cpp
+DYLIB_NAME := plugin
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/odr-handling-with-dylib/TestOdrHandlingWithDylib.py 
b/lldb/test/API/lang/cpp/odr-handling-with-dylib/TestOdrHandlingWithDylib.py
new file mode 100644
index 00..f67d933f6ae51a
--- /dev/null
+++ b/lldb/test/API/lang/cpp/odr-handling-with-dylib/TestOdrHandlingWithDylib.py
@@ -0,0 +1,29 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class OdrHandlingWithDylibTestCase(TestBase):
+@skipIf(
+bugnumber="https://github.com/llvm/llvm-project/issues/50375, 
rdar://135551810"
+)
+def test(self):
+"""
+Tests that the expression evaluator is able to deal with types
+whose definitions conflict across multiple LLDB modules (in this
+case the definition for 'class Service' in the main executable
+has an additional field compared to the definition found in the
+dylib). This causes the ASTImporter to detect a name conflict
+while importing 'Service'. With LLDB's liberal ODRHandlingType
+the ASTImporter happily creates a conflicting AST node for
+'Service' in the scratch ASTContext, leading to a crash down
+the line.
+"""
+self.build()
+
+lldbutil.run_to_source_breakpoint(
+self, "plugin_entry", lldb.SBFileSpec("plugin.cpp")
+)
+
+self.expect_expr("*gProxyThis")

diff  --git a/lldb/test/API/lang/cpp/odr-handling-with-dylib/main.cpp 
b/lldb/test/API/lang/cpp/odr-handling-with-dylib/main.cpp
new file mode 100644
index 00..f3372e0fbe7018
--- /dev/null
+++ b/lldb/test/API/lang/cpp/odr-handling-with-dylib/main.cpp
@@ -0,0 +1,11 @@
+#include "plugin.h"
+
+#define HIDE_FROM_PL

[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-18 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread Shilei Tian via lldb-commits

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

Can't believe this many Lol

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-webassembly

@llvm/pr-subscribers-clang

Author: Jay Foad (jayfoad)


Changes



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


19 Files Affected:

- (modified) clang/utils/TableGen/RISCVVEmitter.cpp (+2-2) 
- (modified) flang/docs/OptionComparison.md (+1-1) 
- (modified) flang/include/flang/Runtime/magic-numbers.h (+1-1) 
- (modified) flang/lib/Evaluate/intrinsics.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Numeric.cpp (+3-3) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Reduction.cpp (+1-1) 
- (modified) lldb/CMakeLists.txt (+1-1) 
- (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SSAUpdater.h (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td (+1-1) 
- (modified) llvm/test/Bitcode/upgrade-aarch64-sve-intrinsics.ll (+1-1) 
- (modified) llvm/test/CodeGen/SystemZ/vec-reduce-add-01.ll (+1-1) 
- (modified) llvm/test/Transforms/JumpThreading/thread-debug-info.ll (+1-1) 
- (modified) llvm/test/Transforms/SROA/fake-use-sroa.ll (+1-1) 
- (modified) llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp (+1-1) 
- (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+1-1) 


``diff
diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 50f161fd38ce69..aecca0f5df8d93 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -169,7 +169,7 @@ static VectorTypeModifier getTupleVTM(unsigned NF) {
 
 static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) {
   // We need a special rule for segment load/store since the data width is not
-  // encoded in the instrinsic name itself.
+  // encoded in the intrinsic name itself.
   const StringRef IRName = RVVI->getIRName();
   constexpr unsigned RVV_VTA = 0x1;
   constexpr unsigned RVV_VMA = 0x2;
@@ -192,7 +192,7 @@ static unsigned getIndexedLoadStorePtrIdx(const 
RVVIntrinsic *RVVI) {
 static unsigned getSegInstLog2SEW(StringRef InstName) {
   // clang-format off
   // We need a special rule for indexed segment load/store since the data width
-  // is not encoded in the instrinsic name itself.
+  // is not encoded in the intrinsic name itself.
   if (InstName.starts_with("vloxseg") || InstName.starts_with("vluxseg") ||
   InstName.starts_with("vsoxseg") || InstName.starts_with("vsuxseg"))
 return (unsigned)-1;
diff --git a/flang/docs/OptionComparison.md b/flang/docs/OptionComparison.md
index 9d6916ef62af2e..fb65498fa1f444 100644
--- a/flang/docs/OptionComparison.md
+++ b/flang/docs/OptionComparison.md
@@ -53,7 +53,7 @@ eN

fdec,
 
-fall-instrinsics
+fall-intrinsics

https://www-01.ibm.com/support/docview.wss?uid=swg27024803&aid=1#page=297";>qxlf77,
 
diff --git a/flang/include/flang/Runtime/magic-numbers.h 
b/flang/include/flang/Runtime/magic-numbers.h
index bab0e9ae05299a..1d3c5dca0b4bfb 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -107,7 +107,7 @@ The denorm value is a nonstandard extension.
 
 #if 0
 ieee_round_type values
-The values are those of the llvm.get.rounding instrinsic, which is assumed by
+The values are those of the llvm.get.rounding intrinsic, which is assumed by
 ieee_arithmetic module rounding procedures.
 #endif
 #define _FORTRAN_RUNTIME_IEEE_TO_ZERO 0
diff --git a/flang/lib/Evaluate/intrinsics.cpp 
b/flang/lib/Evaluate/intrinsics.cpp
index 4271faa0db12bf..aa44967817722e 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1690,7 +1690,7 @@ std::optional IntrinsicInterface::Match(
   // MAX and MIN (and others that map to them) allow their last argument to
   // be repeated indefinitely.  The actualForDummy vector is sized
   // and null-initialized to the non-repeated dummy argument count
-  // for other instrinsics.
+  // for other intrinsics.
   bool isMaxMin{dummyArgPatterns > 0 &&
   dummy[dummyArgPatterns - 1].optionality == Optionality::repeats};
   std::vector actualForDummy(
diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp 
b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
index c13064a284d127..d0092add0118f1 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
@@ -284,7 +284,7 @@ struct ForcedSpacing16 {
   }
 };
 
-/// Generate call to Exponent instrinsic runtime routine.
+/// Generate call to Exponent intrinsic runtime routine.
 mlir::Value fir::runtime::genExponent(fir::FirOpBuilder &builder,
   mlir::Location loc, mlir::Type 
resultType,
   mlir::Value x) {
@@ -320,7 +320,7 @@ mlir::Va

[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread Andrzej Warzyński via lldb-commits

https://github.com/banach-space approved this pull request.

LGTM, thanks!

I blame my editor's dictionary 😂 

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread via lldb-commits

ldrumm wrote:

There are a couple of things to unpack here

> a number of test input files need to be in LF form to work

Which ones? Either there's a bug in a parser somewhere, or I missed some test 
files. In either case I'd like to fix the issue. I watched the buildbots quite 
closely last night and only noticed failures in ARM frame lowering - which 
isn't this, I think.

> Now after this change, due to the added .gitattributes which overrides the 
> core.autocrlf setting, these files get checked out with CRLF newlines (as the 
> native form for the platform).

It's my understanding that `text=auto` does not override `core.autocrlf`. As 
far as I can tell from the documentation it honours the user's configuration 
for `core.eol` in combination with  `core.autocrlf` - from `git config --help`:

>  core.eol
   Sets the line ending type to use in the working directory for files 
that are marked as text (either by having the text attribute set, or by having 
text=auto and
   Git auto-detecting the contents as text). Alternatives are lf, crlf 
and native, which uses the platform’s native line ending. The default value is 
native. See
   gitattributes(5) for more information on end-of-line conversion. 
Note that this value is ignored if core.autocrlf is set to true or input.

and

>  core.autocrlf
   Setting this variable to "true" is the same as setting the text 
attribute to "auto" on all files and core.eol to "crlf". Set to true if you 
want to have CRLF line
   endings in your working directory and the repository has LF line 
endings. This variable can be set to input, in which case no output conversion 
is performed.


> Can we revert this until we figure out these bits

Sure, but like I said, I'm happy to fix these broken cases. The old 
configuration was broken, but not in a controllable way, so I think it's 
reasonable to fix up the broken tests and move forward. Perhaps we also need 
clearer documentation?



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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread via lldb-commits

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

cute typo :)

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The motivating use case is being able to "time out" certain operations (by 
adding a timed callback which will force the termination of the loop), but the 
design is flexible enough to accomodate other use cases as well (e.g. running a 
periodic task in the background).

The implementation builds on the existing "pending callback" mechanism, by 
associating a time point with each callback -- every time the loop wakes up, it 
runs all of the callbacks which are past their point, and it also makes sure to 
sleep only until the next callback is scheduled to run.

I've done some renaming as names like "TriggerPendingCallbacks" were no longer 
accurate -- the function may no longer cause any callbacks to be called (it may 
just cause the main loop thread to recalculate the time it wants to sleep).

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


7 Files Affected:

- (modified) lldb/include/lldb/Host/MainLoopBase.h (+27-6) 
- (modified) lldb/include/lldb/Host/posix/MainLoopPosix.h (+3-3) 
- (modified) lldb/include/lldb/Host/windows/MainLoopWindows.h (+2-2) 
- (modified) lldb/source/Host/common/MainLoopBase.cpp (+28-12) 
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+47-16) 
- (modified) lldb/source/Host/windows/MainLoopWindows.cpp (+26-11) 
- (modified) lldb/unittests/Host/MainLoopTest.cpp (+58-6) 


``diff
diff --git a/lldb/include/lldb/Host/MainLoopBase.h 
b/lldb/include/lldb/Host/MainLoopBase.h
index 7365ee7a65ee64..0b79c52a358f4b 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -13,8 +13,10 @@
 #include "lldb/Utility/Status.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 
@@ -38,6 +40,9 @@ class MainLoopBase {
   class ReadHandle;
 
 public:
+  using TimePoint = std::chrono::time_point;
+
   MainLoopBase() : m_terminate_request(false) {}
   virtual ~MainLoopBase() = default;
 
@@ -52,7 +57,19 @@ class MainLoopBase {
   // Add a pending callback that will be executed once after all the pending
   // events are processed. The callback will be executed even if termination
   // was requested.
-  void AddPendingCallback(const Callback &callback);
+  void AddPendingCallback(const Callback &callback) {
+AddCallback(callback, std::chrono::steady_clock::time_point());
+  }
+
+  // Add a callback that will be executed after a certain amount of time has
+  // passed.
+  void AddCallback(const Callback &callback,
+   std::chrono::nanoseconds delay) {
+AddCallback(callback, std::chrono::steady_clock::now() + delay);
+  }
+
+  // Add a callback that will be executed after a given point in time.
+  void AddCallback(const Callback &callback, TimePoint point);
 
   // Waits for registered events and invoke the proper callbacks. Returns when
   // all callbacks deregister themselves or when someone requests termination.
@@ -69,14 +86,18 @@ class MainLoopBase {
 
   virtual void UnregisterReadObject(IOObject::WaitableHandle handle) = 0;
 
-  // Interrupt the loop that is currently waiting for events and execute
-  // the current pending callbacks immediately.
-  virtual void TriggerPendingCallbacks() = 0;
+  // Interrupt the loop that is currently waiting for events.
+  virtual void Interrupt() = 0;
+
+  void ProcessCallbacks();
 
-  void ProcessPendingCallbacks();
+  std::optional GetNextWakeupTime();
 
   std::mutex m_callback_mutex;
-  std::vector m_pending_callbacks;
+  std::priority_queue,
+  std::vector>,
+  llvm::on_first>>
+  m_callbacks;
   bool m_terminate_request : 1;
 
 private:
diff --git a/lldb/include/lldb/Host/posix/MainLoopPosix.h 
b/lldb/include/lldb/Host/posix/MainLoopPosix.h
index 07497b7b8c259a..bff96583bf5424 100644
--- a/lldb/include/lldb/Host/posix/MainLoopPosix.h
+++ b/lldb/include/lldb/Host/posix/MainLoopPosix.h
@@ -54,7 +54,7 @@ class MainLoopPosix : public MainLoopBase {
   void UnregisterReadObject(IOObject::WaitableHandle handle) override;
   void UnregisterSignal(int signo, std::list::iterator callback_it);
 
-  void TriggerPendingCallbacks() override;
+  void Interrupt() override;
 
 private:
   void ProcessReadObject(IOObject::WaitableHandle handle);
@@ -87,8 +87,8 @@ class MainLoopPosix : public MainLoopBase {
 
   llvm::DenseMap m_read_fds;
   llvm::DenseMap m_signals;
-  Pipe m_trigger_pipe;
-  std::atomic m_triggering;
+  Pipe m_interrupt_pipe;
+  std::atomic m_interrupting = false;
 #if HAVE_SYS_EVENT_H
   int m_kqueue;
 #endif
diff --git a/lldb/include/lldb/Host/windows/MainLoopWindows.h 
b/lldb/include/lldb/Host/windows/MainLoopWindows.h
index 33e179e6c1286c..3937a24645d955 100644
--- a/lldb/include/lldb/Host/windows/MainLoopWindows.h
+++ b/lldb/include/lldb/Host/windows/MainLoopWindows.h
@@ -34,7 +34,7 @@ class MainLoopWindows : public MainLoopBa

[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Pavel Labath via lldb-commits

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

The motivating use case is being able to "time out" certain operations (by 
adding a timed callback which will force the termination of the loop), but the 
design is flexible enough to accomodate other use cases as well (e.g. running a 
periodic task in the background).

The implementation builds on the existing "pending callback" mechanism, by 
associating a time point with each callback -- every time the loop wakes up, it 
runs all of the callbacks which are past their point, and it also makes sure to 
sleep only until the next callback is scheduled to run.

I've done some renaming as names like "TriggerPendingCallbacks" were no longer 
accurate -- the function may no longer cause any callbacks to be called (it may 
just cause the main loop thread to recalculate the time it wants to sleep).

>From cc3a4a94e9e2eb8b4cf763d4c8c477c71776ee93 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 16 Oct 2024 17:34:53 +0200
Subject: [PATCH] [lldb] Add timed callbacks to the MainLoop class

The motivating use case is being able to "time out" certain operations
(by adding a timed callback which will force the termination of the
loop), but the design is flexible enough to accomodate other use cases
as well (e.g. running a periodic task in the background).

The implementation builds on the existing "pending callback" mechanism,
by associating a time point with each callback -- every time the loop
wakes up, it runs all of the callbacks which are past their point, and
it also makes sure to sleep only until the next callback is scheduled to
run.

I've done some renaming as names like "TriggerPendingCallbacks" were
no longer accurate -- the function may no longer cause any callbacks to be
called (it may just cause the main loop thread to recalculate the time
it wants to sleep).
---
 lldb/include/lldb/Host/MainLoopBase.h | 33 --
 lldb/include/lldb/Host/posix/MainLoopPosix.h  |  6 +-
 .../lldb/Host/windows/MainLoopWindows.h   |  4 +-
 lldb/source/Host/common/MainLoopBase.cpp  | 40 
 lldb/source/Host/posix/MainLoopPosix.cpp  | 63 +-
 lldb/source/Host/windows/MainLoopWindows.cpp  | 37 +++
 lldb/unittests/Host/MainLoopTest.cpp  | 64 +--
 7 files changed, 191 insertions(+), 56 deletions(-)

diff --git a/lldb/include/lldb/Host/MainLoopBase.h 
b/lldb/include/lldb/Host/MainLoopBase.h
index 7365ee7a65ee64..0b79c52a358f4b 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -13,8 +13,10 @@
 #include "lldb/Utility/Status.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 
@@ -38,6 +40,9 @@ class MainLoopBase {
   class ReadHandle;
 
 public:
+  using TimePoint = std::chrono::time_point;
+
   MainLoopBase() : m_terminate_request(false) {}
   virtual ~MainLoopBase() = default;
 
@@ -52,7 +57,19 @@ class MainLoopBase {
   // Add a pending callback that will be executed once after all the pending
   // events are processed. The callback will be executed even if termination
   // was requested.
-  void AddPendingCallback(const Callback &callback);
+  void AddPendingCallback(const Callback &callback) {
+AddCallback(callback, std::chrono::steady_clock::time_point());
+  }
+
+  // Add a callback that will be executed after a certain amount of time has
+  // passed.
+  void AddCallback(const Callback &callback,
+   std::chrono::nanoseconds delay) {
+AddCallback(callback, std::chrono::steady_clock::now() + delay);
+  }
+
+  // Add a callback that will be executed after a given point in time.
+  void AddCallback(const Callback &callback, TimePoint point);
 
   // Waits for registered events and invoke the proper callbacks. Returns when
   // all callbacks deregister themselves or when someone requests termination.
@@ -69,14 +86,18 @@ class MainLoopBase {
 
   virtual void UnregisterReadObject(IOObject::WaitableHandle handle) = 0;
 
-  // Interrupt the loop that is currently waiting for events and execute
-  // the current pending callbacks immediately.
-  virtual void TriggerPendingCallbacks() = 0;
+  // Interrupt the loop that is currently waiting for events.
+  virtual void Interrupt() = 0;
+
+  void ProcessCallbacks();
 
-  void ProcessPendingCallbacks();
+  std::optional GetNextWakeupTime();
 
   std::mutex m_callback_mutex;
-  std::vector m_pending_callbacks;
+  std::priority_queue,
+  std::vector>,
+  llvm::on_first>>
+  m_callbacks;
   bool m_terminate_request : 1;
 
 private:
diff --git a/lldb/include/lldb/Host/posix/MainLoopPosix.h 
b/lldb/include/lldb/Host/posix/MainLoopPosix.h
index 07497b7b8c259a..bff96583bf5424 100644
--- a/lldb/include/lldb/Host/posix/MainLoopPosix.h
+++ b/lldb/include/lldb/Host/posix/MainLoopPosix.h
@@ -54,7 +54,7 @@ class MainLoo

[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-18 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

This might be related to https://github.com/llvm/llvm-project/issues/56458 even 
though my repro is different.

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


[Lldb-commits] [lldb] [lldb] Document SymbolFileJSON (PR #112938)

2024-10-18 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

LGTM but it would be nice if we made the `optional` fields stand out more by 
either making it **bold**  in the paragraph or add an `(optional)` on the 
example lists.

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond commented:

A lot of this is over my head, but I left a few comments anyway.

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


[Lldb-commits] [lldb] [lldb] Document SymbolFileJSON (PR #112938)

2024-10-18 Thread Med Ismail Bennani via lldb-commits

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

Also may be you can point to the crashlog script as an example where this is 
already being used.

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


[Lldb-commits] [lldb] a01d7df - [lldb] Avoid repeated map lookups (NFC) (#112823)

2024-10-18 Thread via lldb-commits

Author: Kazu Hirata
Date: 2024-10-18T10:40:13-07:00
New Revision: a01d7df09048e0b0b002c3f8420bcc8c7eab3ea0

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

LOG: [lldb] Avoid repeated map lookups (NFC) (#112823)

Added: 


Modified: 
lldb/source/Commands/CommandObjectMultiword.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 484d9022027ec6..b4cdfea9b1a3ef 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -102,11 +102,9 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
 
   std::string str_name(name);
 
-  auto pos = m_subcommand_dict.find(str_name);
-  if (pos == m_subcommand_dict.end()) {
-m_subcommand_dict[str_name] = cmd_obj_sp;
+  auto [pos, inserted] = m_subcommand_dict.try_emplace(str_name, cmd_obj_sp);
+  if (inserted)
 return llvm::Error::success();
-  }
 
   const char *error_str = nullptr;
   if (!can_replace)
@@ -117,7 +115,7 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
   if (error_str) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(), error_str);
   }
-  m_subcommand_dict[str_name] = cmd_obj_sp;
+  pos->second = cmd_obj_sp;
   return llvm::Error::success();
 }
 



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


[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112823)

2024-10-18 Thread Kazu Hirata via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb][dwarf] Compute fully qualified names on simplified template names with DWARFTypePrinter (PR #112811)

2024-10-18 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu updated 
https://github.com/llvm/llvm-project/pull/112811

>From cee4a4f1ba6cbaa59ccd0278441f65eb26c06f96 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Wed, 9 Oct 2024 22:35:46 -0700
Subject: [PATCH] [lldb][dwarf] Compute fully qualified names on simplified
 template names with DWARFTypePrinter

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 21 +++
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |  7 
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 35 ++
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   | 15 
 .../SymbolFile/DWARF/DWARFFormValue.cpp   | 25 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |  3 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 36 +--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 20 ---
 .../TypeSystem/Clang/TypeSystemClang.h|  4 ---
 .../DWARF/x86/simplified-template-names.cpp   | 31 
 llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h  |  2 ++
 .../llvm/DebugInfo/DWARF/DWARFTypePrinter.h   | 31 ++--
 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp |  9 +
 13 files changed, 170 insertions(+), 69 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a30d898a93cc4d..fbcbbc666f9d1d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -44,6 +44,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -825,11 +826,11 @@ std::string 
DWARFASTParserClang::GetDIEClassTemplateParams(DWARFDIE die) {
   if (llvm::StringRef(die.GetName()).contains("<"))
 return {};
 
-  TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos))
-return m_ast.PrintTemplateParams(template_param_infos);
-
-  return {};
+  std::string result;
+  llvm::raw_string_ostream os(result);
+  llvm::DWARFTypePrinter p(os);
+  p.appendAndTerminateTemplateParameters(die);
+  return result;
 }
 
 void DWARFASTParserClang::MapDeclDIEToDefDIE(
@@ -1617,9 +1618,9 @@ void DWARFASTParserClang::GetUniqueTypeNameAndDeclaration(
 case DW_TAG_structure_type:
 case DW_TAG_union_type: {
   if (const char *class_union_struct_name = parent_decl_ctx_die.GetName()) 
{
-qualified_name.insert(
-0, GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, "::");
+qualified_name.insert(0,
+  GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, class_union_struct_name);
   }
   parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
@@ -1672,6 +1673,12 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   if (attrs.name) {
 GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename,
 unique_decl);
+if (log) {
+  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  log, "SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
+  static_cast(this), die.GetID(), DW_TAG_value_to_name(tag),
+  unique_typename.AsCString());
+}
 if (UniqueDWARFASTType *unique_ast_entry_type =
 dwarf->GetUniqueDWARFASTTypeMap().Find(
 unique_typename, die, unique_decl, byte_size,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 235343d2271223..ca25801137be38 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -24,9 +24,11 @@ class DWARFUnit;
 class DWARFDebugInfoEntry;
 class DWARFDeclContext;
 class SymbolFileDWARF;
+class DWARFFormValue;
 
 class DWARFBaseDIE {
 public:
+  using DWARFFormValue = dwarf::DWARFFormValue;
   DWARFBaseDIE() = default;
 
   DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
@@ -46,6 +48,7 @@ class DWARFBaseDIE {
   explicit operator bool() const { return IsValid(); }
 
   bool IsValid() const { return m_cu && m_die; }
+  bool isValid() const { return IsValid(); }
 
   bool HasChildren() const;
 
@@ -85,6 +88,8 @@ class DWARFBaseDIE {
   // Accessing information about a DIE
   dw_tag_t Tag() const;
 
+  dw_tag_t getTag() const { return Tag(); }
+
   dw_offset_t GetOffset() const;
 
   // Get the LLDB user ID for this DIE. This is often just the DIE offset,
@@ -95,6 +100,8 @@ class DWARFBaseDIE {
 
   const char *GetName() const;
 
+  const char *getShortName() const { return GetName(); }
+
   lldb::ModuleSP GetModule() const;
 
   // Getting attribute values

[Lldb-commits] [lldb] [lldb] Introduce Language::AreEquivalentFunctions (PR #112720)

2024-10-18 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

> > > > > do we have in mind any other languages that will implement this?
> > > > 
> > > > 
> > > > I suspect any language wanting to implement this notion of function 
> > > > splitting (e.g. all the users of corosplitter) and virtual frames could 
> > > > have a use for this
> > > 
> > > 
> > > We already have `.cold` functions that do this in clang. Might be nice to 
> > > support that on the llvm side so this could be testable here.
> > 
> > 
> > There are two things that confuse me about this idea:
> > 
> > * I thought `.cold` functions came from the hot-cold-split pass, not from 
> > Clang?
> 
> I was speaking loosely, meaning "in the llvm.org not the swift fork of 
> llvm-project (and thus testable there). We'd have to decide which runtime 
> this would go in, maybe we need an "assembly language" or a general fallback 
> runtime for this?
> 
> > * Don't those create a new frame on the stack, i.e. a new CFA?
> 
> I don't remember whether they push a frame or tail call.

I looked at the code that creates `.cold` functions, and it doesn't seem to 
tail call, creating a new frame instead (at least the `.ll` tests have no 
`musttail` attribute in those functions).

Maybe some C++-specific construct that could go through the C++ language 
plugin? I tried their coroutines, but the IR generated wasn't very promising 
either and  I'm not familiar with how they are compiled.

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


[Lldb-commits] [lldb] [llvm] [lldb][dwarf] Compute fully qualified names on simplified template names with DWARFTypePrinter (PR #112811)

2024-10-18 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu updated 
https://github.com/llvm/llvm-project/pull/112811

>From db1e81bcbcc65af6963e84992154ffde16b13a10 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Wed, 9 Oct 2024 22:35:46 -0700
Subject: [PATCH] [lldb][dwarf] Compute fully qualified names on simplified
 template names with DWARFTypePrinter

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 21 +++
 .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h   |  7 
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 35 ++
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   | 15 
 .../SymbolFile/DWARF/DWARFFormValue.cpp   | 25 +
 .../Plugins/SymbolFile/DWARF/DWARFFormValue.h |  3 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 36 +--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 20 ---
 .../TypeSystem/Clang/TypeSystemClang.h|  4 ---
 .../DWARF/x86/simplified-template-names.cpp   | 31 
 llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h  |  2 ++
 .../llvm/DebugInfo/DWARF/DWARFTypePrinter.h   | 31 ++--
 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp |  9 +
 13 files changed, 170 insertions(+), 69 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/x86/simplified-template-names.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a30d898a93cc4d..41cb11f94a45e8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -44,6 +44,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h"
 #include "llvm/Demangle/Demangle.h"
 
 #include 
@@ -825,11 +826,11 @@ std::string 
DWARFASTParserClang::GetDIEClassTemplateParams(DWARFDIE die) {
   if (llvm::StringRef(die.GetName()).contains("<"))
 return {};
 
-  TypeSystemClang::TemplateParameterInfos template_param_infos;
-  if (ParseTemplateParameterInfos(die, template_param_infos))
-return m_ast.PrintTemplateParams(template_param_infos);
-
-  return {};
+  std::string name;
+  llvm::raw_string_ostream os(name);
+  llvm::DWARFTypePrinter type_printer(os);
+  type_printer.appendAndTerminateTemplateParameters(die);
+  return name;
 }
 
 void DWARFASTParserClang::MapDeclDIEToDefDIE(
@@ -1617,9 +1618,9 @@ void DWARFASTParserClang::GetUniqueTypeNameAndDeclaration(
 case DW_TAG_structure_type:
 case DW_TAG_union_type: {
   if (const char *class_union_struct_name = parent_decl_ctx_die.GetName()) 
{
-qualified_name.insert(
-0, GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, "::");
+qualified_name.insert(0,
+  GetDIEClassTemplateParams(parent_decl_ctx_die));
 qualified_name.insert(0, class_union_struct_name);
   }
   parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
@@ -1672,6 +1673,12 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   if (attrs.name) {
 GetUniqueTypeNameAndDeclaration(die, cu_language, unique_typename,
 unique_decl);
+if (log) {
+  dwarf->GetObjectFile()->GetModule()->LogMessage(
+  log, "SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
+  static_cast(this), die.GetID(), DW_TAG_value_to_name(tag),
+  unique_typename.AsCString());
+}
 if (UniqueDWARFASTType *unique_ast_entry_type =
 dwarf->GetUniqueDWARFASTTypeMap().Find(
 unique_typename, die, unique_decl, byte_size,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 235343d2271223..ca25801137be38 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -24,9 +24,11 @@ class DWARFUnit;
 class DWARFDebugInfoEntry;
 class DWARFDeclContext;
 class SymbolFileDWARF;
+class DWARFFormValue;
 
 class DWARFBaseDIE {
 public:
+  using DWARFFormValue = dwarf::DWARFFormValue;
   DWARFBaseDIE() = default;
 
   DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
@@ -46,6 +48,7 @@ class DWARFBaseDIE {
   explicit operator bool() const { return IsValid(); }
 
   bool IsValid() const { return m_cu && m_die; }
+  bool isValid() const { return IsValid(); }
 
   bool HasChildren() const;
 
@@ -85,6 +88,8 @@ class DWARFBaseDIE {
   // Accessing information about a DIE
   dw_tag_t Tag() const;
 
+  dw_tag_t getTag() const { return Tag(); }
+
   dw_offset_t GetOffset() const;
 
   // Get the LLDB user ID for this DIE. This is often just the DIE offset,
@@ -95,6 +100,8 @@ class DWARFBaseDIE {
 
   const char *GetName() const;
 
+  const char *getShortName() const { return GetName(); }
+
   lldb::ModuleSP GetModule() const;
 
   // Getting 

[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113024)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) lldb/source/Core/DataFileCache.cpp (+6-8) 


``diff
diff --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index a8127efc1df064..ef0e07a8b03420 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -264,14 +264,12 @@ bool CacheSignature::Decode(const 
lldb_private::DataExtractor &data,
 }
 
 uint32_t ConstStringTable::Add(ConstString s) {
-  auto pos = m_string_to_offset.find(s);
-  if (pos != m_string_to_offset.end())
-return pos->second;
-  const uint32_t offset = m_next_offset;
-  m_strings.push_back(s);
-  m_string_to_offset[s] = offset;
-  m_next_offset += s.GetLength() + 1;
-  return offset;
+  auto [pos, inserted] = m_string_to_offset.try_emplace(s, m_next_offset);
+  if (inserted) {
+m_strings.push_back(s);
+m_next_offset += s.GetLength() + 1;
+  }
+  return pos->second;
 }
 
 static const llvm::StringRef kStringTableIdentifier("STAB");

``




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


[Lldb-commits] [lldb] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (PR #113006)

2024-10-18 Thread Jonas Devlieghere via lldb-commits


@@ -237,6 +237,10 @@ class TypeSystem : public PluginInterface,
 
   virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 
0;
 
+  // Defaults to GetTypeName(type).  Override if your language desires
+  // specialized behavior.

JDevlieghere wrote:

Nit: these should be `///` doxygen style comments. 

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


[Lldb-commits] [lldb] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (PR #113006)

2024-10-18 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (PR #113006)

2024-10-18 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Avoid repeated hash lookups (NFC) (PR #113024)

2024-10-18 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/113024

None

>From 02829d780f3032c86992a3ae6a13ab27017e5635 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Fri, 18 Oct 2024 09:10:44 -0700
Subject: [PATCH] [lldb] Avoid repeated hash lookups (NFC)

---
 lldb/source/Core/DataFileCache.cpp | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index a8127efc1df064..ef0e07a8b03420 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -264,14 +264,12 @@ bool CacheSignature::Decode(const 
lldb_private::DataExtractor &data,
 }
 
 uint32_t ConstStringTable::Add(ConstString s) {
-  auto pos = m_string_to_offset.find(s);
-  if (pos != m_string_to_offset.end())
-return pos->second;
-  const uint32_t offset = m_next_offset;
-  m_strings.push_back(s);
-  m_string_to_offset[s] = offset;
-  m_next_offset += s.GetLength() + 1;
-  return offset;
+  auto [pos, inserted] = m_string_to_offset.try_emplace(s, m_next_offset);
+  if (inserted) {
+m_strings.push_back(s);
+m_next_offset += s.GetLength() + 1;
+  }
+  return pos->second;
 }
 
 static const llvm::StringRef kStringTableIdentifier("STAB");

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


[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-18 Thread Jorge Gorbe Moya via lldb-commits


@@ -98,10 +94,31 @@ void RenderDiagnosticDetails(Stream &stream,
   continue;
 }
 
-auto &loc = *detail.source_location;
 remaining_details.push_back(detail);
+  }
+
+  // Sort the diagnostics.
+  auto sort = [](auto &ds) {
+llvm::sort(ds.begin(), ds.end(), [](auto &d1, auto &d2) {
+  auto l1 = 
d1.source_location.value_or(DiagnosticDetail::SourceLocation{});
+  auto l2 = 
d2.source_location.value_or(DiagnosticDetail::SourceLocation{});
+  return std::pair(l1.line, l2.column) < std::pair(l1.line, l2.column);

slackito wrote:

This comparison is always false, both sides of the `<` operator are identical.

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


[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-18 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff cc13d4fb4a208363ed1dab29829cd200a3e39c52 
eb1f2bbd08d7f50286f0451ce0a6191c71c634eb --extensions cpp,h -- 
lldb/include/lldb/Symbol/Type.h 
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index b90cfc44e9..a8e5b81585 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -84,7 +84,8 @@ FLAGS_ENUM(TypeQueryOptions){
 /// matching type is found. When false, the type query should find all
 /// matching types.
 e_find_one = (1u << 4),
-// If set, treat TypeQuery::m_name as a mangled name that should be 
searched.
+// If set, treat TypeQuery::m_name as a mangled name that should be
+// searched.
 e_search_by_mangled_name = (1u << 5),
 };
 LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)
@@ -302,8 +303,8 @@ public:
   m_options &= ~e_find_one;
   }
 
-  /// Returns true if the type query is supposed to treat the name to be 
searched
-  /// as a mangled name.
+  /// Returns true if the type query is supposed to treat the name to be
+  /// searched as a mangled name.
   bool GetSearchByMangledName() const {
 return (m_options & e_search_by_mangled_name) != 0;
   }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index d4604d72b3..6f7388b3a1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -385,7 +385,8 @@ static void GetDeclContextImpl(DWARFDIE die, bool 
use_mangled_name,
   context.push_back({kind, ConstString(name)});
 };
 
-// Since mangled names are unique there's no need to build an entire 
context.
+// Since mangled names are unique there's no need to build an entire
+// context.
 if (use_mangled_name) {
   push_ctx(CompilerContextKind::AnyType, die.GetMangledName());
   return;
@@ -425,7 +426,8 @@ static void GetDeclContextImpl(DWARFDIE die, bool 
use_mangled_name,
   }
 }
 
-std::vector DWARFDIE::GetDeclContext(bool use_mangled_name) 
const {
+std::vector
+DWARFDIE::GetDeclContext(bool use_mangled_name) const {
   llvm::SmallSet seen;
   std::vector context;
   GetDeclContextImpl(*this, use_mangled_name, seen, context);
@@ -443,7 +445,8 @@ static void GetTypeLookupContextImpl(DWARFDIE die, bool 
use_mangled_name,
   context.push_back({kind, ConstString(name)});
 };
 
-// Since mangled names are unique there's no need to build an entire 
context.
+// Since mangled names are unique there's no need to build an entire
+// context.
 if (use_mangled_name) {
   push_ctx(CompilerContextKind::AnyType, die.GetMangledName());
   return;
@@ -451,7 +454,7 @@ static void GetTypeLookupContextImpl(DWARFDIE die, bool 
use_mangled_name,
 
 // If there is no name, then there is no need to look anything up for this
 // DIE.
-   const char *name = die.GetName();
+const char *name = die.GetName();
 if (!name || !name[0])
   return;
 
@@ -474,7 +477,7 @@ static void GetTypeLookupContextImpl(DWARFDIE die, bool 
use_mangled_name,
   break;
 case DW_TAG_typedef:
   push_ctx(CompilerContextKind::Typedef, die.GetName());
-   break;
+  break;
 case DW_TAG_base_type:
   push_ctx(CompilerContextKind::Builtin, die.GetName());
   break;
@@ -498,7 +501,8 @@ static void GetTypeLookupContextImpl(DWARFDIE die, bool 
use_mangled_name,
   }
 }
 
-std::vector DWARFDIE::GetTypeLookupContext(bool 
use_mangled_name) const {
+std::vector
+DWARFDIE::GetTypeLookupContext(bool use_mangled_name) const {
   llvm::SmallSet seen;
   std::vector context;
   GetTypeLookupContextImpl(*this, use_mangled_name, seen, context);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index 109070bdcb..7ecefe616f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -72,7 +72,8 @@ public:
   /// Return this DIE's decl context as it is needed to look up types
   /// in Clang modules. This context will include any modules or functions that
   /// the type is declared in so an exact module match can be efficiently made.
-  std::vector GetDeclContext(bool use_mangled_name = false) 
const;
+  std::vector
+  GetDeclContext(bool use_mangled_name = false) const;
 
   /// Get a context to a type so it can be lo

[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread Jay Foad via lldb-commits

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


[Lldb-commits] [lldb] More aggressively deduplicate global warnings based on contents. (PR #112801)

2024-10-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/112801

>From e35350b790f34660911c23cdbe34e6a0347f924d Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 17 Oct 2024 16:44:07 -0700
Subject: [PATCH] More aggressively deduplicate global warnings based on
 contents.

I've been getting complaints from users being spammed by -gmodules
missing file warnings going out of control because each object file
depends on an entire DAG of PCM files that usually are all missing at
once. To reduce this problem, this patch does two things:

1. Module now maintains a DenseMap that is used to display
each warning only once, based on its actual text.

2. The PCM warning itself is reworded to include less details, such as
the DIE offset, which is only useful to LLDB developers, who can get
this from the dwarf log if they need it. Because the detail is omitted
the hashing from (1) deduplicates the warnings.

rdar://138144624
---
 lldb/include/lldb/Core/Module.h   |  9 --
 lldb/source/Core/Module.cpp   | 29 ---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 25 
 .../SymbolFile/DWARF/TestDedupWarnings.test   | 22 ++
 4 files changed, 60 insertions(+), 25 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/TestDedupWarnings.test

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 5589c1c9a350dc..e2a99cc7bcf50b 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -30,6 +30,7 @@
 
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/StableHashing.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Chrono.h"
 
@@ -1057,9 +1058,10 @@ class Module : public 
std::enable_shared_from_this,
   /// time for the symbol tables can be aggregated here.
   StatsDuration m_symtab_index_time;
 
-  std::once_flag m_optimization_warning;
-  std::once_flag m_language_warning;
-
+  /// A set of hashes of all warnings and errors, to avoid reporting them
+  /// multiple times to the same Debugger.
+  llvm::DenseMap>
+  m_shown_diagnostics;
   void SymbolIndicesToSymbolContextList(Symtab *symtab,
 std::vector &symbol_indexes,
 SymbolContextList &sc_list);
@@ -1086,6 +1088,7 @@ class Module : public 
std::enable_shared_from_this,
   void ReportWarning(const llvm::formatv_object_base &payload);
   void ReportError(const llvm::formatv_object_base &payload);
   void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
+  std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..1139f7c0bbbae7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
   ss << file_name
  << " was compiled with optimization - stepping may behave "
 "oddly; variables may not be available.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_optimization_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarningUnsupportedLanguage(
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
  << Language::GetNameForLanguageType(language)
  << "\". "
 "Inspection of frame variables will be limited.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_language_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportErrorIfModifyDetected(
@@ -1125,20 +1125,29 @@ void Module::ReportErrorIfModifyDetected(
   }
 }
 
+std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
+  std::lock_guard guard(m_mutex);
+  auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
+  if (!once_ptr)
+once_ptr = std::make_unique();
+  return once_ptr.get();
+}
+
 void Module::ReportError(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportError(strm.GetString().str());
+  std::string msg = payload.str();
+  strm << ' ' << msg;
+  Debugger::ReportError(strm.GetString().str(), {}, 
GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarning(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportWarning(std::string(strm.GetString()));
+  std::string msg = payload.str();
+  strm << ' '

[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112823)

2024-10-18 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/112823

>From 621d5b5a767daa4046dffec522c39e4bc652ac1b Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 17 Oct 2024 07:52:35 -0700
Subject: [PATCH 1/2] [lldb] Avoid repeated map lookups (NFC)

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

diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 484d9022027ec6..71339bd0f28b41 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -102,11 +102,9 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
 
   std::string str_name(name);
 
-  auto pos = m_subcommand_dict.find(str_name);
-  if (pos == m_subcommand_dict.end()) {
-m_subcommand_dict[str_name] = cmd_obj_sp;
+  auto [pos, inserted] = m_subcommand_dict.try_emplace(str_name, cmd_obj_sp);
+  if (inserted)
 return llvm::Error::success();
-  }
 
   const char *error_str = nullptr;
   if (!can_replace)

>From 06d30396715b8cb5d2e4e67e904f62329e84f09f Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Fri, 18 Oct 2024 08:51:41 -0700
Subject: [PATCH 2/2] Use pos at one more place.

---
 lldb/source/Commands/CommandObjectMultiword.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 71339bd0f28b41..b4cdfea9b1a3ef 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -115,7 +115,7 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
   if (error_str) {
 return llvm::createStringError(llvm::inconvertibleErrorCode(), error_str);
   }
-  m_subcommand_dict[str_name] = cmd_obj_sp;
+  pos->second = cmd_obj_sp;
   return llvm::Error::success();
 }
 

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


[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #112823)

2024-10-18 Thread Kazu Hirata via lldb-commits


@@ -102,11 +102,9 @@ llvm::Error CommandObjectMultiword::LoadUserSubcommand(
 
   std::string str_name(name);
 
-  auto pos = m_subcommand_dict.find(str_name);
-  if (pos == m_subcommand_dict.end()) {
-m_subcommand_dict[str_name] = cmd_obj_sp;
+  auto [pos, inserted] = m_subcommand_dict.try_emplace(str_name, cmd_obj_sp);
+  if (inserted)
 return llvm::Error::success();
-  }
 
   const char *error_str = nullptr;
   if (!can_replace)

kazutakahirata wrote:

Thanks!  Addressed in the latest iteration.

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


[Lldb-commits] [lldb] [lldb] Document SymbolFileJSON (PR #112938)

2024-10-18 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/112938

I've had multiple request for documentation about the JSON symbol file format 
that LLDB supports. This patch documents the structure and fields, shows a 
handful of examples and explains how to use it in LLDB.

>From ea45421b4c4e7973abf0461bec75988800babe77 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 18 Oct 2024 10:18:54 -0700
Subject: [PATCH] [lldb] Document SymbolFileJSON

I've had multiple request for documentation about the JSON symbol file
format that LLDB supports. This patch documents the structure and
fields, shows a handful of examples and explains how to use it in LLDB.
---
 lldb/docs/resources/symbolfilejson.rst | 201 +
 1 file changed, 201 insertions(+)
 create mode 100644 lldb/docs/resources/symbolfilejson.rst

diff --git a/lldb/docs/resources/symbolfilejson.rst 
b/lldb/docs/resources/symbolfilejson.rst
new file mode 100644
index 00..54f606ce1ffd58
--- /dev/null
+++ b/lldb/docs/resources/symbolfilejson.rst
@@ -0,0 +1,201 @@
+JSON Symbol File Format
+===
+
+The JSON symbol file format encodes symbols in a text based, human readable
+format. JSON symbol files can be used to symbolicate programs that miss symbol
+information, for example because they have been stripped.
+
+Format
+--
+
+The symbol file contains of a single JSON object with the following top level
+keys:
+
+* ``triple``
+* ``uuid``
+* ``type``
+* ``sections``
+* ``symbols``
+
+The ``triple``, ``uuid`` and ``type`` form the header and should therefore come
+first. The ``type`` field is optional. The body consists ``sections`` and
+``symbols``, each represented as a JSON array. Both arrays are optional, and
+can be omitted and are allowed to be empty.
+
+triple
+``
+
+The triple is a string with the triple of the object file it corresponds to.
+The triple follows the same format as used by LLVM:
+``---``.
+
+.. code-block:: JSON
+
+  { "triple": "arm64-apple-darwin22.0.0" }
+
+uuid
+
+
+The UUID is a string with the textual representation of the UUID of the object
+file it corresponds to. The UUID is represented as outlined in RFC 4122: with
+32 hexadecimal digits, displayed in five groups separated by hyphens, in the
+form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and
+four hyphens).
+
+.. code-block:: JSON
+
+  { "uuid": "2107157B-6D7E-39F6-806D-AECDC15FC533" }
+
+type
+
+The optional ``type`` field allows you to specify the type of object file the
+JSON file represent. This is often unnecessary, and can be omitted, in which
+case the file is considered of the type ``DebugInfo``.
+
+Valid values for the ``type`` field are:
+
+* ``CoreFile``: A core file that has a checkpoint of a program's execution 
state.
+* ``Executable``: A normal executable.
+* ``DebugInfo``: An object file that contains only debug information.
+* ``DynamicLinker``: The platform's dynamic linker executable.
+* ``ObjectFile``: An intermediate object file.
+* ``SharedLibrary``: A shared library that can be used during execution.
+* ``StubLibrary``: A library that can be linked against but not used for 
execution.
+* ``JIT``: JIT code that has symbols, sections and possibly debug info.
+
+
+sections
+
+
+* ``name``: a string representing the section name.
+* ``type``: a string representing the section type (see below).
+* ``address``: a number representing the section file address.
+* ``size``: a number representing the section size in bytes.
+
+.. code-block:: JSON
+
+  {
+  "name": "__TEXT",
+  "type": "code",
+  "address": 0,
+  "size": 546,
+  }
+
+The ``type`` field accepts the following values: ``code``, ``container``,
+``data``, ``debug``.
+
+symbols
+```
+
+Symbols are JSON objects with the following keys:
+
+* ``name``: a string representing the string name.
+* ``value``: a number representing the symbol value.
+* ``address``: a number representing the symbol address in a section.
+* ``size``: a number representing the symbol size.
+* ``type``: an optional string representing the symbol type (see below).
+
+A symbol must contain either a ``value`` or an ``address``. The ``type`` is
+optional.
+
+.. code-block:: JSON
+
+  {
+  "name": "foo",
+  "type": "code",
+  "size": 10,
+  "address": 4294983544,
+  }
+
+The ``type`` field accepts any type in the ``lldb::SymbolType`` enum in
+`lldb-enumerations.h 
`_
+, without the ``eSymbolType``. For example ``code`` maps to ``eSymbolTypeCode``
+and ``variableType`` to ``eSymbolTypeVariableType``.
+
+Usage
+-
+
+Symbol files can be added with the ``target symbol add`` command. The triple
+and UUID will be used to match it to the correct module.
+
+.. code-block:: shell
+
+  (lldb) target symbol add /path/to/symbol.json
+  symbol file '/path/to/symbol.json' has been added to '/path/to/executable'
+
+You

[Lldb-commits] [lldb] [lldb] Document SymbolFileJSON (PR #112938)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

I've had multiple request for documentation about the JSON symbol file format 
that LLDB supports. This patch documents the structure and fields, shows a 
handful of examples and explains how to use it in LLDB.

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


1 Files Affected:

- (added) lldb/docs/resources/symbolfilejson.rst (+201) 


``diff
diff --git a/lldb/docs/resources/symbolfilejson.rst 
b/lldb/docs/resources/symbolfilejson.rst
new file mode 100644
index 00..54f606ce1ffd58
--- /dev/null
+++ b/lldb/docs/resources/symbolfilejson.rst
@@ -0,0 +1,201 @@
+JSON Symbol File Format
+===
+
+The JSON symbol file format encodes symbols in a text based, human readable
+format. JSON symbol files can be used to symbolicate programs that miss symbol
+information, for example because they have been stripped.
+
+Format
+--
+
+The symbol file contains of a single JSON object with the following top level
+keys:
+
+* ``triple``
+* ``uuid``
+* ``type``
+* ``sections``
+* ``symbols``
+
+The ``triple``, ``uuid`` and ``type`` form the header and should therefore come
+first. The ``type`` field is optional. The body consists ``sections`` and
+``symbols``, each represented as a JSON array. Both arrays are optional, and
+can be omitted and are allowed to be empty.
+
+triple
+``
+
+The triple is a string with the triple of the object file it corresponds to.
+The triple follows the same format as used by LLVM:
+``---``.
+
+.. code-block:: JSON
+
+  { "triple": "arm64-apple-darwin22.0.0" }
+
+uuid
+
+
+The UUID is a string with the textual representation of the UUID of the object
+file it corresponds to. The UUID is represented as outlined in RFC 4122: with
+32 hexadecimal digits, displayed in five groups separated by hyphens, in the
+form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and
+four hyphens).
+
+.. code-block:: JSON
+
+  { "uuid": "2107157B-6D7E-39F6-806D-AECDC15FC533" }
+
+type
+
+The optional ``type`` field allows you to specify the type of object file the
+JSON file represent. This is often unnecessary, and can be omitted, in which
+case the file is considered of the type ``DebugInfo``.
+
+Valid values for the ``type`` field are:
+
+* ``CoreFile``: A core file that has a checkpoint of a program's execution 
state.
+* ``Executable``: A normal executable.
+* ``DebugInfo``: An object file that contains only debug information.
+* ``DynamicLinker``: The platform's dynamic linker executable.
+* ``ObjectFile``: An intermediate object file.
+* ``SharedLibrary``: A shared library that can be used during execution.
+* ``StubLibrary``: A library that can be linked against but not used for 
execution.
+* ``JIT``: JIT code that has symbols, sections and possibly debug info.
+
+
+sections
+
+
+* ``name``: a string representing the section name.
+* ``type``: a string representing the section type (see below).
+* ``address``: a number representing the section file address.
+* ``size``: a number representing the section size in bytes.
+
+.. code-block:: JSON
+
+  {
+  "name": "__TEXT",
+  "type": "code",
+  "address": 0,
+  "size": 546,
+  }
+
+The ``type`` field accepts the following values: ``code``, ``container``,
+``data``, ``debug``.
+
+symbols
+```
+
+Symbols are JSON objects with the following keys:
+
+* ``name``: a string representing the string name.
+* ``value``: a number representing the symbol value.
+* ``address``: a number representing the symbol address in a section.
+* ``size``: a number representing the symbol size.
+* ``type``: an optional string representing the symbol type (see below).
+
+A symbol must contain either a ``value`` or an ``address``. The ``type`` is
+optional.
+
+.. code-block:: JSON
+
+  {
+  "name": "foo",
+  "type": "code",
+  "size": 10,
+  "address": 4294983544,
+  }
+
+The ``type`` field accepts any type in the ``lldb::SymbolType`` enum in
+`lldb-enumerations.h 
`_
+, without the ``eSymbolType``. For example ``code`` maps to ``eSymbolTypeCode``
+and ``variableType`` to ``eSymbolTypeVariableType``.
+
+Usage
+-
+
+Symbol files can be added with the ``target symbol add`` command. The triple
+and UUID will be used to match it to the correct module.
+
+.. code-block:: shell
+
+  (lldb) target symbol add /path/to/symbol.json
+  symbol file '/path/to/symbol.json' has been added to '/path/to/executable'
+
+You can use ``image list`` to confirm that the symbol file has been associated
+with the module.
+
+.. code-block:: shell
+
+  (lldb) image list
+  [  0] A711AB38-1FB1-38B1-B38B-859352ED2A20 0x0001 
/path/to/executable
+/path/to/symbol.json
+  [  1] 4BF76A72-53CC-3E42-8945-4E314C101535 0x0001800c6000 /usr/lib/dyld
+
+
+Example
+---
+
+The simplest valid JSON symbol 

[Lldb-commits] [lldb] [lldb] Document SymbolFileJSON (PR #112938)

2024-10-18 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/112938

>From ea45421b4c4e7973abf0461bec75988800babe77 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 18 Oct 2024 10:18:54 -0700
Subject: [PATCH 1/2] [lldb] Document SymbolFileJSON

I've had multiple request for documentation about the JSON symbol file
format that LLDB supports. This patch documents the structure and
fields, shows a handful of examples and explains how to use it in LLDB.
---
 lldb/docs/resources/symbolfilejson.rst | 201 +
 1 file changed, 201 insertions(+)
 create mode 100644 lldb/docs/resources/symbolfilejson.rst

diff --git a/lldb/docs/resources/symbolfilejson.rst 
b/lldb/docs/resources/symbolfilejson.rst
new file mode 100644
index 00..54f606ce1ffd58
--- /dev/null
+++ b/lldb/docs/resources/symbolfilejson.rst
@@ -0,0 +1,201 @@
+JSON Symbol File Format
+===
+
+The JSON symbol file format encodes symbols in a text based, human readable
+format. JSON symbol files can be used to symbolicate programs that miss symbol
+information, for example because they have been stripped.
+
+Format
+--
+
+The symbol file contains of a single JSON object with the following top level
+keys:
+
+* ``triple``
+* ``uuid``
+* ``type``
+* ``sections``
+* ``symbols``
+
+The ``triple``, ``uuid`` and ``type`` form the header and should therefore come
+first. The ``type`` field is optional. The body consists ``sections`` and
+``symbols``, each represented as a JSON array. Both arrays are optional, and
+can be omitted and are allowed to be empty.
+
+triple
+``
+
+The triple is a string with the triple of the object file it corresponds to.
+The triple follows the same format as used by LLVM:
+``---``.
+
+.. code-block:: JSON
+
+  { "triple": "arm64-apple-darwin22.0.0" }
+
+uuid
+
+
+The UUID is a string with the textual representation of the UUID of the object
+file it corresponds to. The UUID is represented as outlined in RFC 4122: with
+32 hexadecimal digits, displayed in five groups separated by hyphens, in the
+form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and
+four hyphens).
+
+.. code-block:: JSON
+
+  { "uuid": "2107157B-6D7E-39F6-806D-AECDC15FC533" }
+
+type
+
+The optional ``type`` field allows you to specify the type of object file the
+JSON file represent. This is often unnecessary, and can be omitted, in which
+case the file is considered of the type ``DebugInfo``.
+
+Valid values for the ``type`` field are:
+
+* ``CoreFile``: A core file that has a checkpoint of a program's execution 
state.
+* ``Executable``: A normal executable.
+* ``DebugInfo``: An object file that contains only debug information.
+* ``DynamicLinker``: The platform's dynamic linker executable.
+* ``ObjectFile``: An intermediate object file.
+* ``SharedLibrary``: A shared library that can be used during execution.
+* ``StubLibrary``: A library that can be linked against but not used for 
execution.
+* ``JIT``: JIT code that has symbols, sections and possibly debug info.
+
+
+sections
+
+
+* ``name``: a string representing the section name.
+* ``type``: a string representing the section type (see below).
+* ``address``: a number representing the section file address.
+* ``size``: a number representing the section size in bytes.
+
+.. code-block:: JSON
+
+  {
+  "name": "__TEXT",
+  "type": "code",
+  "address": 0,
+  "size": 546,
+  }
+
+The ``type`` field accepts the following values: ``code``, ``container``,
+``data``, ``debug``.
+
+symbols
+```
+
+Symbols are JSON objects with the following keys:
+
+* ``name``: a string representing the string name.
+* ``value``: a number representing the symbol value.
+* ``address``: a number representing the symbol address in a section.
+* ``size``: a number representing the symbol size.
+* ``type``: an optional string representing the symbol type (see below).
+
+A symbol must contain either a ``value`` or an ``address``. The ``type`` is
+optional.
+
+.. code-block:: JSON
+
+  {
+  "name": "foo",
+  "type": "code",
+  "size": 10,
+  "address": 4294983544,
+  }
+
+The ``type`` field accepts any type in the ``lldb::SymbolType`` enum in
+`lldb-enumerations.h 
`_
+, without the ``eSymbolType``. For example ``code`` maps to ``eSymbolTypeCode``
+and ``variableType`` to ``eSymbolTypeVariableType``.
+
+Usage
+-
+
+Symbol files can be added with the ``target symbol add`` command. The triple
+and UUID will be used to match it to the correct module.
+
+.. code-block:: shell
+
+  (lldb) target symbol add /path/to/symbol.json
+  symbol file '/path/to/symbol.json' has been added to '/path/to/executable'
+
+You can use ``image list`` to confirm that the symbol file has been associated
+with the module.
+
+.. code-block:: shell
+
+  (lldb) image list
+  [  0] A711AB38-1FB1-38B1-B38B-859352ED2A20 0x0001 

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/112939

Previously lldb didn't support setting breakpoints on call site locations.  
This patch adds that ability.  

It would be very slow if we did this by searching all the debug information for 
every inlined subroutine record looking for a call-site match, so I added one 
restriction to the call-site support.  This change will find all call sites for 
functions that also supply at least one line to the regular line table.  That 
way we can use the fact that the line table search will move the location to 
that subsequent line (but only within the same function).   When we find an 
actually moved source line match, we can search in the function that contained 
that line table entry for the call-site, and set the breakpoint location back 
to that.  

When I started writing tests for this new ability, it quickly became obvious 
that our support for virtual inline stepping was pretty buggy.  We didn't print 
the right file & line number for the breakpoint, and we didn't set the position 
in the "virtual inlined stack" correctly when we hit the breakpoint.  We also 
didn't step through the inlined frames correctly.  There was code to try to 
detect the right inlined stack position, but it had been refactored a while 
back with the comment that it was super confusing and the refactor was supposed 
to make it clearer, but the refactor didn't work either.

That code was made much clearer by abstracting the job of "handling the stack 
readjustment" to the various StopInfo's.  Previously, there was a big (and 
buggy) switch over stop info's.  Moving the responsibility to the stop info 
made this code much easier to reason about.

We also had no tests for virtual inlined stepping (our inlined stepping test 
was actually written specifically to avoid the formation of a virtual inlined 
stack...  So I also added tests for that along with the tests for setting the 
call-site breakpoints.

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH] Add the ability to break on call-site locations, report the
 correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stac

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

Previously lldb didn't support setting breakpoints on call site locations.  
This patch adds that ability.  

It would be very slow if we did this by searching all the debug information for 
every inlined subroutine record looking for a call-site match, so I added one 
restriction to the call-site support.  This change will find all call sites for 
functions that also supply at least one line to the regular line table.  That 
way we can use the fact that the line table search will move the location to 
that subsequent line (but only within the same function).   When we find an 
actually moved source line match, we can search in the function that contained 
that line table entry for the call-site, and set the breakpoint location back 
to that.  

When I started writing tests for this new ability, it quickly became obvious 
that our support for virtual inline stepping was pretty buggy.  We didn't print 
the right file & line number for the breakpoint, and we didn't set the 
position in the "virtual inlined stack" correctly when we hit the breakpoint.  
We also didn't step through the inlined frames correctly.  There was code to 
try to detect the right inlined stack position, but it had been refactored a 
while back with the comment that it was super confusing and the refactor was 
supposed to make it clearer, but the refactor didn't work either.

That code was made much clearer by abstracting the job of "handling the stack 
readjustment" to the various StopInfo's.  Previously, there was a big (and 
buggy) switch over stop info's.  Moving the responsibility to the stop info 
made this code much easier to reason about.

We also had no tests for virtual inlined stepping (our inlined stepping test 
was actually written specifically to avoid the formation of a virtual inlined 
stack...  So I also added tests for that along with the tests for setting the 
call-site breakpoints.

---

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


16 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/BreakpointLocation.h (+31) 
- (modified) lldb/include/lldb/Breakpoint/BreakpointSite.h (+5) 
- (modified) lldb/include/lldb/Target/StopInfo.h (+11) 
- (modified) lldb/include/lldb/Target/ThreadPlanStepInRange.h (+2-2) 
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+59-2) 
- (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+12) 
- (modified) lldb/source/Breakpoint/BreakpointSite.cpp (+16) 
- (modified) lldb/source/Core/Declaration.cpp (+1-1) 
- (modified) lldb/source/Symbol/CompileUnit.cpp (+103-1) 
- (modified) lldb/source/Target/StackFrameList.cpp (+55-115) 
- (modified) lldb/source/Target/StopInfo.cpp (+55) 
- (modified) lldb/source/Target/Thread.cpp (+8) 
- (modified) lldb/source/Target/ThreadPlanStepInRange.cpp (+18-6) 
- (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+1-1) 
- (modified) 
lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py (+54) 
- (modified) lldb/test/API/functionalities/inline-stepping/calling.cpp (+31) 


``diff
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "pre

[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits


@@ -38,6 +40,9 @@ class MainLoopBase {
   class ReadHandle;
 
 public:
+  using TimePoint = std::chrono::time_pointhttps://github.com/llvm/llvm-project/pull/112895
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits


@@ -7,27 +7,43 @@
 
//===--===//
 
 #include "lldb/Host/MainLoopBase.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
 
-void MainLoopBase::AddPendingCallback(const Callback &callback) {
+void MainLoopBase::AddCallback(const Callback &callback, TimePoint point) {
+  bool interrupt_needed;
   {
 std::lock_guard lock{m_callback_mutex};
-m_pending_callbacks.push_back(callback);
+// We need to interrupt the main thread if this callback is scheduled to
+// execute at an earlier time than the earliest callback registered so far.
+interrupt_needed = m_callbacks.empty() || point < m_callbacks.top().first;
+m_callbacks.emplace(point, callback);
   }
-  TriggerPendingCallbacks();
+  if (interrupt_needed)

Jlalond wrote:

If I understand the logic here, we're checking before emplacement if an 
interrupt is needed and then once we emplace we Interrupt,

- Why are we setting interrupt needed when callbacks is empty?
- Should we invert this where we trigger the interrupts before a potentially 
long emplace (this is in response to my nanoseconds fidelity question)

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits


@@ -7,27 +7,43 @@
 
//===--===//
 
 #include "lldb/Host/MainLoopBase.h"
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
 
-void MainLoopBase::AddPendingCallback(const Callback &callback) {
+void MainLoopBase::AddCallback(const Callback &callback, TimePoint point) {
+  bool interrupt_needed;
   {
 std::lock_guard lock{m_callback_mutex};
-m_pending_callbacks.push_back(callback);
+// We need to interrupt the main thread if this callback is scheduled to
+// execute at an earlier time than the earliest callback registered so far.
+interrupt_needed = m_callbacks.empty() || point < m_callbacks.top().first;
+m_callbacks.emplace(point, callback);
   }
-  TriggerPendingCallbacks();
+  if (interrupt_needed)
+Interrupt();
 }
 
-void MainLoopBase::ProcessPendingCallbacks() {
-  // Move the callbacks to a local vector to avoid keeping m_pending_callbacks
-  // locked throughout the calls.
-  std::vector pending_callbacks;
-  {
-std::lock_guard lock{m_callback_mutex};
-pending_callbacks = std::move(m_pending_callbacks);
-  }
+void MainLoopBase::ProcessCallbacks() {
+  while (true) {
+Callback callback;
+{
+  std::lock_guard lock{m_callback_mutex};
+  if (m_callbacks.empty() ||
+  std::chrono::steady_clock::now() < m_callbacks.top().first)
+return;
+  callback = std::move(m_callbacks.top().second);
+  m_callbacks.pop();
+}
 
-  for (const Callback &callback : pending_callbacks)
 callback(*this);
+  }
+}
+
+std::optional MainLoopBase::GetNextWakeupTime() {
+  std::lock_guard lock(m_callback_mutex);

Jlalond wrote:

Should this be a recursive mutex? Is there any situation where invoking a 
callback will end us back at this codepath? I know it's unlikely but my 
question is if it's impossible

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread Jacob Lalonde via lldb-commits


@@ -155,7 +181,9 @@ Status MainLoopPosix::RunImpl::Poll() {
 void *sigset_ptr;
 size_t sigset_len;
   } extra_data = {&kernel_sigset, sizeof(kernel_sigset)};
-  if (syscall(__NR_pselect6, nfds, &read_fd_set, nullptr, nullptr, nullptr,
+  if (syscall(__NR_pselect6, nfds, &read_fd_set, /*writefds=*/nullptr,

Jlalond wrote:

pselect is sufficiently complex that you might want to add a small blurb what 
you're doing

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 7da0a698526ff657c2348a6e4bb835fc764177da 
9c6705b21df14dc911665e1082c9b31ce00d7e7c --extensions h,cpp -- 
lldb/include/lldb/Breakpoint/BreakpointLocation.h 
lldb/include/lldb/Breakpoint/BreakpointSite.h 
lldb/include/lldb/Target/StopInfo.h 
lldb/include/lldb/Target/ThreadPlanStepInRange.h 
lldb/source/Breakpoint/BreakpointLocation.cpp 
lldb/source/Breakpoint/BreakpointResolver.cpp 
lldb/source/Breakpoint/BreakpointSite.cpp lldb/source/Core/Declaration.cpp 
lldb/source/Symbol/CompileUnit.cpp lldb/source/Target/StackFrameList.cpp 
lldb/source/Target/StopInfo.cpp lldb/source/Target/Thread.cpp 
lldb/source/Target/ThreadPlanStepInRange.cpp 
lldb/source/Target/ThreadPlanStepOverRange.cpp 
lldb/test/API/functionalities/inline-stepping/calling.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index f9c258daf1..552fafab97 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -283,7 +283,7 @@ public:
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
-  
+
   // Set the line entry that should be shown to users for this location.
   // It is up to the caller to verify that this is a valid entry to show.
   // The current use of this is to distinguish among line entries from a
@@ -291,7 +291,7 @@ public:
   void SetPreferredLineEntry(const LineEntry &line_entry) {
 m_preferred_line_entry = line_entry;
   }
-  
+
   const std::optional GetPreferredLineEntry() {
 return m_preferred_line_entry;
   }
@@ -319,7 +319,7 @@ protected:
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
-  
+
   // If this location knows that the virtual stack frame it represents is
   // not frame 0, return the suggested stack frame instead.  This will happen
   // when the location's address contains a "virtual inlined call stack" and 
the
@@ -393,13 +393,14 @@ private:
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
-  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
-// description rather than the LineEntry 
-// m_address resolves to directly.  Use 
this
-// for instance when the location was given
-// somewhere in the virtual inlined call
-// stack since the Address always resolves 
-// to the lowest entry in the stack.
+  std::optional
+  m_preferred_line_entry; // If this exists, use it to print the stop
+  // description rather than the LineEntry
+  // m_address resolves to directly.  Use this
+  // for instance when the location was given
+  // somewhere in the virtual inlined call
+  // stack since the Address always resolves
+  // to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 30cb5a80b9..7b3f7be236 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,7 +169,7 @@ public:
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
-  
+
   // This runs through all the breakpoint locations owning this site and 
returns
   // the greatest of their suggested stack frame indexes.  This only handles
   // inlined stack changes.
diff --git a/lldb/include/lldb/Target/StopInfo.h 
b/lldb/include/lldb/Target/StopInfo.h
index d997e0fd6f..45beac129e 100644
--- a/lldb/include/lldb/Target/StopInfo.h
+++ b/lldb/include/lldb/Target/StopInfo.h
@@ -79,13 +79,14 @@ public:
 
   /// This gives the StopInfo a chance to suggest a stack frame to select.
   /// Passing true for inlined_stack will request changes to the inlined
-  /// call stack.  Passing false will request changes to the real stack 
+  /// call stack.  Passing false will request changes to the real stack
   /// frame.  The inlined stack gets adjusted before we call into the thread
   /// plans so they can reason based on the cor

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 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 
7da0a698526ff657c2348a6e4bb835fc764177da...9c6705b21df14dc911665e1082c9b31ce00d7e7c
 lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
``





View the diff from darker here.


``diff
--- TestInlineStepping.py   2024-10-18 17:06:47.00 +
+++ TestInlineStepping.py   2024-10-18 17:28:12.421777 +
@@ -367,11 +367,13 @@
 def run_to_call_site_and_step(self, source_regex, func_name, start_pos):
 main_spec = lldb.SBFileSpec("calling.cpp")
 # Set the breakpoint by file and line, not sourced regex because
 # we want to make sure we can set breakpoints on call sites:
 call_site_line_num = line_number(self.main_source, source_regex)
-target, process, thread, bkpt = lldbutil.run_to_line_breakpoint(self, 
main_spec, call_site_line_num)
+target, process, thread, bkpt = lldbutil.run_to_line_breakpoint(
+self, main_spec, call_site_line_num
+)
 
 # Make sure that the location is at the call site 
(run_to_line_breakpoint already asserted
 # that there's one location.):
 bkpt_loc = bkpt.location[0]
 strm = lldb.SBStream()
@@ -381,19 +383,25 @@
 desc = strm.GetData()
 print(f"Description:\n{desc}\n")
 self.assertIn(f"calling.cpp:{call_site_line_num}", desc, "Right line 
listed")
 # We don't get the function name right yet - so we omit it in printing.
 # Turn on this test when that is working.
-#self.assertIn(func_name, desc, "Right function listed")
+# self.assertIn(func_name, desc, "Right function listed")
 
 pc = thread.frame[0].pc
 for i in range(start_pos, 3):
 thread.StepInto()
 frame_0 = thread.frame[0]
-
-trivial_line_num = line_number(self.main_source, f"In 
caller_trivial_inline_{i}.")
-self.assertEqual(frame_0.line_entry.line, trivial_line_num, 
f"Stepped into the caller_trivial_inline_{i}")
+
+trivial_line_num = line_number(
+self.main_source, f"In caller_trivial_inline_{i}."
+)
+self.assertEqual(
+frame_0.line_entry.line,
+trivial_line_num,
+f"Stepped into the caller_trivial_inline_{i}",
+)
 if pc != frame_0.pc:
 # If we get here, we stepped to the expected line number, but
 # the compiler on this system has decided to insert an 
instruction
 # between the call site of an inlined function with no 
arguments,
 # returning void, and its immediate call to another void 
inlined function
@@ -405,9 +413,11 @@
 target.Clear()
 
 def virtual_inline_stepping(self):
 """Use the Python API's to step through a virtual inlined stack"""
 self.run_to_call_site_and_step("At caller_trivial_inline_1", "main", 1)
-self.run_to_call_site_and_step("In caller_trivial_inline_1", 
"caller_trivial_inline_1", 2)
-self.run_to_call_site_and_step("In caller_trivial_inline_2", 
"caller_trivial_inline_2", 3)
-
-
+self.run_to_call_site_and_step(
+"In caller_trivial_inline_1", "caller_trivial_inline_1", 2
+)
+self.run_to_call_site_and_step(
+"In caller_trivial_inline_2", "caller_trivial_inline_2", 3
+)

``




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


[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-18 Thread Jorge Gorbe Moya via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-18 Thread Jorge Gorbe Moya via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-18 Thread Jorge Gorbe Moya via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix a crash when two diagnostics are on the same column or in … (PR #112451)

2024-10-18 Thread Jorge Gorbe Moya via lldb-commits


@@ -98,10 +94,31 @@ void RenderDiagnosticDetails(Stream &stream,
   continue;
 }
 
-auto &loc = *detail.source_location;
 remaining_details.push_back(detail);
+  }
+
+  // Sort the diagnostics.
+  auto sort = [](auto &ds) {
+llvm::sort(ds.begin(), ds.end(), [](auto &d1, auto &d2) {
+  auto l1 = 
d1.source_location.value_or(DiagnosticDetail::SourceLocation{});
+  auto l2 = 
d2.source_location.value_or(DiagnosticDetail::SourceLocation{});
+  return std::pair(l1.line, l2.column) < std::pair(l1.line, l2.column);

slackito wrote:

Btw, I found that bug because this commit is causing flakiness in the test. So 
the bad comparison is producing the expected results, sometimes.

Some more data I gathered poking around to hopefully help debug. If I change 
the comparator to
```
  return std::pair(l1.line, l1.column) < std::pair(l2.line, l2.column)
```
I still get (non-flaky) test failures. I think at least one of these test cases 
is wrong:
```
// Test that diagnostics in reverse order are emitted correctly.
SourceLocation loc1 = {FileSpec{"a.c"}, 1, 20, 0, false, true};
SourceLocation loc2 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
std::string result =
Render({DiagnosticDetail{loc2, eSeverityError, "X", "X"},
DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
  }
  {
// Test that diagnostics in reverse order are emitted correctly.
SourceLocation loc1 = {FileSpec{"a.c"}, 2, 10, 0, false, true};
SourceLocation loc2 = {FileSpec{"a.c"}, 1, 20, 0, false, true};
std::string result =
Render({DiagnosticDetail{loc2, eSeverityError, "X", "X"},
DiagnosticDetail{loc1, eSeverityError, "Y", "Y"}});
ASSERT_LT(StringRef(result).find("Y"), StringRef(result).find("X"));
  }
```
In the first one, we have "X" in `loc2` (line 2, col 10), and "Y" in `loc1` 
(line 1, col 20) , so they are in reverse order.
In the second one, we have "X" is in `loc2` (line 1, col 20), and "Y" in `loc1` 
(line 2, col 10), so despite the comment they are not in reverse order if lines 
are supposed to be compared first.

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


[Lldb-commits] [lldb] More aggressively deduplicate global warnings based on contents. (PR #112801)

2024-10-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/112801

>From 7d01c051172c89a722e386c9fb607919d4be11bc Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 17 Oct 2024 16:44:07 -0700
Subject: [PATCH] More aggressively deduplicate global warnings based on
 contents.

I've been getting complaints from users being spammed by -gmodules
missing file warnings going out of control because each object file
depends on an entire DAG of PCM files that usually are all missing at
once. To reduce this problem, this patch does two things:

1. Module now maintains a DenseMap that is used to display
each warning only once, based on its actual text.

2. The PCM warning itself is reworded to include less details, such as
the DIE offset, which is only useful to LLDB developers, who can get
this from the dwarf log if they need it. Because the detail is omitted
the hashing from (1) deduplicates the warnings.

rdar://138144624
---
 lldb/include/lldb/Core/Module.h   |  9 +++--
 lldb/source/Core/Module.cpp   | 34 +--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 25 +++---
 .../SymbolFile/DWARF/TestDedupWarnings.test   | 22 
 4 files changed, 65 insertions(+), 25 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/TestDedupWarnings.test

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 5589c1c9a350dc..e2a99cc7bcf50b 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -30,6 +30,7 @@
 
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/StableHashing.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Chrono.h"
 
@@ -1057,9 +1058,10 @@ class Module : public 
std::enable_shared_from_this,
   /// time for the symbol tables can be aggregated here.
   StatsDuration m_symtab_index_time;
 
-  std::once_flag m_optimization_warning;
-  std::once_flag m_language_warning;
-
+  /// A set of hashes of all warnings and errors, to avoid reporting them
+  /// multiple times to the same Debugger.
+  llvm::DenseMap>
+  m_shown_diagnostics;
   void SymbolIndicesToSymbolContextList(Symtab *symtab,
 std::vector &symbol_indexes,
 SymbolContextList &sc_list);
@@ -1086,6 +1088,7 @@ class Module : public 
std::enable_shared_from_this,
   void ReportWarning(const llvm::formatv_object_base &payload);
   void ReportError(const llvm::formatv_object_base &payload);
   void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
+  std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..6edf35566f991b 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
   ss << file_name
  << " was compiled with optimization - stepping may behave "
 "oddly; variables may not be available.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_optimization_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarningUnsupportedLanguage(
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
  << Language::GetNameForLanguageType(language)
  << "\". "
 "Inspection of frame variables will be limited.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_language_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportErrorIfModifyDetected(
@@ -1125,20 +1125,34 @@ void Module::ReportErrorIfModifyDetected(
   }
 }
 
+std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
+  // The manual DWARF index holds the module mutex on one thread, then
+  // spawns multiple worker thread which all can emit diagnostics. If
+  // this happens we give up on deduplicating them.
+  if (!m_mutex.try_lock())
+return nullptr;
+  auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
+  if (!once_ptr)
+once_ptr = std::make_unique();
+  m_mutex.unlock();
+  return once_ptr.get();
+}
+
 void Module::ReportError(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportError(strm.GetString().str());
+  std::string msg = payload.str();
+  strm << ' ' << msg;
+  Debugger::ReportError(strm.GetString().str(), {}, 
GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarning(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDes

[Lldb-commits] [lldb] More aggressively deduplicate global warnings based on contents. (PR #112801)

2024-10-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/112801

>From 3585c9ce2a79e7608ea666c9be5c398d0d5ce1cb Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 17 Oct 2024 16:44:07 -0700
Subject: [PATCH] More aggressively deduplicate global warnings based on
 contents.

I've been getting complaints from users being spammed by -gmodules
missing file warnings going out of control because each object file
depends on an entire DAG of PCM files that usually are all missing at
once. To reduce this problem, this patch does two things:

1. Module now maintains a DenseMap that is used to display
each warning only once, based on its actual text.

2. The PCM warning itself is reworded to include less details, such as
the DIE offset, which is only useful to LLDB developers, who can get
this from the dwarf log if they need it. Because the detail is omitted
the hashing from (1) deduplicates the warnings.

rdar://138144624
---
 lldb/include/lldb/Core/Module.h   |  9 --
 lldb/source/Core/Module.cpp   | 29 ---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 25 
 .../SymbolFile/DWARF/TestDedupWarnings.test   | 22 ++
 4 files changed, 61 insertions(+), 24 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/TestDedupWarnings.test

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 5589c1c9a350dc..23257e429ad0d6 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -30,6 +30,7 @@
 
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/StableHashing.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Chrono.h"
 
@@ -1057,8 +1058,11 @@ class Module : public 
std::enable_shared_from_this,
   /// time for the symbol tables can be aggregated here.
   StatsDuration m_symtab_index_time;
 
-  std::once_flag m_optimization_warning;
-  std::once_flag m_language_warning;
+  /// A set of hashes of all warnings and errors, to avoid reporting them
+  /// multiple times to the same Debugger.
+  llvm::DenseMap>
+  m_shown_diagnostics;
+  std::recursive_mutex m_diagnostic_mutex;
 
   void SymbolIndicesToSymbolContextList(Symtab *symtab,
 std::vector &symbol_indexes,
@@ -1086,6 +1090,7 @@ class Module : public 
std::enable_shared_from_this,
   void ReportWarning(const llvm::formatv_object_base &payload);
   void ReportError(const llvm::formatv_object_base &payload);
   void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
+  std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..03eb81459b29bc 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
   ss << file_name
  << " was compiled with optimization - stepping may behave "
 "oddly; variables may not be available.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_optimization_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarningUnsupportedLanguage(
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
  << Language::GetNameForLanguageType(language)
  << "\". "
 "Inspection of frame variables will be limited.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_language_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportErrorIfModifyDetected(
@@ -1125,20 +1125,29 @@ void Module::ReportErrorIfModifyDetected(
   }
 }
 
+std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
+  std::lock_guard guard(m_diagnostic_mutex);
+  auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
+  if (!once_ptr)
+once_ptr = std::make_unique();
+  return once_ptr.get();
+}
+
 void Module::ReportError(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportError(strm.GetString().str());
+  std::string msg = payload.str();
+  strm << ' ' << msg;
+  Debugger::ReportError(strm.GetString().str(), {}, 
GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarning(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportWarning(std::string(strm.GetString()));
+  std::string msg = payload.str();
+  strm << ' ' << msg;
+  Deb

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 1/2] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this s

[Lldb-commits] [lldb] More aggressively deduplicate global warnings based on contents. (PR #112801)

2024-10-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/112801

>From 14b4120a75f35ef8ade38e6dee2c60685de10c9b Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 17 Oct 2024 16:44:07 -0700
Subject: [PATCH] More aggressively deduplicate global warnings based on
 contents.

I've been getting complaints from users being spammed by -gmodules
missing file warnings going out of control because each object file
depends on an entire DAG of PCM files that usually are all missing at
once. To reduce this problem, this patch does two things:

1. Module now maintains a DenseMap that is used to display
each warning only once, based on its actual text.

2. The PCM warning itself is reworded to include less details, such as
the DIE offset, which is only useful to LLDB developers, who can get
this from the dwarf log if they need it. Because the detail is omitted
the hashing from (1) deduplicates the warnings.

rdar://138144624
---
 lldb/include/lldb/Core/Module.h   |  9 +++--
 lldb/source/Core/Module.cpp   | 34 +--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 25 +++---
 .../SymbolFile/DWARF/TestDedupWarnings.test   | 22 
 4 files changed, 65 insertions(+), 25 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/TestDedupWarnings.test

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 5589c1c9a350dc..e2a99cc7bcf50b 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -30,6 +30,7 @@
 
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/StableHashing.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Chrono.h"
 
@@ -1057,9 +1058,10 @@ class Module : public 
std::enable_shared_from_this,
   /// time for the symbol tables can be aggregated here.
   StatsDuration m_symtab_index_time;
 
-  std::once_flag m_optimization_warning;
-  std::once_flag m_language_warning;
-
+  /// A set of hashes of all warnings and errors, to avoid reporting them
+  /// multiple times to the same Debugger.
+  llvm::DenseMap>
+  m_shown_diagnostics;
   void SymbolIndicesToSymbolContextList(Symtab *symtab,
 std::vector &symbol_indexes,
 SymbolContextList &sc_list);
@@ -1086,6 +1088,7 @@ class Module : public 
std::enable_shared_from_this,
   void ReportWarning(const llvm::formatv_object_base &payload);
   void ReportError(const llvm::formatv_object_base &payload);
   void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
+  std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..9d34256538adf1 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
   ss << file_name
  << " was compiled with optimization - stepping may behave "
 "oddly; variables may not be available.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_optimization_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarningUnsupportedLanguage(
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
  << Language::GetNameForLanguageType(language)
  << "\". "
 "Inspection of frame variables will be limited.";
-  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
-  &m_language_warning);
+  llvm::StringRef msg = ss.GetString();
+  Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportErrorIfModifyDetected(
@@ -1125,20 +1125,34 @@ void Module::ReportErrorIfModifyDetected(
   }
 }
 
+std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
+  // The manual DWARF index holds the module mutex on one thread, then
+  // spawns multiple worker threads which all can emit diagnostics. If
+  // this happens we give up on deduplicating them.
+  if (!m_mutex.try_lock())
+return nullptr;
+  auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
+  if (!once_ptr)
+once_ptr = std::make_unique();
+  m_mutex.unlock();
+  return once_ptr.get();
+}
+
 void Module::ReportError(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
-  strm.PutChar(' ');
-  strm.PutCString(payload.str());
-  Debugger::ReportError(strm.GetString().str());
+  std::string msg = payload.str();
+  strm << ' ' << msg;
+  Debugger::ReportError(strm.GetString().str(), {}, 
GetDiagnosticOnceFlag(msg));
 }
 
 void Module::ReportWarning(const llvm::formatv_object_base &payload) {
   StreamString strm;
   GetDe

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.

adrian-prantl wrote:

same here ...

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


[Lldb-commits] [lldb] 2b7e9d2 - [lldb] Add missing whitespace in help text

2024-10-18 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-10-18T16:55:21-07:00
New Revision: 2b7e9d27817da54c34a6f02dc00d2466c31f6fa0

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

LOG: [lldb] Add missing whitespace in help text

Added: 


Modified: 
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index bfac3f4fea8d40..c990972ca64bcf 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -839,7 +839,7 @@ void CommandInterpreter::LoadCommandDictionary() {
   "argument displays at most that many frames. The argument 'all' "
   "displays all threads. Use 'settings set frame-format' to customize "
   "the printing of individual frames and 'settings set thread-format' "
-  "to customize the thread header. Frame recognizers may filter the"
+  "to customize the thread header. Frame recognizers may filter the "
   "list. Use 'thread backtrace -u (--unfiltered)' to see them all.",
   "bt [ | all]", 0, false));
   if (bt_regex_cmd_up) {



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


[Lldb-commits] [lldb] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (PR #113006)

2024-10-18 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/113006

Swift types have mangled names, so there should be a way to read those from the 
compiler type.

This patch upstreams these two changes from swiftlang/llvm-project (which were 
added there since at least 2016).

>From 4f49df5639b2ff7b9d23ba9e494521c5b74fbffc Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Fri, 18 Oct 2024 16:54:23 -0700
Subject: [PATCH] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType

Swift types have mangled names, so there should be a way to read those
from the compiler type.

This patch upstreams these two changes from swiftlang/llvm-project
(which were added there since at least 2016).
---
 lldb/include/lldb/Symbol/CompilerType.h | 2 ++
 lldb/include/lldb/Symbol/TypeSystem.h   | 4 
 lldb/source/Symbol/CompilerType.cpp | 8 
 lldb/source/Symbol/TypeSystem.cpp   | 4 
 4 files changed, 18 insertions(+)

diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 70dacdcb7986fc..096a8f1ab68e8b 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -279,6 +279,8 @@ class CompilerType {
 
   ConstString GetDisplayTypeName() const;
 
+  ConstString GetMangledTypeName() const;
+
   uint32_t
   GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
 
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..416445a60bd017 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -237,6 +237,10 @@ class TypeSystem : public PluginInterface,
 
   virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 
0;
 
+  // Defaults to GetTypeName(type).  Override if your language desires
+  // specialized behavior.
+  virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type);
+
   virtual uint32_t
   GetTypeInfo(lldb::opaque_compiler_type_t type,
   CompilerType *pointee_or_element_compiler_type) = 0;
diff --git a/lldb/source/Symbol/CompilerType.cpp 
b/lldb/source/Symbol/CompilerType.cpp
index f8da9ef7b7640d..e9e6e3bf2600ce 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -540,6 +540,14 @@ ConstString CompilerType::GetDisplayTypeName() const {
   return ConstString("");
 }
 
+ConstString CompilerType::GetMangledTypeName() const {
+  if (IsValid()) {
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->GetMangledTypeName(m_type);
+  }
+  return ConstString("");
+}
+
 uint32_t CompilerType::GetTypeInfo(
 CompilerType *pointee_or_element_compiler_type) const {
   if (IsValid())
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 931ce1b0203a93..f7d634ffa2dec5 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -157,6 +157,10 @@ bool 
TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
   return false;
 }
 
+ConstString TypeSystem::GetMangledTypeName(void *type) {
+  return GetTypeName(type, false);
+}
+
 ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
   return ConstString();
 }

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


[Lldb-commits] [lldb] [lldb] Add GetMangledTypeName to TypeSystem/CompilerType (PR #113006)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)


Changes

Swift types have mangled names, so there should be a way to read those from the 
compiler type.

This patch upstreams these two changes from swiftlang/llvm-project (which were 
added there since at least 2016).

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


4 Files Affected:

- (modified) lldb/include/lldb/Symbol/CompilerType.h (+2) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+4) 
- (modified) lldb/source/Symbol/CompilerType.cpp (+8) 
- (modified) lldb/source/Symbol/TypeSystem.cpp (+4) 


``diff
diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 70dacdcb7986fc..096a8f1ab68e8b 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -279,6 +279,8 @@ class CompilerType {
 
   ConstString GetDisplayTypeName() const;
 
+  ConstString GetMangledTypeName() const;
+
   uint32_t
   GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) const;
 
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..416445a60bd017 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -237,6 +237,10 @@ class TypeSystem : public PluginInterface,
 
   virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 
0;
 
+  // Defaults to GetTypeName(type).  Override if your language desires
+  // specialized behavior.
+  virtual ConstString GetMangledTypeName(lldb::opaque_compiler_type_t type);
+
   virtual uint32_t
   GetTypeInfo(lldb::opaque_compiler_type_t type,
   CompilerType *pointee_or_element_compiler_type) = 0;
diff --git a/lldb/source/Symbol/CompilerType.cpp 
b/lldb/source/Symbol/CompilerType.cpp
index f8da9ef7b7640d..e9e6e3bf2600ce 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -540,6 +540,14 @@ ConstString CompilerType::GetDisplayTypeName() const {
   return ConstString("");
 }
 
+ConstString CompilerType::GetMangledTypeName() const {
+  if (IsValid()) {
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->GetMangledTypeName(m_type);
+  }
+  return ConstString("");
+}
+
 uint32_t CompilerType::GetTypeInfo(
 CompilerType *pointee_or_element_compiler_type) const {
   if (IsValid())
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 931ce1b0203a93..f7d634ffa2dec5 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -157,6 +157,10 @@ bool 
TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
   return false;
 }
 
+ConstString TypeSystem::GetMangledTypeName(void *type) {
+  return GetTypeName(type, false);
+}
+
 ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
   return ConstString();
 }

``




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


[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-18 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/113007

Swift types have mangled type names. This adds functionality to look up those 
types through the FindTypes API by searching for the mangled type name instead 
of the regular name.

>From eb1f2bbd08d7f50286f0451ce0a6191c71c634eb Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Fri, 18 Oct 2024 16:59:39 -0700
Subject: [PATCH] [lldb] Extend FindTypes to optionally search by mangled type
 name

Swift types have mangled type names. This adds functionality to look up
those types through the FindTypes API by searching for the mangled type
name instead of the regular name.
---
 lldb/include/lldb/Symbol/Type.h   |  8 +
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.cpp  | 14 +---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 35 +++
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |  5 +--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  2 +-
 .../NativePDB/SymbolFileNativePDB.cpp |  5 ++-
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  |  5 ++-
 7 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 03d9f927997476..b90cfc44e907b9 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -84,6 +84,8 @@ FLAGS_ENUM(TypeQueryOptions){
 /// matching type is found. When false, the type query should find all
 /// matching types.
 e_find_one = (1u << 4),
+// If set, treat TypeQuery::m_name as a mangled name that should be 
searched.
+e_search_by_mangled_name = (1u << 5),
 };
 LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)
 
@@ -300,6 +302,12 @@ class TypeQuery {
   m_options &= ~e_find_one;
   }
 
+  /// Returns true if the type query is supposed to treat the name to be 
searched
+  /// as a mangled name.
+  bool GetSearchByMangledName() const {
+return (m_options & e_search_by_mangled_name) != 0;
+  }
+
   /// Access the internal compiler context array.
   ///
   /// Clients can use this to populate the context manually.
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index bb738c3dcc54a0..ee63c21663128a 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -1032,10 +1032,16 @@ void SymbolFileCTF::FindTypes(const 
lldb_private::TypeQuery &match,
 
   ConstString name = match.GetTypeBasename();
   for (TypeSP type_sp : GetTypeList().Types()) {
-if (type_sp && type_sp->GetName() == name) {
-  results.InsertUnique(type_sp);
-  if (results.Done(match))
-return;
+if (type_sp) {
+  auto type_name =
+  match.GetSearchByMangledName()
+  ? type_sp->GetForwardCompilerType().GetMangledTypeName()
+  : type_sp->GetName();
+  if (type_name == name) {
+results.InsertUnique(type_sp);
+if (results.Done(match))
+  return;
+  }
 }
   }
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index d83740f8e2113b..d4604d72b3a3b6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -14,6 +14,7 @@
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
 #include "lldb/Symbol/Type.h"
+#include "lldb/lldb-private-enumerations.h"
 
 #include "llvm/ADT/iterator.h"
 #include "llvm/BinaryFormat/Dwarf.h"
@@ -368,7 +369,7 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE 
&die) const {
   return nullptr;
 }
 
-static void GetDeclContextImpl(DWARFDIE die,
+static void GetDeclContextImpl(DWARFDIE die, bool use_mangled_name,
llvm::SmallSet &seen,
std::vector &context) {
   // Stop if we hit a cycle.
@@ -383,6 +384,13 @@ static void GetDeclContextImpl(DWARFDIE die,
 auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
   context.push_back({kind, ConstString(name)});
 };
+
+// Since mangled names are unique there's no need to build an entire 
context.
+if (use_mangled_name) {
+  push_ctx(CompilerContextKind::AnyType, die.GetMangledName());
+  return;
+}
+
 switch (die.Tag()) {
 case DW_TAG_module:
   push_ctx(CompilerContextKind::Module, die.GetName());
@@ -417,15 +425,15 @@ static void GetDeclContextImpl(DWARFDIE die,
   }
 }
 
-std::vector DWARFDIE::GetDeclContext() const {
+std::vector DWARFDIE::GetDeclContext(bool use_mangled_name) 
const {
   llvm::SmallSet seen;
   std::vector context;
-  GetDeclContextImpl(*this, seen, context);
+  GetDeclContextImpl(*this, use_mangled_name, seen, context);
   std::reverse(context.begin(), context.end());
   return context;
 }
 
-static void GetTypeLookupContextImpl(DWARFDIE die,
+static void GetTypeLookupContextImpl(DWARFDIE die, bool use_mangled_

[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-18 Thread Augusto Noronha via lldb-commits

augusto2112 wrote:

This depends on https://github.com/llvm/llvm-project/pull/113006

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


[Lldb-commits] [lldb] [lldb] Extend FindTypes to optionally search by mangled type name (PR #113007)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)


Changes

Swift types have mangled type names. This adds functionality to look up those 
types through the FindTypes API by searching for the mangled type name instead 
of the regular name.

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


7 Files Affected:

- (modified) lldb/include/lldb/Symbol/Type.h (+8) 
- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+10-4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (+28-7) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (+3-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
(+4-1) 
- (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+4-1) 


``diff
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 03d9f927997476..b90cfc44e907b9 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -84,6 +84,8 @@ FLAGS_ENUM(TypeQueryOptions){
 /// matching type is found. When false, the type query should find all
 /// matching types.
 e_find_one = (1u << 4),
+// If set, treat TypeQuery::m_name as a mangled name that should be 
searched.
+e_search_by_mangled_name = (1u << 5),
 };
 LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)
 
@@ -300,6 +302,12 @@ class TypeQuery {
   m_options &= ~e_find_one;
   }
 
+  /// Returns true if the type query is supposed to treat the name to be 
searched
+  /// as a mangled name.
+  bool GetSearchByMangledName() const {
+return (m_options & e_search_by_mangled_name) != 0;
+  }
+
   /// Access the internal compiler context array.
   ///
   /// Clients can use this to populate the context manually.
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index bb738c3dcc54a0..ee63c21663128a 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -1032,10 +1032,16 @@ void SymbolFileCTF::FindTypes(const 
lldb_private::TypeQuery &match,
 
   ConstString name = match.GetTypeBasename();
   for (TypeSP type_sp : GetTypeList().Types()) {
-if (type_sp && type_sp->GetName() == name) {
-  results.InsertUnique(type_sp);
-  if (results.Done(match))
-return;
+if (type_sp) {
+  auto type_name =
+  match.GetSearchByMangledName()
+  ? type_sp->GetForwardCompilerType().GetMangledTypeName()
+  : type_sp->GetName();
+  if (type_name == name) {
+results.InsertUnique(type_sp);
+if (results.Done(match))
+  return;
+  }
 }
   }
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index d83740f8e2113b..d4604d72b3a3b6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -14,6 +14,7 @@
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
 #include "lldb/Symbol/Type.h"
+#include "lldb/lldb-private-enumerations.h"
 
 #include "llvm/ADT/iterator.h"
 #include "llvm/BinaryFormat/Dwarf.h"
@@ -368,7 +369,7 @@ lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE 
&die) const {
   return nullptr;
 }
 
-static void GetDeclContextImpl(DWARFDIE die,
+static void GetDeclContextImpl(DWARFDIE die, bool use_mangled_name,
llvm::SmallSet &seen,
std::vector &context) {
   // Stop if we hit a cycle.
@@ -383,6 +384,13 @@ static void GetDeclContextImpl(DWARFDIE die,
 auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
   context.push_back({kind, ConstString(name)});
 };
+
+// Since mangled names are unique there's no need to build an entire 
context.
+if (use_mangled_name) {
+  push_ctx(CompilerContextKind::AnyType, die.GetMangledName());
+  return;
+}
+
 switch (die.Tag()) {
 case DW_TAG_module:
   push_ctx(CompilerContextKind::Module, die.GetName());
@@ -417,15 +425,15 @@ static void GetDeclContextImpl(DWARFDIE die,
   }
 }
 
-std::vector DWARFDIE::GetDeclContext() const {
+std::vector DWARFDIE::GetDeclContext(bool use_mangled_name) 
const {
   llvm::SmallSet seen;
   std::vector context;
-  GetDeclContextImpl(*this, seen, context);
+  GetDeclContextImpl(*this, use_mangled_name, seen, context);
   std::reverse(context.begin(), context.end());
   return context;
 }
 
-static void GetTypeLookupContextImpl(DWARFDIE die,
+static void GetTypeLookupContextImpl(DWARFDIE die, bool use_mangled_name,
  llvm::SmallSet &seen,
  std::vector &context) {
   // Stop if we hit a cycle.
@@ -434,6 +442,19 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
 auto push_ctx 

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -312,6 +315,112 @@ void CompileUnit::ResolveSymbolContext(
 0, file_indexes, src_location_spec, &line_entry);
   }
 
+  // If we didn't manage to find a breakpoint that matched the line number
+  // requested, that might be because it is only an inline call site, and
+  // doesn't have a line entry in the line table.  Scan for that here.
+  //
+  // We are making the assumption that if there was an inlined function it will
+  // contribute at least 1 non-call-site entry to the line table.  That's handy
+  // because we don't move line breakpoints over function boundaries, so if we
+  // found a hit, and there were also a call site entry, it would have to be in
+  // the function containing the PC of the line table match.  That way we can
+  // limit the call site search to that function.
+  // We will miss functions that ONLY exist as a call site entry.
+
+  if (line_entry.IsValid() &&
+  (line_entry.line != line || line_entry.column != column_num) &&
+  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+// We don't move lines over function boundaries, so the address in the
+// line entry will be the in function that contained the line that might
+// be a CallSite, and we can just iterate over that function to find any
+// inline records, and dig up their call sites.
+Address start_addr = line_entry.range.GetBaseAddress();
+Function *function = start_addr.CalculateSymbolContextFunction();
+
+Declaration sought_decl(file_spec, line, column_num);
+// We use this recursive function to descend the block structure looking
+// for a block that has this Declaration as in it's CallSite info.
+// This function recursively scans the sibling blocks of the incoming
+// block parameter.
+std::function examine_block =
+[&sought_decl, &sc_list, &src_location_spec, resolve_scope,
+ &examine_block](Block &block) -> void {
+  // Iterate over the sibling child blocks of the incoming block.
+  Block *sibling_block = block.GetFirstChild();
+  while (sibling_block) {
+// We only have to descend through the regular blocks, looking for
+// immediate inlines, since those are the only ones that will have this
+// callsite.
+const InlineFunctionInfo *inline_info =
+sibling_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  // If this is the call-site we are looking for, record that:
+  // We need to be careful because the call site from the debug info
+  // will generally have a column, but the user might not have 
specified
+  // it.
+  Declaration found_decl = inline_info->GetCallSite();
+  uint32_t sought_column = sought_decl.GetColumn();
+  if (found_decl.FileAndLineEqual(sought_decl) &&
+  (sought_column == LLDB_INVALID_COLUMN_NUMBER ||
+   sought_column == found_decl.GetColumn())) {
+// If we found a call site, it belongs not in this inlined block,
+// but in the parent block that inlined it.
+Address parent_start_addr;
+if (sibling_block->GetParent()->GetStartAddress(

adrian-prantl wrote:

etc ...

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.

adrian-prantl wrote:

Nit: these should all be Doxygen comments using ///

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

This breaks a number of tests on Windows.

Previously, to have tests working on Windows, one would do `git config --global 
core.autocrlf false` or similar, before checking out llvm-project - a number of 
test input files _need_ to be in LF form to work. This was brought up earlier 
already by @llvm-beanz in 
https://github.com/llvm/llvm-project/pull/86318#issuecomment-2093160376.

Now after this change, due to the added `.gitattributes` which overrides the 
`core.autocrlf` setting, these files get checked out with CRLF newlines (as the 
native form for the platform).

Based on the comment in the .gitattributes file, it seems like this is both 
known and intentional behaviour:
```
# Checkout as native, commit as LF except in specific circumstances
* text=auto
```

While it was already stated that blanket checkouts with CRLF _will_ fail.

Additionally, the old mechanism of getting working newlines in the files is 
suddenly broken.

---

To make things worse, you won't notice this thing if you're updating an 
existing workdir - files that aren't touched aren't rewritten. (To trigger 
re-checkout of files to get `.gitattributes` applied, one can do something like 
`git rm -r subdir && git reset && git checkout subdir`.) So I guess most 
buildbots will keep chugging along fine, until someone pushes changes that 
touch those files. If running with a fresh checkout of llvm-project, this has a 
much bigger impact.

---

For compiler-rt tests, a handful of the profile tests depend on the right line 
endings - I can push a local `.gitattributes` file to fix that (see 
https://github.com/mstorsjo/llvm-project/commit/99bec81c87dcd2b7a7970954882bc0e42239d381).

But the Clang, clang-tools-extra and LLVM testsuites have _many_ tests that are 
broken - from an initial (unverified) test run, there are around 80 tests 
failing due to this - sorting that out is a much bigger task that I'm not 
volunteering to take on right now.

CC @AaronBallman as the majority of those failing tests are in Clang.

Can we revert this until we figure out these bits? Do we really want checkouts 
to default to having the majority of files with CRLF on Windows? I would expect 
that most people working on Windows don't really want this (this wasn't the 
case so far anyway)? And other than that, we do need to tag the files that rely 
on being in LF form so that things work on Windows with either setting.

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-systemz

Author: Jay Foad (jayfoad)


Changes



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


19 Files Affected:

- (modified) clang/utils/TableGen/RISCVVEmitter.cpp (+2-2) 
- (modified) flang/docs/OptionComparison.md (+1-1) 
- (modified) flang/include/flang/Runtime/magic-numbers.h (+1-1) 
- (modified) flang/lib/Evaluate/intrinsics.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Numeric.cpp (+3-3) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Reduction.cpp (+1-1) 
- (modified) lldb/CMakeLists.txt (+1-1) 
- (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SSAUpdater.h (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td (+1-1) 
- (modified) llvm/test/Bitcode/upgrade-aarch64-sve-intrinsics.ll (+1-1) 
- (modified) llvm/test/CodeGen/SystemZ/vec-reduce-add-01.ll (+1-1) 
- (modified) llvm/test/Transforms/JumpThreading/thread-debug-info.ll (+1-1) 
- (modified) llvm/test/Transforms/SROA/fake-use-sroa.ll (+1-1) 
- (modified) llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp (+1-1) 
- (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+1-1) 


``diff
diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 50f161fd38ce69..aecca0f5df8d93 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -169,7 +169,7 @@ static VectorTypeModifier getTupleVTM(unsigned NF) {
 
 static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) {
   // We need a special rule for segment load/store since the data width is not
-  // encoded in the instrinsic name itself.
+  // encoded in the intrinsic name itself.
   const StringRef IRName = RVVI->getIRName();
   constexpr unsigned RVV_VTA = 0x1;
   constexpr unsigned RVV_VMA = 0x2;
@@ -192,7 +192,7 @@ static unsigned getIndexedLoadStorePtrIdx(const 
RVVIntrinsic *RVVI) {
 static unsigned getSegInstLog2SEW(StringRef InstName) {
   // clang-format off
   // We need a special rule for indexed segment load/store since the data width
-  // is not encoded in the instrinsic name itself.
+  // is not encoded in the intrinsic name itself.
   if (InstName.starts_with("vloxseg") || InstName.starts_with("vluxseg") ||
   InstName.starts_with("vsoxseg") || InstName.starts_with("vsuxseg"))
 return (unsigned)-1;
diff --git a/flang/docs/OptionComparison.md b/flang/docs/OptionComparison.md
index 9d6916ef62af2e..fb65498fa1f444 100644
--- a/flang/docs/OptionComparison.md
+++ b/flang/docs/OptionComparison.md
@@ -53,7 +53,7 @@ eN

fdec,
 
-fall-instrinsics
+fall-intrinsics

https://www-01.ibm.com/support/docview.wss?uid=swg27024803&aid=1#page=297";>qxlf77,
 
diff --git a/flang/include/flang/Runtime/magic-numbers.h 
b/flang/include/flang/Runtime/magic-numbers.h
index bab0e9ae05299a..1d3c5dca0b4bfb 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -107,7 +107,7 @@ The denorm value is a nonstandard extension.
 
 #if 0
 ieee_round_type values
-The values are those of the llvm.get.rounding instrinsic, which is assumed by
+The values are those of the llvm.get.rounding intrinsic, which is assumed by
 ieee_arithmetic module rounding procedures.
 #endif
 #define _FORTRAN_RUNTIME_IEEE_TO_ZERO 0
diff --git a/flang/lib/Evaluate/intrinsics.cpp 
b/flang/lib/Evaluate/intrinsics.cpp
index 4271faa0db12bf..aa44967817722e 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1690,7 +1690,7 @@ std::optional IntrinsicInterface::Match(
   // MAX and MIN (and others that map to them) allow their last argument to
   // be repeated indefinitely.  The actualForDummy vector is sized
   // and null-initialized to the non-repeated dummy argument count
-  // for other instrinsics.
+  // for other intrinsics.
   bool isMaxMin{dummyArgPatterns > 0 &&
   dummy[dummyArgPatterns - 1].optionality == Optionality::repeats};
   std::vector actualForDummy(
diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp 
b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
index c13064a284d127..d0092add0118f1 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
@@ -284,7 +284,7 @@ struct ForcedSpacing16 {
   }
 };
 
-/// Generate call to Exponent instrinsic runtime routine.
+/// Generate call to Exponent intrinsic runtime routine.
 mlir::Value fir::runtime::genExponent(fir::FirOpBuilder &builder,
   mlir::Location loc, mlir::Type 
resultType,
   mlir::Value x) {
@@ -320,7 +320,7 @@ mlir::Value fir::runtime::genExponent(f

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits


@@ -32,6 +32,12 @@ def test_step_in_template_with_python_api(self):
 self.build()
 self.step_in_template()
 
+@add_test_categories(["pyapi"])
+def test_virtual_inline_stepping(self):
+"""Test stepping through a virtual inlined call stack"""
+self.build()
+self.virtual_inline_stepping()
+
 def setUp(self):

jimingham wrote:

Not sure what you mean.  This is the style we often write tests in where we 
have the to unittest significant `test_whatever` function be just a shim on the 
real test function.  That makes it easy to see what all the tests are up front 
without having to wade through the details.  That's how all the other tests in 
this file work as well.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -312,6 +315,112 @@ void CompileUnit::ResolveSymbolContext(
 0, file_indexes, src_location_spec, &line_entry);
   }
 
+  // If we didn't manage to find a breakpoint that matched the line number
+  // requested, that might be because it is only an inline call site, and
+  // doesn't have a line entry in the line table.  Scan for that here.
+  //
+  // We are making the assumption that if there was an inlined function it will
+  // contribute at least 1 non-call-site entry to the line table.  That's handy
+  // because we don't move line breakpoints over function boundaries, so if we
+  // found a hit, and there were also a call site entry, it would have to be in
+  // the function containing the PC of the line table match.  That way we can
+  // limit the call site search to that function.
+  // We will miss functions that ONLY exist as a call site entry.
+
+  if (line_entry.IsValid() &&
+  (line_entry.line != line || line_entry.column != column_num) &&
+  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+// We don't move lines over function boundaries, so the address in the
+// line entry will be the in function that contained the line that might
+// be a CallSite, and we can just iterate over that function to find any
+// inline records, and dig up their call sites.
+Address start_addr = line_entry.range.GetBaseAddress();
+Function *function = start_addr.CalculateSymbolContextFunction();
+
+Declaration sought_decl(file_spec, line, column_num);
+// We use this recursive function to descend the block structure looking
+// for a block that has this Declaration as in it's CallSite info.
+// This function recursively scans the sibling blocks of the incoming
+// block parameter.
+std::function examine_block =
+[&sought_decl, &sc_list, &src_location_spec, resolve_scope,
+ &examine_block](Block &block) -> void {
+  // Iterate over the sibling child blocks of the incoming block.
+  Block *sibling_block = block.GetFirstChild();
+  while (sibling_block) {
+// We only have to descend through the regular blocks, looking for
+// immediate inlines, since those are the only ones that will have this
+// callsite.
+const InlineFunctionInfo *inline_info =
+sibling_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  // If this is the call-site we are looking for, record that:
+  // We need to be careful because the call site from the debug info
+  // will generally have a column, but the user might not have 
specified
+  // it.
+  Declaration found_decl = inline_info->GetCallSite();
+  uint32_t sought_column = sought_decl.GetColumn();
+  if (found_decl.FileAndLineEqual(sought_decl) &&

adrian-prantl wrote:

```suggestion
  if (!found_decl.FileAndLineEqual(sought_decl))
continue;
  if (sought_column != LLDB_INVALID_COLUMN_NUMBER &&
   sought_column != found_decl.GetColumn())
 continue;
```

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.

Very exciting, this is something I've wished for for a long time!

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -32,6 +32,12 @@ def test_step_in_template_with_python_api(self):
 self.build()
 self.step_in_template()
 
+@add_test_categories(["pyapi"])
+def test_virtual_inline_stepping(self):
+"""Test stepping through a virtual inlined call stack"""
+self.build()
+self.virtual_inline_stepping()
+
 def setUp(self):

adrian-prantl wrote:

I was referring to the setUp() function that just calls the parent setUp 
function. If it's still needed ignore this,.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits


@@ -312,6 +315,112 @@ void CompileUnit::ResolveSymbolContext(
 0, file_indexes, src_location_spec, &line_entry);
   }
 
+  // If we didn't manage to find a breakpoint that matched the line number
+  // requested, that might be because it is only an inline call site, and
+  // doesn't have a line entry in the line table.  Scan for that here.
+  //
+  // We are making the assumption that if there was an inlined function it will
+  // contribute at least 1 non-call-site entry to the line table.  That's handy
+  // because we don't move line breakpoints over function boundaries, so if we
+  // found a hit, and there were also a call site entry, it would have to be in
+  // the function containing the PC of the line table match.  That way we can
+  // limit the call site search to that function.
+  // We will miss functions that ONLY exist as a call site entry.
+
+  if (line_entry.IsValid() &&
+  (line_entry.line != line || line_entry.column != column_num) &&
+  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+// We don't move lines over function boundaries, so the address in the
+// line entry will be the in function that contained the line that might
+// be a CallSite, and we can just iterate over that function to find any
+// inline records, and dig up their call sites.
+Address start_addr = line_entry.range.GetBaseAddress();
+Function *function = start_addr.CalculateSymbolContextFunction();
+
+Declaration sought_decl(file_spec, line, column_num);
+// We use this recursive function to descend the block structure looking
+// for a block that has this Declaration as in it's CallSite info.
+// This function recursively scans the sibling blocks of the incoming
+// block parameter.
+std::function examine_block =
+[&sought_decl, &sc_list, &src_location_spec, resolve_scope,
+ &examine_block](Block &block) -> void {
+  // Iterate over the sibling child blocks of the incoming block.
+  Block *sibling_block = block.GetFirstChild();
+  while (sibling_block) {
+// We only have to descend through the regular blocks, looking for
+// immediate inlines, since those are the only ones that will have this
+// callsite.
+const InlineFunctionInfo *inline_info =
+sibling_block->GetInlinedFunctionInfo();
+if (inline_info) {

jimingham wrote:

I don't think that's right.  We still need to do the bit after the if block to 
recurse the children and set the next sibling block.  I'd have to have a 
"goto", you can't just continue here.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop

adrian-prantl wrote:

And if you use the Doxygen comment syntax, IDEs will know to associate the 
comment with the following declaration.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 1/3] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this s

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -312,6 +315,112 @@ void CompileUnit::ResolveSymbolContext(
 0, file_indexes, src_location_spec, &line_entry);
   }
 
+  // If we didn't manage to find a breakpoint that matched the line number
+  // requested, that might be because it is only an inline call site, and
+  // doesn't have a line entry in the line table.  Scan for that here.
+  //
+  // We are making the assumption that if there was an inlined function it will
+  // contribute at least 1 non-call-site entry to the line table.  That's handy
+  // because we don't move line breakpoints over function boundaries, so if we
+  // found a hit, and there were also a call site entry, it would have to be in
+  // the function containing the PC of the line table match.  That way we can
+  // limit the call site search to that function.
+  // We will miss functions that ONLY exist as a call site entry.
+
+  if (line_entry.IsValid() &&
+  (line_entry.line != line || line_entry.column != column_num) &&
+  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+// We don't move lines over function boundaries, so the address in the
+// line entry will be the in function that contained the line that might
+// be a CallSite, and we can just iterate over that function to find any
+// inline records, and dig up their call sites.
+Address start_addr = line_entry.range.GetBaseAddress();
+Function *function = start_addr.CalculateSymbolContextFunction();
+
+Declaration sought_decl(file_spec, line, column_num);
+// We use this recursive function to descend the block structure looking
+// for a block that has this Declaration as in it's CallSite info.
+// This function recursively scans the sibling blocks of the incoming
+// block parameter.
+std::function examine_block =
+[&sought_decl, &sc_list, &src_location_spec, resolve_scope,
+ &examine_block](Block &block) -> void {
+  // Iterate over the sibling child blocks of the incoming block.
+  Block *sibling_block = block.GetFirstChild();
+  while (sibling_block) {
+// We only have to descend through the regular blocks, looking for
+// immediate inlines, since those are the only ones that will have this
+// callsite.
+const InlineFunctionInfo *inline_info =
+sibling_block->GetInlinedFunctionInfo();
+if (inline_info) {

adrian-prantl wrote:

```suggestion
if (!inline_info)
  continue;
```

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 1/4] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this s

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -656,6 +671,49 @@ void 
BreakpointLocation::SendBreakpointLocationChangedEvent(
   }
 }
 
+std::optional BreakpointLocation::GetSuggestedStackFrameIndex() {
+  if (!GetPreferredLineEntry())
+return {};
+  LineEntry preferred = *GetPreferredLineEntry();
+  SymbolContext sc;
+  if (!m_address.CalculateSymbolContext(&sc))
+return {};
+  // Don't return anything special if frame 0 is the preferred line entry.
+  // We not really telling the stack frame list to do anything special in that
+  // case.
+  if (!LineEntry::Compare(sc.line_entry, preferred))
+return {};
+
+  if (!sc.block)
+return {};
+
+  // Blocks have their line info in Declaration form, so make one here:
+  Declaration preferred_decl(preferred.GetFile(), preferred.line,
+ preferred.column);
+
+  uint32_t depth = 0;
+  Block *inlined_block = sc.block->GetContainingInlinedBlock();
+  while (inlined_block) {
+// If we've moved to a block that this isn't the start of, that's not
+// our inlining info or call site, so we can stop here.
+Address start_address;
+if (!inlined_block->GetStartAddress(start_address) ||
+start_address != m_address)
+  return {};
+
+const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo();
+if (info) {
+  if (preferred_decl == info->GetDeclaration())
+return depth;
+  if (preferred_decl == info->GetCallSite())
+return depth + 1;
+}
+inlined_block = inlined_block->GetInlinedParent();
+depth++;

adrian-prantl wrote:

Should there be a `(if depth > 1000) return {}` condition to deal with 
completely broken debug info?

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 1/5] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this s

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop

adrian-prantl wrote:

IMO the end-of line comment style only makes sense if the comment fits on one 
line.
```suggestion
  /// If this exists, use it to print the stop description rather than the 
LineEntry
  /// ...
  std::optional m_preferred_line_entry; 
```

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits


@@ -357,3 +363,61 @@ def step_in_template(self):
 
 step_sequence = [["// In max_value specialized", "into"]]
 self.run_step_sequence(step_sequence)
+
+def run_to_call_site_and_step(self, source_regex, func_name, start_pos):
+main_spec = lldb.SBFileSpec("calling.cpp")
+# Set the breakpoint by file and line, not sourced regex because
+# we want to make sure we can set breakpoints on call sites:
+call_site_line_num = line_number(self.main_source, source_regex)
+target, process, thread, bkpt = lldbutil.run_to_line_breakpoint(
+self, main_spec, call_site_line_num
+)
+
+# Make sure that the location is at the call site 
(run_to_line_breakpoint already asserted
+# that there's one location.):
+bkpt_loc = bkpt.location[0]
+strm = lldb.SBStream()
+result = bkpt_loc.GetDescription(strm, lldb.eDescriptionLevelFull)
+
+self.assertTrue(result, "Got a location description")
+desc = strm.GetData()
+print(f"Description:\n{desc}\n")

jimingham wrote:

Debugging detritus, I'll just remove it.


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


[Lldb-commits] [lldb] [lldb] Introduce Language::AreEquivalentFunctions (PR #112720)

2024-10-18 Thread via lldb-commits

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

It's a bit sad we can't come up with a scenario that uses this for the 
languages in the llvm.org repo.  But the idea is clear the code really simple, 
and it obviously belongs in the Language, so LGTM.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits


@@ -32,6 +32,12 @@ def test_step_in_template_with_python_api(self):
 self.build()
 self.step_in_template()
 
+@add_test_categories(["pyapi"])
+def test_virtual_inline_stepping(self):
+"""Test stepping through a virtual inlined call stack"""
+self.build()
+self.virtual_inline_stepping()
+
 def setUp(self):

jimingham wrote:

Ah.  The other tests still need the setUp.  I don't use need the work it does 
for the test I added, but it doesn't do very much, so IMO it's not worth making 
another test class just to avoid calling it.  

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Med Ismail Bennani via lldb-commits


@@ -508,8 +508,20 @@ void BreakpointLocation::GetDescription(Stream *s,
 s->PutCString("re-exported target = ");
   else
 s->PutCString("where = ");
+
+  // If there's a preferred line entry for printing, use that.
+  bool show_function_info = true;
+  if (GetPreferredLineEntry()) {
+sc.line_entry = *GetPreferredLineEntry();

medismailben wrote:

nit: avoid 2 function calls
```suggestion
  if (auto may_be_line_entry = GetPreferredLineEntry()) {
sc.line_entry = *may_be_line_entry;
```

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Med Ismail Bennani via lldb-commits


@@ -656,6 +671,49 @@ void 
BreakpointLocation::SendBreakpointLocationChangedEvent(
   }
 }
 
+std::optional BreakpointLocation::GetSuggestedStackFrameIndex() {
+  if (!GetPreferredLineEntry())
+return {};
+  LineEntry preferred = *GetPreferredLineEntry();

medismailben wrote:

ditto

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Med Ismail Bennani via lldb-commits


@@ -537,7 +549,10 @@ void BreakpointLocation::GetDescription(Stream *s,
 if (sc.line_entry.line > 0) {
   s->EOL();
   s->Indent("location = ");
-  sc.line_entry.DumpStopContext(s, true);
+  if (GetPreferredLineEntry())
+GetPreferredLineEntry()->DumpStopContext(s, true);

medismailben wrote:

ditto

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

I just had someone in my office hours also running into problems from this 
commit. I went to revert the changes myself and I cannot because of merge 
conflicts... due to line endings.

@ldrumm -- can you revert these changes ASAP? They're causing significant 
problems in practice, so best to get us back to green rather than fix forward. 
Thanks!

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/112939

>From 9c6705b21df14dc911665e1082c9b31ce00d7e7c Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Thu, 3 Oct 2024 18:24:46 -0700
Subject: [PATCH 1/6] Add the ability to break on call-site locations, report
 the correct position in the virtual inlined call stack when they are hit, and
 step through the inlined stack from there.

---
 .../lldb/Breakpoint/BreakpointLocation.h  |  31 
 lldb/include/lldb/Breakpoint/BreakpointSite.h |   5 +
 lldb/include/lldb/Target/StopInfo.h   |  11 ++
 .../lldb/Target/ThreadPlanStepInRange.h   |   4 +-
 lldb/source/Breakpoint/BreakpointLocation.cpp |  61 ++-
 lldb/source/Breakpoint/BreakpointResolver.cpp |  12 ++
 lldb/source/Breakpoint/BreakpointSite.cpp |  16 ++
 lldb/source/Core/Declaration.cpp  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp| 104 ++-
 lldb/source/Target/StackFrameList.cpp | 170 ++
 lldb/source/Target/StopInfo.cpp   |  55 ++
 lldb/source/Target/Thread.cpp |   8 +
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  24 ++-
 .../source/Target/ThreadPlanStepOverRange.cpp |   2 +-
 .../inline-stepping/TestInlineStepping.py |  54 ++
 .../inline-stepping/calling.cpp   |  31 
 16 files changed, 462 insertions(+), 128 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h 
b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index cca00335bc3c67..f9c258daf137f7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -11,10 +11,12 @@
 
 #include 
 #include 
+#include 
 
 #include "lldb/Breakpoint/BreakpointOptions.h"
 #include "lldb/Breakpoint/StoppointHitCounter.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 
@@ -281,6 +283,18 @@ class BreakpointLocation
 
   /// Returns the breakpoint location ID.
   lldb::break_id_t GetID() const { return m_loc_id; }
+  
+  // Set the line entry that should be shown to users for this location.
+  // It is up to the caller to verify that this is a valid entry to show.
+  // The current use of this is to distinguish among line entries from a
+  // virtual inlined call stack that all share the same address.
+  void SetPreferredLineEntry(const LineEntry &line_entry) {
+m_preferred_line_entry = line_entry;
+  }
+  
+  const std::optional GetPreferredLineEntry() {
+return m_preferred_line_entry;
+  }
 
 protected:
   friend class BreakpointSite;
@@ -305,6 +319,16 @@ class BreakpointLocation
   /// It also takes care of decrementing the ignore counters.
   /// If it returns false we should continue, otherwise stop.
   bool IgnoreCountShouldStop();
+  
+  // If this location knows that the virtual stack frame it represents is
+  // not frame 0, return the suggested stack frame instead.  This will happen
+  // when the location's address contains a "virtual inlined call stack" and 
the
+  // breakpoint was set on a file & line that are not at the bottom of that
+  // stack.  For now we key off the "preferred line entry" - looking for that
+  // in the blocks that start with the stop PC.
+  // This version of the API doesn't take an "inlined" parameter because it
+  // only changes frames in the inline stack.
+  std::optional GetSuggestedStackFrameIndex();
 
 private:
   void SwapLocation(lldb::BreakpointLocationSP swap_from);
@@ -369,6 +393,13 @@ class BreakpointLocation
   lldb::break_id_t m_loc_id; ///< Breakpoint location ID.
   StoppointHitCounter m_hit_counter; ///< Number of times this breakpoint
  /// location has been hit.
+  std::optional m_preferred_line_entry; // If this exists, use it 
to print the stop
+// description rather than the LineEntry 
+// m_address resolves to directly.  Use 
this
+// for instance when the location was given
+// somewhere in the virtual inlined call
+// stack since the Address always resolves 
+// to the lowest entry in the stack.
 
   void SetShouldResolveIndirectFunctions(bool do_resolve) {
 m_should_resolve_indirect_functions = do_resolve;
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h 
b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 17b76d51c1ae53..30cb5a80b908e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -169,6 +169,11 @@ class BreakpointSite : public 
std::enable_shared_from_this,
   ///
   /// \see lldb::DescriptionLevel
   void GetDescription(Stream *s, lldb::DescriptionLevel level);
+  
+  // This runs through all the breakpoint locations owning this s

[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -357,3 +363,61 @@ def step_in_template(self):
 
 step_sequence = [["// In max_value specialized", "into"]]
 self.run_step_sequence(step_sequence)
+
+def run_to_call_site_and_step(self, source_regex, func_name, start_pos):
+main_spec = lldb.SBFileSpec("calling.cpp")
+# Set the breakpoint by file and line, not sourced regex because
+# we want to make sure we can set breakpoints on call sites:
+call_site_line_num = line_number(self.main_source, source_regex)
+target, process, thread, bkpt = lldbutil.run_to_line_breakpoint(
+self, main_spec, call_site_line_num
+)
+
+# Make sure that the location is at the call site 
(run_to_line_breakpoint already asserted
+# that there's one location.):
+bkpt_loc = bkpt.location[0]
+strm = lldb.SBStream()
+result = bkpt_loc.GetDescription(strm, lldb.eDescriptionLevelFull)
+
+self.assertTrue(result, "Got a location description")
+desc = strm.GetData()
+print(f"Description:\n{desc}\n")

adrian-prantl wrote:

should this be `if self.TraceOn():`?

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread via lldb-commits


@@ -656,6 +671,49 @@ void 
BreakpointLocation::SendBreakpointLocationChangedEvent(
   }
 }
 
+std::optional BreakpointLocation::GetSuggestedStackFrameIndex() {
+  if (!GetPreferredLineEntry())
+return {};
+  LineEntry preferred = *GetPreferredLineEntry();
+  SymbolContext sc;
+  if (!m_address.CalculateSymbolContext(&sc))
+return {};
+  // Don't return anything special if frame 0 is the preferred line entry.
+  // We not really telling the stack frame list to do anything special in that
+  // case.
+  if (!LineEntry::Compare(sc.line_entry, preferred))
+return {};
+
+  if (!sc.block)
+return {};
+
+  // Blocks have their line info in Declaration form, so make one here:
+  Declaration preferred_decl(preferred.GetFile(), preferred.line,
+ preferred.column);
+
+  uint32_t depth = 0;
+  Block *inlined_block = sc.block->GetContainingInlinedBlock();
+  while (inlined_block) {
+// If we've moved to a block that this isn't the start of, that's not
+// our inlining info or call site, so we can stop here.
+Address start_address;
+if (!inlined_block->GetStartAddress(start_address) ||
+start_address != m_address)
+  return {};
+
+const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo();
+if (info) {
+  if (preferred_decl == info->GetDeclaration())
+return depth;
+  if (preferred_decl == info->GetCallSite())
+return depth + 1;
+}
+inlined_block = inlined_block->GetInlinedParent();
+depth++;

jimingham wrote:

That would mean there were cycles in the blocks?  I don't think we guard 
against that anywhere else that we're traversing the block structure.

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


[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)

2024-10-18 Thread Adrian Prantl via lldb-commits


@@ -32,6 +32,12 @@ def test_step_in_template_with_python_api(self):
 self.build()
 self.step_in_template()
 
+@add_test_categories(["pyapi"])
+def test_virtual_inline_stepping(self):
+"""Test stepping through a virtual inlined call stack"""
+self.build()
+self.virtual_inline_stepping()
+
 def setUp(self):

adrian-prantl wrote:

I believe this entire function is no longer needed.

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


[Lldb-commits] [lldb] [lldb] Improve unwinding for discontinuous functions (PR #111409)

2024-10-18 Thread Pavel Labath via lldb-commits

labath wrote:

Thank you for looking into this.

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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-18 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,20 @@
+#ifndef SERVICE_H_IN
+#define SERVICE_H_IN
+
+struct ServiceAux;
+
+struct Service {
+  struct State;
+  bool start(State *) { return true; }
+
+#ifdef HIDE_FROM_PLUGIN

labath wrote:

I'm wondering if this is really how the original code looked like. This is a 
particularly nasty form of ODR violation as it messes with the offsets of every 
field that comes after it (including of the non-plugin Proxy class which 
inherits from it). It doesn't really matter, as I still think it lldb should be 
able to handle this kind of a situation, but I'm surprised that code like this 
could ever work. Could it be that the original code used a milder form of this, 
like declaring a field with a different name/type (but the same size&alignment)?

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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-18 Thread Michael Buch via lldb-commits


@@ -0,0 +1,20 @@
+#ifndef SERVICE_H_IN
+#define SERVICE_H_IN
+
+struct ServiceAux;
+
+struct Service {
+  struct State;
+  bool start(State *) { return true; }
+
+#ifdef HIDE_FROM_PLUGIN

Michael137 wrote:

Yea unfortunately this is what the internal users are doing. I reached out to 
them to understand how this is not causing issues for them. They compile with a 
non-standards conforming extensions, so that might be part of the story

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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-18 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread Jay Foad via lldb-commits

https://github.com/jayfoad created 
https://github.com/llvm/llvm-project/pull/112899

None

>From 3a3b67f30cde766adaede4cc53bec340fbe5d99f Mon Sep 17 00:00:00 2001
From: Jay Foad 
Date: Fri, 18 Oct 2024 13:53:51 +0100
Subject: [PATCH] Fix typo "instrinsic"

---
 clang/utils/TableGen/RISCVVEmitter.cpp   | 4 ++--
 flang/docs/OptionComparison.md   | 2 +-
 flang/include/flang/Runtime/magic-numbers.h  | 2 +-
 flang/lib/Evaluate/intrinsics.cpp| 2 +-
 flang/lib/Optimizer/Builder/Runtime/Numeric.cpp  | 6 +++---
 flang/lib/Optimizer/Builder/Runtime/Reduction.cpp| 2 +-
 lldb/CMakeLists.txt  | 2 +-
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td | 2 +-
 llvm/include/llvm/Transforms/Utils/SSAUpdater.h  | 2 +-
 llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp | 2 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td  | 2 +-
 llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td  | 2 +-
 llvm/test/Bitcode/upgrade-aarch64-sve-intrinsics.ll  | 2 +-
 llvm/test/CodeGen/SystemZ/vec-reduce-add-01.ll   | 2 +-
 llvm/test/Transforms/JumpThreading/thread-debug-info.ll  | 2 +-
 llvm/test/Transforms/SROA/fake-use-sroa.ll   | 2 +-
 llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp| 2 +-
 mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp | 2 +-
 mlir/lib/Target/LLVMIR/ModuleImport.cpp  | 2 +-
 19 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 50f161fd38ce69..aecca0f5df8d93 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -169,7 +169,7 @@ static VectorTypeModifier getTupleVTM(unsigned NF) {
 
 static unsigned getIndexedLoadStorePtrIdx(const RVVIntrinsic *RVVI) {
   // We need a special rule for segment load/store since the data width is not
-  // encoded in the instrinsic name itself.
+  // encoded in the intrinsic name itself.
   const StringRef IRName = RVVI->getIRName();
   constexpr unsigned RVV_VTA = 0x1;
   constexpr unsigned RVV_VMA = 0x2;
@@ -192,7 +192,7 @@ static unsigned getIndexedLoadStorePtrIdx(const 
RVVIntrinsic *RVVI) {
 static unsigned getSegInstLog2SEW(StringRef InstName) {
   // clang-format off
   // We need a special rule for indexed segment load/store since the data width
-  // is not encoded in the instrinsic name itself.
+  // is not encoded in the intrinsic name itself.
   if (InstName.starts_with("vloxseg") || InstName.starts_with("vluxseg") ||
   InstName.starts_with("vsoxseg") || InstName.starts_with("vsuxseg"))
 return (unsigned)-1;
diff --git a/flang/docs/OptionComparison.md b/flang/docs/OptionComparison.md
index 9d6916ef62af2e..fb65498fa1f444 100644
--- a/flang/docs/OptionComparison.md
+++ b/flang/docs/OptionComparison.md
@@ -53,7 +53,7 @@ eN

fdec,
 
-fall-instrinsics
+fall-intrinsics

https://www-01.ibm.com/support/docview.wss?uid=swg27024803&aid=1#page=297";>qxlf77,
 
diff --git a/flang/include/flang/Runtime/magic-numbers.h 
b/flang/include/flang/Runtime/magic-numbers.h
index bab0e9ae05299a..1d3c5dca0b4bfb 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -107,7 +107,7 @@ The denorm value is a nonstandard extension.
 
 #if 0
 ieee_round_type values
-The values are those of the llvm.get.rounding instrinsic, which is assumed by
+The values are those of the llvm.get.rounding intrinsic, which is assumed by
 ieee_arithmetic module rounding procedures.
 #endif
 #define _FORTRAN_RUNTIME_IEEE_TO_ZERO 0
diff --git a/flang/lib/Evaluate/intrinsics.cpp 
b/flang/lib/Evaluate/intrinsics.cpp
index 4271faa0db12bf..aa44967817722e 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1690,7 +1690,7 @@ std::optional IntrinsicInterface::Match(
   // MAX and MIN (and others that map to them) allow their last argument to
   // be repeated indefinitely.  The actualForDummy vector is sized
   // and null-initialized to the non-repeated dummy argument count
-  // for other instrinsics.
+  // for other intrinsics.
   bool isMaxMin{dummyArgPatterns > 0 &&
   dummy[dummyArgPatterns - 1].optionality == Optionality::repeats};
   std::vector actualForDummy(
diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp 
b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
index c13064a284d127..d0092add0118f1 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
@@ -284,7 +284,7 @@ struct ForcedSpacing16 {
   }
 };
 
-/// Generate call to Exponent instrinsic runtime routine.
+/// Generate call to Exponent intrinsic runtime routine.
 mlir::Value fir::runtime::genExponent(fir::FirOpBuilder &builder,
   mlir::Location loc, mlir::Type 
resultType,
   

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread Arthur Eubanks via lldb-commits

aeubanks wrote:

I believe Chrome is also seeing many test failures due to this 
(https://crbug.com/374115887), although I haven't yet confirmed it's due to 
this specific commit.

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)

2024-10-18 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

https://github.com/llvm/llvm-project/commit/c742a5dc2e67e1f0020a1fd9f602b369b740eafc

Jinsong already authored a fix this to this build warning this morning

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


[Lldb-commits] [lldb] [lldb][test] Add test for ASTImporter's name conflict resolution (PR #112566)

2024-10-18 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-10-18 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

> The code I'm referring to is the `UniqueDWARFASTTypeMap` class (and the code 
> surrounding it). We use that to determine whether to DIEs describe the same 
> type. My idea was something like: a) look up the type that is supposed to 
> contain the variable we're searching for (using `FindTypes` or something like 
> that); b) get the DWARF DIE describing that type; c) look at the children of 
> that DIE for the variable

Thank you, I will look into it.

> It might actually be better to fix this problem during indexing, in the 
> ManualDWARFIndex -- basically, if we're indexing a v4 unit _and_ we run into 
> a static const(expr?) variable (can we detect that reliably by looking at the 
> DIE alone?), then we add it to the index, just as if it was a v5 
> DW_TAG_variable.

This sounds like the best solution indeed. I will try doing this first and see 
if it's possible at all to detect such a case. However, there might be other 
cases where global variables are not tagged as `DW_TAG_variable`, but to be 
honest I don't know any other example other than `static constexpr` anyway.

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


[Lldb-commits] [lldb] [lldb] Add timed callbacks to the MainLoop class (PR #112895)

2024-10-18 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 1a871b2122470491f73b51f3e57718bc3bda08f1 
cc3a4a94e9e2eb8b4cf763d4c8c477c71776ee93 --extensions h,cpp -- 
lldb/include/lldb/Host/MainLoopBase.h 
lldb/include/lldb/Host/posix/MainLoopPosix.h 
lldb/include/lldb/Host/windows/MainLoopWindows.h 
lldb/source/Host/common/MainLoopBase.cpp 
lldb/source/Host/posix/MainLoopPosix.cpp 
lldb/source/Host/windows/MainLoopWindows.cpp 
lldb/unittests/Host/MainLoopTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Host/MainLoopBase.h 
b/lldb/include/lldb/Host/MainLoopBase.h
index 0b79c52a35..be9a2676e7 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -63,8 +63,7 @@ public:
 
   // Add a callback that will be executed after a certain amount of time has
   // passed.
-  void AddCallback(const Callback &callback,
-   std::chrono::nanoseconds delay) {
+  void AddCallback(const Callback &callback, std::chrono::nanoseconds delay) {
 AddCallback(callback, std::chrono::steady_clock::now() + delay);
   }
 
diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp 
b/lldb/source/Host/posix/MainLoopPosix.cpp
index 788c6c2300..0461b0f414 100644
--- a/lldb/source/Host/posix/MainLoopPosix.cpp
+++ b/lldb/source/Host/posix/MainLoopPosix.cpp
@@ -43,7 +43,6 @@ static void SignalHandler(int signo, siginfo_t *info, void *) 
{
   g_signal_flags[signo] = 1;
 }
 
-
 class ToTimeSpec {
 public:
   explicit ToTimeSpec(std::optional point) {
@@ -259,16 +258,16 @@ MainLoopPosix::MainLoopPosix() {
   Status error = m_interrupt_pipe.CreateNew(/*child_process_inherit=*/false);
   assert(error.Success());
   const int interrupt_pipe_fd = m_interrupt_pipe.GetReadFileDescriptor();
-  m_read_fds.insert({interrupt_pipe_fd,
- [interrupt_pipe_fd](MainLoopBase &loop) {
-   char c;
-   ssize_t bytes_read = llvm::sys::RetryAfterSignal(
-   -1, ::read, interrupt_pipe_fd, &c, 1);
-   assert(bytes_read == 1);
-   UNUSED_IF_ASSERT_DISABLED(bytes_read);
-   // NB: This implicitly causes another loop iteration
-   // and therefore the execution of pending callbacks.
- }});
+  m_read_fds.insert(
+  {interrupt_pipe_fd, [interrupt_pipe_fd](MainLoopBase &loop) {
+ char c;
+ ssize_t bytes_read =
+ llvm::sys::RetryAfterSignal(-1, ::read, interrupt_pipe_fd, &c, 1);
+ assert(bytes_read == 1);
+ UNUSED_IF_ASSERT_DISABLED(bytes_read);
+ // NB: This implicitly causes another loop iteration
+ // and therefore the execution of pending callbacks.
+   }});
 #if HAVE_SYS_EVENT_H
   m_kqueue = kqueue();
   assert(m_kqueue >= 0);
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp 
b/lldb/source/Host/windows/MainLoopWindows.cpp
index 2f2249b108..0a5a35e9db 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -149,6 +149,4 @@ Status MainLoopWindows::Run() {
   return Status();
 }
 
-void MainLoopWindows::Interrupt() {
-  WSASetEvent(m_interrupt_event);
-}
+void MainLoopWindows::Interrupt() { WSASetEvent(m_interrupt_event); }

``




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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-10-18 Thread Michael Buch via lldb-commits


@@ -0,0 +1,43 @@
+"""
+Test SBTarget::FindGlobalVariables API.
+"""

Michael137 wrote:

Could we re-use `TestConstStaticIntegralMember.py`? Surprised it doesn't 
already have the tests added here XFAILed

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] Fix typo "instrinsic" (PR #112899)

2024-10-18 Thread Christian Ulmann via lldb-commits

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

LGTM, thanks for the fixes 😄 

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


[Lldb-commits] [lldb] [lldb] Fix crash missing MSInheritanceAttr on CXXRecordDecl with DWARF on Windows (PR #112928)

2024-10-18 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail created 
https://github.com/llvm/llvm-project/pull/112928

In the MS ABI, member pointers to `CXXRecordDecl`s must have a 
`MSInheritanceAttr` in order to be complete. Otherwise we cannot query their 
size in memory. This patch checks `MemberPointer` types for completeness 
(eventually looking at the existence of the attribute) to avoid a crash 
[further down in the clang AST 
context](https://github.com/llvm/llvm-project/blob/release/19.x/clang/lib/AST/MicrosoftCXXABI.cpp#L282).

From bb66f56138cab9651aff4ac09096ede975c90701 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Fri, 18 Oct 2024 17:44:26 +0200
Subject: [PATCH] [lldb] Fix crash due to missing MSInheritanceAttr on
 CXXRecordDecl for DWARF on Windows

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..a23dce97f3f299 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2771,6 +2771,9 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
 ast, llvm::cast(qual_type)->getModifiedType(),
 allow_completion);
 
+  case clang::Type::MemberPointer:
+return !qual_type.getTypePtr()->isIncompleteType();
+
   default:
 break;
   }

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


[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-10-18 Thread Martin Storsjö via lldb-commits

mstorsjo wrote:

> > a number of test input files need to be in LF form to work
> 
> Which ones?

A whole bunch of them. @AaronBallman's link to 
https://buildkite.com/llvm-project/github-pull-requests/builds/65#0192a01b-d3ac-44ad-abff-e53ac4a206ab
 shows mostly what I saw. If including `clang-tools-extra` and `llvm` in the 
set of tests to run, I have failures in the following tests as well:

```
   Clang Tools :: clang-move/move-used-helper-decls.cpp
   LLVM :: MC/ELF/warn-newline-in-escaped-string.s
   LLVM :: TableGen/x86-fold-tables.td
   LLVM :: tools/llvm-rc/tag-html.test
   lit :: shtest-shell.py
```

> Either there's a bug in a parser somewhere,

In the vast majority of cases, it's not a bug in a parser, but a test that 
relies on the exact contents of the source files. E.g. for 
`tools/llvm-rc/tag-html.test` I would guess that the issue is that the test 
takes a text file (which now has variable line endings) and includes it in a 
binary resource file, and checks the output to match bitwise the expected 
output.

In my nightly run of compiler-rt tests 
https://github.com/mstorsjo/llvm-mingw/actions/runs/11395494568/job/31717433112,
 I had the following failures:
```
Failed Tests (5):
  Profile-x86_64 :: instrprof-gcov-exceptions.test
  Profile-x86_64 :: instrprof-gcov-multiple-bbs-single-line.test
  Profile-x86_64 :: instrprof-gcov-one-line-function.test
  Profile-x86_64 :: instrprof-gcov-switch.test
  Profile-x86_64 :: instrprof-gcov-two-objects.test
```

I think the issue here may be something around testing the exact amount of 
whitespace somewhere or so.

Mostly "brittle" tests that don't expect the source files to vary.

>  or I missed some test files. In either case I'd like to fix the issue. I 
> watched the buildbots quite closely last night and only noticed failures in 
> ARM frame lowering - which isn't this, I think.

Did you do a test run on Windows? Even on Linux, I guess it should be possible 
to check out the code, forcing Git to prefer checking out text files as CRLF, 
so you could experience the same amount of fallout.

> > Now after this change, due to the added .gitattributes which overrides the 
> > core.autocrlf setting, these files get checked out with CRLF newlines (as 
> > the native form for the platform).
> 
> It's my understanding that `text=auto` does not override `core.autocrlf`. As 
> far as I can tell from the documentation it honours the user's configuration 
> for `core.eol` in combination with `core.autocrlf` - from `git config --help`:

This doesn't match my experience.

See https://github.com/mstorsjo/llvm-project/commit/inspect-newlines for a test 
github actions job that shows checking out the repo on Windows. First we check 
out an old branch, with default settings - we get CRLF. Then we set 
`core.autocrlf=false` and retry the above, we get a file with LF newlines. Then 
we check out the new version with gitattributes, and we notice how we now 
suddenly are getting CRLF again, despite our setting. See 
https://github.com/mstorsjo/llvm-project/actions/runs/11407224268 for the 
actual run log.

Feel free to play around with such an action, to come up with a better way of 
checking it out while still getting LF newlines - but this is the way I have 
been doing it (which is scripted in a number of places), and I would expect 
that many others have the same setup.

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


  1   2   >