-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCor…
…e() 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.
- Loading branch information
Showing
30 changed files
with
412 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,69 @@ | ||
//===-- SBSaveCoreOptions.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_SBSAVECOREOPTIONS_H | ||
#define LLDB_API_SBSAVECOREOPTIONS_H | ||
|
||
#include "lldb/API/SBDefines.h" | ||
#include "lldb/Symbol/SaveCoreOptions.h" | ||
|
||
namespace lldb { | ||
|
||
class LLDB_API SBSaveCoreOptions { | ||
public: | ||
SBSaveCoreOptions(); | ||
SBSaveCoreOptions(const lldb::SBSaveCoreOptions &rhs); | ||
~SBSaveCoreOptions() = default; | ||
|
||
const SBSaveCoreOptions &operator=(const lldb::SBSaveCoreOptions &rhs); | ||
|
||
/// Set the plugin name. Supplying null or empty string will reset | ||
/// the option. | ||
/// | ||
/// \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::SaveCoreOptions &ref() const; | ||
|
||
private: | ||
std::unique_ptr<lldb_private::SaveCoreOptions> m_opaque_up; | ||
}; // SBSaveCoreOptions | ||
} // namespace lldb | ||
|
||
#endif // LLDB_API_SBSAVECOREOPTIONS_H |
This file contains 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 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 @@ | ||
//===-- SaveCoreOptions.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_SaveCoreOPTIONS_H | ||
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H | ||
|
||
#include "lldb/Utility/FileSpec.h" | ||
#include "lldb/lldb-forward.h" | ||
#include "lldb/lldb-types.h" | ||
|
||
#include <optional> | ||
#include <string> | ||
|
||
namespace lldb_private { | ||
|
||
class SaveCoreOptions { | ||
public: | ||
SaveCoreOptions(){}; | ||
~SaveCoreOptions() = 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_SaveCoreOPTIONS_H |
This file contains 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 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 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 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,85 @@ | ||
//===-- SBSaveCoreOptions.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/SBSaveCoreOptions.h" | ||
#include "lldb/API/SBError.h" | ||
#include "lldb/API/SBFileSpec.h" | ||
#include "lldb/Host/FileSystem.h" | ||
#include "lldb/Symbol/SaveCoreOptions.h" | ||
#include "lldb/Utility/Instrumentation.h" | ||
|
||
#include "Utils.h" | ||
|
||
using namespace lldb; | ||
|
||
SBSaveCoreOptions::SBSaveCoreOptions() { | ||
LLDB_INSTRUMENT_VA(this) | ||
|
||
m_opaque_up = std::make_unique<lldb_private::SaveCoreOptions>(); | ||
} | ||
|
||
SBSaveCoreOptions::SBSaveCoreOptions(const SBSaveCoreOptions &rhs) { | ||
LLDB_INSTRUMENT_VA(this, rhs); | ||
|
||
m_opaque_up = clone(rhs.m_opaque_up); | ||
} | ||
|
||
const SBSaveCoreOptions & | ||
SBSaveCoreOptions::operator=(const SBSaveCoreOptions &rhs) { | ||
LLDB_INSTRUMENT_VA(this, rhs); | ||
|
||
if (this != &rhs) | ||
m_opaque_up = clone(rhs.m_opaque_up); | ||
return *this; | ||
} | ||
|
||
SBError SBSaveCoreOptions::SetPluginName(const char *name) { | ||
LLDB_INSTRUMENT_VA(this, name); | ||
lldb_private::Status error = m_opaque_up->SetPluginName(name); | ||
return SBError(error); | ||
} | ||
|
||
void SBSaveCoreOptions::SetStyle(lldb::SaveCoreStyle style) { | ||
LLDB_INSTRUMENT_VA(this, style); | ||
m_opaque_up->SetStyle(style); | ||
} | ||
|
||
void SBSaveCoreOptions::SetOutputFile(lldb::SBFileSpec file_spec) { | ||
LLDB_INSTRUMENT_VA(this, file_spec); | ||
m_opaque_up->SetOutputFile(file_spec.ref()); | ||
} | ||
|
||
const char *SBSaveCoreOptions::GetPluginName() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
const auto name = m_opaque_up->GetPluginName(); | ||
if (!name) | ||
return nullptr; | ||
return lldb_private::ConstString(name.value()).GetCString(); | ||
} | ||
|
||
SBFileSpec SBSaveCoreOptions::GetOutputFile() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
const auto file_spec = m_opaque_up->GetOutputFile(); | ||
if (file_spec) | ||
return SBFileSpec(file_spec.value()); | ||
return SBFileSpec(); | ||
} | ||
|
||
lldb::SaveCoreStyle SBSaveCoreOptions::GetStyle() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
return m_opaque_up->GetStyle(); | ||
} | ||
|
||
void SBSaveCoreOptions::Clear() { | ||
LLDB_INSTRUMENT_VA(this); | ||
m_opaque_up->Clear(); | ||
} | ||
|
||
lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const { | ||
return *m_opaque_up.get(); | ||
} |
Oops, something went wrong.