1 //===-- BreakpointResolverFileLine.h ----------------------------*- C++ -*-===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H 10 #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H 11 12 #include "lldb/Breakpoint/BreakpointResolver.h" 13 #include "lldb/Core/SourceLocationSpec.h" 14 #include <optional> 15 16 namespace lldb_private { 17 18 /// \class BreakpointResolverFileLine BreakpointResolverFileLine.h 19 /// "lldb/Breakpoint/BreakpointResolverFileLine.h" This class sets breakpoints 20 /// by file and line. Optionally, it will look for inlined instances of the 21 /// file and line specification. 22 23 class BreakpointResolverFileLine : public BreakpointResolver { 24 public: 25 BreakpointResolverFileLine( 26 const lldb::BreakpointSP &bkpt, lldb::addr_t offset, bool skip_prologue, 27 const SourceLocationSpec &location_spec, 28 std::optional<llvm::StringRef> removed_prefix_opt = std::nullopt); 29 30 static BreakpointResolver * 31 CreateFromStructuredData(const lldb::BreakpointSP &bkpt, 32 const StructuredData::Dictionary &data_dict, 33 Status &error); 34 35 StructuredData::ObjectSP SerializeToStructuredData() override; 36 37 ~BreakpointResolverFileLine() override = default; 38 39 Searcher::CallbackReturn SearchCallback(SearchFilter &filter, 40 SymbolContext &context, 41 Address *addr) override; 42 43 lldb::SearchDepth GetDepth() override; 44 45 void GetDescription(Stream *s) override; 46 47 void Dump(Stream *s) const override; 48 49 /// Methods for support type inquiry through isa, cast, and dyn_cast: classof(const BreakpointResolverFileLine *)50 static inline bool classof(const BreakpointResolverFileLine *) { 51 return true; 52 } classof(const BreakpointResolver * V)53 static inline bool classof(const BreakpointResolver *V) { 54 return V->getResolverID() == BreakpointResolver::FileLineResolver; 55 } 56 57 lldb::BreakpointResolverSP 58 CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; 59 60 protected: 61 void FilterContexts(SymbolContextList &sc_list); 62 void DeduceSourceMapping(SymbolContextList &sc_list); 63 64 friend class Breakpoint; 65 SourceLocationSpec m_location_spec; 66 bool m_skip_prologue; 67 // Any previously removed file path prefix by reverse source mapping. 68 // This is used to auto deduce source map if needed. 69 std::optional<llvm::StringRef> m_removed_prefix_opt; 70 71 private: 72 BreakpointResolverFileLine(const BreakpointResolverFileLine &) = delete; 73 const BreakpointResolverFileLine & 74 operator=(const BreakpointResolverFileLine &) = delete; 75 }; 76 77 } // namespace lldb_private 78 79 #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H 80