-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again. #162370
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 3 commits
ee58ec0
0af04fa
bbfd5f5
13674b3
84d6611
a99811e
113e064
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 @@ | ||
//--------------------------------------------===// | ||
// | ||
// 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 "TestingSupport/SubsystemRAII.h" | ||
#include "TestingSupport/TestUtilities.h" | ||
#include "lldb/API/SBBreakpoint.h" | ||
#include "lldb/API/SBBreakpointLocation.h" | ||
#include "lldb/API/SBDebugger.h" | ||
#include "lldb/API/SBTarget.h" | ||
jimingham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include "gtest/gtest.h" | ||
#include <memory> | ||
#include <mutex> | ||
|
||
using namespace lldb_private; | ||
using namespace lldb; | ||
|
||
class BreakpointClearConditionTest : public ::testing::Test { | ||
public: | ||
void SetUp() override { | ||
m_sb_debugger = SBDebugger::Create(/*source_init_files=*/false); | ||
}; | ||
|
||
void TearDown() override { SBDebugger::Destroy(m_sb_debugger); } | ||
SBDebugger m_sb_debugger; | ||
SubsystemRAII<lldb::SBDebugger> subsystems; | ||
}; | ||
|
||
template <typename T> void test_condition(T sb_object) { | ||
const char *in_cond_str = "Here is a condition"; | ||
sb_object.SetCondition(in_cond_str); | ||
// Make sure we set the condition correctly: | ||
const char *out_cond_str = sb_object.GetCondition(); | ||
EXPECT_STREQ(in_cond_str, out_cond_str); | ||
// Now unset it by passing in nullptr and make sure that works: | ||
const char *empty_tokens[2] = {nullptr, ""}; | ||
for (auto token : empty_tokens) { | ||
sb_object.SetCondition(token); | ||
out_cond_str = sb_object.GetCondition(); | ||
// And make sure an unset condition returns nullptr: | ||
EXPECT_EQ(nullptr, out_cond_str); | ||
} | ||
} | ||
|
||
TEST_F(BreakpointClearConditionTest, BreakpointClearConditionTest) { | ||
// Create target | ||
SBTarget sb_target; | ||
SBError error; | ||
sb_target = | ||
m_sb_debugger.CreateTarget("", "x86_64-apple-macosx-", "remote-macosx", | ||
/*add_dependent=*/false, error); | ||
|
||
EXPECT_EQ(sb_target.IsValid(), true); | ||
|
||
// Create breakpoint | ||
SBBreakpoint sb_breakpoint = sb_target.BreakpointCreateByAddress(0xDEADBEEF); | ||
test_condition(sb_breakpoint); | ||
|
||
// Address breakpoints always have one location, so we can also use this | ||
// to test the location: | ||
SBBreakpointLocation sb_loc = sb_breakpoint.GetLocationAtIndex(0); | ||
EXPECT_EQ(sb_loc.IsValid(), true); | ||
test_condition(sb_loc); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
add_lldb_unittest(LLDBBreakpointTests | ||
add_lldb_unittest(LLDBBreakpointTests | ||
BreakpointIDTest.cpp | ||
WatchpointAlgorithmsTests.cpp | ||
|
||
LINK_COMPONENTS | ||
Support | ||
LINK_LIBS | ||
liblldb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not enforced, as in the test builds and runs successfully where it is... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no problem moving it, but if you were expecting this to have been a real as opposed to a theoretical thing, it isn't... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, if this is a rule, it would be good to have it documented somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you mix static and dynamic libraries that contain the same code, you end up with two copies of the same symbols which leads to various hard-to-debug issues (like having two copies of globals). When you say it "works" you mean you don't notice any of these issues for this particular test, but that doesn't make it any less wrong :-) I like the idea of enforcing this at the CMake layer. I've filed: #162378 |
||
lldbBreakpoint | ||
lldbCore | ||
LLVMTestingSupport | ||
lldbUtilityHelpers | ||
lldbPluginPlatformMacOSX | ||
) |
Uh oh!
There was an error while loading. Please reload this page.