Skip to content

Commit 7e31143

Browse files
committed
Run gcf
1 parent 6b40db1 commit 7e31143

File tree

5 files changed

+65
-56
lines changed

5 files changed

+65
-56
lines changed

lldb/include/lldb/Target/CoreFileMemoryRanges.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ struct CoreFileMemoryRange {
3737
}
3838
};
3939

40-
41-
class CoreFileMemoryRanges : public lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t, CoreFileMemoryRange> {
42-
public:
43-
/// Finalize and merge all overlapping ranges in this collection. Ranges
44-
/// will be seperated based on permissions.
45-
Status FinalizeCoreFileSaveRanges();
40+
class CoreFileMemoryRanges
41+
: public lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t,
42+
CoreFileMemoryRange> {
43+
public:
44+
/// Finalize and merge all overlapping ranges in this collection. Ranges
45+
/// will be seperated based on permissions.
46+
Status FinalizeCoreFileSaveRanges();
4647
};
4748
} // namespace lldb_private
4849

lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ class MinidumpFileBuilder {
120120
// trigger a flush.
121121
lldb_private::Status AddData(const void *data, uint64_t size);
122122
// Add MemoryList stream, containing dumps of important memory segments
123-
lldb_private::Status AddMemoryList_64(
124-
std::vector<lldb_private::CoreFileMemoryRange> &ranges);
125-
lldb_private::Status AddMemoryList_32(
126-
std::vector<lldb_private::CoreFileMemoryRange> &ranges);
123+
lldb_private::Status
124+
AddMemoryList_64(std::vector<lldb_private::CoreFileMemoryRange> &ranges);
125+
lldb_private::Status
126+
AddMemoryList_32(std::vector<lldb_private::CoreFileMemoryRange> &ranges);
127127
// Update the thread list on disk with the newly emitted stack RVAs.
128128
lldb_private::Status FixThreadStacks();
129129
lldb_private::Status FlushBufferToDisk();

lldb/source/Target/CoreFileMemoryRanges.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,38 @@ using namespace lldb;
1212
using namespace lldb_private;
1313

1414
Status CoreFileMemoryRanges::FinalizeCoreFileSaveRanges() {
15-
Status error;
16-
std::vector<size_t> indexes_to_remove;
17-
this->Sort();
18-
for (size_t i = this->GetSize() - 1; i > 0; i--) {
19-
auto region = this->GetMutableEntryAtIndex(i);
20-
auto next_region = this->GetMutableEntryAtIndex(i - 1);
21-
if (next_region->GetRangeEnd() >= region->GetRangeBase() &&
22-
region->GetRangeBase() <= next_region->GetRangeEnd() &&
23-
region->data.lldb_permissions == next_region->data.lldb_permissions) {
24-
const addr_t base =
25-
std::min(region->GetRangeBase(), next_region->GetRangeBase());
26-
const addr_t byte_size =
27-
std::max(region->GetRangeEnd(), next_region->GetRangeEnd()) - base;
15+
Status error;
16+
std::vector<size_t> indexes_to_remove;
17+
this->Sort();
18+
for (size_t i = this->GetSize() - 1; i > 0; i--) {
19+
auto region = this->GetMutableEntryAtIndex(i);
20+
auto next_region = this->GetMutableEntryAtIndex(i - 1);
21+
if (next_region->GetRangeEnd() >= region->GetRangeBase() &&
22+
region->GetRangeBase() <= next_region->GetRangeEnd() &&
23+
region->data.lldb_permissions == next_region->data.lldb_permissions) {
24+
const addr_t base =
25+
std::min(region->GetRangeBase(), next_region->GetRangeBase());
26+
const addr_t byte_size =
27+
std::max(region->GetRangeEnd(), next_region->GetRangeEnd()) - base;
2828

29-
next_region->SetRangeBase(base);
30-
next_region->SetByteSize(byte_size);
29+
next_region->SetRangeBase(base);
30+
next_region->SetByteSize(byte_size);
3131

32-
// Because this is a range data vector, the entry has a base as well
33-
// as the data contained in the entry. So we have to update both.
34-
// And llvm::AddressRange isn't mutable so we have to create a new one.
35-
llvm::AddressRange range (base, base + byte_size);
36-
const CoreFileMemoryRange core_range = {range, next_region->data.lldb_permissions};
37-
next_region->data = core_range;
38-
if (!this->Erase(i, i + 1)) {
39-
error = Status::FromErrorString(
40-
"Core file memory ranges mutated outside of "
41-
"CalculateCoreFileSaveRanges");
42-
return error;
43-
}
32+
// Because this is a range data vector, the entry has a base as well
33+
// as the data contained in the entry. So we have to update both.
34+
// And llvm::AddressRange isn't mutable so we have to create a new one.
35+
llvm::AddressRange range(base, base + byte_size);
36+
const CoreFileMemoryRange core_range = {
37+
range, next_region->data.lldb_permissions};
38+
next_region->data = core_range;
39+
if (!this->Erase(i, i + 1)) {
40+
error = Status::FromErrorString(
41+
"Core file memory ranges mutated outside of "
42+
"CalculateCoreFileSaveRanges");
43+
return error;
4444
}
4545
}
46-
47-
return error;
46+
}
47+
48+
return error;
4849
}

lldb/source/Target/Process.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6563,10 +6563,11 @@ static void AddRegion(const MemoryRegionInfo &region, bool try_dirty_pages,
65636563
CreateCoreFileMemoryRange(region));
65646564
}
65656565

6566-
static void SaveOffRegionsWithStackPointers(
6567-
Process &process, const SaveCoreOptions &core_options,
6568-
const MemoryRegionInfos &regions, CoreFileMemoryRanges &ranges,
6569-
std::set<addr_t> &stack_ends) {
6566+
static void SaveOffRegionsWithStackPointers(Process &process,
6567+
const SaveCoreOptions &core_options,
6568+
const MemoryRegionInfos &regions,
6569+
CoreFileMemoryRanges &ranges,
6570+
std::set<addr_t> &stack_ends) {
65706571
const bool try_dirty_pages = true;
65716572

65726573
// Before we take any dump, we want to save off the used portions of the
@@ -6620,9 +6621,10 @@ static void GetCoreFileSaveRangesFull(Process &process,
66206621
// least some dirty pages, as some OS versions don't support reporting what
66216622
// pages are dirty within an memory region. If no memory regions have dirty
66226623
// page information fall back to saving out all ranges with write permissions.
6623-
static void GetCoreFileSaveRangesDirtyOnly(
6624-
Process &process, const MemoryRegionInfos &regions,
6625-
CoreFileMemoryRanges &ranges, std::set<addr_t> &stack_ends) {
6624+
static void GetCoreFileSaveRangesDirtyOnly(Process &process,
6625+
const MemoryRegionInfos &regions,
6626+
CoreFileMemoryRanges &ranges,
6627+
std::set<addr_t> &stack_ends) {
66266628

66276629
// Iterate over the regions and find all dirty pages.
66286630
bool have_dirty_page_info = false;
@@ -6651,9 +6653,10 @@ static void GetCoreFileSaveRangesDirtyOnly(
66516653
// dirty regions as this will make the core file smaller. If the process
66526654
// doesn't support dirty regions, then it will fall back to adding the full
66536655
// stack region.
6654-
static void GetCoreFileSaveRangesStackOnly(
6655-
Process &process, const MemoryRegionInfos &regions,
6656-
CoreFileMemoryRanges &ranges, std::set<addr_t> &stack_ends) {
6656+
static void GetCoreFileSaveRangesStackOnly(Process &process,
6657+
const MemoryRegionInfos &regions,
6658+
CoreFileMemoryRanges &ranges,
6659+
std::set<addr_t> &stack_ends) {
66576660
const bool try_dirty_pages = true;
66586661
// Some platforms support annotating the region information that tell us that
66596662
// it comes from a thread stack. So look for those regions first.
@@ -6666,9 +6669,10 @@ static void GetCoreFileSaveRangesStackOnly(
66666669
}
66676670
}
66686671

6669-
static void GetUserSpecifiedCoreFileSaveRanges(
6670-
Process &process, const MemoryRegionInfos &regions,
6671-
const SaveCoreOptions &options, CoreFileMemoryRanges &ranges) {
6672+
static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
6673+
const MemoryRegionInfos &regions,
6674+
const SaveCoreOptions &options,
6675+
CoreFileMemoryRanges &ranges) {
66726676
const auto &option_ranges = options.GetCoreFileMemoryRanges();
66736677
if (option_ranges.IsEmpty())
66746678
return;

lldb/unittests/Process/Utility/CoreFileMemoryRangesTest.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//===-- CoreFileMemoryRangesTests.cpp ---------------------------------------------===//
1+
//===-- CoreFileMemoryRangesTests.cpp
2+
//---------------------------------------------===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,8 +10,8 @@
910
#include "gmock/gmock.h"
1011
#include "gtest/gtest.h"
1112

12-
#include "lldb/lldb-types.h"
1313
#include "lldb/Target/CoreFileMemoryRanges.h"
14+
#include "lldb/lldb-types.h"
1415

1516
using namespace lldb_private;
1617

@@ -88,7 +89,8 @@ TEST(CoreFileMemoryRangesTest, MapPartialOverlappingRanges) {
8889
const uint32_t permissions = 0x3;
8990
const CoreFileMemoryRange core_range = {range, permissions};
9091
// The range data is Start, Size, While the range is start-end.
91-
CoreFileMemoryRanges::Entry entry = {unique_start, unique_end - unique_start, core_range};
92+
CoreFileMemoryRanges::Entry entry = {unique_start, unique_end - unique_start,
93+
core_range};
9294
ranges.Append(entry);
9395

9496
Status error = ranges.FinalizeCoreFileSaveRanges();
@@ -97,7 +99,8 @@ TEST(CoreFileMemoryRangesTest, MapPartialOverlappingRanges) {
9799
const auto merged_range = ranges.GetEntryAtIndex(0);
98100
ASSERT_TRUE(merged_range);
99101
ASSERT_THAT(start_addr, merged_range->GetRangeBase());
100-
ASSERT_THAT(start_addr + (iterations * increment_addr), merged_range->GetRangeEnd());
102+
ASSERT_THAT(start_addr + (iterations * increment_addr),
103+
merged_range->GetRangeEnd());
101104
const auto unique_range = ranges.GetEntryAtIndex(1);
102105
ASSERT_TRUE(unique_range);
103106
ASSERT_THAT(unique_start, unique_range->GetRangeBase());

0 commit comments

Comments
 (0)