Skip to content

Commit f4c5cb2

Browse files
DavidSpickettkcloudy0717
authored andcommitted
[lldb] Make sure SBError is valid when SBDebugger::InitializeWithErrorHandling succeeds (llvm#170156)
Fixes llvm#169788 When this function fails to initialise the debugger, it sets the SBError using the returned error from the initialise function. This results in Success being false and isVaid being true. This is expected behaviour. When it does not fail to initialise, it was returning the default constructed SBError which has Success() == true but IsValid == false. IsValid should be true, to show that the success can be trusted. To fix this, construct the SBError using a default constructed Status, which results in Success and IsValid being true.
1 parent e6804ef commit f4c5cb2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lldb/source/API/SBDebugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void SBDebugger::Initialize() {
179179
lldb::SBError SBDebugger::InitializeWithErrorHandling() {
180180
LLDB_INSTRUMENT();
181181

182-
SBError error;
182+
SBError error((Status()));
183183
if (auto e = g_debugger_lifetime->Initialize(
184184
std::make_unique<SystemInitializerFull>())) {
185185
error.SetError(Status::FromError(std::move(e)));

lldb/unittests/DAP/TestBase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void DAPTestBase::TearDown() {
7272

7373
void DAPTestBase::SetUpTestSuite() {
7474
lldb::SBError error = SBDebugger::InitializeWithErrorHandling();
75+
EXPECT_TRUE(error.IsValid());
7576
EXPECT_TRUE(error.Success());
7677
}
7778
void DAPTestBase::TeatUpTestSuite() { SBDebugger::Terminate(); }

0 commit comments

Comments
 (0)