Skip to content

Commit 86f7374

Browse files
committed
Revert "[LLDB][SBSaveCore] Fix bug where default values are not propagated. (#101770)"
This reverts commit 34766d0 which caused a msan failure, see comment #101770 (comment) for details.
1 parent bf540ce commit 86f7374

File tree

13 files changed

+21
-45
lines changed

13 files changed

+21
-45
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-
lldb_private::SaveCoreOptions &core_options);
197+
const 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-
lldb_private::SaveCoreOptions &options,
60+
const 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-
lldb_private::SaveCoreOptions &options) {
705+
const 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: 5 additions & 6 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-
lldb_private::SaveCoreOptions &options) {
6354+
const lldb_private::SaveCoreOptions &options) {
63556355
Target &target = process_sp->GetTarget();
63566356
ModuleList modules = target.GetImages();
63576357

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

65246524
bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
6525-
lldb_private::SaveCoreOptions &options,
6525+
const lldb_private::SaveCoreOptions &options,
65266526
Status &error) {
6527+
auto core_style = options.GetStyle();
6528+
if (core_style == SaveCoreStyle::eSaveCoreUnspecified)
6529+
core_style = SaveCoreStyle::eSaveCoreDirtyOnly;
65276530
// The FileSpec and Process are already checked in PluginManager::SaveCore.
65286531
assert(options.GetOutputFile().has_value());
65296532
assert(process_sp);
65306533
const FileSpec outfile = options.GetOutputFile().value();
65316534

6532-
// MachO defaults to dirty pages
6533-
if (options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
6534-
options.SetStyle(eSaveCoreDirtyOnly);
6535-
65366535
Target &target = process_sp->GetTarget();
65376536
const ArchSpec target_arch = target.GetArchitecture();
65386537
const llvm::Triple &target_triple = target_arch.GetTriple();

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-
lldb_private::SaveCoreOptions &options,
65+
const 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-
lldb_private::SaveCoreOptions &save_core_options)
79+
const 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ size_t ObjectFileMinidump::GetModuleSpecifications(
5656
}
5757

5858
bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp,
59-
lldb_private::SaveCoreOptions &options,
59+
const 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

6565
// Minidump defaults to stacks only.
66-
if (options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified)
67-
options.SetStyle(SaveCoreStyle::eSaveCoreStackOnly);
66+
SaveCoreStyle core_style = options.GetStyle();
67+
if (core_style == SaveCoreStyle::eSaveCoreUnspecified)
68+
core_style = SaveCoreStyle::eSaveCoreStackOnly;
6869

6970
llvm::Expected<lldb::FileUP> maybe_core_file = FileSystem::Instance().Open(
7071
options.GetOutputFile().value(),

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-
lldb_private::SaveCoreOptions &options,
58+
const 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-
lldb_private::SaveCoreOptions &options,
358+
const 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-
lldb_private::SaveCoreOptions &options,
85+
const 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
namespace lldb_private {
2222

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

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

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

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

1920
} // namespace lldb_private
2021

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010

1111

1212
class ProcessSaveCoreTestCase(TestBase):
13-
def validate_core_pid(self, pid, core_path):
14-
target = self.dbg.CreateTarget(None)
15-
process = target.LoadCore(core_path)
16-
return process.GetProcessID() == pid
17-
1813
@skipIfRemote
1914
@skipUnlessWindows
2015
def test_cannot_save_core_unless_process_stopped(self):
@@ -93,24 +88,3 @@ def test_save_core_via_process_plugin(self):
9388
os.unlink(core)
9489
except OSError:
9590
pass
96-
97-
@skipUnlessPlatform(["linux"])
98-
def test_save_core_default_values_for_style_minidump(self):
99-
"""Test we can still save a core for minidump when no
100-
core style is specified."""
101-
self.build()
102-
exe = self.getBuildArtifact("a.out")
103-
core = self.getBuildArtifact("core.dmp")
104-
target = self.dbg.CreateTarget(exe)
105-
target.BreakpointCreateByName("bar")
106-
process = target.LaunchSimple(None, None, self.get_process_working_directory())
107-
self.assertState(process.GetState(), lldb.eStateStopped)
108-
pid = process.GetProcessID()
109-
options = lldb.SBSaveCoreOptions()
110-
minidump_path = core + ".minidump"
111-
options.SetOutputFile(lldb.SBFileSpec(minidump_path))
112-
options.SetPluginName("minidump")
113-
error = process.SaveCore(options)
114-
self.assertSuccess(error, error.GetCString())
115-
self.assertTrue(os.path.isfile(minidump_path))
116-
self.assertTrue(self.validate_core_pid(pid, minidump_path))

0 commit comments

Comments
 (0)