[Lldb-commits] [lldb] [LLDB/Coredump] Only take the Pthread from stack start to the stackpointer + red_zone (PR #92002)
via lldb-commits
lldb-commits at lists.llvm.org
Wed May 15 15:11:01 PDT 2024
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 e3ca558ffb1441cb16da7aba021e12c6f110000f 25ff389fd2b1ca5caccfe239d8ab1bd166ee75cb -- lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Target/Process.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 190c7670d1..1f0101bc01 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -491,8 +491,9 @@ findStackHelper(const lldb::ProcessSP &process_sp, uint64_t rsp) {
return llvm::createStringError(
std::errc::not_supported,
"unable to load stack segment of the process");
- // This is a duplicate of the logic in Process::SaveOffRegionsWithStackPointers
- // but ultimately, we need to only save up from the start of `the stack down to the stack pointer.
+ // This is a duplicate of the logic in
+ // Process::SaveOffRegionsWithStackPointers but ultimately, we need to only
+ // save up from the start of `the stack down to the stack pointer.
const addr_t range_end = range_info.GetRange().GetRangeEnd();
const size_t red_zone = process_sp->GetABI()->GetRedZoneSize();
const addr_t addr = rsp - red_zone;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6a3bfe0a6a..216d2f21ab 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6335,16 +6335,15 @@ static void AddRegion(const MemoryRegionInfo ®ion, bool try_dirty_pages,
ranges.push_back(CreateCoreFileMemoryRange(region));
}
-static void
-SaveOffRegionsWithStackPointers(Process &process,
- const MemoryRegionInfos ®ions,
- Process::CoreFileMemoryRanges &ranges,
- std::set<addr_t> &stack_ends) {
+static void SaveOffRegionsWithStackPointers(
+ Process &process, const MemoryRegionInfos ®ions,
+ Process::CoreFileMemoryRanges &ranges, std::set<addr_t> &stack_ends) {
const bool try_dirty_pages = true;
- // Before we take any dump, we want to save off the used portions of the stacks
- // and mark those memory regions as saved. This prevents us from saving the unused portion
- // of the stack below the stack pointer. Saving space on the dump.
+ // Before we take any dump, we want to save off the used portions of the
+ // stacks and mark those memory regions as saved. This prevents us from saving
+ // the unused portion of the stack below the stack pointer. Saving space on
+ // the dump.
for (lldb::ThreadSP thread_sp : process.GetThreadList().Threads()) {
if (!thread_sp)
continue;
@@ -6358,12 +6357,12 @@ SaveOffRegionsWithStackPointers(Process &process,
const size_t red_zone = process.GetABI()->GetRedZoneSize();
lldb_private::MemoryRegionInfo sp_region;
if (process.GetMemoryRegionInfo(sp, sp_region).Success()) {
- const size_t stack_head = (sp - red_zone);
- const size_t stack_size = sp_region.GetRange().GetRangeEnd() - stack_head;
- sp_region.GetRange().SetRangeBase(stack_head);
- sp_region.GetRange().SetByteSize(stack_size);
- stack_ends.insert(sp_region.GetRange().GetRangeEnd());
- AddRegion(sp_region, try_dirty_pages, ranges);
+ const size_t stack_head = (sp - red_zone);
+ const size_t stack_size = sp_region.GetRange().GetRangeEnd() - stack_head;
+ sp_region.GetRange().SetRangeBase(stack_head);
+ sp_region.GetRange().SetByteSize(stack_size);
+ stack_ends.insert(sp_region.GetRange().GetRangeEnd());
+ AddRegion(sp_region, try_dirty_pages, ranges);
}
}
}
@@ -6386,17 +6385,15 @@ const bool try_dirty_pages = false;
// least some dirty pages, as some OS versions don't support reporting what
// pages are dirty within an memory region. If no memory regions have dirty
// page information fall back to saving out all ranges with write permissions.
-static void
-GetCoreFileSaveRangesDirtyOnly(Process &process,
- const MemoryRegionInfos ®ions,
- Process::CoreFileMemoryRanges &ranges,
- std::set<addr_t> &stack_ends) {
+static void GetCoreFileSaveRangesDirtyOnly(
+ Process &process, const MemoryRegionInfos ®ions,
+ Process::CoreFileMemoryRanges &ranges, std::set<addr_t> &stack_ends) {
// Iterate over the regions and find all dirty pages.
bool have_dirty_page_info = false;
for (const auto ®ion : regions) {
- if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0
- && AddDirtyPages(region, ranges))
+ if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0 &&
+ AddDirtyPages(region, ranges))
have_dirty_page_info = true;
}
@@ -6405,8 +6402,8 @@ GetCoreFileSaveRangesDirtyOnly(Process &process,
// plug-in so fall back to any region with write access permissions.
const bool try_dirty_pages = false;
for (const auto ®ion : regions)
- if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0
- && region.GetWritable() == MemoryRegionInfo::eYes)
+ if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0 &&
+ region.GetWritable() == MemoryRegionInfo::eYes)
AddRegion(region, try_dirty_pages, ranges);
}
}
@@ -6419,20 +6416,18 @@ GetCoreFileSaveRangesDirtyOnly(Process &process,
// dirty regions as this will make the core file smaller. If the process
// doesn't support dirty regions, then it will fall back to adding the full
// stack region.
-static void
-GetCoreFileSaveRangesStackOnly(Process &process,
- const MemoryRegionInfos ®ions,
- Process::CoreFileMemoryRanges &ranges,
- std::set<addr_t> &stack_ends) {
+static void GetCoreFileSaveRangesStackOnly(
+ Process &process, const MemoryRegionInfos ®ions,
+ Process::CoreFileMemoryRanges &ranges, std::set<addr_t> &stack_ends) {
const bool try_dirty_pages = true;
// Some platforms support annotating the region information that tell us that
// it comes from a thread stack. So look for those regions first.
for (const auto ®ion : regions) {
// Save all the stack memory ranges not associated with a stack pointer.
- if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0
- && region.IsStackMemory() == MemoryRegionInfo::eYes)
- AddRegion(region, try_dirty_pages, ranges);
+ if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0 &&
+ region.IsStackMemory() == MemoryRegionInfo::eYes)
+ AddRegion(region, try_dirty_pages, ranges);
}
}
@@ -6446,7 +6441,7 @@ Status Process::CalculateCoreFileSaveRanges(lldb::SaveCoreStyle core_style,
return Status("failed to get any valid memory regions from the process");
if (core_style == eSaveCoreUnspecified)
return Status("callers must set the core_style to something other than "
- "eSaveCoreUnspecified");
+ "eSaveCoreUnspecified");
std::set<addr_t> stack_ends;
SaveOffRegionsWithStackPointers(*this, regions, ranges, stack_ends);
``````````
</details>
https://github.com/llvm/llvm-project/pull/92002
More information about the lldb-commits
mailing list