1 //===-- FileLineResolver.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/Core/FileLineResolver.h" 11 12 // Project includes 13 #include "lldb/Core/Log.h" 14 #include "lldb/Core/StreamString.h" 15 #include "lldb/Symbol/CompileUnit.h" 16 #include "lldb/Symbol/LineTable.h" 17 18 using namespace lldb; 19 using namespace lldb_private; 20 21 //---------------------------------------------------------------------- 22 // FileLineResolver: 23 //---------------------------------------------------------------------- 24 FileLineResolver::FileLineResolver 25 ( 26 const FileSpec &file_spec, 27 uint32_t line_no, 28 bool check_inlines 29 ) : 30 Searcher (), 31 m_file_spec (file_spec), 32 m_line_number (line_no), 33 m_inlines (check_inlines) 34 { 35 } 36 37 FileLineResolver::~FileLineResolver () 38 { 39 } 40 41 Searcher::CallbackReturn 42 FileLineResolver::SearchCallback 43 ( 44 SearchFilter &filter, 45 SymbolContext &context, 46 Address *addr, 47 bool containing 48 ) 49 { 50 CompileUnit *cu = context.comp_unit; 51 52 if (m_inlines || m_file_spec.Compare(*cu, m_file_spec, (bool)m_file_spec.GetDirectory())) 53 { 54 uint32_t start_file_idx = 0; 55 uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false); 56 if (file_idx != UINT32_MAX) 57 { 58 LineTable *line_table = cu->GetLineTable(); 59 if (line_table) 60 { 61 if (m_line_number == 0) 62 { 63 // Match all lines in a file... 64 const bool append = true; 65 while (file_idx != UINT32_MAX) 66 { 67 line_table->FineLineEntriesForFileIndex (file_idx, append, m_sc_list); 68 // Get the next file index in case we have multiple file 69 // entries for the same file 70 file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1, m_file_spec, false); 71 } 72 } 73 else 74 { 75 // Match a specific line in a file... 76 } 77 } 78 } 79 } 80 return Searcher::eCallbackReturnContinue; 81 } 82 83 Searcher::Depth 84 FileLineResolver::GetDepth() 85 { 86 return Searcher::eDepthCompUnit; 87 } 88 89 void 90 FileLineResolver::GetDescription (Stream *s) 91 { 92 s->Printf ("File and line resolver for file: \"%s\" line: %u", 93 m_file_spec.GetPath().c_str(), 94 m_line_number); 95 } 96 97 void 98 FileLineResolver::Clear() 99 { 100 m_file_spec.Clear(); 101 m_line_number = UINT32_MAX; 102 m_sc_list.Clear(); 103 m_inlines = true; 104 } 105 106 void 107 FileLineResolver::Reset (const FileSpec &file_spec, 108 uint32_t line, 109 bool check_inlines) 110 { 111 m_file_spec = file_spec; 112 m_line_number = line; 113 m_sc_list.Clear(); 114 m_inlines = check_inlines; 115 } 116 117