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