[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 8 21:30:41 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


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

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 21861991e760e7e845dc1be5b804c950543d699a 9ff1e92175f90613de6f07dfb4821b8fc0226939 -- lldb/include/lldb/Target/MemoryRegionInfo.h lldb/include/lldb/Target/Process.h lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp lldb/source/Target/Process.cpp lldb/source/Target/TraceDumper.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 335cb64768a6..96811cd93bb2 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -355,12 +355,10 @@ public:
   };
   // This is all the event bits the public process broadcaster broadcasts.
   // The process shadow listener signs up for all these bits...
-  static constexpr int g_all_event_bits = eBroadcastBitStateChanged
-                                        | eBroadcastBitInterrupt
-                                        | eBroadcastBitSTDOUT
-                                        | eBroadcastBitSTDERR
-                                        | eBroadcastBitProfileData
-                                        | eBroadcastBitStructuredData;
+  static constexpr int g_all_event_bits =
+      eBroadcastBitStateChanged | eBroadcastBitInterrupt | eBroadcastBitSTDOUT |
+      eBroadcastBitSTDERR | eBroadcastBitProfileData |
+      eBroadcastBitStructuredData;
 
   enum {
     eBroadcastInternalStateControlStop = (1 << 0),
@@ -706,7 +704,7 @@ public:
   virtual llvm::Expected<bool> SaveCore(llvm::StringRef outfile);
 
   struct CoreFileMemoryRange {
-    llvm::AddressRange range; /// The address range to save into the core file.
+    llvm::AddressRange range;  /// The address range to save into the core file.
     uint32_t lldb_permissions; /// A bit set of lldb::Permissions bits.
 
     bool operator==(const CoreFileMemoryRange &rhs) const {
@@ -735,7 +733,6 @@ public:
                                      CoreFileMemoryRanges &ranges);
 
 protected:
-
   virtual JITLoaderList &GetJITLoaders();
 
 public:
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 4277555e5219..abeb6129e4c4 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6306,14 +6306,13 @@ static void AddRegion(const MemoryRegionInfo &region, bool try_dirty_pages,
 
 // Save all memory regions that are not empty or have at least some permissions
 // for a full core file style.
-static Status
-GetCoreFileSaveRangesFull(Process &process,
-                          const MemoryRegionInfos &regions,
-                          Process::CoreFileMemoryRanges &ranges) {
+static Status GetCoreFileSaveRangesFull(Process &process,
+                                        const MemoryRegionInfos &regions,
+                                        Process::CoreFileMemoryRanges &ranges) {
 
   // Don't add only dirty pages, add full regions.
   const bool try_dirty_pages = false;
-  for (const auto &region: regions)
+  for (const auto &region : regions)
     AddRegion(region, try_dirty_pages, ranges);
   return Status();
 }
@@ -6328,7 +6327,7 @@ GetCoreFileSaveRangesDirtyOnly(Process &process,
                                Process::CoreFileMemoryRanges &ranges) {
   // Iterate over the regions and find all dirty pages.
   bool have_dirty_page_info = false;
-  for (const auto &region: regions) {
+  for (const auto &region : regions) {
     if (AddDirtyPages(region, ranges))
       have_dirty_page_info = true;
   }
@@ -6358,7 +6357,7 @@ GetCoreFileSaveRangesStackOnly(Process &process,
   std::set<addr_t> stack_bases;
 
   const bool try_dirty_pages = true;
-  for (const auto &region: regions) {
+  for (const auto &region : regions) {
     if (region.IsStackMemory() == MemoryRegionInfo::eYes) {
       stack_bases.insert(region.GetRange().GetRangeBase());
       AddRegion(region, try_dirty_pages, ranges);
@@ -6369,9 +6368,9 @@ GetCoreFileSaveRangesStackOnly(Process &process,
   // and add those regions if not already added above
   ThreadList &thread_list = process.GetThreadList();
   const size_t num_threads = thread_list.GetSize();
-  for (size_t idx=0; idx<num_threads; ++idx) {
+  for (size_t idx = 0; idx < num_threads; ++idx) {
     lldb::ThreadSP thread_sp =
-        thread_list.GetThreadAtIndex(idx, /*can_update*/false);
+        thread_list.GetThreadAtIndex(idx, /*can_update*/ false);
     if (!thread_sp)
       continue;
     StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
@@ -6386,7 +6385,7 @@ GetCoreFileSaveRangesStackOnly(Process &process,
       // Only add this region if not already added above. If our stack pointer
       // is pointing off in the weeds, we will want this range.
       if (stack_bases.count(sp_region.GetRange().GetRangeBase()) == 0)
-         AddRegion(sp_region, try_dirty_pages, ranges);
+        AddRegion(sp_region, try_dirty_pages, ranges);
     }
   }
   return Status();

``````````

</details>


https://github.com/llvm/llvm-project/pull/71772


More information about the lldb-commits mailing list