Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 1 | //===-- BreakpointResolverFileRegex.cpp --------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 17 | #include "lldb/Core/SourceManager.h" |
| 18 | #include "lldb/Core/Log.h" |
| 19 | #include "lldb/Core/StreamString.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 20 | #include "lldb/Symbol/CompileUnit.h" |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 21 | #include "lldb/Target/Target.h" |
| 22 | #include "lldb/lldb-private-log.h" |
| 23 | |
| 24 | using namespace lldb; |
| 25 | using namespace lldb_private; |
| 26 | |
| 27 | //---------------------------------------------------------------------- |
| 28 | // BreakpointResolverFileRegex: |
| 29 | //---------------------------------------------------------------------- |
| 30 | BreakpointResolverFileRegex::BreakpointResolverFileRegex |
| 31 | ( |
| 32 | Breakpoint *bkpt, |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 33 | RegularExpression ®ex |
| 34 | ) : |
| 35 | BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 36 | m_regex (regex) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | BreakpointResolverFileRegex::~BreakpointResolverFileRegex () |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | Searcher::CallbackReturn |
| 45 | BreakpointResolverFileRegex::SearchCallback |
| 46 | ( |
| 47 | SearchFilter &filter, |
| 48 | SymbolContext &context, |
| 49 | Address *addr, |
| 50 | bool containing |
| 51 | ) |
| 52 | { |
| 53 | |
| 54 | assert (m_breakpoint != NULL); |
| 55 | if (!context.target_sp) |
| 56 | return eCallbackReturnContinue; |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 57 | |
| 58 | CompileUnit *cu = context.comp_unit; |
| 59 | FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu)); |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 60 | std::vector<uint32_t> line_matches; |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 61 | context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); |
| 62 | |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 63 | uint32_t num_matches = line_matches.size(); |
Andy Gibbs | a297a97 | 2013-06-19 19:04:53 +0000 | [diff] [blame] | 64 | for (uint32_t i = 0; i < num_matches; i++) |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 65 | { |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 66 | SymbolContextList sc_list; |
| 67 | const bool search_inlines = false; |
| 68 | const bool exact = false; |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 69 | |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 70 | cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, exact, eSymbolContextEverything, sc_list); |
| 71 | const bool skip_prologue = true; |
| 72 | |
| 73 | BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText()); |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 74 | } |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 75 | assert (m_breakpoint != NULL); |
| 76 | |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 77 | return Searcher::eCallbackReturnContinue; |
| 78 | } |
| 79 | |
| 80 | Searcher::Depth |
| 81 | BreakpointResolverFileRegex::GetDepth() |
| 82 | { |
| 83 | return Searcher::eDepthCompUnit; |
| 84 | } |
| 85 | |
| 86 | void |
| 87 | BreakpointResolverFileRegex::GetDescription (Stream *s) |
| 88 | { |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 89 | s->Printf ("source regex = \"%s\"", m_regex.GetText()); |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void |
| 93 | BreakpointResolverFileRegex::Dump (Stream *s) const |
| 94 | { |
| 95 | |
| 96 | } |
| 97 | |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame^] | 98 | lldb::BreakpointResolverSP |
| 99 | BreakpointResolverFileRegex::CopyForBreakpoint (Breakpoint &breakpoint) |
| 100 | { |
| 101 | lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(&breakpoint, m_regex)); |
| 102 | return ret_sp; |
| 103 | } |
| 104 | |