diff options
author | Jacob Lalonde <jalalonde@fb.com> | 2024-07-18 17:10:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-18 17:10:15 -0700 |
commit | 4120570dc408a6ccc7133b4bdbaf5cf6c4af9db7 (patch) | |
tree | 5eb2d81a5dac8722296ee3a60ed32386164623d0 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | 996d31c7ba841fdc3bd375f3fed4d8324618425b (diff) | |
download | llvm-4120570dc408a6ccc7133b4bdbaf5cf6c4af9db7.zip llvm-4120570dc408a6ccc7133b4bdbaf5cf6c4af9db7.tar.gz llvm-4120570dc408a6ccc7133b4bdbaf5cf6c4af9db7.tar.bz2 |
[LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (#98403)
This PR adds `SBSaveCoreOptions`, which is a container class for options
when LLDB is taking coredumps. For this first iteration this container
just keeps parity with the extant API of `file, style, plugin`. In the
future this options object can be extended to allow users to take a
subset of their core dumps.
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 8685d5761..50695af 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1273,13 +1273,13 @@ public: switch (short_option) { case 'p': - m_requested_plugin_name = option_arg.str(); + error = m_core_dump_options.SetPluginName(option_arg.data()); break; case 's': - m_requested_save_core_style = + m_core_dump_options.SetStyle( (lldb::SaveCoreStyle)OptionArgParser::ToOptionEnum( option_arg, GetDefinitions()[option_idx].enum_values, - eSaveCoreUnspecified, error); + eSaveCoreUnspecified, error)); break; default: llvm_unreachable("Unimplemented option"); @@ -1289,13 +1289,11 @@ public: } void OptionParsingStarting(ExecutionContext *execution_context) override { - m_requested_save_core_style = eSaveCoreUnspecified; - m_requested_plugin_name.clear(); + m_core_dump_options.Clear(); } // Instance variables to hold the values for command options. - SaveCoreStyle m_requested_save_core_style = eSaveCoreUnspecified; - std::string m_requested_plugin_name; + SaveCoreOptions m_core_dump_options; }; protected: @@ -1305,13 +1303,14 @@ protected: if (command.GetArgumentCount() == 1) { FileSpec output_file(command.GetArgumentAtIndex(0)); FileSystem::Instance().Resolve(output_file); - SaveCoreStyle corefile_style = m_options.m_requested_save_core_style; - Status error = - PluginManager::SaveCore(process_sp, output_file, corefile_style, - m_options.m_requested_plugin_name); + auto &core_dump_options = m_options.m_core_dump_options; + core_dump_options.SetOutputFile(output_file); + Status error = PluginManager::SaveCore(process_sp, core_dump_options); if (error.Success()) { - if (corefile_style == SaveCoreStyle::eSaveCoreDirtyOnly || - corefile_style == SaveCoreStyle::eSaveCoreStackOnly) { + if (core_dump_options.GetStyle() == + SaveCoreStyle::eSaveCoreDirtyOnly || + core_dump_options.GetStyle() == + SaveCoreStyle::eSaveCoreStackOnly) { result.AppendMessageWithFormat( "\nModified-memory or stack-memory only corefile " "created. This corefile may \n" |