Skip to content

Commit 21df337

Browse files
committed
Further code review feedback and formatting.
1 parent 06c0538 commit 21df337

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

lldb/include/lldb/API/SBCoreDumpOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class LLDB_API SBCoreDumpOptions {
2222

2323
const SBCoreDumpOptions &operator=(const lldb::SBCoreDumpOptions &rhs);
2424

25-
/// Set the plugin name.
25+
/// Set the plugin name. Supplying null or empty string will reset
26+
/// the option.
2627
///
2728
/// \param plugin Name of the object file plugin.
2829
SBError SetPluginName(const char *plugin);

lldb/include/lldb/Core/PluginManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class PluginManager {
178178

179179
static bool UnregisterPlugin(ObjectFileCreateInstance create_callback);
180180

181-
static bool IsRegisteredPluginName(const char *name);
181+
static bool IsRegisteredObjectFilePluginName(llvm::StringRef name);
182182

183183
static ObjectFileCreateInstance
184184
GetObjectFileCreateCallbackAtIndex(uint32_t idx);

lldb/source/API/SBCoreDumpOptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ lldb_private::CoreDumpOptions &SBCoreDumpOptions::ref() const {
8080
return *m_opaque_up.get();
8181
}
8282

83-
void SBCoreDumpOptions::Clear() {
84-
LLDB_INSTRUMENT_VA(this);
85-
m_opaque_up->Clear();
83+
void SBCoreDumpOptions::Clear() {
84+
LLDB_INSTRUMENT_VA(this);
85+
m_opaque_up->Clear();
8686
}

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {
12561256

12571257
class CommandOptions : public Options {
12581258
public:
1259-
CommandOptions(){};
1259+
CommandOptions() = default;
12601260

12611261
~CommandOptions() override = default;
12621262

lldb/source/Core/PluginManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ static ObjectFileInstances &GetObjectFileInstances() {
640640
return g_instances;
641641
}
642642

643-
bool PluginManager::IsRegisteredPluginName(const char *name) {
644-
if (!name || !name[0])
643+
bool PluginManager::IsRegisteredObjectFilePluginName(llvm::StringRef name) {
644+
if (name.empty())
645645
return false;
646646

647647
const auto &instances = GetObjectFileInstances().GetInstances();

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6524,11 +6524,10 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
65246524
auto core_style = options.GetStyle();
65256525
if (core_style == SaveCoreStyle::eSaveCoreUnspecified)
65266526
core_style = SaveCoreStyle::eSaveCoreDirtyOnly;
6527-
// The FileSpec is already checked in PluginManager::SaveCore.
6527+
// The FileSpec and Process are already checked in PluginManager::SaveCore.
65286528
assert(options.GetOutputFile().has_value());
65296529
const FileSpec outfile = options.GetOutputFile().value();
6530-
if (!process_sp)
6531-
return false;
6530+
assert(process_sp);
65326531

65336532
Target &target = process_sp->GetTarget();
65346533
const ArchSpec target_arch = target.GetArchitecture();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ size_t ObjectFileMinidump::GetModuleSpecifications(
5858
bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp,
5959
const lldb_private::CoreDumpOptions &options,
6060
lldb_private::Status &error) {
61+
// Output file and process_sp are both checked in PluginManager::SaveCore.
6162
assert(options.GetOutputFile().has_value());
62-
if (!process_sp)
63-
return false;
63+
assert(process_sp);
6464

6565
// Minidump defaults to stacks only.
6666
SaveCoreStyle core_style = options.GetStyle();

lldb/source/Symbol/CoreDumpOptions.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ Status CoreDumpOptions::SetPluginName(const char *name) {
1616
Status error;
1717
if (!name || !name[0]) {
1818
m_plugin_name = std::nullopt;
19-
error.SetErrorString("no plugin name specified");
2019
}
2120

22-
if (!PluginManager::IsRegisteredPluginName(name)) {
21+
if (!PluginManager::IsRegisteredObjectFilePluginName(name)) {
2322
error.SetErrorStringWithFormat(
24-
"plugin name '%s' is not a registered plugin", name);
23+
"plugin name '%s' is not a valid ObjectFile plugin name", name);
2524
return error;
2625
}
2726

@@ -38,9 +37,7 @@ std::optional<std::string> CoreDumpOptions::GetPluginName() const {
3837
}
3938

4039
lldb::SaveCoreStyle CoreDumpOptions::GetStyle() const {
41-
if (!m_style.has_value())
42-
return lldb::eSaveCoreUnspecified;
43-
return m_style.value();
40+
return m_style.value_or(lldb::eSaveCoreUnspecified);
4441
}
4542

4643
const std::optional<lldb_private::FileSpec>

lldb/test/API/python_api/sbcoredumpoptions/TestSBCoreDumpOptions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ def test_plugin_name_assignment(self):
1010
"""Test assignment ensuring valid plugin names only."""
1111
options = lldb.SBCoreDumpOptions()
1212
error = options.SetPluginName(None)
13-
self.assertTrue(error.Fail())
13+
self.assertTrue(error.Success())
1414
self.assertEqual(options.GetPluginName(), None)
1515
error = options.SetPluginName("Not a real plugin")
16-
self.assertTrue(error.Fail())
16+
self.assertTrue(error.Success())
1717
self.assertEqual(options.GetPluginName(), None)
1818
error = options.SetPluginName("minidump")
1919
self.assertTrue(error.Success())
2020
self.assertEqual(options.GetPluginName(), "minidump")
21+
error = options.SetPluginName("")
22+
self.assertTrue(error.Success())
23+
self.assertEqual(options.GetPluginName(), None)
2124

2225
def test_default_corestyle_behavior(self):
2326
"""Test that the default core style is unspecified."""

0 commit comments

Comments
 (0)