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