Author: Ebuka Ezike
Date: 2025-12-19T10:59:20Z
New Revision: 556eb902ce50fcbc4c41b42358af97cfef160f57

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

LOG: [lldb][API] Make SB-API functions const if possible. (#172687)

Only applied to functions that were added after 22.x tag.

Added: 
    

Modified: 
    lldb/include/lldb/API/SBDebugger.h
    lldb/include/lldb/API/SBModuleSpec.h
    lldb/include/lldb/API/SBSaveCoreOptions.h
    lldb/include/lldb/API/SBSymbol.h
    lldb/include/lldb/API/SBTarget.h
    lldb/include/lldb/API/SBThread.h
    lldb/include/lldb/Symbol/SaveCoreOptions.h
    lldb/source/API/SBDebugger.cpp
    lldb/source/API/SBModuleSpec.cpp
    lldb/source/API/SBSaveCoreOptions.cpp
    lldb/source/API/SBSymbol.cpp
    lldb/source/API/SBTarget.cpp
    lldb/source/API/SBThread.cpp

Removed: 
    


################################################################################
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/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..de3912d160b52 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.
   ///
@@ -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/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/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/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/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..83555c82a980f 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());
 }
@@ -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/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index 3030c83292127..fd68a3820181d 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -202,7 +202,7 @@ SymbolType SBSymbol::GetType() {
   return eSymbolTypeInvalid;
 }
 
-uint32_t SBSymbol::GetID() {
+uint32_t SBSymbol::GetID() const {
   LLDB_INSTRUMENT_VA(this);
 
   if (m_opaque_ptr)
@@ -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()) {

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

Reply via email to