-
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4752ada
Create CoreDumpOption class, and SB equivalent
Jlalond 3acae92
Finish all the plumbing and successfully migrate TestProcessSaveCoreM…
Jlalond e842579
Add descriptions to sbcoredumpoptions methods. Run git-clang-format
Jlalond 2673674
Code review feedback on all API's, fix tests, and remove default beha…
Jlalond 92bc0b3
Code review feedback. Run git-clang-format. Run Python Format
Jlalond d4d702d
Revert TestMinidump.py as it only had a line added, and assign the er…
Jlalond 117d71a
Add omitted test description
Jlalond 06c0538
Have SBProcess savecore always call the method with core dump options…
Jlalond 21df337
Further code review feedback and formatting.
Jlalond b2f6d60
Another round of feedback, remove instrumentation and reorder private…
Jlalond 1785ad3
Add the error string that Greg recommended after I had saved changes …
Jlalond 6edb284
Rename every to SaveCoreOptions, fix null string setting the optional…
Jlalond 1e95cc7
Fix upper case and return error if plugin name returns an error
Jlalond d555d84
Fix test that got accidentally set to error.success()
Jlalond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 Core dump plugin name. | ||
| /// | ||
| /// \param plugin Name of the object file plugin. | ||
| void SetCoreDumpPluginName(const char *plugin); | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Get the Core dump plugin name, if set. | ||
| /// | ||
| /// \return The name of the plugin, or null if not set. | ||
| const char * GetCoreDumpPluginName() const; | ||
|
|
||
| /// Set the Core dump style. | ||
| /// | ||
| /// \param style The style of the core dump. | ||
| void SetCoreDumpStyle(lldb::SaveCoreStyle style); | ||
|
|
||
| /// Get the Core dump style, if set. | ||
| /// | ||
| /// \return The core dump style, or undefined if not set. | ||
| lldb::SaveCoreStyle GetCoreDumpStyle() 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; | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private: | ||
| std::unique_ptr<lldb_private::CoreDumpOptions> m_opaque_up; | ||
| }; // SBCoreDumpOptions | ||
| } // namespace lldb | ||
|
|
||
| #endif // LLDB_API_SBCOREDUMPOPTIONS_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| void SetCoreDumpPluginName(const char * name); | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| std::optional<std::string> GetCoreDumpPluginName() const; | ||
|
|
||
| void SetCoreDumpStyle(lldb::SaveCoreStyle style); | ||
| lldb::SaveCoreStyle GetCoreDumpStyle() 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/SBFileSpec.h" | ||
| #include "lldb/API/SBCoreDumpOptions.h" | ||
| #include "lldb/Host/FileSystem.h" | ||
| #include "lldb/Symbol/CoreDumpOptions.h" | ||
| #include "lldb/Utility/Instrumentation.h" | ||
|
|
||
| #include "Utils.h" | ||
|
|
||
| using namespace lldb; | ||
|
|
||
| SBCoreDumpOptions::SBCoreDumpOptions() { | ||
| 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; | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { | ||
| m_opaque_up->SetCoreDumpPluginName(name); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { | ||
| m_opaque_up->SetCoreDumpStyle(style); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::SetOutputFile(lldb::SBFileSpec &file_spec) { | ||
| m_opaque_up->SetOutputFile(file_spec.ref()); | ||
| } | ||
|
|
||
| const char * | ||
| SBCoreDumpOptions::GetCoreDumpPluginName() const { | ||
| const auto name = m_opaque_up->GetCoreDumpPluginName(); | ||
| 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::GetCoreDumpStyle() const { | ||
| return m_opaque_up->GetCoreDumpStyle(); | ||
| } | ||
|
|
||
| lldb_private::CoreDumpOptions &SBCoreDumpOptions::Ref() const { | ||
| return *m_opaque_up.get(); | ||
| } | ||
|
|
||
| void SBCoreDumpOptions::Clear() { | ||
| m_opaque_up->Clear(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?