https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/172687
>From ea490988d93e73289ae4360ce32a7964cb8016b8 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Wed, 17 Dec 2025 15:53:45 +0000 Subject: [PATCH 1/2] [lldb][API] Make SB-API functions const if possible. Only applied to functions that were added after 22.x tag. --- lldb/include/lldb/API/SBDebugger.h | 2 +- lldb/include/lldb/API/SBMemoryRegionInfo.h | 2 +- lldb/include/lldb/API/SBModuleSpec.h | 2 +- lldb/include/lldb/API/SBSaveCoreOptions.h | 2 +- lldb/include/lldb/API/SBSymbol.h | 4 ++-- lldb/include/lldb/API/SBTarget.h | 4 ++-- lldb/include/lldb/Symbol/SaveCoreOptions.h | 2 +- lldb/source/API/SBDebugger.cpp | 2 +- lldb/source/API/SBMemoryRegionInfo.cpp | 2 +- lldb/source/API/SBModuleSpec.cpp | 2 +- lldb/source/API/SBSaveCoreOptions.cpp | 2 +- lldb/source/API/SBSymbol.cpp | 6 +++--- lldb/source/API/SBTarget.cpp | 4 ++-- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 7a08a08262207..39980349065cf 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -360,7 +360,7 @@ class LLDB_API SBDebugger { const char *arch); /// Find a target with the specified unique ID. - lldb::SBTarget FindTargetByGloballyUniqueID(lldb::user_id_t id); + lldb::SBTarget FindTargetByGloballyUniqueID(lldb::user_id_t id) const; /// Get the number of targets in the debugger. uint32_t GetNumTargets(); diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h b/lldb/include/lldb/API/SBMemoryRegionInfo.h index dc5aa0858e1e3..3ff9b6beff20c 100644 --- a/lldb/include/lldb/API/SBMemoryRegionInfo.h +++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h @@ -126,7 +126,7 @@ class LLDB_API SBMemoryRegionInfo { /// /// The description format is: [Hex start - Hex End) with associated /// permissions (RWX) - bool GetDescription(lldb::SBStream &description); + bool GetDescription(lldb::SBStream &description) const; private: friend class SBProcess; diff --git a/lldb/include/lldb/API/SBModuleSpec.h b/lldb/include/lldb/API/SBModuleSpec.h index b80a52b7a235f..0e7f0f3489596 100644 --- a/lldb/include/lldb/API/SBModuleSpec.h +++ b/lldb/include/lldb/API/SBModuleSpec.h @@ -87,7 +87,7 @@ class LLDB_API SBModuleSpec { bool GetDescription(lldb::SBStream &description); - lldb::SBTarget GetTarget(); + lldb::SBTarget GetTarget() const; /// Set the target to be used when resolving a module. /// diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h b/lldb/include/lldb/API/SBSaveCoreOptions.h index 7b05377966965..5f5f99a46f206 100644 --- a/lldb/include/lldb/API/SBSaveCoreOptions.h +++ b/lldb/include/lldb/API/SBSaveCoreOptions.h @@ -84,7 +84,7 @@ class LLDB_API SBSaveCoreOptions { /// /// \return /// The set process, or an invalid SBProcess if no process is set. - SBProcess GetProcess(); + SBProcess GetProcess() const; /// Add a thread to save in the core file. /// diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h index 580458ede212d..3ec0dab5112f5 100644 --- a/lldb/include/lldb/API/SBSymbol.h +++ b/lldb/include/lldb/API/SBSymbol.h @@ -91,7 +91,7 @@ class LLDB_API SBSymbol { /// /// \returns /// Returns the ID of this symbol. - uint32_t GetID(); + uint32_t GetID() const; bool operator==(const lldb::SBSymbol &rhs) const; @@ -108,7 +108,7 @@ class LLDB_API SBSymbol { bool IsSynthetic(); /// Returns true if the symbol is a debug symbol. - bool IsDebug(); + bool IsDebug() const; /// Get the string representation of a symbol type. static const char *GetTypeAsString(lldb::SymbolType symbol_type); diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 0318492f1054c..dd2cf59b831da 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -338,7 +338,7 @@ class LLDB_API SBTarget { /// \return /// A lldb::SBModule object that represents the found module, or an /// invalid SBModule object if no module was found. - lldb::SBModule FindModule(const lldb::SBModuleSpec &module_spec); + lldb::SBModule FindModule(const lldb::SBModuleSpec &module_spec) const; /// Find compile units related to *this target and passed source /// file. @@ -359,7 +359,7 @@ class LLDB_API SBTarget { const char *GetTriple(); - const char *GetArchName(); + const char *GetArchName() const; const char *GetABIName(); diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h b/lldb/include/lldb/Symbol/SaveCoreOptions.h index 697549706ed07..5be7b8c45efd5 100644 --- a/lldb/include/lldb/Symbol/SaveCoreOptions.h +++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h @@ -37,7 +37,7 @@ class SaveCoreOptions { const std::optional<lldb_private::FileSpec> GetOutputFile() const; Status SetProcess(lldb::ProcessSP process_sp); - lldb::ProcessSP GetProcess() { return m_process_sp; } + lldb::ProcessSP GetProcess() const { return m_process_sp; } Status AddThread(lldb::ThreadSP thread_sp); bool RemoveThread(lldb::ThreadSP thread_sp); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 38d21241cbea3..e97fdd0e352f2 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -937,7 +937,7 @@ uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP()); } -SBTarget SBDebugger::FindTargetByGloballyUniqueID(lldb::user_id_t id) { +SBTarget SBDebugger::FindTargetByGloballyUniqueID(lldb::user_id_t id) const { LLDB_INSTRUMENT_VA(this, id); SBTarget sb_target; if (m_opaque_sp) { diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index cd25be5d52769..1c0de6aece097 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -160,7 +160,7 @@ int SBMemoryRegionInfo::GetPageSize() { return m_opaque_up->GetPageSize(); } -bool SBMemoryRegionInfo::GetDescription(SBStream &description) { +bool SBMemoryRegionInfo::GetDescription(SBStream &description) const { LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp index 031ba1256d18a..8371106dcbf9e 100644 --- a/lldb/source/API/SBModuleSpec.cpp +++ b/lldb/source/API/SBModuleSpec.cpp @@ -175,7 +175,7 @@ void SBModuleSpec::SetObjectSize(uint64_t object_size) { m_opaque_up->SetObjectSize(object_size); } -SBTarget SBModuleSpec::GetTarget() { +SBTarget SBModuleSpec::GetTarget() const { LLDB_INSTRUMENT_VA(this); return SBTarget(m_opaque_up->GetTargetSP()); diff --git a/lldb/source/API/SBSaveCoreOptions.cpp b/lldb/source/API/SBSaveCoreOptions.cpp index e8b81ee57f5a9..54be64a9cc5a8 100644 --- a/lldb/source/API/SBSaveCoreOptions.cpp +++ b/lldb/source/API/SBSaveCoreOptions.cpp @@ -81,7 +81,7 @@ SBError SBSaveCoreOptions::SetProcess(lldb::SBProcess process) { return m_opaque_up->SetProcess(process.GetSP()); } -SBProcess SBSaveCoreOptions::GetProcess() { +SBProcess SBSaveCoreOptions::GetProcess() const { LLDB_INSTRUMENT_VA(this); return SBProcess(m_opaque_up->GetProcess()); } diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 3030c83292127..73f082ebde6a3 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -202,12 +202,12 @@ SymbolType SBSymbol::GetType() { return eSymbolTypeInvalid; } -uint32_t SBSymbol::GetID() { +uint32_t SBSymbol::GetID() const { LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetID(); - return 0; + return UINT32_MAX; } bool SBSymbol::IsExternal() { @@ -226,7 +226,7 @@ bool SBSymbol::IsSynthetic() { return false; } -bool SBSymbol::IsDebug() { +bool SBSymbol::IsDebug() const { LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 78c2d49d647b5..99dfbb3fd9bce 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1581,7 +1581,7 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { return sb_module; } -SBModule SBTarget::FindModule(const SBModuleSpec &sb_module_spec) { +SBModule SBTarget::FindModule(const SBModuleSpec &sb_module_spec) const { LLDB_INSTRUMENT_VA(this, sb_module_spec); SBModule sb_module; @@ -1624,7 +1624,7 @@ const char *SBTarget::GetTriple() { return nullptr; } -const char *SBTarget::GetArchName() { +const char *SBTarget::GetArchName() const { LLDB_INSTRUMENT_VA(this); if (TargetSP target_sp = GetSP()) { >From a476fee4a0fa595e6995be47012fb19d3c8c424d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Wed, 17 Dec 2025 18:15:33 +0000 Subject: [PATCH 2/2] [lldb] add missed changes --- lldb/include/lldb/API/SBMemoryRegionInfo.h | 2 +- lldb/include/lldb/API/SBSaveCoreOptions.h | 2 +- lldb/include/lldb/API/SBThread.h | 2 +- lldb/source/API/SBMemoryRegionInfo.cpp | 2 +- lldb/source/API/SBSaveCoreOptions.cpp | 2 +- lldb/source/API/SBThread.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h b/lldb/include/lldb/API/SBMemoryRegionInfo.h index 3ff9b6beff20c..dc5aa0858e1e3 100644 --- a/lldb/include/lldb/API/SBMemoryRegionInfo.h +++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h @@ -126,7 +126,7 @@ class LLDB_API SBMemoryRegionInfo { /// /// The description format is: [Hex start - Hex End) with associated /// permissions (RWX) - bool GetDescription(lldb::SBStream &description) const; + bool GetDescription(lldb::SBStream &description); private: friend class SBProcess; diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h b/lldb/include/lldb/API/SBSaveCoreOptions.h index 5f5f99a46f206..de3912d160b52 100644 --- a/lldb/include/lldb/API/SBSaveCoreOptions.h +++ b/lldb/include/lldb/API/SBSaveCoreOptions.h @@ -132,7 +132,7 @@ class LLDB_API SBSaveCoreOptions { /// \returns /// An unsorted copy of all memory regions to save. If no process or style /// is specified an empty collection will be returned. - SBMemoryRegionInfoList GetMemoryRegionsToSave(); + SBMemoryRegionInfoList GetMemoryRegionsToSave() const; /// Get the current total number of bytes the core is expected to have /// excluding the overhead of the core file format. Requires a Process and diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index 639e7a0a1a5c0..97d3b838492fb 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -186,7 +186,7 @@ class LLDB_API SBThread { lldb::SBFrame GetFrameAtIndex(uint32_t idx); - lldb::SBFrameList GetFrames(); + lldb::SBFrameList GetFrames() const; lldb::SBFrame GetSelectedFrame(); diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index 1c0de6aece097..cd25be5d52769 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -160,7 +160,7 @@ int SBMemoryRegionInfo::GetPageSize() { return m_opaque_up->GetPageSize(); } -bool SBMemoryRegionInfo::GetDescription(SBStream &description) const { +bool SBMemoryRegionInfo::GetDescription(SBStream &description) { LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); diff --git a/lldb/source/API/SBSaveCoreOptions.cpp b/lldb/source/API/SBSaveCoreOptions.cpp index 54be64a9cc5a8..83555c82a980f 100644 --- a/lldb/source/API/SBSaveCoreOptions.cpp +++ b/lldb/source/API/SBSaveCoreOptions.cpp @@ -133,7 +133,7 @@ uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) { return *expected_bytes; } -lldb::SBMemoryRegionInfoList SBSaveCoreOptions::GetMemoryRegionsToSave() { +lldb::SBMemoryRegionInfoList SBSaveCoreOptions::GetMemoryRegionsToSave() const { LLDB_INSTRUMENT_VA(this); llvm::Expected<lldb_private::CoreFileMemoryRanges> memory_ranges = m_opaque_up->GetMemoryRegionsToSave(); diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index f32c5c56444cd..e8711791beed8 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -1103,7 +1103,7 @@ SBFrame SBThread::GetFrameAtIndex(uint32_t idx) { return sb_frame; } -lldb::SBFrameList SBThread::GetFrames() { +lldb::SBFrameList SBThread::GetFrames() const { LLDB_INSTRUMENT_VA(this); SBFrameList sb_frame_list; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
