brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 993f7f9 Raw
70 lines · cpp
1//===----------------------------------------------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8// Use the umbrella header for -Wdocumentation.9#include "lldb/API/LLDB.h"10 11#include "TestingSupport/SubsystemRAII.h"12#include "lldb/API/SBBreakpoint.h"13#include "lldb/API/SBBreakpointLocation.h"14#include "lldb/API/SBDebugger.h"15#include "lldb/API/SBTarget.h"16#include "gtest/gtest.h"17#include <memory>18#include <mutex>19 20using namespace lldb_private;21using namespace lldb;22 23class BreakpointClearConditionTest : public ::testing::Test {24public:25  void SetUp() override {26    m_sb_debugger = SBDebugger::Create(/*source_init_files=*/false);27  };28 29  void TearDown() override { SBDebugger::Destroy(m_sb_debugger); }30  SBDebugger m_sb_debugger;31  SubsystemRAII<lldb::SBDebugger> subsystems;32};33 34template <typename T> void test_condition(T sb_object) {35  const char *in_cond_str = "Here is a condition";36  sb_object.SetCondition(in_cond_str);37  // Make sure we set the condition correctly:38  const char *out_cond_str = sb_object.GetCondition();39  EXPECT_STREQ(in_cond_str, out_cond_str);40  // Now unset it by passing in nullptr and make sure that works:41  const char *empty_tokens[2] = {nullptr, ""};42  for (auto token : empty_tokens) {43    sb_object.SetCondition(token);44    out_cond_str = sb_object.GetCondition();45    // And make sure an unset condition returns nullptr:46    EXPECT_EQ(nullptr, out_cond_str);47  }48}49 50TEST_F(BreakpointClearConditionTest, BreakpointClearConditionTest) {51  // Create target52  SBTarget sb_target;53  SBError error;54  sb_target =55      m_sb_debugger.CreateTarget("", "x86_64-apple-macosx-", "remote-macosx",56                                 /*add_dependent=*/false, error);57 58  EXPECT_EQ(sb_target.IsValid(), true);59 60  // Create breakpoint61  SBBreakpoint sb_breakpoint = sb_target.BreakpointCreateByAddress(0xDEADBEEF);62  test_condition(sb_breakpoint);63 64  // Address breakpoints always have one location, so we can also use this65  // to test the location:66  SBBreakpointLocation sb_loc = sb_breakpoint.GetLocationAtIndex(0);67  EXPECT_EQ(sb_loc.IsValid(), true);68  test_condition(sb_loc);69}70