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" |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 22 | |
| 23 | using namespace lldb; |
| 24 | using namespace lldb_private; |
| 25 | |
| 26 | //---------------------------------------------------------------------- |
| 27 | // BreakpointResolverFileRegex: |
| 28 | //---------------------------------------------------------------------- |
| 29 | BreakpointResolverFileRegex::BreakpointResolverFileRegex |
| 30 | ( |
| 31 | Breakpoint *bkpt, |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 32 | RegularExpression ®ex |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 33 | ) : |
| 34 | BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 35 | m_regex (regex) |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 36 | { |
| 37 | } |
| 38 | |
| 39 | BreakpointResolverFileRegex::~BreakpointResolverFileRegex () |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | Searcher::CallbackReturn |
| 44 | BreakpointResolverFileRegex::SearchCallback |
| 45 | ( |
| 46 | SearchFilter &filter, |
| 47 | SymbolContext &context, |
| 48 | Address *addr, |
| 49 | bool containing |
| 50 | ) |
| 51 | { |
| 52 | |
| 53 | assert (m_breakpoint != NULL); |
| 54 | if (!context.target_sp) |
| 55 | return eCallbackReturnContinue; |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 56 | |
| 57 | CompileUnit *cu = context.comp_unit; |
| 58 | FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu)); |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 59 | std::vector<uint32_t> line_matches; |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 60 | context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); |
| 61 | |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 62 | uint32_t num_matches = line_matches.size(); |
Andy Gibbs | a297a97 | 2013-06-19 19:04:53 +0000 | [diff] [blame] | 63 | for (uint32_t i = 0; i < num_matches; i++) |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 64 | { |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 65 | SymbolContextList sc_list; |
| 66 | const bool search_inlines = false; |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 67 | const bool exact = false; |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 68 | |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 69 | cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, exact, eSymbolContextEverything, sc_list); |
Jim Ingham | f642373 | 2013-09-27 01:16:58 +0000 | [diff] [blame] | 70 | const bool skip_prologue = true; |
| 71 | |
| 72 | BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText()); |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 73 | } |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 74 | assert (m_breakpoint != NULL); |
| 75 | |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 76 | return Searcher::eCallbackReturnContinue; |
| 77 | } |
| 78 | |
| 79 | Searcher::Depth |
| 80 | BreakpointResolverFileRegex::GetDepth() |
| 81 | { |
| 82 | return Searcher::eDepthCompUnit; |
| 83 | } |
| 84 | |
| 85 | void |
| 86 | BreakpointResolverFileRegex::GetDescription (Stream *s) |
| 87 | { |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 88 | s->Printf ("source regex = \"%s\"", m_regex.GetText()); |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void |
| 92 | BreakpointResolverFileRegex::Dump (Stream *s) const |
| 93 | { |
| 94 | |
| 95 | } |
| 96 | |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 97 | lldb::BreakpointResolverSP |
| 98 | BreakpointResolverFileRegex::CopyForBreakpoint (Breakpoint &breakpoint) |
| 99 | { |
Vince Harron | a66c695 | 2015-05-15 21:43:26 +0000 | [diff] [blame] | 100 | lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(&breakpoint, m_regex)); |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 101 | return ret_sp; |
| 102 | } |
| 103 | |