Skip to content

Commit 994e965

Browse files
Jlalondjasonmolenda
authored andcommitted
Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (llvm#106293)
Reverts llvm#105442. Due to `TestSkinnyCoreFailing` and root causing of the failure will likely take longer than EOD. (cherry picked from commit b959532)
1 parent a321a98 commit 994e965

20 files changed

+33
-309
lines changed

lldb/include/lldb/API/SBMemoryRegionInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
120120
private:
121121
friend class SBProcess;
122122
friend class SBMemoryRegionInfoList;
123-
friend class SBSaveCoreOptions;
123+
124124
friend class lldb_private::ScriptInterpreter;
125125

126126
lldb_private::MemoryRegionInfo &ref();

lldb/include/lldb/API/SBSaveCoreOptions.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,6 @@ class LLDB_API SBSaveCoreOptions {
9696
/// True if the thread was removed, false if it was not in the list.
9797
bool RemoveThread(lldb::SBThread thread);
9898

99-
/// Add a memory region to save in the core file.
100-
///
101-
/// \param region
102-
/// The memory region to save.
103-
///
104-
/// \returns
105-
/// An empty SBError upon success, or an error if the region is invalid.
106-
///
107-
/// \note
108-
/// Ranges that overlapped will be unioned into a single region, this also
109-
/// supercedes stack minification. Specifying full regions and a non-custom
110-
/// core style will include the specified regions and union them with all
111-
/// style specific regions.
112-
SBError AddMemoryRegionToSave(const SBMemoryRegionInfo &region);
113-
11499
/// Reset all options.
115100
void Clear();
116101

lldb/include/lldb/Symbol/SaveCoreOptions.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
1111

1212
#include "lldb/Utility/FileSpec.h"
13-
#include "lldb/Utility/RangeMap.h"
13+
#include "lldb/lldb-forward.h"
14+
#include "lldb/lldb-types.h"
1415

1516
#include <optional>
16-
#include <set>
1717
#include <string>
1818
#include <unordered_set>
1919

20-
using MemoryRanges = lldb_private::RangeVector<lldb::addr_t, lldb::addr_t>;
21-
2220
namespace lldb_private {
2321

2422
class SaveCoreOptions {
@@ -40,12 +38,8 @@ class SaveCoreOptions {
4038
Status AddThread(lldb::ThreadSP thread_sp);
4139
bool RemoveThread(lldb::ThreadSP thread_sp);
4240
bool ShouldThreadBeSaved(lldb::tid_t tid) const;
43-
bool HasSpecifiedThreads() const;
4441

4542
Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
46-
const MemoryRanges &GetCoreFileMemoryRanges() const;
47-
48-
void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo &region);
4943

5044
void Clear();
5145

@@ -57,7 +51,6 @@ class SaveCoreOptions {
5751
std::optional<lldb::SaveCoreStyle> m_style;
5852
lldb::ProcessSP m_process_sp;
5953
std::unordered_set<lldb::tid_t> m_threads_to_save;
60-
MemoryRanges m_regions_to_save;
6154
};
6255
} // namespace lldb_private
6356

lldb/include/lldb/Target/Process.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "lldb/Host/ProcessLaunchInfo.h"
3636
#include "lldb/Host/ProcessRunLock.h"
3737
#include "lldb/Symbol/ObjectFile.h"
38-
#include "lldb/Symbol/SaveCoreOptions.h"
3938
#include "lldb/Target/ExecutionContextScope.h"
4039
#include "lldb/Target/InstrumentationRuntime.h"
4140
#include "lldb/Target/Memory.h"
@@ -735,9 +734,7 @@ class Process : public std::enable_shared_from_this<Process>,
735734
}
736735
};
737736

738-
using CoreFileMemoryRanges =
739-
lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t,
740-
CoreFileMemoryRange>;
737+
using CoreFileMemoryRanges = std::vector<CoreFileMemoryRange>;
741738

742739
/// Helper function for Process::SaveCore(...) that calculates the address
743740
/// ranges that should be saved. This allows all core file plug-ins to save

lldb/include/lldb/Utility/RangeMap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ class RangeDataVector {
450450

451451
void Append(const Entry &entry) { m_entries.emplace_back(entry); }
452452

453-
void Append(B &&b, S &&s, T &&t) { m_entries.emplace_back(Entry(b, s, t)); }
454-
455453
bool Erase(uint32_t start, uint32_t end) {
456454
if (start >= end || end > m_entries.size())
457455
return false;

lldb/include/lldb/lldb-enumerations.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,6 @@ enum SaveCoreStyle {
12531253
eSaveCoreFull = 1,
12541254
eSaveCoreDirtyOnly = 2,
12551255
eSaveCoreStackOnly = 3,
1256-
eSaveCoreCustomOnly = 4,
12571256
};
12581257

12591258
/// Events that might happen during a trace session.

lldb/include/lldb/lldb-forward.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ class StackFrameRecognizer;
206206
class StackFrameRecognizerManager;
207207
class StackID;
208208
class Status;
209-
class SaveCoreOptions;
210209
class StopInfo;
211210
class Stoppoint;
212211
class StoppointCallbackContext;

lldb/include/lldb/lldb-private-interfaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLDB_LLDB_PRIVATE_INTERFACES_H
1010
#define LLDB_LLDB_PRIVATE_INTERFACES_H
1111

12+
#include "lldb/Symbol/SaveCoreOptions.h"
1213
#include "lldb/lldb-enumerations.h"
1314
#include "lldb/lldb-forward.h"
1415
#include "lldb/lldb-private-enumerations.h"

lldb/source/API/SBSaveCoreOptions.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "lldb/API/SBSaveCoreOptions.h"
10-
#include "lldb/API/SBMemoryRegionInfo.h"
1110
#include "lldb/Host/FileSystem.h"
1211
#include "lldb/Symbol/SaveCoreOptions.h"
1312
#include "lldb/Utility/Instrumentation.h"
@@ -90,16 +89,6 @@ bool SBSaveCoreOptions::RemoveThread(lldb::SBThread thread) {
9089
return m_opaque_up->RemoveThread(thread.GetSP());
9190
}
9291

93-
lldb::SBError
94-
SBSaveCoreOptions::AddMemoryRegionToSave(const SBMemoryRegionInfo &region) {
95-
LLDB_INSTRUMENT_VA(this, region);
96-
// Currently add memory region can't fail, so we always return a success
97-
// SBerror, but because these API's live forever, this is the most future
98-
// proof thing to do.
99-
m_opaque_up->AddMemoryRegionToSave(region.ref());
100-
return SBError();
101-
}
102-
10392
void SBSaveCoreOptions::Clear() {
10493
LLDB_INSTRUMENT_VA(this);
10594
m_opaque_up->Clear();

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "lldb/Interpreter/OptionArgParser.h"
2626
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
2727
#include "lldb/Interpreter/Options.h"
28-
#include "lldb/Symbol/SaveCoreOptions.h"
2928
#include "lldb/Target/Platform.h"
3029
#include "lldb/Target/Process.h"
3130
#include "lldb/Target/StopInfo.h"

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6605,9 +6605,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
66056605
const uint32_t addr_byte_size = target_arch.GetAddressByteSize();
66066606
const ByteOrder byte_order = target_arch.GetByteOrder();
66076607
std::vector<llvm::MachO::segment_command_64> segment_load_commands;
6608-
for (const auto &core_range_info : core_ranges) {
6609-
// TODO: Refactor RangeDataVector to have a data iterator.
6610-
const auto &core_range = core_range_info.data;
6608+
for (const auto &core_range : core_ranges) {
66116609
uint32_t cmd_type = LC_SEGMENT_64;
66126610
uint32_t segment_size = sizeof(llvm::MachO::segment_command_64);
66136611
if (addr_byte_size == 4) {

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "lldb/Core/Address.h"
1313
#include "lldb/Host/SafeMachO.h"
1414
#include "lldb/Symbol/ObjectFile.h"
15-
#include "lldb/Symbol/SaveCoreOptions.h"
1615
#include "lldb/Utility/FileSpec.h"
1716
#include "lldb/Utility/FileSpecList.h"
1817
#include "lldb/Utility/RangeMap.h"

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -826,32 +826,25 @@ Status MinidumpFileBuilder::AddMemoryList() {
826826
// bytes of the core file. Thread structures in minidump files can only use
827827
// 32 bit memory descriptiors, so we emit them first to ensure the memory is
828828
// in accessible with a 32 bit offset.
829-
std::vector<Process::CoreFileMemoryRange> ranges_32;
830-
std::vector<Process::CoreFileMemoryRange> ranges_64;
829+
Process::CoreFileMemoryRanges ranges_32;
830+
Process::CoreFileMemoryRanges ranges_64;
831831
Process::CoreFileMemoryRanges all_core_memory_ranges;
832832
error = m_process_sp->CalculateCoreFileSaveRanges(m_save_core_options,
833833
all_core_memory_ranges);
834-
835-
std::vector<Process::CoreFileMemoryRange> all_core_memory_vec;
836-
// Extract all the data into just a vector of data. So we can mutate this in
837-
// place.
838-
for (const auto &core_range : all_core_memory_ranges)
839-
all_core_memory_vec.push_back(core_range.data);
840-
841834
if (error.Fail())
842835
return error;
843836

844837
// Start by saving all of the stacks and ensuring they fit under the 32b
845838
// limit.
846839
uint64_t total_size = GetCurrentDataEndOffset();
847-
auto iterator = all_core_memory_vec.begin();
848-
while (iterator != all_core_memory_vec.end()) {
840+
auto iterator = all_core_memory_ranges.begin();
841+
while (iterator != all_core_memory_ranges.end()) {
849842
if (m_saved_stack_ranges.count(iterator->range.start()) > 0) {
850843
// We don't save stacks twice.
851844
ranges_32.push_back(*iterator);
852845
total_size +=
853846
iterator->range.size() + sizeof(llvm::minidump::MemoryDescriptor);
854-
iterator = all_core_memory_vec.erase(iterator);
847+
iterator = all_core_memory_ranges.erase(iterator);
855848
} else {
856849
iterator++;
857850
}
@@ -871,11 +864,11 @@ Status MinidumpFileBuilder::AddMemoryList() {
871864
// Then anything overflow extends into 64b addressable space.
872865
// All core memeroy ranges will either container nothing on stacks only
873866
// or all the memory ranges including stacks
874-
if (!all_core_memory_vec.empty())
875-
total_size += 256 + (all_core_memory_vec.size() *
867+
if (!all_core_memory_ranges.empty())
868+
total_size += 256 + (all_core_memory_ranges.size() *
876869
sizeof(llvm::minidump::MemoryDescriptor_64));
877870

878-
for (const auto &core_range : all_core_memory_vec) {
871+
for (const auto &core_range : all_core_memory_ranges) {
879872
const addr_t range_size = core_range.range.size();
880873
// We don't need to check for stacks here because we already removed them
881874
// from all_core_memory_ranges.
@@ -960,15 +953,15 @@ Status MinidumpFileBuilder::DumpDirectories() const {
960953
}
961954

962955
static uint64_t
963-
GetLargestRangeSize(const std::vector<Process::CoreFileMemoryRange> &ranges) {
956+
GetLargestRangeSize(const Process::CoreFileMemoryRanges &ranges) {
964957
uint64_t max_size = 0;
965958
for (const auto &core_range : ranges)
966959
max_size = std::max(max_size, core_range.range.size());
967960
return max_size;
968961
}
969962

970-
Status MinidumpFileBuilder::AddMemoryList_32(
971-
std::vector<Process::CoreFileMemoryRange> &ranges) {
963+
Status
964+
MinidumpFileBuilder::AddMemoryList_32(Process::CoreFileMemoryRanges &ranges) {
972965
std::vector<MemoryDescriptor> descriptors;
973966
Status error;
974967
if (ranges.size() == 0)
@@ -1042,8 +1035,8 @@ Status MinidumpFileBuilder::AddMemoryList_32(
10421035
return error;
10431036
}
10441037

1045-
Status MinidumpFileBuilder::AddMemoryList_64(
1046-
std::vector<Process::CoreFileMemoryRange> &ranges) {
1038+
Status
1039+
MinidumpFileBuilder::AddMemoryList_64(Process::CoreFileMemoryRanges &ranges) {
10471040
Status error;
10481041
if (ranges.empty())
10491042
return error;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <utility>
2424
#include <variant>
2525

26-
#include "lldb/Symbol/SaveCoreOptions.h"
2726
#include "lldb/Target/Process.h"
2827
#include "lldb/Target/Target.h"
2928
#include "lldb/Utility/DataBufferHeap.h"
@@ -120,10 +119,10 @@ class MinidumpFileBuilder {
120119
// trigger a flush.
121120
lldb_private::Status AddData(const void *data, uint64_t size);
122121
// Add MemoryList stream, containing dumps of important memory segments
123-
lldb_private::Status AddMemoryList_64(
124-
std::vector<lldb_private::Process::CoreFileMemoryRange> &ranges);
125-
lldb_private::Status AddMemoryList_32(
126-
std::vector<lldb_private::Process::CoreFileMemoryRange> &ranges);
122+
lldb_private::Status
123+
AddMemoryList_64(lldb_private::Process::CoreFileMemoryRanges &ranges);
124+
lldb_private::Status
125+
AddMemoryList_32(lldb_private::Process::CoreFileMemoryRanges &ranges);
127126
// Update the thread list on disk with the newly emitted stack RVAs.
128127
lldb_private::Status FixThreadStacks();
129128
lldb_private::Status FlushBufferToDisk();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H
2222

2323
#include "lldb/Symbol/ObjectFile.h"
24-
#include "lldb/Symbol/SaveCoreOptions.h"
2524
#include "lldb/Utility/ArchSpec.h"
2625

2726
class ObjectFileMinidump : public lldb_private::PluginInterface {

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "lldb/Interpreter/OptionValueDictionary.h"
1818
#include "lldb/Interpreter/OptionValueProperties.h"
1919
#include "lldb/Symbol/ObjectFile.h"
20-
#include "lldb/Symbol/SaveCoreOptions.h"
2120
#include "lldb/Target/Process.h"
2221
#include "lldb/Target/SectionLoadList.h"
2322
#include "lldb/Target/Target.h"

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <vector>
1414

1515
#include "lldb/Symbol/ObjectFile.h"
16-
#include "lldb/Symbol/SaveCoreOptions.h"
1716
#include "llvm/Object/COFF.h"
1817

1918
class ObjectFilePECOFF : public lldb_private::ObjectFile {

lldb/source/Symbol/SaveCoreOptions.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,6 @@ bool SaveCoreOptions::ShouldThreadBeSaved(lldb::tid_t tid) const {
102102
return m_threads_to_save.count(tid) > 0;
103103
}
104104

105-
bool SaveCoreOptions::HasSpecifiedThreads() const {
106-
return !m_threads_to_save.empty();
107-
}
108-
109-
void SaveCoreOptions::AddMemoryRegionToSave(
110-
const lldb_private::MemoryRegionInfo &region) {
111-
m_regions_to_save.Insert(region.GetRange(), /*combine=*/true);
112-
}
113-
114-
const MemoryRanges &SaveCoreOptions::GetCoreFileMemoryRanges() const {
115-
return m_regions_to_save;
116-
}
117-
118105
Status SaveCoreOptions::EnsureValidConfiguration(
119106
lldb::ProcessSP process_sp) const {
120107
Status error;
@@ -144,5 +131,4 @@ void SaveCoreOptions::Clear() {
144131
m_style = std::nullopt;
145132
m_threads_to_save.clear();
146133
m_process_sp.reset();
147-
m_regions_to_save.Clear();
148134
}

0 commit comments

Comments
 (0)