-
Notifications
You must be signed in to change notification settings - Fork 15.7k
[LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload #98403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4752ada
3acae92
e842579
2673674
92bc0b3
d4d702d
117d71a
06c0538
21df337
b2f6d60
1785ad3
6edb284
1e95cc7
d555d84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| //===-- SBCoreDumpOptions.h -------------------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLDB_API_SBCOREDUMPOPTIONS_H | ||
| #define LLDB_API_SBCOREDUMPOPTIONS_H | ||
|
|
||
| #include "lldb/API/SBDefines.h" | ||
| #include "lldb/Symbol/CoreDumpOptions.h" | ||
|
|
||
| namespace lldb { | ||
|
|
||
| class LLDB_API SBCoreDumpOptions { | ||
| public: | ||
| SBCoreDumpOptions(); | ||
| SBCoreDumpOptions(const lldb::SBCoreDumpOptions &rhs); | ||
| ~SBCoreDumpOptions() = default; | ||
|
|
||
| const SBCoreDumpOptions &operator=(const lldb::SBCoreDumpOptions &rhs); | ||
|
|
||
| /// Set the plugin name. | ||
| /// | ||
| /// \param plugin Name of the object file plugin. | ||
| SBError SetPluginName(const char *plugin); | ||
|
|
||
| /// Get the Core dump plugin name, if set. | ||
| /// | ||
| /// \return The name of the plugin, or null if not set. | ||
| const char *GetPluginName() const; | ||
|
|
||
| /// Set the Core dump style. | ||
| /// | ||
| /// \param style The style of the core dump. | ||
| void SetStyle(lldb::SaveCoreStyle style); | ||
|
|
||
| /// Get the Core dump style, if set. | ||
| /// | ||
| /// \return The core dump style, or undefined if not set. | ||
| lldb::SaveCoreStyle GetStyle() const; | ||
|
|
||
| /// Set the output file path | ||
| /// | ||
| /// \param output_file a | ||
| /// \class SBFileSpec object that describes the output file. | ||
| void SetOutputFile(SBFileSpec output_file); | ||
|
|
||
| /// Get the output file spec | ||
| /// | ||
| /// \return The output file spec. | ||
| SBFileSpec GetOutputFile() const; | ||
|
|
||
| /// Reset all options. | ||
| void Clear(); | ||
|
|
||
| protected: | ||
| friend class SBProcess; | ||
| lldb_private::CoreDumpOptions &ref() const; | ||
|
|
||
| private: | ||
| std::unique_ptr<lldb_private::CoreDumpOptions> m_opaque_up; | ||
| }; // SBCoreDumpOptions | ||
| } // namespace lldb | ||
|
|
||
| #endif // LLDB_API_SBCOREDUMPOPTIONS_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,8 @@ class PluginManager { | |
|
|
||
| static bool UnregisterPlugin(ObjectFileCreateInstance create_callback); | ||
|
|
||
| static bool IsRegisteredPluginName(const char *name); | ||
|
||
|
|
||
| static ObjectFileCreateInstance | ||
| GetObjectFileCreateCallbackAtIndex(uint32_t idx); | ||
|
|
||
|
|
@@ -191,9 +193,7 @@ class PluginManager { | |
| GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name); | ||
|
|
||
| static Status SaveCore(const lldb::ProcessSP &process_sp, | ||
| const FileSpec &outfile, | ||
| lldb::SaveCoreStyle &core_style, | ||
| llvm::StringRef plugin_name); | ||
| const lldb_private::CoreDumpOptions &core_options); | ||
|
|
||
| // ObjectContainer | ||
| static bool RegisterPlugin( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //===-- CoreDumpOptions.h ---------------------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H | ||
| #define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H | ||
|
|
||
| #include "lldb/Utility/FileSpec.h" | ||
| #include "lldb/lldb-forward.h" | ||
| #include "lldb/lldb-types.h" | ||
|
|
||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| namespace lldb_private { | ||
|
|
||
| class CoreDumpOptions { | ||
|
||
| public: | ||
| CoreDumpOptions(){}; | ||
| ~CoreDumpOptions() = default; | ||
|
|
||
| lldb_private::Status SetPluginName(const char *name); | ||
| std::optional<std::string> GetPluginName() const; | ||
|
|
||
| void SetStyle(lldb::SaveCoreStyle style); | ||
| lldb::SaveCoreStyle GetStyle() const; | ||
|
|
||
| void SetOutputFile(lldb_private::FileSpec file); | ||
| const std::optional<lldb_private::FileSpec> GetOutputFile() const; | ||
|
|
||
| void Clear(); | ||
|
|
||
| private: | ||
| std::optional<std::string> m_plugin_name; | ||
| std::optional<lldb_private::FileSpec> m_file; | ||
| std::optional<lldb::SaveCoreStyle> m_style; | ||
| }; | ||
| } // namespace lldb_private | ||
|
|
||
| #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| //===-- SBCoreDumpOptions.cpp -----------------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "lldb/API/SBCoreDumpOptions.h" | ||
| #include "lldb/API/SBError.h" | ||
| #include "lldb/API/SBFileSpec.h" | ||
| #include "lldb/Host/FileSystem.h" | ||
| #include "lldb/Symbol/CoreDumpOptions.h" | ||
| #include "lldb/Utility/Instrumentation.h" | ||
|
|
||
| #include "Utils.h" | ||
|
|
||
| using namespace lldb; | ||
|
|
||
| SBCoreDumpOptions::SBCoreDumpOptions() { | ||
| LLDB_INSTRUMENT_VA(this) | ||
|
|
||
| m_opaque_up = std::make_unique<lldb_private::CoreDumpOptions>(); | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { | ||
| LLDB_INSTRUMENT_VA(this, rhs); | ||
|
|
||
| m_opaque_up = clone(rhs.m_opaque_up); | ||
| } | ||
|
|
||
| const SBCoreDumpOptions & | ||
| SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { | ||
| LLDB_INSTRUMENT_VA(this, rhs); | ||
|
|
||
| if (this != &rhs) | ||
| m_opaque_up = clone(rhs.m_opaque_up); | ||
| return *this; | ||
| } | ||
|
|
||
| SBError SBCoreDumpOptions::SetPluginName(const char *name) { | ||
| lldb_private::Status error = m_opaque_up->SetPluginName(name); | ||
Jlalond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return SBError(error); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::SetStyle(lldb::SaveCoreStyle style) { | ||
| m_opaque_up->SetStyle(style); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::SetOutputFile(lldb::SBFileSpec file_spec) { | ||
| m_opaque_up->SetOutputFile(file_spec.ref()); | ||
| } | ||
|
|
||
| const char *SBCoreDumpOptions::GetPluginName() const { | ||
| const auto name = m_opaque_up->GetPluginName(); | ||
| if (!name) | ||
| return nullptr; | ||
| return lldb_private::ConstString(name.value()).GetCString(); | ||
| } | ||
|
|
||
| SBFileSpec SBCoreDumpOptions::GetOutputFile() const { | ||
| const auto file_spec = m_opaque_up->GetOutputFile(); | ||
| if (file_spec) | ||
| return SBFileSpec(file_spec.value()); | ||
| return SBFileSpec(); | ||
| } | ||
|
|
||
| lldb::SaveCoreStyle SBCoreDumpOptions::GetStyle() const { | ||
| return m_opaque_up->GetStyle(); | ||
| } | ||
|
|
||
| lldb_private::CoreDumpOptions &SBCoreDumpOptions::ref() const { | ||
| return *m_opaque_up.get(); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::Clear() { m_opaque_up->Clear(); } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change the name to
SBSaveCoreOptions?SBCoreDumpOptionsseems like they would be used to dump a core dump to the terminal?