1 //===-- SBSaveCoreOptions.cpp -----------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBSaveCoreOptions.h"
10 #include "lldb/API/SBMemoryRegionInfo.h"
11 #include "lldb/Host/FileSystem.h"
12 #include "lldb/Symbol/SaveCoreOptions.h"
13 #include "lldb/Utility/Instrumentation.h"
19 SBSaveCoreOptions::SBSaveCoreOptions() {
20 LLDB_INSTRUMENT_VA(this)
22 m_opaque_up
= std::make_unique
<lldb_private::SaveCoreOptions
>();
25 SBSaveCoreOptions::SBSaveCoreOptions(const SBSaveCoreOptions
&rhs
) {
26 LLDB_INSTRUMENT_VA(this, rhs
);
28 m_opaque_up
= clone(rhs
.m_opaque_up
);
31 SBSaveCoreOptions::~SBSaveCoreOptions() = default;
33 const SBSaveCoreOptions
&
34 SBSaveCoreOptions::operator=(const SBSaveCoreOptions
&rhs
) {
35 LLDB_INSTRUMENT_VA(this, rhs
);
38 m_opaque_up
= clone(rhs
.m_opaque_up
);
42 SBError
SBSaveCoreOptions::SetPluginName(const char *name
) {
43 LLDB_INSTRUMENT_VA(this, name
);
44 return SBError(m_opaque_up
->SetPluginName(name
));
47 void SBSaveCoreOptions::SetStyle(lldb::SaveCoreStyle style
) {
48 LLDB_INSTRUMENT_VA(this, style
);
49 m_opaque_up
->SetStyle(style
);
52 void SBSaveCoreOptions::SetOutputFile(lldb::SBFileSpec file_spec
) {
53 LLDB_INSTRUMENT_VA(this, file_spec
);
54 m_opaque_up
->SetOutputFile(file_spec
.ref());
57 const char *SBSaveCoreOptions::GetPluginName() const {
58 LLDB_INSTRUMENT_VA(this);
59 const auto name
= m_opaque_up
->GetPluginName();
62 return lldb_private::ConstString(name
.value()).GetCString();
65 SBFileSpec
SBSaveCoreOptions::GetOutputFile() const {
66 LLDB_INSTRUMENT_VA(this);
67 const auto file_spec
= m_opaque_up
->GetOutputFile();
69 return SBFileSpec(file_spec
.value());
73 lldb::SaveCoreStyle
SBSaveCoreOptions::GetStyle() const {
74 LLDB_INSTRUMENT_VA(this);
75 return m_opaque_up
->GetStyle();
78 SBError
SBSaveCoreOptions::SetProcess(lldb::SBProcess process
) {
79 LLDB_INSTRUMENT_VA(this, process
);
80 return m_opaque_up
->SetProcess(process
.GetSP());
83 SBError
SBSaveCoreOptions::AddThread(lldb::SBThread thread
) {
84 LLDB_INSTRUMENT_VA(this, thread
);
85 return m_opaque_up
->AddThread(thread
.GetSP());
88 bool SBSaveCoreOptions::RemoveThread(lldb::SBThread thread
) {
89 LLDB_INSTRUMENT_VA(this, thread
);
90 return m_opaque_up
->RemoveThread(thread
.GetSP());
94 SBSaveCoreOptions::AddMemoryRegionToSave(const SBMemoryRegionInfo
®ion
) {
95 LLDB_INSTRUMENT_VA(this, region
);
96 // Currently add memory region can't fail, so we always return a success
97 // SBerror, but because these API's live forever, this is the most future
99 m_opaque_up
->AddMemoryRegionToSave(region
.ref());
103 void SBSaveCoreOptions::Clear() {
104 LLDB_INSTRUMENT_VA(this);
105 m_opaque_up
->Clear();
108 lldb_private::SaveCoreOptions
&SBSaveCoreOptions::ref() const {
109 return *m_opaque_up
.get();