LLDB  mainline
SourceManager.cpp
Go to the documentation of this file.
1 //===-- SourceManager.cpp -------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Core/Address.h"
12 #include "lldb/Core/AddressRange.h"
13 #include "lldb/Core/Debugger.h"
14 #include "lldb/Core/FormatEntity.h"
15 #include "lldb/Core/Highlighter.h"
16 #include "lldb/Core/Module.h"
17 #include "lldb/Core/ModuleList.h"
18 #include "lldb/Host/FileSystem.h"
20 #include "lldb/Symbol/Function.h"
21 #include "lldb/Symbol/LineEntry.h"
24 #include "lldb/Target/Target.h"
30 #include "lldb/Utility/Stream.h"
31 #include "lldb/lldb-enumerations.h"
32 
33 #include "llvm/ADT/Twine.h"
34 
35 #include <memory>
36 #include <utility>
37 
38 #include <cassert>
39 #include <cstdio>
40 
41 namespace lldb_private {
42 class ExecutionContext;
43 }
44 namespace lldb_private {
45 class ValueObject;
46 }
47 
48 using namespace lldb;
49 using namespace lldb_private;
50 
51 static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
52 
53 // SourceManager constructor
54 SourceManager::SourceManager(const TargetSP &target_sp)
55  : m_last_line(0), m_last_count(0), m_default_set(false),
56  m_target_wp(target_sp),
57  m_debugger_wp(target_sp->GetDebugger().shared_from_this()) {}
58 
59 SourceManager::SourceManager(const DebuggerSP &debugger_sp)
60  : m_last_line(0), m_last_count(0), m_default_set(false), m_target_wp(),
61  m_debugger_wp(debugger_sp) {}
62 
63 // Destructor
64 SourceManager::~SourceManager() = default;
65 
66 SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
67  if (!file_spec)
68  return nullptr;
69 
70  DebuggerSP debugger_sp(m_debugger_wp.lock());
71  FileSP file_sp;
72  if (debugger_sp && debugger_sp->GetUseSourceCache())
73  file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
74 
75  TargetSP target_sp(m_target_wp.lock());
76 
77  // It the target source path map has been updated, get this file again so we
78  // can successfully remap the source file
79  if (target_sp && file_sp &&
80  file_sp->GetSourceMapModificationID() !=
81  target_sp->GetSourcePathMap().GetModificationID())
82  file_sp.reset();
83 
84  // Update the file contents if needed if we found a file
85  if (file_sp)
86  file_sp->UpdateIfNeeded();
87 
88  // If file_sp is no good or it points to a non-existent file, reset it.
89  if (!file_sp || !FileSystem::Instance().Exists(file_sp->GetFileSpec())) {
90  if (target_sp)
91  file_sp = std::make_shared<File>(file_spec, target_sp.get());
92  else
93  file_sp = std::make_shared<File>(file_spec, debugger_sp);
94 
95  if (debugger_sp && debugger_sp->GetUseSourceCache())
96  debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
97  }
98  return file_sp;
99 }
100 
101 static bool should_highlight_source(DebuggerSP debugger_sp) {
102  if (!debugger_sp)
103  return false;
104 
105  // We don't use ANSI stop column formatting if the debugger doesn't think it
106  // should be using color.
107  if (!debugger_sp->GetUseColor())
108  return false;
109 
110  return debugger_sp->GetHighlightSource();
111 }
112 
113 static bool should_show_stop_column_with_ansi(DebuggerSP debugger_sp) {
114  // We don't use ANSI stop column formatting if we can't lookup values from
115  // the debugger.
116  if (!debugger_sp)
117  return false;
118 
119  // We don't use ANSI stop column formatting if the debugger doesn't think it
120  // should be using color.
121  if (!debugger_sp->GetUseColor())
122  return false;
123 
124  // We only use ANSI stop column formatting if we're either supposed to show
125  // ANSI where available (which we know we have when we get to this point), or
126  // if we're only supposed to use ANSI.
127  const auto value = debugger_sp->GetStopShowColumn();
128  return ((value == eStopShowColumnAnsiOrCaret) ||
129  (value == eStopShowColumnAnsi));
130 }
131 
132 static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp) {
133  // We don't use text-based stop column formatting if we can't lookup values
134  // from the debugger.
135  if (!debugger_sp)
136  return false;
137 
138  // If we're asked to show the first available of ANSI or caret, then we do
139  // show the caret when ANSI is not available.
140  const auto value = debugger_sp->GetStopShowColumn();
141  if ((value == eStopShowColumnAnsiOrCaret) && !debugger_sp->GetUseColor())
142  return true;
143 
144  // The only other time we use caret is if we're explicitly asked to show
145  // caret.
146  return value == eStopShowColumnCaret;
147 }
148 
149 static bool should_show_stop_line_with_ansi(DebuggerSP debugger_sp) {
150  return debugger_sp && debugger_sp->GetUseColor();
151 }
152 
154  uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column,
155  const char *current_line_cstr, Stream *s,
156  const SymbolContextList *bp_locs) {
157  if (count == 0)
158  return 0;
159 
160  Stream::ByteDelta delta(*s);
161 
162  if (start_line == 0) {
163  if (m_last_line != 0 && m_last_line != UINT32_MAX)
164  start_line = m_last_line + m_last_count;
165  else
166  start_line = 1;
167  }
168 
169  if (!m_default_set) {
170  FileSpec tmp_spec;
171  uint32_t tmp_line;
172  GetDefaultFileAndLine(tmp_spec, tmp_line);
173  }
174 
175  m_last_line = start_line;
176  m_last_count = count;
177 
178  if (FileSP last_file_sp = GetLastFile()) {
179  const uint32_t end_line = start_line + count - 1;
180  for (uint32_t line = start_line; line <= end_line; ++line) {
181  if (!last_file_sp->LineIsValid(line)) {
183  break;
184  }
185 
186  std::string prefix;
187  if (bp_locs) {
188  uint32_t bp_count = bp_locs->NumLineEntriesWithLine(line);
189 
190  if (bp_count > 0)
191  prefix = llvm::formatv("[{0}]", bp_count);
192  else
193  prefix = " ";
194  }
195 
196  char buffer[3];
197  sprintf(buffer, "%2.2s", (line == curr_line) ? current_line_cstr : "");
198  std::string current_line_highlight(buffer);
199 
200  auto debugger_sp = m_debugger_wp.lock();
201  if (should_show_stop_line_with_ansi(debugger_sp)) {
202  current_line_highlight = ansi::FormatAnsiTerminalCodes(
203  (debugger_sp->GetStopShowLineMarkerAnsiPrefix() +
204  current_line_highlight +
205  debugger_sp->GetStopShowLineMarkerAnsiSuffix())
206  .str());
207  }
208 
209  s->Printf("%s%s %-4u\t", prefix.c_str(), current_line_highlight.c_str(),
210  line);
211 
212  // So far we treated column 0 as a special 'no column value', but
213  // DisplaySourceLines starts counting columns from 0 (and no column is
214  // expressed by passing an empty optional).
215  llvm::Optional<size_t> columnToHighlight;
216  if (line == curr_line && column)
217  columnToHighlight = column - 1;
218 
219  size_t this_line_size =
220  last_file_sp->DisplaySourceLines(line, columnToHighlight, 0, 0, s);
221  if (column != 0 && line == curr_line &&
222  should_show_stop_column_with_caret(debugger_sp)) {
223  // Display caret cursor.
224  std::string src_line;
225  last_file_sp->GetLine(line, src_line);
226  s->Printf(" \t");
227  // Insert a space for every non-tab character in the source line.
228  for (size_t i = 0; i + 1 < column && i < src_line.length(); ++i)
229  s->PutChar(src_line[i] == '\t' ? '\t' : ' ');
230  // Now add the caret.
231  s->Printf("^\n");
232  }
233  if (this_line_size == 0) {
235  break;
236  }
237  }
238  }
239  return *delta;
240 }
241 
243  const FileSpec &file_spec, uint32_t line, uint32_t column,
244  uint32_t context_before, uint32_t context_after,
245  const char *current_line_cstr, Stream *s,
246  const SymbolContextList *bp_locs) {
247  FileSP file_sp(GetFile(file_spec));
248 
249  uint32_t start_line;
250  uint32_t count = context_before + context_after + 1;
251  if (line > context_before)
252  start_line = line - context_before;
253  else
254  start_line = 1;
255 
256  FileSP last_file_sp(GetLastFile());
257  if (last_file_sp.get() != file_sp.get()) {
258  if (line == 0)
259  m_last_line = 0;
260  m_last_file_spec = file_spec;
261  }
263  start_line, count, line, column, current_line_cstr, s, bp_locs);
264 }
265 
267  Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs) {
268  // If we get called before anybody has set a default file and line, then try
269  // to figure it out here.
270  FileSP last_file_sp(GetLastFile());
271  const bool have_default_file_line = last_file_sp && m_last_line > 0;
272  if (!m_default_set) {
273  FileSpec tmp_spec;
274  uint32_t tmp_line;
275  GetDefaultFileAndLine(tmp_spec, tmp_line);
276  }
277 
278  if (last_file_sp) {
279  if (m_last_line == UINT32_MAX)
280  return 0;
281 
282  if (reverse && m_last_line == 1)
283  return 0;
284 
285  if (count > 0)
286  m_last_count = count;
287  else if (m_last_count == 0)
288  m_last_count = 10;
289 
290  if (m_last_line > 0) {
291  if (reverse) {
292  // If this is the first time we've done a reverse, then back up one
293  // more time so we end up showing the chunk before the last one we've
294  // shown:
297  else
298  m_last_line = 1;
299  } else if (have_default_file_line)
301  } else
302  m_last_line = 1;
303 
304  const uint32_t column = 0;
306  m_last_line, m_last_count, UINT32_MAX, column, "", s, bp_locs);
307  }
308  return 0;
309 }
310 
312  uint32_t line) {
313  m_default_set = true;
314  FileSP file_sp(GetFile(file_spec));
315 
316  if (file_sp) {
317  m_last_line = line;
318  m_last_file_spec = file_spec;
319  return true;
320  } else {
321  return false;
322  }
323 }
324 
326  if (FileSP last_file_sp = GetLastFile()) {
327  file_spec = m_last_file_spec;
328  line = m_last_line;
329  return true;
330  } else if (!m_default_set) {
331  TargetSP target_sp(m_target_wp.lock());
332 
333  if (target_sp) {
334  // If nobody has set the default file and line then try here. If there's
335  // no executable, then we will try again later when there is one.
336  // Otherwise, if we can't find it we won't look again, somebody will have
337  // to set it (for instance when we stop somewhere...)
338  Module *executable_ptr = target_sp->GetExecutableModulePointer();
339  if (executable_ptr) {
340  SymbolContextList sc_list;
341  ConstString main_name("main");
342 
343  ModuleFunctionSearchOptions function_options;
344  function_options.include_symbols =
345  false; // Force it to be a debug symbol.
346  function_options.include_inlines = true;
347  executable_ptr->FindFunctions(main_name, CompilerDeclContext(),
348  lldb::eFunctionNameTypeBase,
349  function_options, sc_list);
350  size_t num_matches = sc_list.GetSize();
351  for (size_t idx = 0; idx < num_matches; idx++) {
352  SymbolContext sc;
353  sc_list.GetContextAtIndex(idx, sc);
354  if (sc.function) {
355  lldb_private::LineEntry line_entry;
356  if (sc.function->GetAddressRange()
357  .GetBaseAddress()
358  .CalculateSymbolContextLineEntry(line_entry)) {
359  SetDefaultFileAndLine(line_entry.file, line_entry.line);
360  file_spec = m_last_file_spec;
361  line = m_last_line;
362  return true;
363  }
364  }
365  }
366  }
367  }
368  }
369  return false;
370 }
371 
373  RegularExpression &regex,
374  uint32_t start_line,
375  uint32_t end_line,
376  std::vector<uint32_t> &match_lines) {
377  match_lines.clear();
378  FileSP file_sp = GetFile(file_spec);
379  if (!file_sp)
380  return;
381  return file_sp->FindLinesMatchingRegex(regex, start_line, end_line,
382  match_lines);
383 }
384 
386  lldb::DebuggerSP debugger_sp)
387  : m_file_spec_orig(file_spec), m_file_spec(file_spec),
388  m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
389  m_debugger_wp(debugger_sp) {
390  CommonInitializer(file_spec, nullptr);
391 }
392 
393 SourceManager::File::File(const FileSpec &file_spec, Target *target)
394  : m_file_spec_orig(file_spec), m_file_spec(file_spec),
395  m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
396  m_debugger_wp(target ? target->GetDebugger().shared_from_this()
397  : DebuggerSP()) {
398  CommonInitializer(file_spec, target);
399 }
400 
402  Target *target) {
403  if (m_mod_time == llvm::sys::TimePoint<>()) {
404  if (target) {
405  m_source_map_mod_id = target->GetSourcePathMap().GetModificationID();
406 
407  if (!file_spec.GetDirectory() && file_spec.GetFilename()) {
408  // If this is just a file name, lets see if we can find it in the
409  // target:
410  bool check_inlines = false;
411  SymbolContextList sc_list;
412  size_t num_matches =
414  file_spec.GetFilename().AsCString(), 0, check_inlines,
415  SymbolContextItem(eSymbolContextModule |
416  eSymbolContextCompUnit),
417  sc_list);
418  bool got_multiple = false;
419  if (num_matches != 0) {
420  if (num_matches > 1) {
421  SymbolContext sc;
422  CompileUnit *test_cu = nullptr;
423 
424  for (unsigned i = 0; i < num_matches; i++) {
425  sc_list.GetContextAtIndex(i, sc);
426  if (sc.comp_unit) {
427  if (test_cu) {
428  if (test_cu != sc.comp_unit)
429  got_multiple = true;
430  break;
431  } else
432  test_cu = sc.comp_unit;
433  }
434  }
435  }
436  if (!got_multiple) {
437  SymbolContext sc;
438  sc_list.GetContextAtIndex(0, sc);
439  if (sc.comp_unit)
440  m_file_spec = sc.comp_unit->GetPrimaryFile();
441  m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
442  }
443  }
444  }
445  // Try remapping if m_file_spec does not correspond to an existing file.
446  if (!FileSystem::Instance().Exists(m_file_spec)) {
447  // Check target specific source remappings (i.e., the
448  // target.source-map setting), then fall back to the module
449  // specific remapping (i.e., the .dSYM remapping dictionary).
450  auto remapped = target->GetSourcePathMap().FindFile(m_file_spec);
451  if (!remapped) {
452  FileSpec new_spec;
453  if (target->GetImages().FindSourceFile(m_file_spec, new_spec))
454  remapped = new_spec;
455  }
456  if (remapped) {
457  m_file_spec = *remapped;
458  m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
459  }
460  }
461  }
462  }
463 
464  if (m_mod_time != llvm::sys::TimePoint<>())
465  m_data_sp = FileSystem::Instance().CreateDataBuffer(m_file_spec);
466 }
467 
469  if (line == 0)
470  return UINT32_MAX;
471 
472  if (line == 1)
473  return 0;
474 
475  if (CalculateLineOffsets(line)) {
476  if (line < m_offsets.size())
477  return m_offsets[line - 1]; // yes we want "line - 1" in the index
478  }
479  return UINT32_MAX;
480 }
481 
483  CalculateLineOffsets();
484  return m_offsets.size();
485 }
486 
488  if (!LineIsValid(line))
489  return nullptr;
490 
491  size_t line_offset = GetLineOffset(line);
492  if (line_offset < m_data_sp->GetByteSize())
493  return (const char *)m_data_sp->GetBytes() + line_offset;
494  return nullptr;
495 }
496 
498  bool include_newline_chars) {
499  if (!LineIsValid(line))
500  return false;
501 
502  size_t start_offset = GetLineOffset(line);
503  size_t end_offset = GetLineOffset(line + 1);
504  if (end_offset == UINT32_MAX)
505  end_offset = m_data_sp->GetByteSize();
506 
507  if (end_offset > start_offset) {
508  uint32_t length = end_offset - start_offset;
509  if (!include_newline_chars) {
510  const char *line_start =
511  (const char *)m_data_sp->GetBytes() + start_offset;
512  while (length > 0) {
513  const char last_char = line_start[length - 1];
514  if ((last_char == '\r') || (last_char == '\n'))
515  --length;
516  else
517  break;
518  }
519  }
520  return length;
521  }
522  return 0;
523 }
524 
526  if (line == 0)
527  return false;
528 
529  if (CalculateLineOffsets(line))
530  return line < m_offsets.size();
531  return false;
532 }
533 
535  // TODO: use host API to sign up for file modifications to anything in our
536  // source cache and only update when we determine a file has been updated.
537  // For now we check each time we want to display info for the file.
538  auto curr_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
539 
540  if (curr_mod_time != llvm::sys::TimePoint<>() &&
541  m_mod_time != curr_mod_time) {
542  m_mod_time = curr_mod_time;
543  m_data_sp = FileSystem::Instance().CreateDataBuffer(m_file_spec);
544  m_offsets.clear();
545  }
546 }
547 
549  llvm::Optional<size_t> column,
550  uint32_t context_before,
551  uint32_t context_after,
552  Stream *s) {
553  // Nothing to write if there's no stream.
554  if (!s)
555  return 0;
556 
557  // Sanity check m_data_sp before proceeding.
558  if (!m_data_sp)
559  return 0;
560 
561  size_t bytes_written = s->GetWrittenBytes();
562 
563  auto debugger_sp = m_debugger_wp.lock();
564 
565  HighlightStyle style;
566  // Use the default Vim style if source highlighting is enabled.
567  if (should_highlight_source(debugger_sp))
569 
570  // If we should mark the stop column with color codes, then copy the prefix
571  // and suffix to our color style.
572  if (should_show_stop_column_with_ansi(debugger_sp))
573  style.selected.Set(debugger_sp->GetStopShowColumnAnsiPrefix(),
574  debugger_sp->GetStopShowColumnAnsiSuffix());
575 
576  HighlighterManager mgr;
577  std::string path = GetFileSpec().GetPath(/*denormalize*/ false);
578  // FIXME: Find a way to get the definitive language this file was written in
579  // and pass it to the highlighter.
580  const auto &h = mgr.getHighlighterFor(lldb::eLanguageTypeUnknown, path);
581 
582  const uint32_t start_line =
583  line <= context_before ? 1 : line - context_before;
584  const uint32_t start_line_offset = GetLineOffset(start_line);
585  if (start_line_offset != UINT32_MAX) {
586  const uint32_t end_line = line + context_after;
587  uint32_t end_line_offset = GetLineOffset(end_line + 1);
588  if (end_line_offset == UINT32_MAX)
589  end_line_offset = m_data_sp->GetByteSize();
590 
591  assert(start_line_offset <= end_line_offset);
592  if (start_line_offset < end_line_offset) {
593  size_t count = end_line_offset - start_line_offset;
594  const uint8_t *cstr = m_data_sp->GetBytes() + start_line_offset;
595 
596  auto ref = llvm::StringRef(reinterpret_cast<const char *>(cstr), count);
597 
598  h.Highlight(style, ref, column, "", *s);
599 
600  // Ensure we get an end of line character one way or another.
601  if (!is_newline_char(ref.back()))
602  s->EOL();
603  }
604  }
605  return s->GetWrittenBytes() - bytes_written;
606 }
607 
609  RegularExpression &regex, uint32_t start_line, uint32_t end_line,
610  std::vector<uint32_t> &match_lines) {
611  match_lines.clear();
612 
613  if (!LineIsValid(start_line) ||
614  (end_line != UINT32_MAX && !LineIsValid(end_line)))
615  return;
616  if (start_line > end_line)
617  return;
618 
619  for (uint32_t line_no = start_line; line_no < end_line; line_no++) {
620  std::string buffer;
621  if (!GetLine(line_no, buffer))
622  break;
623  if (regex.Execute(buffer)) {
624  match_lines.push_back(line_no);
625  }
626  }
627 }
628 
630  const SourceManager::File &rhs) {
631  if (lhs.m_file_spec != rhs.m_file_spec)
632  return false;
633  return lhs.m_mod_time == rhs.m_mod_time;
634 }
635 
637  line =
638  UINT32_MAX; // TODO: take this line out when we support partial indexing
639  if (line == UINT32_MAX) {
640  // Already done?
641  if (!m_offsets.empty() && m_offsets[0] == UINT32_MAX)
642  return true;
643 
644  if (m_offsets.empty()) {
645  if (m_data_sp.get() == nullptr)
646  return false;
647 
648  const char *start = (char *)m_data_sp->GetBytes();
649  if (start) {
650  const char *end = start + m_data_sp->GetByteSize();
651 
652  // Calculate all line offsets from scratch
653 
654  // Push a 1 at index zero to indicate the file has been completely
655  // indexed.
656  m_offsets.push_back(UINT32_MAX);
657  const char *s;
658  for (s = start; s < end; ++s) {
659  char curr_ch = *s;
660  if (is_newline_char(curr_ch)) {
661  if (s + 1 < end) {
662  char next_ch = s[1];
663  if (is_newline_char(next_ch)) {
664  if (curr_ch != next_ch)
665  ++s;
666  }
667  }
668  m_offsets.push_back(s + 1 - start);
669  }
670  }
671  if (!m_offsets.empty()) {
672  if (m_offsets.back() < size_t(end - start))
673  m_offsets.push_back(end - start);
674  }
675  return true;
676  }
677  } else {
678  // Some lines have been populated, start where we last left off
679  assert("Not implemented yet" && false);
680  }
681 
682  } else {
683  // Calculate all line offsets up to "line"
684  assert("Not implemented yet" && false);
685  }
686  return false;
687 }
688 
690  if (!LineIsValid(line_no))
691  return false;
692 
693  size_t start_offset = GetLineOffset(line_no);
694  size_t end_offset = GetLineOffset(line_no + 1);
695  if (end_offset == UINT32_MAX) {
696  end_offset = m_data_sp->GetByteSize();
697  }
698  buffer.assign((char *)m_data_sp->GetBytes() + start_offset,
699  end_offset - start_offset);
700 
701  return true;
702 }
703 
705  FileSpec file_spec = file_sp->GetFileSpec();
706  FileCache::iterator pos = m_file_cache.find(file_spec);
707  if (pos == m_file_cache.end())
708  m_file_cache[file_spec] = file_sp;
709  else {
710  if (file_sp != pos->second)
711  m_file_cache[file_spec] = file_sp;
712  }
713 }
714 
716  const FileSpec &file_spec) const {
717  FileSP file_sp;
718  FileCache::const_iterator pos = m_file_cache.find(file_spec);
719  if (pos != m_file_cache.end())
720  file_sp = pos->second;
721  return file_sp;
722 }
should_highlight_source
static bool should_highlight_source(DebuggerSP debugger_sp)
Definition: SourceManager.cpp:101
RegularExpression.h
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::SourceManager::File::PeekLineData
const char * PeekLineData(uint32_t line)
Definition: SourceManager.cpp:487
lldb_private::SourceManager::File::FindLinesMatchingRegex
void FindLinesMatchingRegex(RegularExpression &regex, uint32_t start_line, uint32_t end_line, std::vector< uint32_t > &match_lines)
Definition: SourceManager.cpp:608
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
lldb_private::RegularExpression
Definition: RegularExpression.h:18
FileSystem.h
lldb_private::HighlightStyle::MakeVimStyle
static HighlightStyle MakeVimStyle()
Returns a HighlightStyle that is based on vim's default highlight style.
Definition: Highlighter.cpp:56
lldb_private::Module::FindFunctions
void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by name.
CompileUnit.h
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:461
lldb_private::HighlightStyle::ColorStyle::Set
void Set(llvm::StringRef prefix, llvm::StringRef suffix)
Sets the prefix and suffix strings.
Definition: Highlighter.cpp:22
lldb_private::HighlighterManager::getHighlighterFor
const Highlighter & getHighlighterFor(lldb::LanguageType language_type, llvm::StringRef path) const
Queries all known highlighter for one that can highlight some source code.
Definition: Highlighter.cpp:65
lldb_private::SourceManager::File
Definition: SourceManager.h:33
lldb_private::SourceManager::File::m_file_spec
FileSpec m_file_spec
Definition: SourceManager.h:72
Module.h
SourceManager.h
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::SymbolContextList::GetContextAtIndex
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Definition: SymbolContext.cpp:1265
lldb_private::Module
Definition: Module.h:84
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb_private::HighlightStyle::selected
ColorStyle selected
The style for the token which is below the cursor of the user.
Definition: Highlighter.h:52
should_show_stop_column_with_caret
static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp)
Definition: SourceManager.cpp:132
lldb_private::SourceManager::DisplaySourceLinesWithLineNumbers
size_t DisplaySourceLinesWithLineNumbers(const FileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, Stream *s, const SymbolContextList *bp_locs=nullptr)
Definition: SourceManager.cpp:242
lldb_private::SourceManager::File::UpdateIfNeeded
void UpdateIfNeeded()
Definition: SourceManager.cpp:534
lldb_private::Stream
Definition: Stream.h:28
lldb_private::FileSystem
Definition: FileSystem.h:29
lldb_private::ModuleFunctionSearchOptions::include_symbols
bool include_symbols
Include the symbol table.
Definition: Module.h:64
Debugger.h
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:454
lldb_private::SourceManager::File::m_mod_time
llvm::sys::TimePoint m_mod_time
Definition: SourceManager.h:77
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:928
lldb_private::SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile
size_t DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column, const char *current_line_cstr, Stream *s, const SymbolContextList *bp_locs=nullptr)
Definition: SourceManager.cpp:153
lldb_private::SourceManager::File::GetLineOffset
uint32_t GetLineOffset(uint32_t line)
Definition: SourceManager.cpp:468
lldb_private::ModuleFunctionSearchOptions::include_inlines
bool include_inlines
Include inlined functions.
Definition: Module.h:66
lldb_private::CompileUnit
Definition: CompileUnit.h:38
Target.h
lldb::eStopShowColumnCaret
@ eStopShowColumnCaret
Definition: lldb-enumerations.h:503
lldb_private::Address::CalculateSymbolContextLineEntry
bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const
Definition: Address.cpp:890
lldb_private::operator==
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:999
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::SourceManager::SourceFileCache::AddSourceFile
void AddSourceFile(const FileSP &file_sp)
Definition: SourceManager.cpp:704
lldb_private::HighlighterManager
Manages the available highlighters.
Definition: Highlighter.h:136
ModuleList.h
should_show_stop_line_with_ansi
static bool should_show_stop_line_with_ansi(DebuggerSP debugger_sp)
Definition: SourceManager.cpp:149
lldb_private::SourceManager::GetDefaultFileAndLine
bool GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line)
Definition: SourceManager.cpp:325
lldb_private::SourceManager::m_last_count
uint32_t m_last_count
Definition: SourceManager.h:157
lldb_private::Stream::ByteDelta
Definition: Stream.h:43
LineEntry.h
lldb_private::SourceManager::File::File
File(const FileSpec &file_spec, Target *target)
Definition: SourceManager.cpp:393
lldb_private::ModuleList::ResolveSymbolContextForFilePath
uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const
Resolve items in the symbol context for a given file and line. (const char
Definition: ModuleList.cpp:664
lldb_private::SourceManager::File::GetLineLength
uint32_t GetLineLength(uint32_t line, bool include_newline_chars)
Definition: SourceManager.cpp:497
lldb::eStopShowColumnAnsiOrCaret
@ eStopShowColumnAnsiOrCaret
Definition: lldb-enumerations.h:501
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1281
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::FileSystem::CreateDataBuffer
std::shared_ptr< DataBufferLLVM > CreateDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
Create memory buffer from path.
Definition: common/FileSystem.cpp:297
lldb_private::SourceManager::GetFile
FileSP GetFile(const FileSpec &file_spec)
Definition: SourceManager.cpp:66
lldb-enumerations.h
lldb_private::SourceManager::m_last_line
uint32_t m_last_line
Definition: SourceManager.h:156
lldb_private::SourceManager::m_debugger_wp
lldb::DebuggerWP m_debugger_wp
Definition: SourceManager.h:160
Highlighter.h
lldb_private::FileSystem::GetModificationTime
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
Definition: common/FileSystem.cpp:116
lldb_private::CompileUnit::GetPrimaryFile
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
is_newline_char
static bool is_newline_char(char ch)
Definition: SourceManager.cpp:51
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:39
lldb::eStopShowColumnAnsi
@ eStopShowColumnAnsi
Definition: lldb-enumerations.h:502
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::SourceManager::SetDefaultFileAndLine
bool SetDefaultFileAndLine(const FileSpec &file_spec, uint32_t line)
Definition: SourceManager.cpp:311
Address.h
AnsiTerminal.h
lldb_private::SymbolContextList::NumLineEntriesWithLine
uint32_t NumLineEntriesWithLine(uint32_t line) const
Definition: SymbolContext.cpp:1285
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::LineEntry::line
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:62
should_show_stop_column_with_ansi
static bool should_show_stop_column_with_ansi(DebuggerSP debugger_sp)
Definition: SourceManager.cpp:113
lldb_private::PathMappingList::FindFile
llvm::Optional< FileSpec > FindFile(const FileSpec &orig_spec) const
Finds a source file given a file spec using the path remappings.
Definition: PathMappingList.cpp:220
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::SourceManager::m_last_file_spec
FileSpec m_last_file_spec
Definition: SourceManager.h:155
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::SourceManager::GetLastFile
FileSP GetLastFile()
Definition: SourceManager.h:122
lldb_private::SourceManager::m_target_wp
lldb::TargetWP m_target_wp
Definition: SourceManager.h:159
uint32_t
DataBufferLLVM.h
lldb_private::SourceManager::m_default_set
bool m_default_set
Definition: SourceManager.h:158
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::SourceManager::File::GetNumLines
uint32_t GetNumLines()
Definition: SourceManager.cpp:482
lldb_private::HighlightStyle
Represents style that the highlighter should apply to the given source code.
Definition: Highlighter.h:23
lldb_private::PathMappingList::GetModificationID
uint32_t GetModificationID() const
Definition: PathMappingList.h:109
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
FormatEntity.h
Function.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:45
lldb_private::SourceManager::SourceFileCache::FindSourceFile
FileSP FindSourceFile(const FileSpec &file_spec) const
Definition: SourceManager.cpp:715
SymbolContext.h
lldb_private::SourceManager::FileSP
std::shared_ptr< File > FileSP
Definition: SourceManager.h:91
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::SourceManager::FindLinesMatchingRegex
void FindLinesMatchingRegex(FileSpec &file_spec, RegularExpression &regex, uint32_t start_line, uint32_t end_line, std::vector< uint32_t > &match_lines)
Definition: SourceManager.cpp:372
lldb_private::SourceManager::File::GetLine
bool GetLine(uint32_t line_no, std::string &buffer)
Definition: SourceManager.cpp:689
lldb_private::Stream::GetWrittenBytes
size_t GetWrittenBytes() const
Definition: Stream.h:107
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
lldb_private::SourceManager::File::CalculateLineOffsets
bool CalculateLineOffsets(uint32_t line=UINT32_MAX)
Definition: SourceManager.cpp:636
lldb_private::FileSpec::GetDirectory
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:335
ConstString.h
lldb_private::SourceManager::DisplayMoreWithLineNumbers
size_t DisplayMoreWithLineNumbers(Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs=nullptr)
Definition: SourceManager.cpp:266
lldb_private::TargetProperties::GetSourcePathMap
PathMappingList & GetSourcePathMap() const
Definition: Target.cpp:4039
Stream.h
PathMappingList.h
DataBuffer.h
lldb_private::SourceManager::File::DisplaySourceLines
size_t DisplaySourceLines(uint32_t line, llvm::Optional< size_t > column, uint32_t context_before, uint32_t context_after, Stream *s)
Definition: SourceManager.cpp:548
lldb_private::SourceManager::File::CommonInitializer
void CommonInitializer(const FileSpec &file_spec, Target *target)
Definition: SourceManager.cpp:401
AddressRange.h
lldb
Definition: SBAddress.h:15
lldb_private::SourceManager::File::LineIsValid
bool LineIsValid(uint32_t line)
Definition: SourceManager.cpp:525
lldb_private::FileSpec::GetFilename
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:341
lldb_private::LineEntry
Definition: LineEntry.h:20
lldb_private::ansi::FormatAnsiTerminalCodes
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
Definition: AnsiTerminal.h:66
lldb_private::ModuleList::FindSourceFile
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Definition: ModuleList.cpp:558