Skip to content

Commit 78e09d7

Browse files
committed
Drop const reference so mutations can be pushed back to the user. Run formatter for C++, and Py
1 parent 9d105b2 commit 78e09d7

File tree

13 files changed

+24
-35
lines changed

13 files changed

+24
-35
lines changed

lldb/include/lldb/Core/PluginManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class PluginManager {
194194
GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name);
195195

196196
static Status SaveCore(const lldb::ProcessSP &process_sp,
197-
const lldb_private::SaveCoreOptions &core_options);
197+
lldb_private::SaveCoreOptions &core_options);
198198

199199
// ObjectContainer
200200
static bool RegisterPlugin(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
5757
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
5858
const lldb::ProcessSP &process_sp, lldb::addr_t offset);
5959
typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
60-
const lldb_private::SaveCoreOptions &options,
60+
lldb_private::SaveCoreOptions &options,
6161
Status &error);
6262
typedef EmulateInstruction *(*EmulateInstructionCreateInstance)(
6363
const ArchSpec &arch, InstructionType inst_type);

lldb/source/Core/PluginManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ PluginManager::GetObjectFileCreateMemoryCallbackForPluginName(
702702
}
703703

704704
Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp,
705-
const lldb_private::SaveCoreOptions &options) {
705+
lldb_private::SaveCoreOptions &options) {
706706
Status error;
707707
if (!options.GetOutputFile()) {
708708
error.SetErrorString("No output file specified");

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6351,7 +6351,7 @@ static offset_t
63516351
CreateAllImageInfosPayload(const lldb::ProcessSP &process_sp,
63526352
offset_t initial_file_offset,
63536353
StreamString &all_image_infos_payload,
6354-
const lldb_private::SaveCoreOptions &options) {
6354+
lldb_private::SaveCoreOptions &options) {
63556355
Target &target = process_sp->GetTarget();
63566356
ModuleList modules = target.GetImages();
63576357

@@ -6522,19 +6522,16 @@ struct page_object {
65226522
};
65236523

65246524
bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
6525-
const lldb_private::SaveCoreOptions &options,
6525+
lldb_private::SaveCoreOptions &options,
65266526
Status &error) {
65276527
// The FileSpec and Process are already checked in PluginManager::SaveCore.
65286528
assert(options.GetOutputFile().has_value());
65296529
assert(process_sp);
65306530
const FileSpec outfile = options.GetOutputFile().value();
6531-
6532-
// We have to make a local copy of the options, so that if we default
6533-
// the save core style, we can proprogate that when we pass options
6534-
// to process calculate save core ranges
6535-
lldb_private::SaveCoreOptions core_options = options;
6536-
if (core_options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
6537-
core_options.SetStyle(eSaveCoreDirtyOnly);
6531+
6532+
// MachO defaults to dirty pages
6533+
if (options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
6534+
options.SetStyle(eSaveCoreDirtyOnly);
65386535

65396536
Target &target = process_sp->GetTarget();
65406537
const ArchSpec target_arch = target.GetArchitecture();
@@ -6565,7 +6562,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
65656562

65666563
if (make_core) {
65676564
Process::CoreFileMemoryRanges core_ranges;
6568-
error = process_sp->CalculateCoreFileSaveRanges(core_options, core_ranges);
6565+
error = process_sp->CalculateCoreFileSaveRanges(options, core_ranges);
65696566
if (error.Success()) {
65706567
const uint32_t addr_byte_size = target_arch.GetAddressByteSize();
65716568
const ByteOrder byte_order = target_arch.GetByteOrder();
@@ -6737,7 +6734,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
67376734
StructuredData::ArraySP threads(
67386735
std::make_shared<StructuredData::Array>());
67396736
for (const ThreadSP &thread_sp :
6740-
process_sp->CalculateCoreFileThreadList(core_options)) {
6737+
process_sp->CalculateCoreFileThreadList(options)) {
67416738
StructuredData::DictionarySP thread(
67426739
std::make_shared<StructuredData::Dictionary>());
67436740
thread->AddIntegerItem("thread_id", thread_sp->GetID());
@@ -6760,7 +6757,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
67606757
all_image_infos_lcnote_up->payload_file_offset = file_offset;
67616758
file_offset = CreateAllImageInfosPayload(
67626759
process_sp, file_offset, all_image_infos_lcnote_up->payload,
6763-
core_options);
6760+
options);
67646761
lc_notes.push_back(std::move(all_image_infos_lcnote_up));
67656762

67666763
// Add LC_NOTE load commands

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
6262
lldb_private::ModuleSpecList &specs);
6363

6464
static bool SaveCore(const lldb::ProcessSP &process_sp,
65-
const lldb_private::SaveCoreOptions &options,
65+
lldb_private::SaveCoreOptions &options,
6666
lldb_private::Status &error);
6767

6868
static bool MagicBytesMatch(lldb::DataBufferSP data_sp, lldb::addr_t offset,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class MinidumpFileBuilder {
7676
public:
7777
MinidumpFileBuilder(lldb::FileUP &&core_file,
7878
const lldb::ProcessSP &process_sp,
79-
const lldb_private::SaveCoreOptions &save_core_options)
79+
lldb_private::SaveCoreOptions &save_core_options)
8080
: m_process_sp(process_sp), m_core_file(std::move(core_file)),
8181
m_save_core_options(save_core_options){};
8282

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,15 @@ size_t ObjectFileMinidump::GetModuleSpecifications(
5656
}
5757

5858
bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp,
59-
const lldb_private::SaveCoreOptions &options,
59+
lldb_private::SaveCoreOptions &options,
6060
lldb_private::Status &error) {
6161
// Output file and process_sp are both checked in PluginManager::SaveCore.
6262
assert(options.GetOutputFile().has_value());
6363
assert(process_sp);
6464

65-
// We have to make a local copy of the options, so that if we default
66-
// the save core style, we can proprogate that when we pass options
67-
// to process calculate save core ranges
68-
lldb_private::SaveCoreOptions core_options = options;
6965
// Minidump defaults to stacks only.
70-
if (core_options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
71-
core_options.SetStyle(SaveCoreStyle::eSaveCoreStackOnly);
66+
if (options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
67+
options.SetStyle(SaveCoreStyle::eSaveCoreStackOnly);
7268

7369
llvm::Expected<lldb::FileUP> maybe_core_file = FileSystem::Instance().Open(
7470
options.GetOutputFile().value(),
@@ -78,7 +74,7 @@ bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp,
7874
return false;
7975
}
8076
MinidumpFileBuilder builder(std::move(maybe_core_file.get()), process_sp,
81-
core_options);
77+
options);
8278

8379
Log *log = GetLog(LLDBLog::Object);
8480
error = builder.AddHeaderAndCalculateDirectories();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ObjectFileMinidump : public lldb_private::PluginInterface {
5555

5656
// Saves dump in Minidump file format
5757
static bool SaveCore(const lldb::ProcessSP &process_sp,
58-
const lldb_private::SaveCoreOptions &options,
58+
lldb_private::SaveCoreOptions &options,
5959
lldb_private::Status &error);
6060

6161
private:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
355355
}
356356

357357
bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp,
358-
const lldb_private::SaveCoreOptions &options,
358+
lldb_private::SaveCoreOptions &options,
359359
lldb_private::Status &error) {
360360
// Outfile and process_sp are validated by PluginManager::SaveCore
361361
assert(options.GetOutputFile().has_value());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
8282
lldb_private::ModuleSpecList &specs);
8383

8484
static bool SaveCore(const lldb::ProcessSP &process_sp,
85-
const lldb_private::SaveCoreOptions &options,
85+
lldb_private::SaveCoreOptions &options,
8686
lldb_private::Status &error);
8787

8888
static bool MagicBytesMatch(lldb::DataBufferSP data_sp);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
namespace lldb_private {
2222

2323
bool SaveMiniDump(const lldb::ProcessSP &process_sp,
24-
const SaveCoreOptions &core_options,
25-
lldb_private::Status &error) {
24+
SaveCoreOptions &core_options, lldb_private::Status &error) {
2625
if (!process_sp)
2726
return false;
2827
#ifdef _WIN32

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
namespace lldb_private {
1515

1616
bool SaveMiniDump(const lldb::ProcessSP &process_sp,
17-
const SaveCoreOptions &core_options,
18-
lldb_private::Status &error);
17+
SaveCoreOptions &core_options, lldb_private::Status &error);
1918

2019
} // namespace lldb_private
2120

lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ def test_save_core_default_values_for_style_minidump(self):
103103
core = self.getBuildArtifact("core.dmp")
104104
target = self.dbg.CreateTarget(exe)
105105
target.BreakpointCreateByName("bar")
106-
process = target.LaunchSimple(
107-
None, None, self.get_process_working_directory()
108-
)
106+
process = target.LaunchSimple(None, None, self.get_process_working_directory())
109107
self.assertState(process.GetState(), lldb.eStateStopped)
110108
pid = process.GetProcessID()
111109
options = lldb.SBSaveCoreOptions()

0 commit comments

Comments
 (0)