[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [libcxxabi] [libunwind] [lldb] [llvm] [mlir] [openmp] [NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (PR #154537)
llvmbot wrote: /pull-request llvm/llvm-project#156505 https://github.com/llvm/llvm-project/pull/154537 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [openmp] Fix typos and spelling errors across codebase (PR #156270)
https://github.com/jhuber6 approved this pull request. libc and openmp LG https://github.com/llvm/llvm-project/pull/156270 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [openmp] Fix typos and spelling errors across codebase (PR #156270)
https://github.com/kuhar approved this pull request. Support LGTM, but I'd also prefer for it to be split into a few smaller PRs https://github.com/llvm/llvm-project/pull/156270 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
Nerixyz wrote:
Oops, was testing something unrelated...
https://github.com/llvm/llvm-project/pull/156370
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fix(LLDB): Repair OC_Bridge variable display issue when load-on-demand is true (PR #156582)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/156582 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fix(LLDB): Repair OC_Bridge variable display issue when load-on-demand is true (PR #156582)
https://github.com/zzjconcent created
https://github.com/llvm/llvm-project/pull/156582
fix(LLDB): Repair OC_Bridge variable display issue when load-on-demand is true
When symbols.load-on-demand is enabled in LLDB, variables from OC-bridged Swift
objects were not being displayed. This was due to SymbolFileOndemand not
correctly overriding the GetAstData method, causing it to return an empty
implementation from the base SymbolFile class.
This commit fixes the issue by providing the correct implementation of
GetAstData in SymbolFileOndemand, ensuring that the necessary AST data is
loaded and OC-bridged variables can be correctly resolved and displayed during
debugging.
Problem
When the symbols.load-on-demand setting in LLDB is set to True, member
variables of Objective-C bridged Swift objects (OC Bridge variables) fail to
display during debugging sessions.
Root Cause
The underlying issue is related to how LLDB handles symbol loading with the
on-demand setting enabled.
Class Inheritance and Method Overriding: The SymbolFileOndemand class, which is
active when on-demand symbol loading is enabled, inherits from the SymbolFile
base class.
Missing Implementation: The SymbolFile base class provides a virtual method
called GetAstData, but its default implementation returns an empty object.
While other, direct subclasses of SymbolFile provide a proper override for this
method, SymbolFileOndemand does not.
Incorrect Method Resolution: Consequently, when LLDB attempts to resolve
symbols for OC Bridge variables in on-demand mode, it calls the empty base
class implementation of GetAstData through the SymbolFileOndemand object. This
fails to retrieve the necessary Abstract Syntax Tree (AST) data required to
parse and display these variables.
In contrast, when symbols.load-on-demand is False, LLDB uses a different
SymbolFile subclass that correctly implements GetAstData, and the variables are
displayed as expected.
Solution
The solution is to provide the missing override for the GetAstData method in
the SymbolFileOndemand class.
The implementation now delegates the call to the original SymbolFile object
that SymbolFileOndemand wraps. This ensures that even when operating in
on-demand mode, LLDB can correctly fetch the AST data, allowing it to resolve
and display the OC Bridge variables correctly.
>From 6842bc5976049baf7c5c463a1e580b188e4887d3 Mon Sep 17 00:00:00 2001
From: ccc
Date: Wed, 3 Sep 2025 11:39:20 +0800
Subject: [PATCH] fix(LLDB): Repair OC_Bridge variable display issue when
load-on-demand is true When symbols.load-on-demand is enabled in LLDB,
variables from OC-bridged Swift objects were not being displayed. This was
due to SymbolFileOndemand not correctly overriding the GetAstData method,
causing it to return an empty implementation from the base SymbolFile class.
This commit fixes the issue by providing the correct implementation of
GetAstData in SymbolFileOndemand, ensuring that the necessary AST data is
loaded and OC-bridged variables can be correctly resolved and displayed
during debugging.
---
lldb/include/lldb/Symbol/SymbolFileOnDemand.h | 2 ++
lldb/source/Symbol/SymbolFileOnDemand.cpp | 9 +
2 files changed, 11 insertions(+)
diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index 6e3c2477d1769..1a9fe670ed12e 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -178,6 +178,8 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
void PreloadSymbols() override;
+ std::vector GetASTData(lldb::LanguageType language)
override;
+
uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override;
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override;
diff --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp
b/lldb/source/Symbol/SymbolFileOnDemand.cpp
index 807c2124e48d9..71d07776e820f 100644
--- a/lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -535,6 +535,15 @@ void SymbolFileOnDemand::PreloadSymbols() {
return m_sym_file_impl->PreloadSymbols();
}
+std::vector
SymbolFileOnDemand::GetASTData(lldb::LanguageType language) {
+ if (!m_debug_info_enabled) {
+LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(),
+ __FUNCTION__);
+return {};
+ }
+ return m_sym_file_impl->GetASTData(language);
+}
+
uint64_t SymbolFileOnDemand::GetDebugInfoSize(bool load_all_debug_info) {
// Always return the real debug info size.
LLDB_LOG(GetLog(), "[{0}] {1} is not skipped", GetSymbolFileName(),
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f0c8198 - [lldb][windows] use OutputDebugStringA instead of c to log events (#156474)
Author: Charles Zablit
Date: 2025-09-02T18:06:15+01:00
New Revision: f0c819868dddc844f7539c532acfc4b7ab956bbe
URL:
https://github.com/llvm/llvm-project/commit/f0c819868dddc844f7539c532acfc4b7ab956bbe
DIFF:
https://github.com/llvm/llvm-project/commit/f0c819868dddc844f7539c532acfc4b7ab956bbe.diff
LOG: [lldb][windows] use OutputDebugStringA instead of c to log events (#156474)
In https://github.com/llvm/llvm-project/pull/150213 we made use of the
Event Viewer on Windows (equivalent of system logging on Darwin) rather
than piping to the standard output. This turned out to be too verbose in
practice, as the Event Viewer is developer oriented and not user
oriented.
This patch swaps the use of `ReportEventW` for `OutputDebugStringA`,
allowing to use tools such as `DebugView` to record logs when we are
interested in receiving them, rather than continuously writing to the
buffer. Please see an example below:
https://github.com/user-attachments/assets/4a326e46-d8a4-4c99-8c96-1bee62da8d55";
/>
Added:
Modified:
lldb/source/Host/windows/Host.cpp
Removed:
diff --git a/lldb/source/Host/windows/Host.cpp
b/lldb/source/Host/windows/Host.cpp
index 4277b8edb38e5..e8973a3fb937a 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -22,10 +22,8 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ConvertUTF.h"
-#include "llvm/Support/ManagedStatic.h"
// Windows includes
#include
@@ -308,52 +306,28 @@ Environment Host::GetEnvironment() {
return env;
}
-/// Manages the lifecycle of a Windows Event's Source.
-/// The destructor will call DeregisterEventSource.
-/// This class is meant to be used with \ref llvm::ManagedStatic.
-class WindowsEventLog {
-public:
- WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {}
-
- ~WindowsEventLog() {
-if (handle)
- DeregisterEventSource(handle);
- }
-
- HANDLE GetHandle() const { return handle; }
-
-private:
- HANDLE handle;
-};
-
-static llvm::ManagedStatic event_log;
-
void Host::SystemLog(Severity severity, llvm::StringRef message) {
if (message.empty())
return;
- HANDLE h = event_log->GetHandle();
- if (!h)
-return;
-
- llvm::SmallVector argsUTF16;
- if (UTF8ToUTF16(message.str(), argsUTF16))
-return;
+ std::string log_msg;
+ llvm::raw_string_ostream stream(log_msg);
- WORD event_type;
switch (severity) {
case lldb::eSeverityWarning:
-event_type = EVENTLOG_WARNING_TYPE;
+stream << "[Warning] ";
break;
case lldb::eSeverityError:
-event_type = EVENTLOG_ERROR_TYPE;
+stream << "[Error] ";
break;
case lldb::eSeverityInfo:
default:
-event_type = EVENTLOG_INFORMATION_TYPE;
+stream << "[Info] ";
+break;
}
- LPCWSTR messages[1] = {argsUTF16.data()};
- ReportEventW(h, event_type, 0, 0, nullptr, std::size(messages), 0, messages,
- nullptr);
+ stream << message;
+ stream.flush();
+
+ OutputDebugStringA(log_msg.c_str());
}
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [openmp] Fix typos and spelling errors across codebase (PR #156270)
https://github.com/tblah approved this pull request. Flang and flang-rt changes LGTM. https://github.com/llvm/llvm-project/pull/156270 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Destroy debugger when debug session terminates (PR #156231)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/156231 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fix(LLDB): Repair OC_Bridge variable display issue when load-on-demand is true (PR #156582)
https://github.com/zzjconcent closed https://github.com/llvm/llvm-project/pull/156582 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Introduce ScriptedFrame (PR #149622)
https://github.com/medismailben updated
https://github.com/llvm/llvm-project/pull/149622
>From 583a83e1001a824fcfbc9a0811af3fbaf446e5ca Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani
Date: Tue, 2 Sep 2025 17:36:27 -0700
Subject: [PATCH 1/2] [lldb] Mark scripted frames as synthetic instead of
artificial
This patch changes the way frames created from scripted affordances like
Scripted Threads are displayed. Currently, they're marked artificial
which is used usually for compiler generated frames.
This patch changes that behaviour by introducing a new synthetic
StackFrame kind and moves 'artificial' to be a distinct StackFrame attribut.
On top of making these frames less confusing, this allows us to know
when a frame was created from a scripted affordance.
rdar://155949703
Signed-off-by: Med Ismail Bennani
---
lldb/include/lldb/API/SBFrame.h | 2 ++
lldb/include/lldb/Core/FormatEntity.h | 1 +
lldb/include/lldb/Target/StackFrame.h | 17 +++---
lldb/source/API/SBFrame.cpp | 16 ++
lldb/source/Core/CoreProperties.td| 4 +--
lldb/source/Core/FormatEntity.cpp | 14
.../Process/scripted/ScriptedThread.cpp | 4 ++-
lldb/source/Target/StackFrame.cpp | 14
lldb/source/Target/StackFrameList.cpp | 6 ++--
.../scripted_process/TestScriptedProcess.py | 2 +-
.../app_specific_backtrace_crashlog.test | 32 +--
.../interactive_crashlog_arm64_register.test | 30 -
.../Crashlog/interactive_crashlog_json.test | 30 -
.../Crashlog/interactive_crashlog_legacy.test | 30 -
.../last_exception_backtrace_crashlog.test| 32 +--
.../skipped_status_interactive_crashlog.test | 30 -
lldb/unittests/Core/FormatEntityTest.cpp | 1 +
17 files changed, 156 insertions(+), 109 deletions(-)
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 08de0605b3240..e4bbcd5ddcd9c 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -104,6 +104,8 @@ class LLDB_API SBFrame {
bool IsArtificial() const;
+ bool IsSynthetic() const;
+
/// Return whether a frame recognizer decided this frame should not
/// be displayes in backtraces etc.
bool IsHidden() const;
diff --git a/lldb/include/lldb/Core/FormatEntity.h
b/lldb/include/lldb/Core/FormatEntity.h
index d602edffb4c88..40916dc48a70b 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -80,6 +80,7 @@ struct Entry {
FrameRegisterFlags,
FrameRegisterByName,
FrameIsArtificial,
+FrameKind,
ScriptFrame,
FunctionID,
FunctionDidChange,
diff --git a/lldb/include/lldb/Target/StackFrame.h
b/lldb/include/lldb/Target/StackFrame.h
index d4104bfe49d20..4ffbf97ce6e90 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -60,10 +60,9 @@ class StackFrame : public ExecutionContextScope,
/// local variables.
History,
-/// An artificial stack frame (e.g. a synthesized result of inferring
-/// missing tail call frames from a backtrace) with limited support for
-/// local variables.
-Artificial
+/// An synthetic stack frame (e.g. a synthesized result from script
+/// resource) possibly without support for local variables or register.
+Synthetic
};
/// Construct a StackFrame object without supplying a RegisterContextSP.
@@ -109,7 +108,8 @@ class StackFrame : public ExecutionContextScope,
StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx,
lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa,
bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind,
- bool behaves_like_zeroth_frame, const SymbolContext *sc_ptr);
+ bool artificial, bool behaves_like_zeroth_frame,
+ const SymbolContext *sc_ptr);
StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx,
lldb::user_id_t concrete_frame_idx,
@@ -400,6 +400,9 @@ class StackFrame : public ExecutionContextScope,
/// true if this is an inlined frame.
bool IsInlined();
+ /// Query whether this frame is synthetic.
+ bool IsSynthetic() const;
+
/// Query whether this frame is part of a historical backtrace.
bool IsHistorical() const;
@@ -571,6 +574,10 @@ class StackFrame : public ExecutionContextScope,
/// Does this frame have a CFA? Different from CFA == LLDB_INVALID_ADDRESS.
bool m_cfa_is_valid;
Kind m_stack_frame_kind;
+ /// Is this an artificial stack frame (e.g. a synthesized result of inferring
+ /// missing tail call frames from a backtrace) with limited support for
+ /// local variables. Orthogonal to `StackFrame::Kind`.
+ bool m_artificial;
/// Whether this frame behaves like the zeroth frame, in the sense
/// that its pc va
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/153585
>From ce9c2cc6748c22ce4b0f5178b8f5e877d430 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Wed, 13 Aug 2025 18:38:23 -0700
Subject: [PATCH 1/5] [lldb] Call FixUpPointer in WritePointerToMemory (try 2)
In architectures where pointers may contain metadata, such as arm64e,
the metadata may need to be cleaned prior to sending this pointer to be
used in expression evaluation generated code.
This patch is a step towards allowing consumers of pointers to decide
whether they want to keep or remove metadata, as opposed to discarding
metadata at the moment pointers are created. See #150537.
This was tested running the LLDB test suite on arm64e.
(The first attempt at this patch caused a failure in
TestScriptedProcessEmptyMemoryRegion.py. This test exercises a case
where IRMemoryMap uses host memory in its allocations; pointers to such
allocations should not be fixed, which is what the original patch failed
to account for).
---
lldb/source/Expression/IRMemoryMap.cpp | 7 +++
1 file changed, 7 insertions(+)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 150699352a2e3..3ac42649d0834 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -640,6 +640,13 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
lldb::addr_t address, Status &error) {
error.Clear();
+ /// Only ask the Process to fix the address if this address belongs to the
+ /// process (host allocations are stored in m_data).
+ if (auto it = FindAllocation(process_address, 1);
+ it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
+if (auto process_sp = GetProcessWP().lock())
+ address = process_sp->FixAnyAddress(address);
+
Scalar scalar(address);
WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);
>From 36dcebb09eecd46f649feb4073c4f10b75423699 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 14 Aug 2025 08:22:44 -0700
Subject: [PATCH 2/5] fixup! Improve comment
---
lldb/source/Expression/IRMemoryMap.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 3ac42649d0834..7faf6809383eb 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -641,7 +641,8 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
error.Clear();
/// Only ask the Process to fix the address if this address belongs to the
- /// process (host allocations are stored in m_data).
+ /// process. An address belongs to the process if the Allocation contains a
+ /// non-empty m_data member.
if (auto it = FindAllocation(process_address, 1);
it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
if (auto process_sp = GetProcessWP().lock())
>From 579c985eb3bbce4d10e86de7ff87238541936232 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 14 Aug 2025 08:22:58 -0700
Subject: [PATCH 3/5] fixup! Add {} to if statement
---
lldb/source/Expression/IRMemoryMap.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 7faf6809383eb..8b6d87b589c1b 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -644,9 +644,10 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
/// process. An address belongs to the process if the Allocation contains a
/// non-empty m_data member.
if (auto it = FindAllocation(process_address, 1);
- it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
+ it != m_allocations.end() && it->second.m_data.GetByteSize() == 0) {
if (auto process_sp = GetProcessWP().lock())
address = process_sp->FixAnyAddress(address);
+ }
Scalar scalar(address);
>From d098df34532dfc20a2e6b1f566082ce5b9af24d9 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Wed, 27 Aug 2025 14:26:29 -0700
Subject: [PATCH 4/5] fixup! Fix address confusion
---
lldb/source/Expression/IRMemoryMap.cpp | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 8b6d87b589c1b..26e59b76a4dac 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -641,13 +641,13 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
error.Clear();
/// Only ask the Process to fix the address if this address belongs to the
- /// process. An address belongs to the process if the Allocation contains a
- /// non-empty m_data member.
- if (auto it = FindAllo
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
@@ -11,6 +11,7 @@ #include "ExceptionBreakpoint.h" #include "LLDBUtils.h" #include "ProtocolUtils.h" +#include "Variables.h" Anthony-Eid wrote: I also removed it. Thanks for the heads up https://github.com/llvm/llvm-project/pull/124232 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
asavonic wrote: @jimingham, thanks a lot for the explanation! I think `MemoryPressureDetected` is a better solution than what I was trying to do originally. > I'd suggest adding another API like `RemoveAllSharedModules` that ignores > reference count - but that API should only ever be called from > Debugger::Terminate. I almost prepared a patch to add that, but tests highlighted another problem - there seems to be no way to recover from `Debugger::Terminate` and re-initialize. Initialization fails because Terminate leaves global pointers as non-zero and we get `Debugger::Initialize called more than once!`. Without a way to re-initialize, this dance around modules in Terminate makes even less sense. I think we can drop this patch, I don't see a practical reason to do it. Thank you @jimingham and @JDevlieghere for your guidance here. https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use weak pointers instead of shared pointers in DynamicLoader (PR #156446)
https://github.com/asavonic created
https://github.com/llvm/llvm-project/pull/156446
DynamicLoaderWindowsDYLD uses pointers to mModules to maintain a map from
modules to their addresses, but it does not need to keep "strong" references to
them. Weak pointers should be enough, and would allow modules to be released
elsewhere.
Other DynamicLoader classes do not use shared pointers as well. For example,
DynamicLoaderPOSIXDYLD has a similar map with weak pointers.
Actually testing for modules being completely released can be tricky. The test
here is just to illustrate the case where shared pointers kept modules in
DynamicLoaderWindowsDYLD and prevented them from being released. The test
executes the following sequence:
1. Create a target, load an executable and run it.
2. Remove one module from the target. The target should be the last actual
use of the module, but we have another reference to it in the shared module
cache.
3. Call MemoryPressureDetected to remove this last reference from the cache.
4. Replace the corresponding DLL file.
LLDB memory maps DLLs, and this makes files read-only on Windows. Unless the
modules are completely released (and therefore unmapped), (4) is going to fail
with "access denied".
However, the test does not trigger the bug completely - it passes with and
without the change.
>From 1ddf63f5018dce7db3a7e5a5ba43e7f1d3d9764c Mon Sep 17 00:00:00 2001
From: Andrew Savonichev
Date: Tue, 2 Sep 2025 17:41:13 +0900
Subject: [PATCH] [lldb] Use weak pointers instead of shared pointers in
DynamicLoader
DynamicLoaderWindowsDYLD uses pointers to Modules to maintain a map
from modules to their addresses, but it does not need to keep "strong"
references to them. Weak pointers should be enough, and would allow
modules to be released elsewhere.
Other DynamicLoader classes do not use shared pointers as well. For
example, DynamicLoaderPOSIXDYLD has a similar map with weak pointers.
Actually testing for modules being completely released can be
tricky. The test here is just to illustrate the case where shared
pointers kept modules in DynamicLoaderWindowsDYLD and prevented them
from being released. The test executes the following sequence:
1. Create a target, load an executable and run it.
2. Remove one module from the target. The target should be the last
actual use of the module, but we have another reference to it
in the shared module cache.
3. Call MemoryPressureDetected to remove this last reference from
the cache.
4. Replace the corresponding DLL file.
LLDB memory maps DLLs, and this makes the files read-only on
Windows. Unless the modules are completely released (and therefore
unmapped), (4) is going to fail with "access denied".
However, the test does not trigger the bug completely - it passes with
and without the change.
---
.../Windows-DYLD/DynamicLoaderWindowsDYLD.h | 3 +-
.../API/windows/launch/replace-dll/Makefile | 1 +
.../launch/replace-dll/TestReplaceDLL.py | 62 +++
.../test/API/windows/launch/replace-dll/bar.c | 1 +
.../test/API/windows/launch/replace-dll/foo.c | 1 +
.../API/windows/launch/replace-dll/test.c | 3 +
6 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 lldb/test/API/windows/launch/replace-dll/Makefile
create mode 100644 lldb/test/API/windows/launch/replace-dll/TestReplaceDLL.py
create mode 100644 lldb/test/API/windows/launch/replace-dll/bar.c
create mode 100644 lldb/test/API/windows/launch/replace-dll/foo.c
create mode 100644 lldb/test/API/windows/launch/replace-dll/test.c
diff --git
a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
index 42ea5aacecb40..8b1c3c3f467f4 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -45,7 +45,8 @@ class DynamicLoaderWindowsDYLD : public DynamicLoader {
lldb::addr_t GetLoadAddress(lldb::ModuleSP executable);
private:
- std::map m_loaded_modules;
+ std::map>
+ m_loaded_modules;
};
} // namespace lldb_private
diff --git a/lldb/test/API/windows/launch/replace-dll/Makefile
b/lldb/test/API/windows/launch/replace-dll/Makefile
new file mode 100644
index 0..22f1051530f87
--- /dev/null
+++ b/lldb/test/API/windows/launch/replace-dll/Makefile
@@ -0,0 +1 @@
+include Makefile.rules
diff --git a/lldb/test/API/windows/launch/replace-dll/TestReplaceDLL.py
b/lldb/test/API/windows/launch/replace-dll/TestReplaceDLL.py
new file mode 100644
index 0..afa97cf4afe50
--- /dev/null
+++ b/lldb/test/API/windows/launch/replace-dll/TestReplaceDLL.py
@@ -0,0 +1,62 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import gc
+import os
+
+
+class ReplaceDllTestCase(TestBase):
+@skipUnlessWindows
+
[Lldb-commits] [clang] [lldb] [lldb][Expression] Add structor variant to LLDB's function call labels (PR #149827)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/149827 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/156370
>From 967d3453e997ed25c3548898d69a40d079d307b1 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 1 Sep 2025 21:02:33 +0200
Subject: [PATCH 1/5] [LLDB] Complete constant array member types in class
members
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 15 ++-
.../NativePDB/Inputs/incomplete-tag-type.cpp | 5 +
.../NativePDB/incomplete-tag-type.cpp | 45
.../NativePDB/incomplete-tag-type.test| 109 ++
4 files changed, 126 insertions(+), 48 deletions(-)
delete mode 100644 lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
create mode 100644
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 39aacdb58e694..038677f68b991 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9577,12 +9577,21 @@ TypeSystemClang::DeclContextGetTypeSystemClang(const
CompilerDeclContext &dc) {
}
void TypeSystemClang::RequireCompleteType(CompilerType type) {
+ if (!type)
+return;
+
+ clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
+ if (qual_type.isNull())
+return;
+
// Technically, enums can be incomplete too, but we don't handle those as
they
// are emitted even under -flimit-debug-info.
- if (!TypeSystemClang::IsCXXClassType(type))
-return;
+ bool is_constant_array = qual_type->isConstantArrayType();
+ bool is_cxx_record = qual_type->getAsCXXRecordDecl() != nullptr;
+ if (is_constant_array || is_cxx_record)
+type.GetCompleteType();
- if (type.GetCompleteType())
+ if (!is_cxx_record)
return;
// No complete definition in this module. Mark the class as complete to
diff --git
a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
index c930338905445..d08f49d1014ba 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
deleted file mode 100644
index 7bc7e618667f7..0
--- a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// clang-format off
-// REQUIRES: lld, x86
-
-// RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
-// RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj -- %s
-// RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
-// RUN: %lldb -f %t.exe -o \
-// RUN: "settings set interpreter.stop-command-source-on-error false" \
-// RUN: -o "expression b" -o "expression d" -o "expression static_e_ref" -o
"exit" 2>&1 | FileCheck %s
-
-// CHECK: (lldb) expression b
-// CHECK: (B) $0 = {}
-// CHECK: (lldb) expression d
-// CHECK: (D) $1 = {}
-// CHECK: (lldb) expression static_e_ref
-// CHECK: error:{{.*}}incomplete type 'E' where a complete type is required
-
-// Complete base class.
-struct A { int x; A(); };
-struct B : A {};
-B b;
-
-// Complete data member.
-struct C {
- C();
-};
-
-struct D {
- C c;
-};
-D d;
-
-// Incomplete static data member should return error.
-struct E {
- E();
-};
-
-struct F {
- static E static_e;
-};
-
-E F::static_e = E();
-E& static_e_ref = F::static_e;
-
-int main(){}
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
new file mode 100644
index 0..f30866ccdd6f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
@@ -0,0 +1,109 @@
+# REQUIRES: lld, x86
+
+# RUN: split-file %s %t
+
+# RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
+# RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj --
%t/main.cpp
+# RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
+
+# RUN: %lldb -f %t.exe -s %t/target-var.input 2>&1 | FileCheck %s
--check-prefix=TARGET-VAR
+# RUN: %lldb -f %t.exe -s %t/expr.input 2>&1 | FileCheck %s --check-prefix=EXPR
+
+#--- main.cpp
+
+// Complete base class.
+struct A { int x; A(); };
+struct B : A {};
+B b;
+
+// Complete data member.
+struct C {
+ C();
+};
+
+struct D {
+ C c;
+};
+D d;
+
+// Incomplete static data member should return error.
+struct E {
+ E();
+};
+
+struct F {
+ static E static_e;
+};
+
+E F::static_e = E();
+E& static_e_ref = F::static_e;
+
+struct G {
+ int foo = 1;
+};
+struct H {
+ G g[2];
+};
+H
[Lldb-commits] [lldb] [lldb-dap] Destroy debugger when debug session terminates (PR #156231)
royitaqi wrote: > do you know if destroying the debugger will free the module cache? @walter-erquinigo: I assume, by "module cache", you meant the global module list accessible by `ModuleList::GetSharedModule()` and `ModuleList::GetSharedModuleList()`. I think destroying the debugger will NOT free it (which I think is the desired behavior). Verified by the commands below, where the memory address of the `Module` object of the main executable didn't change (as printed by the `-p` flag) after the first session has terminated. ``` // Server mode. // 1st session, after target creation. (lldb) image list -u -p -f -S -g [ 0] 091DE3B7-FE99-4174-BE03-4F90EFEB4584 0x12b780128 /Users/royshi/demo/simple/a.out /Users/royshi/demo/simple/a.out.dSYM/Contents/Resources/DWARF/a.out ... // 2nd session, before target creation (as init command). (lldb) image list -u -p -f -S -g [ 0] 091DE3B7-FE99-4174-BE03-4F90EFEB4584 0x12b780128 /Users/royshi/demo/simple/a.out /Users/royshi/demo/simple/a.out.dSYM/Contents/Resources/DWARF/a.out ... ``` https://github.com/llvm/llvm-project/pull/156231 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz edited https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz edited https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
https://github.com/asavonic closed https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Complete constant array member types in class members (PR #156370)
Nerixyz wrote: > It completes the element type. As in, "if an array type is encountered, it's immediately completed"? Because in native PDB (with this PR too), it would be delayed. > Is there a place in the PDB plugin where we can do the same thing we do for > DWARF? Yes, in `PdbAstBuilder::createArrayType` a `CompleteType(element_type)` could be added, and the test would pass too: https://github.com/llvm/llvm-project/blob/74b9484fd62d6be9bc49e154800ceef0d74ef24f/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp#L1170-L1172 Would this be a better place? https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV][test] make atomic region stepping test more robust (PR #156506)
https://github.com/dlav-sc created
https://github.com/llvm/llvm-project/pull/156506
Currently, the tests that check stepping through atomic sequences use a
hardcoded step distance, which is unreliable because this distance depends on
LLVM's codegeneration.
This patch rewrites the test to avoid this disadvantage. The test now checks
the opcode of the instruction after the step instead of the step distance.
>From 46ea86d5f13e71bc4bc635bb8c1ce05883aa8e17 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev
Date: Wed, 16 Jul 2025 14:52:27 +
Subject: [PATCH] [lldb][RISCV][test] make atomic region stepping test more
robust
Currently, the tests that check stepping through atomic sequences use a
hardcoded step distance, which is unreliable because this distance
depends on LLVM's codegeneration.
This patch rewrites the test to avoid this disadvantage. The test now
checks the opcode of the instruction after the step instead of the step
distance.
---
lldb/test/API/riscv/step/TestSoftwareStep.py | 35
lldb/test/API/riscv/step/branch.c| 1 +
lldb/test/API/riscv/step/main.c | 1 +
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/lldb/test/API/riscv/step/TestSoftwareStep.py
b/lldb/test/API/riscv/step/TestSoftwareStep.py
index 279c4c1b797e0..f0151eafc896f 100644
--- a/lldb/test/API/riscv/step/TestSoftwareStep.py
+++ b/lldb/test/API/riscv/step/TestSoftwareStep.py
@@ -26,19 +26,26 @@ def do_sequence_test(self, filename, bkpt_name):
substrs=["stopped", "stop reason = instruction step into"],
)
-pc = cur_thread.GetFrameAtIndex(0).GetPC()
+# Get the instruction we stopped at
+pc = cur_thread.GetFrameAtIndex(0).GetPCAddress()
+inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0)
-return pc - entry_pc
+inst_mnemonic = inst.GetMnemonic(target)
+inst_operands = inst.GetOperands(target)
+if not inst_operands:
+return inst_mnemonic
-@skipIf(archs=no_match("^rv.*"))
+return f"{inst_mnemonic} {inst_operands}"
+
+@skipIf(archs=no_match("^riscv.*"))
def test_cas(self):
"""
This test verifies LLDB instruction step handling of a proper lr/sc
pair.
"""
-difference = self.do_sequence_test("main", "cas")
-self.assertEqual(difference, 0x1A)
+instruction = self.do_sequence_test("main", "cas")
+self.assertEqual(instruction, "nop")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_branch_cas(self):
"""
LLDB cannot predict the actual state of registers within a critical
section (i.e., inside an atomic
@@ -51,29 +58,29 @@ def test_branch_cas(self):
test is nearly identical to the previous one, except for the branch
condition, which is inverted and
will result in a taken jump.
"""
-difference = self.do_sequence_test("branch", "branch_cas")
-self.assertEqual(difference, 0x1A)
+instruction = self.do_sequence_test("branch", "branch_cas")
+self.assertEqual(instruction, "ret")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_incomplete_sequence_without_lr(self):
"""
This test verifies the behavior of a standalone sc instruction without
a preceding lr. Since the sc
lacks the required lr pairing, LLDB should treat it as a non-atomic
store rather than part of an
atomic sequence.
"""
-difference = self.do_sequence_test(
+instruction = self.do_sequence_test(
"incomplete_sequence_without_lr", "incomplete_cas"
)
-self.assertEqual(difference, 0x4)
+self.assertEqual(instruction, "and a5, a2, a4")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_incomplete_sequence_without_sc(self):
"""
This test checks the behavior of a standalone lr instruction without a
subsequent sc. Since the lr
lacks its required sc counterpart, LLDB should treat it as a
non-atomic load rather than part of an
atomic sequence.
"""
-difference = self.do_sequence_test(
+instruction = self.do_sequence_test(
"incomplete_sequence_without_sc", "incomplete_cas"
)
-self.assertEqual(difference, 0x4)
+self.assertEqual(instruction, "and a5, a2, a4")
diff --git a/lldb/test/API/riscv/step/branch.c
b/lldb/test/API/riscv/step/branch.c
index 79bf0ca005db1..93d6c51ec75e0 100644
--- a/lldb/test/API/riscv/step/branch.c
+++ b/lldb/test/API/riscv/step/branch.c
@@ -11,6 +11,7 @@ void __attribute__((naked)) branch_cas(int *a, int *b) {
"xor a5, a2, a5\n\t"
"sc.w a5, a1, (a3)\n\t"
"beqz a5, 1b\n\t"
+ "nop\n\t"
"2:\n\t"
"ret\n\t");
}
diff --git a/
[Lldb-commits] [lldb] [lldb][windows] use OutputDebugStringA instead of c to log events (PR #156474)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/156474 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [libcxx] [libcxxabi] [libunwind] [lldb] [llvm] [mlir] [openmp] [NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (PR #154537)
amy-kwan wrote: This is is required to build AIX with the latest CMake versions. /cherry-pick 63195d3d7a8bde05590f91a38398f986bb4265b2 3e6ec475b756559560cba4a16c2bc755aa8caee5 https://github.com/llvm/llvm-project/pull/154537 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add Pythonic API to SBStructuredData extension (PR #155061)
https://github.com/kastiglione updated
https://github.com/llvm/llvm-project/pull/155061
>From eff269a2c869b3a3c73ed0198f3b749fd914b2aa Mon Sep 17 00:00:00 2001
From: Dave Lee
Date: Fri, 22 Aug 2025 19:34:57 -0700
Subject: [PATCH 1/4] [lldb] Add Pythonic API to SBStructuredData extension
* Implements `__getitem__` for array and dictionary subscripting
* Updates `__iter__` to support dictionary instances
* Adds converstion to `str`, `int`, and `float`
* Adds `bool` conversion
Additionally did some cleanup in TestStructuredDataAPI.py.
---
.../interface/SBStructuredDataExtensions.i| 119 -
.../sbstructureddata/TestStructuredDataAPI.py | 121 ++
2 files changed, 210 insertions(+), 30 deletions(-)
diff --git a/lldb/bindings/interface/SBStructuredDataExtensions.i
b/lldb/bindings/interface/SBStructuredDataExtensions.i
index ca3d0966f9fc1..900dc192df2bb 100644
--- a/lldb/bindings/interface/SBStructuredDataExtensions.i
+++ b/lldb/bindings/interface/SBStructuredDataExtensions.i
@@ -3,16 +3,127 @@ STRING_EXTENSION_OUTSIDE(SBStructuredData)
%extend lldb::SBStructuredData {
#ifdef SWIGPYTHON
%pythoncode%{
-def __int__(self):
- return self.GetSignedInteger()
-
def __len__(self):
'''Return the number of element in a lldb.SBStructuredData object.'''
return self.GetSize()
def __iter__(self):
'''Iterate over all the elements in a lldb.SBStructuredData object.'''
-return lldb_iter(self, 'GetSize', 'GetItemAtIndex')
+data_type = self.GetType()
+if data_type == eStructuredDataTypeArray:
+return lldb_iter(self, 'GetSize', 'GetItemAtIndex')
+elif data_type == eStructuredDataTypeDictionary:
+keys = SBStringList()
+self.GetKeys(keys)
+return iter(keys)
+raise TypeError(f"cannot iterate {self.type_name(data_type)} type")
+
+def __getitem__(self, key):
+data_type = self.GetType()
+if data_type == eStructuredDataTypeArray:
+if not isinstance(key, int):
+raise TypeError("subscript index must be an integer")
+count = len(self)
+if -count <= key < count:
+key %= count
+return self.GetItemAtIndex(key)
+raise IndexError("index out of range")
+elif data_type == eStructuredDataTypeDictionary:
+if not isinstance(key, str):
+raise TypeError("subscript key must be a string")
+return self.GetValueForKey(key)
+else:
+raise TypeError(f"cannot subscript {self.type_name(data_type)}
type")
+
+def __bool__(self):
+data_type = self.GetType()
+if data_type == eStructuredDataTypeBoolean:
+return self.GetBooleanValue()
+elif data_type == eStructuredDataTypeInteger:
+return bool(int(self))
+elif data_type == eStructuredDataTypeSignedInteger:
+return bool(int(self))
+elif data_type == eStructuredDataTypeFloat:
+return bool(float(self))
+elif data_type == eStructuredDataTypeString:
+return bool(str(self))
+elif data_type == eStructuredDataTypeArray:
+return bool(len(self))
+elif data_type == eStructuredDataTypeDictionary:
+return bool(len(self))
+elif data_type == eStructuredDataTypeNull:
+return False
+elif data_type == eStructuredDataTypeInvalid:
+return False
+else:
+raise TypeError(f"cannot convert {self.type_name(data_type)} to
bool")
+
+def __str__(self):
+data_type = self.GetType()
+if data_type == eStructuredDataTypeString:
+size = len(self) or 1023
+return self.GetStringValue(size + 1)
+elif data_type == eStructuredDataTypeInteger:
+return str(int(self))
+elif data_type == eStructuredDataTypeSignedInteger:
+return str(int(self))
+elif data_type == eStructuredDataTypeFloat:
+return str(float(self))
+else:
+raise TypeError(f"cannot convert {self.type_name(data_type)} to
string")
+
+def __int__(self):
+data_type = self.GetType()
+if data_type == eStructuredDataTypeInteger:
+return self.GetUnsignedIntegerValue()
+elif data_type == eStructuredDataTypeSignedInteger:
+return self.GetSignedIntegerValue()
+elif data_type == eStructuredDataTypeFloat:
+return int(float(self))
+elif data_type == eStructuredDataTypeString:
+return int(str(self))
+elif data_type == eStructuredDataTypeBoolean:
+return int(bool(self))
+else:
+raise TypeError(f"cannot convert {self.type_name(data_type)} to
int")
+
+def __float__(self):
+data_type = self.GetType()
+if data_type == eStructuredDataTypeFloat:
+return self.GetFloatV
[Lldb-commits] [lldb] [lldb][windows] use Windows APIs to print to the console (PR #156469)
https://github.com/Nerixyz approved this pull request. (Windows 11, x86) Rendering in the terminal works as expected and the previously failing tests now pass for me. https://github.com/llvm/llvm-project/pull/156469 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/ZequanWu approved this pull request. LGTM as it aligns with dwarf plugin's behaviour. https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][RISCV][test] make atomic region stepping test more robust (PR #156506)
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 origin/main...HEAD
lldb/test/API/riscv/step/TestSoftwareStep.py
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from darker here.
``diff
--- TestSoftwareStep.py 2025-09-02 17:46:07.00 +
+++ TestSoftwareStep.py 2025-09-02 17:51:09.014678 +
@@ -28,11 +28,11 @@
# Get the instruction we stopped at
pc = cur_thread.GetFrameAtIndex(0).GetPCAddress()
inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0)
-inst_mnemonic = inst.GetMnemonic(target)
+inst_mnemonic = inst.GetMnemonic(target)
inst_operands = inst.GetOperands(target)
if not inst_operands:
return inst_mnemonic
return f"{inst_mnemonic} {inst_operands}"
``
https://github.com/llvm/llvm-project/pull/156506
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
felipepiovezan wrote: Added a test! https://github.com/llvm/llvm-project/pull/153585 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Delay creation of ConstStrings when parsing MachO symtab (PR #155931)
bulbazord wrote: > This change looks good to me. I might not have read it sufficiently closely, > but the duplicate symbols we're looking at here are only when there are debug > map entries for .o file debugging, maybe? Possibly? I'm definitely doing .o debugging, didn't try with dSYMs at all. Either way, this does cut down on the cost of `ConstString` creation in my test case by 12-25% on average. Will update the logic on 2800 as well. https://github.com/llvm/llvm-project/pull/155931 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
https://github.com/felipepiovezan updated
https://github.com/llvm/llvm-project/pull/153585
>From ce9c2cc6748c22ce4b0f5178b8f5e877d430 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Wed, 13 Aug 2025 18:38:23 -0700
Subject: [PATCH 1/5] [lldb] Call FixUpPointer in WritePointerToMemory (try 2)
In architectures where pointers may contain metadata, such as arm64e,
the metadata may need to be cleaned prior to sending this pointer to be
used in expression evaluation generated code.
This patch is a step towards allowing consumers of pointers to decide
whether they want to keep or remove metadata, as opposed to discarding
metadata at the moment pointers are created. See #150537.
This was tested running the LLDB test suite on arm64e.
(The first attempt at this patch caused a failure in
TestScriptedProcessEmptyMemoryRegion.py. This test exercises a case
where IRMemoryMap uses host memory in its allocations; pointers to such
allocations should not be fixed, which is what the original patch failed
to account for).
---
lldb/source/Expression/IRMemoryMap.cpp | 7 +++
1 file changed, 7 insertions(+)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 150699352a2e3..3ac42649d0834 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -640,6 +640,13 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
lldb::addr_t address, Status &error) {
error.Clear();
+ /// Only ask the Process to fix the address if this address belongs to the
+ /// process (host allocations are stored in m_data).
+ if (auto it = FindAllocation(process_address, 1);
+ it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
+if (auto process_sp = GetProcessWP().lock())
+ address = process_sp->FixAnyAddress(address);
+
Scalar scalar(address);
WriteScalarToMemory(process_address, scalar, GetAddressByteSize(), error);
>From 36dcebb09eecd46f649feb4073c4f10b75423699 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 14 Aug 2025 08:22:44 -0700
Subject: [PATCH 2/5] fixup! Improve comment
---
lldb/source/Expression/IRMemoryMap.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 3ac42649d0834..7faf6809383eb 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -641,7 +641,8 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
error.Clear();
/// Only ask the Process to fix the address if this address belongs to the
- /// process (host allocations are stored in m_data).
+ /// process. An address belongs to the process if the Allocation contains a
+ /// non-empty m_data member.
if (auto it = FindAllocation(process_address, 1);
it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
if (auto process_sp = GetProcessWP().lock())
>From 579c985eb3bbce4d10e86de7ff87238541936232 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Thu, 14 Aug 2025 08:22:58 -0700
Subject: [PATCH 3/5] fixup! Add {} to if statement
---
lldb/source/Expression/IRMemoryMap.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 7faf6809383eb..8b6d87b589c1b 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -644,9 +644,10 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
/// process. An address belongs to the process if the Allocation contains a
/// non-empty m_data member.
if (auto it = FindAllocation(process_address, 1);
- it != m_allocations.end() && it->second.m_data.GetByteSize() == 0)
+ it != m_allocations.end() && it->second.m_data.GetByteSize() == 0) {
if (auto process_sp = GetProcessWP().lock())
address = process_sp->FixAnyAddress(address);
+ }
Scalar scalar(address);
>From d098df34532dfc20a2e6b1f566082ce5b9af24d9 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan
Date: Wed, 27 Aug 2025 14:26:29 -0700
Subject: [PATCH 4/5] fixup! Fix address confusion
---
lldb/source/Expression/IRMemoryMap.cpp | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Expression/IRMemoryMap.cpp
b/lldb/source/Expression/IRMemoryMap.cpp
index 8b6d87b589c1b..26e59b76a4dac 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -641,13 +641,13 @@ void IRMemoryMap::WritePointerToMemory(lldb::addr_t
process_address,
error.Clear();
/// Only ask the Process to fix the address if this address belongs to the
- /// process. An address belongs to the process if the Allocation contains a
- /// non-empty m_data member.
- if (auto it = FindAllo
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
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 origin/main HEAD --extensions c,cpp --
lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
lldb/source/Expression/IRMemoryMap.cpp
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from clang-format here.
``diff
diff --git a/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
b/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
index cad88495e..71d22bd2d 100644
--- a/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
+++ b/lldb/test/API/macosx/arm-pointer-metadata-stripping/main.c
@@ -2,7 +2,6 @@
#include
#include
-
int myglobal = 41;
uint64_t get_high_bits(void *ptr) {
@@ -13,8 +12,8 @@ uint64_t get_high_bits(void *ptr) {
return high_bits;
}
-int main (){
+int main() {
int x = 42;
assert(0 == get_high_bits(&x));
- return 0; //break here
+ return 0; // break here
}
``
https://github.com/llvm/llvm-project/pull/153585
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NativePDB] Sort function name maps deterministically. (PR #156530)
https://github.com/ZequanWu created
https://github.com/llvm/llvm-project/pull/156530
https://github.com/llvm/llvm-project/pull/153160 created those function maps
and uses default sort comparator which is not deterministic when there are
multiple entries with same name because llvm::sort is unstable sort.
This fixes it by comparing the id value when tie happens.
>From ca5ad064c8e12454df9e1cdd1ef22da070f55703 Mon Sep 17 00:00:00 2001
From: Zequan Wu
Date: Tue, 2 Sep 2025 13:38:04 -0700
Subject: [PATCH] [lldb][NativePDB] Sort function name maps deterministically.
---
.../Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp| 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 112eb06e462fc..f7a807366070e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1735,11 +1735,11 @@ void SymbolFileNativePDB::CacheFunctionNames() {
}
// Sort them before value searching is working properly.
- m_func_full_names.Sort();
+ m_func_full_names.Sort(std::less());
m_func_full_names.SizeToFit();
- m_func_method_names.Sort();
+ m_func_method_names.Sort(std::less());
m_func_method_names.SizeToFit();
- m_func_base_names.Sort();
+ m_func_base_names.Sort(std::less());
m_func_base_names.SizeToFit();
}
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NativePDB] Sort function name maps deterministically. (PR #156530)
https://github.com/Nerixyz approved this pull request. LGTM, thank you for noticing! The type-name map uses the same map type and [doesn't specify a comparator either](https://github.com/llvm/llvm-project/blob/3c7bf3b3c3a4871d13f7b7d5d60bbf190eaf8f3a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp#L2429). That could also use one to make `FindType` deterministic, I suppose. https://github.com/llvm/llvm-project/pull/156530 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3c7bf3b - [LLDB][NativePDB] Complete array member types in AST builder (#156370)
Author: nerix
Date: 2025-09-02T22:53:44+02:00
New Revision: 3c7bf3b3c3a4871d13f7b7d5d60bbf190eaf8f3a
URL:
https://github.com/llvm/llvm-project/commit/3c7bf3b3c3a4871d13f7b7d5d60bbf190eaf8f3a
DIFF:
https://github.com/llvm/llvm-project/commit/3c7bf3b3c3a4871d13f7b7d5d60bbf190eaf8f3a.diff
LOG: [LLDB][NativePDB] Complete array member types in AST builder (#156370)
Added:
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
Modified:
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
Removed:
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 709281cb32709..933c4361d93da 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1169,6 +1169,7 @@ clang::QualType
PdbAstBuilder::CreateEnumType(PdbTypeSymId id,
clang::QualType PdbAstBuilder::CreateArrayType(const ArrayRecord &ar) {
clang::QualType element_type = GetOrCreateType(ar.ElementType);
+ TypeSystemClang::RequireCompleteType(ToCompilerType(element_type));
SymbolFileNativePDB *pdb = static_cast(
m_clang.GetSymbolFile()->GetBackingSymbolFile());
diff --git
a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
index c930338905445..d08f49d1014ba 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
deleted file mode 100644
index 7bc7e618667f7..0
--- a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// clang-format off
-// REQUIRES: lld, x86
-
-// RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
-// RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj -- %s
-// RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
-// RUN: %lldb -f %t.exe -o \
-// RUN: "settings set interpreter.stop-command-source-on-error false" \
-// RUN: -o "expression b" -o "expression d" -o "expression static_e_ref" -o
"exit" 2>&1 | FileCheck %s
-
-// CHECK: (lldb) expression b
-// CHECK: (B) $0 = {}
-// CHECK: (lldb) expression d
-// CHECK: (D) $1 = {}
-// CHECK: (lldb) expression static_e_ref
-// CHECK: error:{{.*}}incomplete type 'E' where a complete type is required
-
-// Complete base class.
-struct A { int x; A(); };
-struct B : A {};
-B b;
-
-// Complete data member.
-struct C {
- C();
-};
-
-struct D {
- C c;
-};
-D d;
-
-// Incomplete static data member should return error.
-struct E {
- E();
-};
-
-struct F {
- static E static_e;
-};
-
-E F::static_e = E();
-E& static_e_ref = F::static_e;
-
-int main(){}
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
new file mode 100644
index 0..f30866ccdd6f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
@@ -0,0 +1,109 @@
+# REQUIRES: lld, x86
+
+# RUN: split-file %s %t
+
+# RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
+# RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj --
%t/main.cpp
+# RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
+
+# RUN: %lldb -f %t.exe -s %t/target-var.input 2>&1 | FileCheck %s
--check-prefix=TARGET-VAR
+# RUN: %lldb -f %t.exe -s %t/expr.input 2>&1 | FileCheck %s --check-prefix=EXPR
+
+#--- main.cpp
+
+// Complete base class.
+struct A { int x; A(); };
+struct B : A {};
+B b;
+
+// Complete data member.
+struct C {
+ C();
+};
+
+struct D {
+ C c;
+};
+D d;
+
+// Incomplete static data member should return error.
+struct E {
+ E();
+};
+
+struct F {
+ static E static_e;
+};
+
+E F::static_e = E();
+E& static_e_ref = F::static_e;
+
+struct G {
+ int foo = 1;
+};
+struct H {
+ G g[2];
+};
+H h;
+
+struct I {
+ I();
+};
+struct J {
+ I i[2];
+};
+J j;
+
+
+int main(){}
+
+#--- target-var.input
+
+target variable b
+target variable d
+target variable h
+target variable j
+target variable static_e_ref
+exit
+
+#--- expr.input
+
+settings set interpreter.stop-command-source-on-error false
+expression b
+expression d
+expression h
+expression j
+expression static_e_ref
+exit
+
+# TARGET-VAR: (lldb) target variable b
+# TARGET-VAR-NEXT
[Lldb-commits] [lldb] [lldb][windows] use OutputDebugStringA instead of c to log events (PR #156474)
https://github.com/adrian-prantl approved this pull request. Otherwise lgtm https://github.com/llvm/llvm-project/pull/156474 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][windows] use Windows APIs to print to the console (PR #156469)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/156469 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
felipepiovezan wrote: > Also is there a store reference to memory and if so does it do its own thing > or call store pointer? could you elaborate? Not sure what you meant by "store reference to memory". https://github.com/llvm/llvm-project/pull/153585 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [RISCV-LLDB] RISCV feature attribute support and allows overriding additional(default) feature (PR #147990)
santhoshe447 wrote: Hi @jasonmolenda, Could we please prioritize merging this PR? It has been working successfully across our projects without any issues. If there are no further comments. https://github.com/llvm/llvm-project/pull/147990 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
@@ -103,3 +120,76 @@ lldb::SBValue Variables::FindVariable(uint64_t
variablesReference,
}
return variable;
}
+
+std::optional
+Variables::GetScopeKind(const int64_t variablesReference) {
+ auto scope_kind_iter = m_scope_kinds.find(variablesReference);
+ if (scope_kind_iter == m_scope_kinds.end()) {
+return std::nullopt;
+ }
+
+ auto scope_iter = m_frames.find(scope_kind_iter->second.second);
+ if (scope_iter == m_frames.end()) {
+return std::nullopt;
+ }
+
+ switch (scope_kind_iter->second.first) {
+ case lldb_dap::ScopeKind::Locals:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<0>(scope_iter->second));
+ case lldb_dap::ScopeKind::Globals:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<1>(scope_iter->second));
+ case lldb_dap::ScopeKind::Registers:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<2>(scope_iter->second));
+ }
+
+ return std::nullopt;
+}
+
+lldb::SBValueList *Variables::GetScope(const uint32_t frame_id,
+ const ScopeKind kind) {
+
+ auto frame = m_frames.find(frame_id);
+ if (m_frames.find(frame_id) == m_frames.end()) {
+return nullptr;
+ }
+
+ switch (kind) {
+ case ScopeKind::Locals:
+return &std::get<0>(frame->second);
+ case ScopeKind::Globals:
+return &std::get<1>(frame->second);
+ case ScopeKind::Registers:
+return &std::get<2>(frame->second);
+ }
+
+ return nullptr;
+}
+
+void Variables::ReadyFrame(uint32_t frame_id, lldb::SBFrame &frame) {
Anthony-Eid wrote:
Done
https://github.com/llvm/llvm-project/pull/124232
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
Michael137 wrote:
What's this used for?
https://github.com/llvm/llvm-project/pull/156370
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Complete constant array member types in class members (PR #156370)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/156370
>From 967d3453e997ed25c3548898d69a40d079d307b1 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 1 Sep 2025 21:02:33 +0200
Subject: [PATCH 1/3] [LLDB] Complete constant array member types in class
members
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 15 ++-
.../NativePDB/Inputs/incomplete-tag-type.cpp | 5 +
.../NativePDB/incomplete-tag-type.cpp | 45
.../NativePDB/incomplete-tag-type.test| 109 ++
4 files changed, 126 insertions(+), 48 deletions(-)
delete mode 100644 lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
create mode 100644
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 39aacdb58e694..038677f68b991 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9577,12 +9577,21 @@ TypeSystemClang::DeclContextGetTypeSystemClang(const
CompilerDeclContext &dc) {
}
void TypeSystemClang::RequireCompleteType(CompilerType type) {
+ if (!type)
+return;
+
+ clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
+ if (qual_type.isNull())
+return;
+
// Technically, enums can be incomplete too, but we don't handle those as
they
// are emitted even under -flimit-debug-info.
- if (!TypeSystemClang::IsCXXClassType(type))
-return;
+ bool is_constant_array = qual_type->isConstantArrayType();
+ bool is_cxx_record = qual_type->getAsCXXRecordDecl() != nullptr;
+ if (is_constant_array || is_cxx_record)
+type.GetCompleteType();
- if (type.GetCompleteType())
+ if (!is_cxx_record)
return;
// No complete definition in this module. Mark the class as complete to
diff --git
a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
index c930338905445..d08f49d1014ba 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
deleted file mode 100644
index 7bc7e618667f7..0
--- a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// clang-format off
-// REQUIRES: lld, x86
-
-// RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
-// RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj -- %s
-// RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
-// RUN: %lldb -f %t.exe -o \
-// RUN: "settings set interpreter.stop-command-source-on-error false" \
-// RUN: -o "expression b" -o "expression d" -o "expression static_e_ref" -o
"exit" 2>&1 | FileCheck %s
-
-// CHECK: (lldb) expression b
-// CHECK: (B) $0 = {}
-// CHECK: (lldb) expression d
-// CHECK: (D) $1 = {}
-// CHECK: (lldb) expression static_e_ref
-// CHECK: error:{{.*}}incomplete type 'E' where a complete type is required
-
-// Complete base class.
-struct A { int x; A(); };
-struct B : A {};
-B b;
-
-// Complete data member.
-struct C {
- C();
-};
-
-struct D {
- C c;
-};
-D d;
-
-// Incomplete static data member should return error.
-struct E {
- E();
-};
-
-struct F {
- static E static_e;
-};
-
-E F::static_e = E();
-E& static_e_ref = F::static_e;
-
-int main(){}
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
new file mode 100644
index 0..f30866ccdd6f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
@@ -0,0 +1,109 @@
+# REQUIRES: lld, x86
+
+# RUN: split-file %s %t
+
+# RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
+# RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj --
%t/main.cpp
+# RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
+
+# RUN: %lldb -f %t.exe -s %t/target-var.input 2>&1 | FileCheck %s
--check-prefix=TARGET-VAR
+# RUN: %lldb -f %t.exe -s %t/expr.input 2>&1 | FileCheck %s --check-prefix=EXPR
+
+#--- main.cpp
+
+// Complete base class.
+struct A { int x; A(); };
+struct B : A {};
+B b;
+
+// Complete data member.
+struct C {
+ C();
+};
+
+struct D {
+ C c;
+};
+D d;
+
+// Incomplete static data member should return error.
+struct E {
+ E();
+};
+
+struct F {
+ static E static_e;
+};
+
+E F::static_e = E();
+E& static_e_ref = F::static_e;
+
+struct G {
+ int foo = 1;
+};
+struct H {
+ G g[2];
+};
+H
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
DavidSpickett wrote: Also is there a store reference to memory and if so does it do its own thing or call store pointer? https://github.com/llvm/llvm-project/pull/153585 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Complete constant array member types in class members (PR #156370)
Michael137 wrote: > > It completes the element type. > > As in, "if an array type is encountered, it's immediately completed"? Because > in native PDB (with this PR too), it would be delayed. I meant, "completing a ConstantArrayType" is the same as "completing the element type". This PR implements the former, whereas the DWARF plugin we opted for the latter. > > Is there a place in the PDB plugin where we can do the same thing we do for > > DWARF? > > Yes, in `PdbAstBuilder::createArrayType` a `CompleteType(element_type)` could > be added, and the test would pass too: > > https://github.com/llvm/llvm-project/blob/74b9484fd62d6be9bc49e154800ceef0d74ef24f/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp#L1170-L1172 > > Would this be a better place? Yea that seems like the right thing to do https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
@@ -103,3 +120,76 @@ lldb::SBValue Variables::FindVariable(uint64_t
variablesReference,
}
return variable;
}
+
+std::optional
+Variables::GetScopeKind(const int64_t variablesReference) {
+ auto scope_kind_iter = m_scope_kinds.find(variablesReference);
+ if (scope_kind_iter == m_scope_kinds.end()) {
+return std::nullopt;
+ }
+
+ auto scope_iter = m_frames.find(scope_kind_iter->second.second);
+ if (scope_iter == m_frames.end()) {
+return std::nullopt;
+ }
+
+ switch (scope_kind_iter->second.first) {
+ case lldb_dap::ScopeKind::Locals:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<0>(scope_iter->second));
+ case lldb_dap::ScopeKind::Globals:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<1>(scope_iter->second));
+ case lldb_dap::ScopeKind::Registers:
+return ScopeData(scope_kind_iter->second.first,
+ std::get<2>(scope_iter->second));
+ }
+
+ return std::nullopt;
+}
+
+lldb::SBValueList *Variables::GetScope(const uint32_t frame_id,
+ const ScopeKind kind) {
+
+ auto frame = m_frames.find(frame_id);
+ if (m_frames.find(frame_id) == m_frames.end()) {
+return nullptr;
+ }
+
+ switch (kind) {
+ case ScopeKind::Locals:
+return &std::get<0>(frame->second);
+ case ScopeKind::Globals:
+return &std::get<1>(frame->second);
+ case ScopeKind::Registers:
+return &std::get<2>(frame->second);
+ }
+
+ return nullptr;
+}
+
+void Variables::ReadyFrame(uint32_t frame_id, lldb::SBFrame &frame) {
+ if (m_frames.find(frame_id) == m_frames.end()) {
+
+auto locals = frame.GetVariables(/*arguments=*/true,
+ /*locals=*/true,
+ /*statics=*/false,
+ /*in_scope_only=*/true);
+
+auto globals = frame.GetVariables(/*arguments=*/false,
+ /*locals=*/false,
+ /*statics=*/true,
+ /*in_scope_only=*/true);
+
+auto registers = frame.GetRegisters();
+
+m_frames.insert(
+std::make_pair(frame_id, std::make_tuple(locals, globals, registers)));
+ }
+}
+
+void Variables::AddScopeKind(int64_t variable_reference, ScopeKind kind,
+ uint32_t frame_id) {
+
+ m_scope_kinds[variable_reference] = std::make_pair(kind, frame_id);
+}
Anthony-Eid wrote:
Done
https://github.com/llvm/llvm-project/pull/124232
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBFunction::GetBaseName() & SBSymbol::GetBaseName() (PR #155939)
slydiman wrote: @JDevlieghere, @omjavaid, Is there any reason why GetDemangledName returns empty on Windows? The problem is hidden now. Could you create an issue and add the link to @expectedFailureAll(bugnumber="...") at least, please. https://github.com/llvm/llvm-project/pull/155939 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)
athierry-oct wrote: @labath ok, thanks for explaining why HandleCommand() works this way So in synchronous mode, should `EvaluateExpression()` (and more specifically, `RunThreadPlan()`) avoid rebroadcasting the stop event when expression evaluation fails due to a process stop? I may be missing something, but it seems to me that rebroadcasting the event is only necessary in async mode, since there’s an actual driver that needs to be notified. In sync mode, to find out what happened, the user can simply read the error from the function they used to evaluate the expression, e.g., `SBFrame::EvaluateExpression()` https://github.com/llvm/llvm-project/pull/144919 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1cee0e7 - [lldb][windows] use Windows APIs to print to the console (#156469)
Author: Charles Zablit
Date: 2025-09-03T00:05:22+01:00
New Revision: 1cee0e7b6281e5f82154a101eed09a7197a295a6
URL:
https://github.com/llvm/llvm-project/commit/1cee0e7b6281e5f82154a101eed09a7197a295a6
DIFF:
https://github.com/llvm/llvm-project/commit/1cee0e7b6281e5f82154a101eed09a7197a295a6.diff
LOG: [lldb][windows] use Windows APIs to print to the console (#156469)
This is a relanding of https://github.com/llvm/llvm-project/pull/149493.
The tests were failing because we were interpreting a proper file
descriptor as a console file descriptor.
This patch uses the Windows APIs to print to the Windows Console,
through `llvm::raw_fd_ostream`.
This fixes a rendering issue where the characters defined in
`DiagnosticsRendering.cpp` ("╰" for instance) are not rendered properly
on Windows out of the box, because the default codepage is not `utf-8`.
This solution is based on [this patch
downstream](https://github.com/swiftlang/swift/pull/40632/files#diff-e948e4bd7a601e3ca82d596058ccb39326459a4751470eec4d393adeaf516977R37-R38).
rdar://156064500
Added:
Modified:
lldb/include/lldb/Host/File.h
lldb/source/Host/common/File.cpp
Removed:
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index 9e2d0abe0b1af..7402a2231735a 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -382,15 +382,11 @@ class NativeFile : public File {
Unowned = false,
};
- NativeFile() : m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream) {}
+ NativeFile();
- NativeFile(FILE *fh, bool transfer_ownership)
- : m_descriptor(kInvalidDescriptor), m_own_descriptor(false),
m_stream(fh),
-m_options(), m_own_stream(transfer_ownership) {}
+ NativeFile(FILE *fh, bool transfer_ownership);
- NativeFile(int fd, OpenOptions options, bool transfer_ownership)
- : m_descriptor(fd), m_own_descriptor(transfer_ownership),
-m_stream(kInvalidStream), m_options(options), m_own_stream(false) {}
+ NativeFile(int fd, OpenOptions options, bool transfer_ownership);
~NativeFile() override { Close(); }
@@ -444,17 +440,19 @@ class NativeFile : public File {
return ValueGuard(m_stream_mutex, StreamIsValidUnlocked());
}
- int m_descriptor;
+ int m_descriptor = kInvalidDescriptor;
bool m_own_descriptor = false;
mutable std::mutex m_descriptor_mutex;
- FILE *m_stream;
+ FILE *m_stream = kInvalidStream;
mutable std::mutex m_stream_mutex;
OpenOptions m_options{};
bool m_own_stream = false;
std::mutex offset_access_mutex;
+ bool is_windows_console = false;
+
private:
NativeFile(const NativeFile &) = delete;
const NativeFile &operator=(const NativeFile &) = delete;
diff --git a/lldb/source/Host/common/File.cpp
b/lldb/source/Host/common/File.cpp
index 23b6dc9fe850d..8fd1ca069dc01 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -36,6 +36,7 @@
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
+#include "llvm/Support/raw_ostream.h"
using namespace lldb;
using namespace lldb_private;
@@ -247,6 +248,32 @@ uint32_t File::GetPermissions(Status &error) const {
return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
}
+NativeFile::NativeFile() = default;
+
+NativeFile::NativeFile(FILE *fh, bool transfer_ownership)
+: m_stream(fh), m_own_stream(transfer_ownership) {
+#ifdef _WIN32
+ // In order to properly display non ASCII characters in Windows, we need to
+ // use Windows APIs to print to the console. This is only required if the
+ // stream outputs to a console.
+ int fd = _fileno(fh);
+ is_windows_console =
+ ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;
+#endif
+}
+
+NativeFile::NativeFile(int fd, OpenOptions options, bool transfer_ownership)
+: m_descriptor(fd), m_own_descriptor(transfer_ownership),
+ m_options(options) {
+#ifdef _WIN32
+ // In order to properly display non ASCII characters in Windows, we need to
+ // use Windows APIs to print to the console. This is only required if the
+ // file outputs to a console.
+ is_windows_console =
+ ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR;
+#endif
+}
+
bool NativeFile::IsValid() const {
std::scoped_lock lock(m_descriptor_mutex,
m_stream_mutex);
return DescriptorIsValidUnlocked() || StreamIsValidUnlocked();
@@ -629,6 +656,13 @@ Status NativeFile::Write(const void *buf, size_t
&num_bytes) {
}
if (ValueGuard stream_guard = StreamIsValid()) {
+#ifdef _WIN32
+if (is_windows_console) {
+ llvm::raw_fd_ostream(_fileno(m_stream), false)
+ .write((char *)buf, num_bytes);
+ return error;
+}
+#endif
bytes_written = ::fwrite(buf, 1, num_bytes, m_stream);
if (bytes_written == 0) {
___
lldb-commits maili
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
https://github.com/Anthony-Eid updated
https://github.com/llvm/llvm-project/pull/124232
>From 30658e994b18b7c0db114a297036421c8de2dea3 Mon Sep 17 00:00:00 2001
From: Anthony
Date: Wed, 27 Aug 2025 13:04:26 -0400
Subject: [PATCH 01/15] Fix variable request from reusing variable_ids
---
.../lldb-dap/Handler/ScopesRequestHandler.cpp | 45 ++-
lldb/tools/lldb-dap/JSONUtils.h | 1 +
lldb/tools/lldb-dap/Variables.cpp | 80 +--
lldb/tools/lldb-dap/Variables.h | 18 -
4 files changed, 119 insertions(+), 25 deletions(-)
diff --git a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
index aaad0e20f9c21..160d8e264d089 100644
--- a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
@@ -29,8 +29,8 @@ namespace lldb_dap {
///
/// \return
/// A `protocol::Scope`
-static Scope CreateScope(const llvm::StringRef name, int64_t
variablesReference,
- int64_t namedVariables, bool expensive) {
+Scope CreateScope(const llvm::StringRef name, int64_t variablesReference,
+ int64_t namedVariables, bool expensive) {
Scope scope;
scope.name = name;
@@ -75,22 +75,31 @@ ScopesRequestHandler::Run(const ScopesArguments &args)
const {
frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread());
frame.GetThread().SetSelectedFrame(frame.GetFrameID());
}
- dap.variables.locals = frame.GetVariables(/*arguments=*/true,
-/*locals=*/true,
-/*statics=*/false,
-/*in_scope_only=*/true);
- dap.variables.globals = frame.GetVariables(/*arguments=*/false,
- /*locals=*/false,
- /*statics=*/true,
- /*in_scope_only=*/true);
- dap.variables.registers = frame.GetRegisters();
-
- std::vector scopes = {CreateScope("Locals", VARREF_LOCALS,
-dap.variables.locals.GetSize(), false),
-CreateScope("Globals", VARREF_GLOBALS,
-dap.variables.globals.GetSize(), false),
-CreateScope("Registers", VARREF_REGS,
-dap.variables.registers.GetSize(), false)};
+
+ uint32_t frame_id = frame.GetFrameID();
+
+ dap.variables.ReadyFrame(frame_id, frame);
+ dap.variables.SwitchFrame(frame_id);
+
+ std::vector scopes = {};
+
+ int64_t variable_reference = dap.variables.GetNewVariableReference(false);
+ scopes.push_back(CreateScope("Locals", variable_reference,
+ dap.variables.locals.GetSize(), false));
+
+ dap.variables.AddScopeKind(variable_reference, ScopeKind::Locals, frame_id);
+
+ variable_reference = dap.variables.GetNewVariableReference(false);
+ scopes.push_back(CreateScope("Globals", variable_reference,
+ dap.variables.globals.GetSize(), false));
+ dap.variables.AddScopeKind(variable_reference, ScopeKind::Globals, frame_id);
+
+ variable_reference = dap.variables.GetNewVariableReference(false);
+ scopes.push_back(CreateScope("Registers", variable_reference,
+ dap.variables.registers.GetSize(), false));
+
+ dap.variables.AddScopeKind(variable_reference, ScopeKind::Registers,
+ frame_id);
return ScopesResponseBody{std::move(scopes)};
}
diff --git a/lldb/tools/lldb-dap/JSONUtils.h b/lldb/tools/lldb-dap/JSONUtils.h
index e9094f67b94ec..6575411acd878 100644
--- a/lldb/tools/lldb-dap/JSONUtils.h
+++ b/lldb/tools/lldb-dap/JSONUtils.h
@@ -9,6 +9,7 @@
#ifndef LLDB_TOOLS_LLDB_DAP_JSONUTILS_H
#define LLDB_TOOLS_LLDB_DAP_JSONUTILS_H
+#include "DAP.h"
#include "DAPForward.h"
#include "Protocol/ProtocolTypes.h"
#include "lldb/API/SBCompileUnit.h"
diff --git a/lldb/tools/lldb-dap/Variables.cpp
b/lldb/tools/lldb-dap/Variables.cpp
index 777e3183d8c0d..9ed3773df817d 100644
--- a/lldb/tools/lldb-dap/Variables.cpp
+++ b/lldb/tools/lldb-dap/Variables.cpp
@@ -8,20 +8,33 @@
#include "Variables.h"
#include "JSONUtils.h"
+#include "lldb/API/SBFrame.h"
using namespace lldb_dap;
lldb::SBValueList *Variables::GetTopLevelScope(int64_t variablesReference) {
- switch (variablesReference) {
- case VARREF_LOCALS:
+ auto iter = m_scope_kinds.find(variablesReference);
+ if (iter == m_scope_kinds.end()) {
+return nullptr;
+ }
+
+ ScopeKind scope_kind = iter->second.first;
+ uint32_t frame_id = iter->second.second;
+
+ if (!SwitchFrame(frame_id)) {
+return nullptr;
+ }
+
+ switch (scope_kind) {
+ case lldb_dap::ScopeKind::Locals:
return &locals;
- case VARREF_GLOBALS:
+ case lldb_dap::ScopeKind::Globals:
return &globals;
- case VARREF_REGS:
+ c
[Lldb-commits] [lldb] [lldb] Add utility to create Mach-O corefile from YAML desc (PR #153911)
jasonmolenda wrote: > > You could imagine someone making an ELF corefile output capability, for > > instance. > > Yes I'd love to be generating the core files eventually. Maybe we can with > yaml2obj but I never seriously looked into it. As right now, patching in > notes by hand makes for smaller files, but it's not reproducible or self > documenting. > > I assume the existing yaml2obj cannot make core files, or you wouldn't be > writing this. I don't think yaml2obj does make corefiles, but I believe this utility serves a different purpose. yaml2obj could if you already have a small corefile (they're rarely small) that only contains the bytes needed to reproduce a bug that you want to test. You may need to hand-modify an existing corefile to remove unnecessary memory segments, or to change values to elicit some behavior you want to test. The idea with this tool is that you have the memory bytes that are critical to show an issue, or register values, and you want to construct a corefile based on those bytes. You may not be starting with a real corefile to begin with. For that matter, you might construct stack memory values manually to elicit an unwinder bug, for instance. (nb until I find a way for ObjectFileJSON to specify unwind rules for functions, this is unlikely to work, unless you copy the bytes of the relevant functions into the YAML so lldb can do its instruction emulation unwind plan). Last week I had a bug report of someone seeing an issue with lldb in a firmware environment, where it would be difficult for me to set up the environment and corefiles were not an option. I got the register values & 400 bytes of stack memory (lit. just "reg read" and "mem read"), and a copy of the relevant binary + dSYM, reformatted it all into YAML and created a Mach-O corefile that was able to reproduce the issue on my desktop. Pretty handy! Agree this is not common, but it was funny it came up only a couple weeks after I wrote the tool. I think it fills a niche distinct from obj2yaml / yaml2obj, regardless of corefile support in that tool. https://github.com/llvm/llvm-project/pull/153911 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Set IsDynmaicCXXType metadata for records (PR #155853)
https://github.com/ZequanWu edited https://github.com/llvm/llvm-project/pull/155853 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Set IsDynmaicCXXType metadata for records (PR #155853)
@@ -601,21 +601,26 @@ PdbAstBuilder::CreateModifierType(const ModifierRecord
&modifier) {
}
clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
-const TagRecord &record) {
+const CVTagRecord &record) {
clang::DeclContext *context = nullptr;
std::string uname;
- std::tie(context, uname) = CreateDeclInfoForType(record, id.index);
+ std::tie(context, uname) = CreateDeclInfoForType(record.asTag(), id.index);
if (!context)
return {};
- clang::TagTypeKind ttk = TranslateUdtKind(record);
+ clang::TagTypeKind ttk = TranslateUdtKind(record.asTag());
lldb::AccessType access = (ttk == clang::TagTypeKind::Class)
? lldb::eAccessPrivate
: lldb::eAccessPublic;
ClangASTMetadata metadata;
metadata.SetUserID(toOpaqueUid(id));
- metadata.SetIsDynamicCXXType(false);
+ // If a class has a vtable, it is dynamic.
+ // Otherwise, we wait until the record is completed - it might have virtual
+ // bases.
+ if (record.contextKind() == CompilerContextKind::ClassOrStruct &&
+ !record.asClass().getVTableShape().isNoneType())
+metadata.SetIsDynamicCXXType(true);
ZequanWu wrote:
Shouldn't we set it to false when the condition is false, like
`metadata.SetIsDynamicCXXType(record.contextKind() ==
CompilerContextKind::ClassOrStruct &&
!record.asClass().getVTableShape().isNoneType())`? By default it's
`std::nullopt`.
https://github.com/llvm/llvm-project/pull/155853
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Set IsDynmaicCXXType metadata for records (PR #155853)
https://github.com/ZequanWu commented: In terms of testing, we should avoid adding binaries in test suite. https://github.com/llvm/llvm-project/blob/2fc0e2c888521489f4a286b0902a6896506f8d8e/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp#L47-L49 dumps dynamic type info, but I'm not sure if it's actually used anywhere. https://github.com/llvm/llvm-project/pull/155853 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add AArch64 support to the premerge tests (PR #155274)
https://github.com/tstellar updated
https://github.com/llvm/llvm-project/pull/155274
>From 57697a66cfdddf2028c7260f1ce61ecacc550d00 Mon Sep 17 00:00:00 2001
From: Tom Stellard
Date: Mon, 25 Aug 2025 17:15:36 +
Subject: [PATCH 01/56] Add AArch64 support to the premerge tests
---
.github/workflows/premerge.yaml | 8 +++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 9d925517a7211..6d83573702a79 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,7 +28,13 @@ jobs:
if: >-
github.repository_owner == 'llvm' &&
(github.event_name != 'pull_request' || github.event.action !=
'closed')
-runs-on: llvm-premerge-linux-runners
+matrix:
+ runs-on:
+- llvm-premerge-linux-runners
+- depot-ubuntu-24.04-arm-64
+runs-on: ${{ matrix.runs-on }}
+container:
+ image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
steps:
- name: Checkout LLVM
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #
v5.0.0
>From 8ba375b2d80614f4a769af1b417bf21f1712786c Mon Sep 17 00:00:00 2001
From: Tom Stellard
Date: Mon, 25 Aug 2025 17:20:38 +
Subject: [PATCH 02/56] Fix typo
---
.github/workflows/premerge.yaml | 9 +
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 6d83573702a79..f88dbc6143ab4 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -28,10 +28,11 @@ jobs:
if: >-
github.repository_owner == 'llvm' &&
(github.event_name != 'pull_request' || github.event.action !=
'closed')
-matrix:
- runs-on:
-- llvm-premerge-linux-runners
-- depot-ubuntu-24.04-arm-64
+strategy:
+ matrix:
+runs-on:
+ - llvm-premerge-linux-runners
+ - depot-ubuntu-24.04-arm-64
runs-on: ${{ matrix.runs-on }}
container:
image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
>From af39d1af7635196606ceaeff6a2cf1db72e142e4 Mon Sep 17 00:00:00 2001
From: Tom Stellard
Date: Mon, 25 Aug 2025 17:21:51 +
Subject: [PATCH 03/56] Fix quotes
---
.github/workflows/premerge.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index f88dbc6143ab4..914713bb4a352 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
- depot-ubuntu-24.04-arm-64
runs-on: ${{ matrix.runs-on }}
container:
- image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
"ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent" ) || null }}
+ image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
steps:
- name: Checkout LLVM
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #
v5.0.0
>From 0330faf41115cab59d8667dbe77bf9414ea3455c Mon Sep 17 00:00:00 2001
From: Tom Stellard
Date: Mon, 25 Aug 2025 17:24:18 +
Subject: [PATCH 04/56] Fix container name
---
.github/workflows/premerge.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index 914713bb4a352..edb7248d792fe 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
- depot-ubuntu-24.04-arm-64
runs-on: ${{ matrix.runs-on }}
container:
- image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
'ghcr.io/$GITHUB_REPOSITORY_OWNER/arm64v8/ci-ubuntu-24.04-agent' ) || null }}
+ image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
format('ghcr.io/{}/arm64v8/ci-ubuntu-24.04-agent',github.repository_owner) ) ||
null }}
steps:
- name: Checkout LLVM
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #
v5.0.0
>From 0492ee60484cd594f80b6cadcb7ebc5755b6710c Mon Sep 17 00:00:00 2001
From: Tom Stellard
Date: Mon, 25 Aug 2025 17:29:25 +
Subject: [PATCH 05/56] Fix format string
---
.github/workflows/premerge.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml
index edb7248d792fe..28d79518bc1df 100644
--- a/.github/workflows/premerge.yaml
+++ b/.github/workflows/premerge.yaml
@@ -35,7 +35,7 @@ jobs:
- depot-ubuntu-24.04-arm-64
runs-on: ${{ matrix.runs-on }}
container:
- image: ${{ (startsWith(matrix.runs-on, 'depot-ubuntu-24.04-arm') &&
format('ghcr.io/{}/arm64v8/ci-ub
[Lldb-commits] [lldb] [lldb][RISCV][test] make atomic region stepping test more robust (PR #156506)
https://github.com/dlav-sc updated
https://github.com/llvm/llvm-project/pull/156506
>From d9ede8035d1786a62375295fdb855fb2a08f0c72 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev
Date: Wed, 16 Jul 2025 14:52:27 +
Subject: [PATCH] [lldb][RISCV][test] make atomic region stepping test more
robust
Currently, the tests that check stepping through atomic sequences use a
hardcoded step distance, which is unreliable because this distance
depends on LLVM's codegeneration.
This patch rewrites the test to avoid this disadvantage. The test now
checks the opcode of the instruction after the step instead of the step
distance.
---
lldb/test/API/riscv/step/TestSoftwareStep.py | 35
lldb/test/API/riscv/step/branch.c| 1 +
lldb/test/API/riscv/step/main.c | 1 +
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/lldb/test/API/riscv/step/TestSoftwareStep.py
b/lldb/test/API/riscv/step/TestSoftwareStep.py
index 279c4c1b797e0..0544d2102d0f9 100644
--- a/lldb/test/API/riscv/step/TestSoftwareStep.py
+++ b/lldb/test/API/riscv/step/TestSoftwareStep.py
@@ -26,19 +26,26 @@ def do_sequence_test(self, filename, bkpt_name):
substrs=["stopped", "stop reason = instruction step into"],
)
-pc = cur_thread.GetFrameAtIndex(0).GetPC()
+# Get the instruction we stopped at
+pc = cur_thread.GetFrameAtIndex(0).GetPCAddress()
+inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0)
-return pc - entry_pc
+inst_mnemonic = inst.GetMnemonic(target)
+inst_operands = inst.GetOperands(target)
+if not inst_operands:
+return inst_mnemonic
-@skipIf(archs=no_match("^rv.*"))
+return f"{inst_mnemonic} {inst_operands}"
+
+@skipIf(archs=no_match("^riscv.*"))
def test_cas(self):
"""
This test verifies LLDB instruction step handling of a proper lr/sc
pair.
"""
-difference = self.do_sequence_test("main", "cas")
-self.assertEqual(difference, 0x1A)
+instruction = self.do_sequence_test("main", "cas")
+self.assertEqual(instruction, "nop")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_branch_cas(self):
"""
LLDB cannot predict the actual state of registers within a critical
section (i.e., inside an atomic
@@ -51,29 +58,29 @@ def test_branch_cas(self):
test is nearly identical to the previous one, except for the branch
condition, which is inverted and
will result in a taken jump.
"""
-difference = self.do_sequence_test("branch", "branch_cas")
-self.assertEqual(difference, 0x1A)
+instruction = self.do_sequence_test("branch", "branch_cas")
+self.assertEqual(instruction, "ret")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_incomplete_sequence_without_lr(self):
"""
This test verifies the behavior of a standalone sc instruction without
a preceding lr. Since the sc
lacks the required lr pairing, LLDB should treat it as a non-atomic
store rather than part of an
atomic sequence.
"""
-difference = self.do_sequence_test(
+instruction = self.do_sequence_test(
"incomplete_sequence_without_lr", "incomplete_cas"
)
-self.assertEqual(difference, 0x4)
+self.assertEqual(instruction, "and a5, a2, a4")
-@skipIf(archs=no_match("^rv.*"))
+@skipIf(archs=no_match("^riscv.*"))
def test_incomplete_sequence_without_sc(self):
"""
This test checks the behavior of a standalone lr instruction without a
subsequent sc. Since the lr
lacks its required sc counterpart, LLDB should treat it as a
non-atomic load rather than part of an
atomic sequence.
"""
-difference = self.do_sequence_test(
+instruction = self.do_sequence_test(
"incomplete_sequence_without_sc", "incomplete_cas"
)
-self.assertEqual(difference, 0x4)
+self.assertEqual(instruction, "and a5, a2, a4")
diff --git a/lldb/test/API/riscv/step/branch.c
b/lldb/test/API/riscv/step/branch.c
index 79bf0ca005db1..93d6c51ec75e0 100644
--- a/lldb/test/API/riscv/step/branch.c
+++ b/lldb/test/API/riscv/step/branch.c
@@ -11,6 +11,7 @@ void __attribute__((naked)) branch_cas(int *a, int *b) {
"xor a5, a2, a5\n\t"
"sc.w a5, a1, (a3)\n\t"
"beqz a5, 1b\n\t"
+ "nop\n\t"
"2:\n\t"
"ret\n\t");
}
diff --git a/lldb/test/API/riscv/step/main.c b/lldb/test/API/riscv/step/main.c
index 35e8aee2cae4b..5ed2ced87e7b3 100644
--- a/lldb/test/API/riscv/step/main.c
+++ b/lldb/test/API/riscv/step/main.c
@@ -11,6 +11,7 @@ void __attribute__((naked)) cas(int *a, int *b) {
"xor a5, a2, a5\n\t"
"sc.w a5, a1, (a3)\n\t"
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Introduce ScriptedFrame affordance (PR #149622)
https://github.com/medismailben ready_for_review https://github.com/llvm/llvm-project/pull/149622 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
https://github.com/Anthony-Eid edited https://github.com/llvm/llvm-project/pull/124232 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Call FixUpPointer in WritePointerToMemory (try 2) (PR #153585)
DavidSpickett wrote: Yes that's right. I'm still a bit unclear how it makes its way to WritePointerToMemory, but as long as it'll break if we change things, that's the point. I think it is that: * Expression evaluation needs to pass `void* ptr` to the function. * To do that we allocate a stack slot in the expression wrapper, and write it there - using WritePointerToMemory. * The wrapper loads it back from memory to call the function. Yes, because the wrapper itself has no arguments. So this isn't like a normal compilation where you put the pointer in a register, everything has to be on the stack first. Also stylistic point, use `uintptr_t` for the pointer manipulation. No practical difference in this case, but a bit more self-describing. A new variable name is a good idea too, if you check both in the test, if it does fail, the difference between the 2 will be a big clue to figuring it out. https://github.com/llvm/llvm-project/pull/153585 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][windows] use OutputDebugStringA instead of c to log events (PR #156474)
@@ -308,52 +306,24 @@ Environment Host::GetEnvironment() {
return env;
}
-/// Manages the lifecycle of a Windows Event's Source.
-/// The destructor will call DeregisterEventSource.
-/// This class is meant to be used with \ref llvm::ManagedStatic.
-class WindowsEventLog {
-public:
- WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {}
-
- ~WindowsEventLog() {
-if (handle)
- DeregisterEventSource(handle);
- }
-
- HANDLE GetHandle() const { return handle; }
-
-private:
- HANDLE handle;
-};
-
-static llvm::ManagedStatic event_log;
-
void Host::SystemLog(Severity severity, llvm::StringRef message) {
if (message.empty())
return;
- HANDLE h = event_log->GetHandle();
- if (!h)
-return;
-
- llvm::SmallVector argsUTF16;
- if (UTF8ToUTF16(message.str(), argsUTF16))
-return;
-
- WORD event_type;
+ std::string log_prefix;
switch (severity) {
case lldb::eSeverityWarning:
-event_type = EVENTLOG_WARNING_TYPE;
+log_prefix = "[Warning] ";
break;
case lldb::eSeverityError:
-event_type = EVENTLOG_ERROR_TYPE;
+log_prefix = "[Error] ";
break;
case lldb::eSeverityInfo:
default:
-event_type = EVENTLOG_INFORMATION_TYPE;
+log_prefix = "[Info] ";
+break;
}
- LPCWSTR messages[1] = {argsUTF16.data()};
- ReportEventW(h, event_type, 0, 0, nullptr, std::size(messages), 0, messages,
- nullptr);
+ std::string final_message = log_prefix + message.str();
+ OutputDebugStringA(final_message.c_str());
compnerd wrote:
I'm half tempted to say that this should be `(Twine{log_prefix} +
message).str().c_str()` instead of the `std::string` and then calling
`OutputDebugStringA`.
https://github.com/llvm/llvm-project/pull/156474
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][windows] use OutputDebugStringA instead of c to log events (PR #156474)
https://github.com/compnerd approved this pull request. https://github.com/llvm/llvm-project/pull/156474 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)
Anthony-Eid wrote: I just finished merging the `ReadyFrame` and `SwitchFrame` logic. Please let me know what else I should change https://github.com/llvm/llvm-project/pull/124232 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [openmp] Fix typos and spelling errors across codebase (PR #156270)
https://github.com/felipepiovezan commented: the LLDB changes are ok, but I also support the need to split this; this is touching some test files (and test names), and I dread to think if the cross-project revert someone would need to do if we accidentally break a test. https://github.com/llvm/llvm-project/pull/156270 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz edited https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Complete array member types in AST builder (PR #156370)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/156370
>From 967d3453e997ed25c3548898d69a40d079d307b1 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 1 Sep 2025 21:02:33 +0200
Subject: [PATCH 1/4] [LLDB] Complete constant array member types in class
members
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 15 ++-
.../NativePDB/Inputs/incomplete-tag-type.cpp | 5 +
.../NativePDB/incomplete-tag-type.cpp | 45
.../NativePDB/incomplete-tag-type.test| 109 ++
4 files changed, 126 insertions(+), 48 deletions(-)
delete mode 100644 lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
create mode 100644
lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 39aacdb58e694..038677f68b991 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9577,12 +9577,21 @@ TypeSystemClang::DeclContextGetTypeSystemClang(const
CompilerDeclContext &dc) {
}
void TypeSystemClang::RequireCompleteType(CompilerType type) {
+ if (!type)
+return;
+
+ clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
+ if (qual_type.isNull())
+return;
+
// Technically, enums can be incomplete too, but we don't handle those as
they
// are emitted even under -flimit-debug-info.
- if (!TypeSystemClang::IsCXXClassType(type))
-return;
+ bool is_constant_array = qual_type->isConstantArrayType();
+ bool is_cxx_record = qual_type->getAsCXXRecordDecl() != nullptr;
+ if (is_constant_array || is_cxx_record)
+type.GetCompleteType();
- if (type.GetCompleteType())
+ if (!is_cxx_record)
return;
// No complete definition in this module. Mark the class as complete to
diff --git
a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
index c930338905445..d08f49d1014ba 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/Inputs/incomplete-tag-type.cpp
@@ -13,3 +13,8 @@ struct E {
E();
};
E::E() = default;
+
+struct I {
+ I();
+};
+I::I() = default;
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
deleted file mode 100644
index 7bc7e618667f7..0
--- a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// clang-format off
-// REQUIRES: lld, x86
-
-// RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
-// RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj -- %s
-// RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
-// RUN: %lldb -f %t.exe -o \
-// RUN: "settings set interpreter.stop-command-source-on-error false" \
-// RUN: -o "expression b" -o "expression d" -o "expression static_e_ref" -o
"exit" 2>&1 | FileCheck %s
-
-// CHECK: (lldb) expression b
-// CHECK: (B) $0 = {}
-// CHECK: (lldb) expression d
-// CHECK: (D) $1 = {}
-// CHECK: (lldb) expression static_e_ref
-// CHECK: error:{{.*}}incomplete type 'E' where a complete type is required
-
-// Complete base class.
-struct A { int x; A(); };
-struct B : A {};
-B b;
-
-// Complete data member.
-struct C {
- C();
-};
-
-struct D {
- C c;
-};
-D d;
-
-// Incomplete static data member should return error.
-struct E {
- E();
-};
-
-struct F {
- static E static_e;
-};
-
-E F::static_e = E();
-E& static_e_ref = F::static_e;
-
-int main(){}
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
new file mode 100644
index 0..f30866ccdd6f0
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/incomplete-tag-type.test
@@ -0,0 +1,109 @@
+# REQUIRES: lld, x86
+
+# RUN: split-file %s %t
+
+# RUN: %clang_cl --target=x86_64-windows-msvc -c /Fo%t1.obj --
%p/Inputs/incomplete-tag-type.cpp
+# RUN: %clang_cl --target=x86_64-windows-msvc /O1 /Z7 -c /Fo%t2.obj --
%t/main.cpp
+# RUN: lld-link /debug:full /nodefaultlib /entry:main %t1.obj %t2.obj
/out:%t.exe /pdb:%t.pdb
+
+# RUN: %lldb -f %t.exe -s %t/target-var.input 2>&1 | FileCheck %s
--check-prefix=TARGET-VAR
+# RUN: %lldb -f %t.exe -s %t/expr.input 2>&1 | FileCheck %s --check-prefix=EXPR
+
+#--- main.cpp
+
+// Complete base class.
+struct A { int x; A(); };
+struct B : A {};
+B b;
+
+// Complete data member.
+struct C {
+ C();
+};
+
+struct D {
+ C c;
+};
+D d;
+
+// Incomplete static data member should return error.
+struct E {
+ E();
+};
+
+struct F {
+ static E static_e;
+};
+
+E F::static_e = E();
+E& static_e_ref = F::static_e;
+
+struct G {
+ int foo = 1;
+};
+struct H {
+ G g[2];
+};
+H
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] [clang][modules] Serialize `CodeGenOptions` (PR #146422)
@@ -0,0 +1,15 @@ +// This test checks that under implicit modules, different optimization levels jansvoboda11 wrote: Thank you for letting me know, @paperchalice. My IDE does this in certain situations and I didn't notice before committing. Fixed in 96c27761. https://github.com/llvm/llvm-project/pull/146422 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Destroy debugger when debug session terminates (PR #156231)
walter-erquinigo wrote: Good, this looks good to me! I'll let @kusmour do the final approval https://github.com/llvm/llvm-project/pull/156231 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][windows] use OutputDebugStringA instead of c to log events (PR #156474)
@@ -308,52 +306,24 @@ Environment Host::GetEnvironment() {
return env;
}
-/// Manages the lifecycle of a Windows Event's Source.
-/// The destructor will call DeregisterEventSource.
-/// This class is meant to be used with \ref llvm::ManagedStatic.
-class WindowsEventLog {
-public:
- WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {}
-
- ~WindowsEventLog() {
-if (handle)
- DeregisterEventSource(handle);
- }
-
- HANDLE GetHandle() const { return handle; }
-
-private:
- HANDLE handle;
-};
-
-static llvm::ManagedStatic event_log;
-
void Host::SystemLog(Severity severity, llvm::StringRef message) {
if (message.empty())
return;
- HANDLE h = event_log->GetHandle();
- if (!h)
-return;
-
- llvm::SmallVector argsUTF16;
- if (UTF8ToUTF16(message.str(), argsUTF16))
-return;
-
- WORD event_type;
+ std::string log_prefix;
switch (severity) {
case lldb::eSeverityWarning:
-event_type = EVENTLOG_WARNING_TYPE;
+log_prefix = "[Warning] ";
break;
case lldb::eSeverityError:
-event_type = EVENTLOG_ERROR_TYPE;
+log_prefix = "[Error] ";
break;
case lldb::eSeverityInfo:
default:
-event_type = EVENTLOG_INFORMATION_TYPE;
+log_prefix = "[Info] ";
+break;
}
- LPCWSTR messages[1] = {argsUTF16.data()};
- ReportEventW(h, event_type, 0, 0, nullptr, std::size(messages), 0, messages,
- nullptr);
+ std::string final_message = log_prefix + message.str();
+ OutputDebugStringA(final_message.c_str());
charles-zablit wrote:
Went with the `llvm::raw_string_ostream` approach
https://github.com/llvm/llvm-project/pull/156474
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Complete constant array member types in class members (PR #156370)
https://github.com/Michael137 commented: The way we do it for DWARF (for better or for worse) is that we complete the array element type, not the array type itself. FWIW, that's what completing a `ConstantArrayType` does anyway. It completes the element type. Is there a place in the PDB plugin where we can do the same thing we do for DWARF? https://github.com/llvm/llvm-project/blob/74b9484fd62d6be9bc49e154800ceef0d74ef24f/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1507-L1508 https://github.com/llvm/llvm-project/pull/156370 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][windows] use Windows APIs to print to the console (PR #156469)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/156469 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
