1969795f1SJim Ingham //===-- BreakpointResolverFileRegex.cpp --------------------------*- C++ -*-===// 2969795f1SJim Ingham // 3969795f1SJim Ingham // The LLVM Compiler Infrastructure 4969795f1SJim Ingham // 5969795f1SJim Ingham // This file is distributed under the University of Illinois Open Source 6969795f1SJim Ingham // License. See LICENSE.TXT for details. 7969795f1SJim Ingham // 8969795f1SJim Ingham //===----------------------------------------------------------------------===// 9969795f1SJim Ingham 10969795f1SJim Ingham #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" 11969795f1SJim Ingham 12969795f1SJim Ingham // C Includes 13969795f1SJim Ingham // C++ Includes 14969795f1SJim Ingham // Other libraries and framework includes 15969795f1SJim Ingham // Project includes 16969795f1SJim Ingham #include "lldb/Breakpoint/BreakpointLocation.h" 17969795f1SJim Ingham #include "lldb/Core/SourceManager.h" 18969795f1SJim Ingham #include "lldb/Core/Log.h" 19969795f1SJim Ingham #include "lldb/Core/StreamString.h" 201f746071SGreg Clayton #include "lldb/Symbol/CompileUnit.h" 21969795f1SJim Ingham #include "lldb/Target/Target.h" 22969795f1SJim Ingham #include "lldb/lldb-private-log.h" 23969795f1SJim Ingham 24969795f1SJim Ingham using namespace lldb; 25969795f1SJim Ingham using namespace lldb_private; 26969795f1SJim Ingham 27969795f1SJim Ingham //---------------------------------------------------------------------- 28969795f1SJim Ingham // BreakpointResolverFileRegex: 29969795f1SJim Ingham //---------------------------------------------------------------------- 30969795f1SJim Ingham BreakpointResolverFileRegex::BreakpointResolverFileRegex 31969795f1SJim Ingham ( 32969795f1SJim Ingham Breakpoint *bkpt, 33969795f1SJim Ingham RegularExpression ®ex 34969795f1SJim Ingham ) : 35969795f1SJim Ingham BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), 36969795f1SJim Ingham m_regex (regex) 37969795f1SJim Ingham { 38969795f1SJim Ingham } 39969795f1SJim Ingham 40969795f1SJim Ingham BreakpointResolverFileRegex::~BreakpointResolverFileRegex () 41969795f1SJim Ingham { 42969795f1SJim Ingham } 43969795f1SJim Ingham 44969795f1SJim Ingham Searcher::CallbackReturn 45969795f1SJim Ingham BreakpointResolverFileRegex::SearchCallback 46969795f1SJim Ingham ( 47969795f1SJim Ingham SearchFilter &filter, 48969795f1SJim Ingham SymbolContext &context, 49969795f1SJim Ingham Address *addr, 50969795f1SJim Ingham bool containing 51969795f1SJim Ingham ) 52969795f1SJim Ingham { 53969795f1SJim Ingham 54969795f1SJim Ingham assert (m_breakpoint != NULL); 55969795f1SJim Ingham if (!context.target_sp) 56969795f1SJim Ingham return eCallbackReturnContinue; 57969795f1SJim Ingham 585160ce5cSGreg Clayton Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); 59969795f1SJim Ingham 60969795f1SJim Ingham CompileUnit *cu = context.comp_unit; 61969795f1SJim Ingham FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu)); 62969795f1SJim Ingham std::vector<uint32_t> line_matches; 63969795f1SJim Ingham context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); 64*f642373cSJim Ingham 65969795f1SJim Ingham uint32_t num_matches = line_matches.size(); 66a297a97eSAndy Gibbs for (uint32_t i = 0; i < num_matches; i++) 67969795f1SJim Ingham { 68*f642373cSJim Ingham SymbolContextList sc_list; 69*f642373cSJim Ingham const bool search_inlines = false; 70*f642373cSJim Ingham const bool exact = false; 71969795f1SJim Ingham 72*f642373cSJim Ingham cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, exact, eSymbolContextEverything, sc_list); 73*f642373cSJim Ingham const bool skip_prologue = true; 74969795f1SJim Ingham 75*f642373cSJim Ingham BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText()); 76969795f1SJim Ingham } 77969795f1SJim Ingham assert (m_breakpoint != NULL); 78969795f1SJim Ingham 79969795f1SJim Ingham return Searcher::eCallbackReturnContinue; 80969795f1SJim Ingham } 81969795f1SJim Ingham 82969795f1SJim Ingham Searcher::Depth 83969795f1SJim Ingham BreakpointResolverFileRegex::GetDepth() 84969795f1SJim Ingham { 85969795f1SJim Ingham return Searcher::eDepthCompUnit; 86969795f1SJim Ingham } 87969795f1SJim Ingham 88969795f1SJim Ingham void 89969795f1SJim Ingham BreakpointResolverFileRegex::GetDescription (Stream *s) 90969795f1SJim Ingham { 9187df91b8SJim Ingham s->Printf ("source regex = \"%s\"", m_regex.GetText()); 92969795f1SJim Ingham } 93969795f1SJim Ingham 94969795f1SJim Ingham void 95969795f1SJim Ingham BreakpointResolverFileRegex::Dump (Stream *s) const 96969795f1SJim Ingham { 97969795f1SJim Ingham 98969795f1SJim Ingham } 99969795f1SJim Ingham 100