blob: 8d68df2929b84e4dbc753b3cf5a64ee06d366637 [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"
16#include "lldb/Symbol/LineTable.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
21//----------------------------------------------------------------------
22// FileLineResolver:
23//----------------------------------------------------------------------
24FileLineResolver::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
37FileLineResolver::~FileLineResolver ()
38{
39}
40
41Searcher::CallbackReturn
42FileLineResolver::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, m_file_spec.GetDirectory()))
53 {
54 uint32_t start_file_idx = 0;
Jim Ingham87df91b2011-09-23 00:54:11 +000055 uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false);
Greg Clayton176761e2011-04-19 04:19:37 +000056 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
Jim Ingham87df91b2011-09-23 00:54:11 +000070 file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1, m_file_spec, false);
Greg Clayton176761e2011-04-19 04:19:37 +000071 }
72 }
73 else
74 {
75 // Match a specific line in a file...
76 }
77 }
78 }
79 }
80 return Searcher::eCallbackReturnContinue;
81}
82
83Searcher::Depth
84FileLineResolver::GetDepth()
85{
86 return Searcher::eDepthCompUnit;
87}
88
89void
90FileLineResolver::GetDescription (Stream *s)
91{
92 s->Printf ("File and line resolver for file: \"%s%s%s\" line: %u",
93 m_file_spec.GetDirectory().GetCString(),
94 m_file_spec.GetDirectory() ? "/" : "",
95 m_file_spec.GetFilename().GetCString(),
96 m_line_number);
97}
98
99void
100FileLineResolver::Clear()
101{
102 m_file_spec.Clear();
103 m_line_number = UINT32_MAX;
104 m_sc_list.Clear();
105 m_inlines = true;
106}
107
108void
109FileLineResolver::Reset (const FileSpec &file_spec,
110 uint32_t line,
111 bool check_inlines)
112{
113 m_file_spec = file_spec;
114 m_line_number = line;
115 m_sc_list.Clear();
116 m_inlines = check_inlines;
117}
118