87 FileSpec file_spec = support_file_nsp->GetSpecOnly();
96 if (!debugger_sp || !debugger_sp->GetUseSourceCache()) {
97 LLDB_LOG(log,
"Source file caching disabled: creating new source file: {0}",
100 return std::make_shared<File>(support_file_nsp, target_sp);
101 return std::make_shared<File>(support_file_nsp, debugger_sp);
110 process_sp->GetSourceFileCache().FindSourceFile(file_spec)) {
111 LLDB_LOG(log,
"Found source file in the process cache: {0}", file_spec);
112 if (file_sp->PathRemappingIsStale()) {
113 LLDB_LOG(log,
"Path remapping is stale: removing file from caches: {0}",
118 debugger_sp->GetSourceFileCache().RemoveSourceFile(file_sp);
119 process_sp->GetSourceFileCache().RemoveSourceFile(file_sp);
129 FileSP file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
134 LLDB_LOG(log,
"Found source file in the debugger cache: {0}", file_spec);
137 if (file_sp && file_sp->PathRemappingIsStale()) {
138 LLDB_LOG(log,
"Path remapping is stale: {0}", file_spec);
143 if (file_sp && file_sp->ModificationTimeIsStale()) {
144 LLDB_LOG(log,
"Modification time is stale: {0}", file_spec);
150 file_sp->GetSupportFile()->GetSpecOnly())) {
151 LLDB_LOG(log,
"File doesn't exist on disk: {0}", file_spec);
158 LLDB_LOG(log,
"Creating and caching new source file: {0}", file_spec);
162 file_sp = std::make_shared<File>(support_file_nsp, target_sp);
164 file_sp = std::make_shared<File>(support_file_nsp, debugger_sp);
168 debugger_sp->GetSourceFileCache().AddSourceFile(file_spec, file_sp);
170 process_sp->GetSourceFileCache().AddSourceFile(file_spec, file_sp);
229 uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column,
237 if (start_line == 0) {
251 const uint32_t end_line = start_line + count - 1;
252 for (uint32_t line = start_line; line <= end_line; ++line) {
253 if (!last_file_sp->LineIsValid(line)) {
263 prefix = llvm::formatv(
"[{0}]", bp_count);
269 snprintf(buffer,
sizeof(buffer),
"%2.2s",
270 (line == curr_line) ? current_line_cstr :
"");
271 std::string current_line_highlight(buffer);
276 (debugger_sp->GetStopShowLineMarkerAnsiPrefix() +
277 current_line_highlight +
278 debugger_sp->GetStopShowLineMarkerAnsiSuffix())
282 s->
Printf(
"%s%s %-4u\t", prefix.c_str(), current_line_highlight.c_str(),
288 std::optional<size_t> columnToHighlight;
289 if (line == curr_line && column)
290 columnToHighlight = column - 1;
292 size_t this_line_size = last_file_sp->DisplaySourceLines(
293 line, columnToHighlight, 0, 0, s, language_type);
294 if (column != 0 && line == curr_line &&
297 std::string src_line;
298 last_file_sp->GetLine(line, src_line);
301 for (
size_t i = 0; i + 1 < column && i < src_line.length(); ++i)
302 s->
PutChar(src_line[i] ==
'\t' ?
'\t' :
' ');
306 if (this_line_size == 0) {
313 last_file_sp->GetSupportFile()->GetChecksum();
314 Checksum on_disk_checksum = last_file_sp->GetChecksum();
315 if (line_table_checksum && line_table_checksum != on_disk_checksum)
318 "{0}: source file checksum mismatch between line table "
319 "({1}) and file on disk ({2})",
320 last_file_sp->GetSupportFile()->GetSpecOnly().GetFilename(),
322 std::nullopt, &last_file_sp->GetChecksumWarningOnceFlag());
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *>
Report warning events.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
llvm::StringRef GetFilename() const
Filename string const get accessor.
llvm::StringRef GetDirectory() const
Directory string const get accessor.
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
std::shared_ptr< DataBuffer > CreateDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
Create memory buffer from path.
void Set(llvm::StringRef prefix, llvm::StringRef suffix)
Sets the prefix and suffix strings.
Manages the available highlighters.
const Highlighter & getHighlighterFor(lldb::LanguageType language_type, llvm::StringRef path) const
Queries all known highlighter for one that can highlight some source code.
A class that describes an executable image and its associated object and symbol files.
void FindFunctions(llvm::ArrayRef< LookupInfo > lookup_infos, const CompilerDeclContext &parent_decl_ctx, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by a vector of lookup infos.
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...
lldb::TargetWP m_target_wp
bool ModificationTimeIsStale() const
void CommonInitializerImpl(SupportFileNSP support_file_nsp, lldb::TargetSP target_sp)
llvm::sys::TimePoint m_mod_time
File(SupportFileNSP support_file_nsp, lldb::TargetSP target_sp)
uint32_t GetSourceMapModificationID() const
void FindLinesMatchingRegex(RegularExpression ®ex, uint32_t start_line, uint32_t end_line, std::vector< uint32_t > &match_lines)
void CommonInitializer(SupportFileNSP support_file_nsp, lldb::TargetSP target_sp)
const char * PeekLineData(uint32_t line)
size_t DisplaySourceLines(uint32_t line, std::optional< size_t > column, uint32_t context_before, uint32_t context_after, Stream *s, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown)
bool LineIsValid(uint32_t line)
SupportFileNSP GetSupportFile() const
Checksum m_checksum
Keep track of the on-disk checksum.
bool PathRemappingIsStale() const
uint32_t GetLineLength(uint32_t line, bool include_newline_chars)
bool CalculateLineOffsets(uint32_t line=UINT32_MAX)
lldb::DataBufferSP m_data_sp
SupportFileNSP m_support_file_nsp
The support file.
lldb::DebuggerWP m_debugger_wp
bool GetLine(uint32_t line_no, std::string &buffer)
uint32_t GetLineOffset(uint32_t line)
uint32_t m_source_map_mod_id
void SetSupportFile(SupportFileNSP support_file_nsp)
Set file and update modification time.
void AddSourceFileImpl(const FileSpec &file_spec, FileSP file_sp)
void RemoveSourceFile(const FileSP &file_sp)
FileSP FindSourceFile(const FileSpec &file_spec) const
llvm::sys::RWMutex m_mutex
void Dump(Stream &stream) const
void AddSourceFile(const FileSpec &file_spec, FileSP file_sp)
void FindLinesMatchingRegex(SupportFileNSP support_file_nsp, RegularExpression ®ex, uint32_t start_line, uint32_t end_line, std::vector< uint32_t > &match_lines)
std::shared_ptr< File > FileSP
std::optional< SupportFileAndLine > GetDefaultFileAndLine()
size_t DisplayMoreWithLineNumbers(Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs=nullptr, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown)
bool AtLastLine(bool reverse)
SourceManager(const lldb::DebuggerSP &debugger_sp)
A source manager can be made with a valid Target, in which case it can use the path remappings to fin...
lldb::DebuggerWP m_debugger_wp
FileSP GetFile(SupportFileNSP support_file_nsp)
size_t DisplaySourceLinesWithLineNumbers(SupportFileNSP support_file_nsp, 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, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown)
lldb::TargetWP m_target_wp
bool SetDefaultFileAndLine(SupportFileNSP support_file_nsp, uint32_t line)
SupportFileNSP m_last_support_file_nsp
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, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown)
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
size_t GetWrittenBytes() const
Wraps a FileSpec and an optional Checksum.
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
uint32_t NumLineEntriesWithLine(uint32_t line) const
Defines a symbol context baton that can be handed other debug core functions.
CompileUnit * comp_unit
The CompileUnit for a given query.
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
NonNullSharedPtr< lldb_private::SupportFile > SupportFileNSP
bool operator==(const Address &lhs, const Address &rhs)
std::string toString(FormatterBytecode::OpCodes op)
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
@ eStopShowColumnAnsiOrCaret
std::shared_ptr< lldb_private::Target > TargetSP
Represents style that the highlighter should apply to the given source code.
static HighlightStyle MakeVimStyle()
Returns a HighlightStyle that is based on vim's default highlight style.
ColorStyle selected
The style for the token which is below the cursor of the user.
A line table entry class.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
SupportFileNSP file_sp
The source file, possibly mapped by the target.source-map setting.
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.