forked from OSchip/llvm-project
[lldb] Add new LLDB setting: use-source-cache
Summary: LLDB memory-maps large source files, and at the same time, caches all source files in the Source Cache. On Windows, memory-mapped source files are not writeable, causing bad user experience in IDEs (such as errors when saving edited files). IDEs should have the ability to disable the Source Cache at LLDB startup, so that users can edit source files while debugging. Bug: llvm.org/PR45310 Reviewers: labath, JDevlieghere, jingham Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76804
This commit is contained in:
parent
9cd9f3f1b8
commit
acae69d08c
|
@ -199,6 +199,10 @@ public:
|
||||||
|
|
||||||
bool GetUseColor() const;
|
bool GetUseColor() const;
|
||||||
|
|
||||||
|
bool SetUseSourceCache(bool use_source_cache);
|
||||||
|
|
||||||
|
bool GetUseSourceCache() const;
|
||||||
|
|
||||||
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
|
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
|
||||||
|
|
||||||
static bool SetDefaultArchitecture(const char *arch_name);
|
static bool SetDefaultArchitecture(const char *arch_name);
|
||||||
|
|
|
@ -273,6 +273,10 @@ public:
|
||||||
|
|
||||||
bool SetUseColor(bool use_color);
|
bool SetUseColor(bool use_color);
|
||||||
|
|
||||||
|
bool GetUseSourceCache() const;
|
||||||
|
|
||||||
|
bool SetUseSourceCache(bool use_source_cache);
|
||||||
|
|
||||||
bool GetHighlightSource() const;
|
bool GetHighlightSource() const;
|
||||||
|
|
||||||
lldb::StopShowColumn GetStopShowColumn() const;
|
lldb::StopShowColumn GetStopShowColumn() const;
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
void AddSourceFile(const FileSP &file_sp);
|
void AddSourceFile(const FileSP &file_sp);
|
||||||
FileSP FindSourceFile(const FileSpec &file_spec) const;
|
FileSP FindSourceFile(const FileSpec &file_spec) const;
|
||||||
|
|
||||||
|
// Removes all elements from the cache.
|
||||||
|
void Clear() { m_file_cache.clear(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::map<FileSpec, FileSP> FileCache;
|
typedef std::map<FileSpec, FileSP> FileCache;
|
||||||
FileCache m_file_cache;
|
FileCache m_file_cache;
|
||||||
|
|
|
@ -1374,6 +1374,18 @@ bool SBDebugger::GetUseColor() const {
|
||||||
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
|
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SBDebugger::SetUseSourceCache(bool value) {
|
||||||
|
LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value);
|
||||||
|
|
||||||
|
return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SBDebugger::GetUseSourceCache() const {
|
||||||
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache);
|
||||||
|
|
||||||
|
return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
|
||||||
|
}
|
||||||
|
|
||||||
bool SBDebugger::GetDescription(SBStream &description) {
|
bool SBDebugger::GetDescription(SBStream &description) {
|
||||||
LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
|
LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
|
||||||
description);
|
description);
|
||||||
|
|
|
@ -103,6 +103,10 @@ let Definition = "debugger" in {
|
||||||
Global,
|
Global,
|
||||||
DefaultTrue,
|
DefaultTrue,
|
||||||
Desc<"Whether to use Ansi color codes or not.">;
|
Desc<"Whether to use Ansi color codes or not.">;
|
||||||
|
def UseSourceCache: Property<"use-source-cache", "Boolean">,
|
||||||
|
Global,
|
||||||
|
DefaultTrue,
|
||||||
|
Desc<"Whether to cache source files in memory or not.">;
|
||||||
def AutoOneLineSummaries: Property<"auto-one-line-summaries", "Boolean">,
|
def AutoOneLineSummaries: Property<"auto-one-line-summaries", "Boolean">,
|
||||||
Global,
|
Global,
|
||||||
DefaultTrue,
|
DefaultTrue,
|
||||||
|
|
|
@ -212,6 +212,11 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
|
||||||
// use-color changed. Ping the prompt so it can reset the ansi terminal
|
// use-color changed. Ping the prompt so it can reset the ansi terminal
|
||||||
// codes.
|
// codes.
|
||||||
SetPrompt(GetPrompt());
|
SetPrompt(GetPrompt());
|
||||||
|
} else if (property_path == g_debugger_properties[ePropertyUseSourceCache].name) {
|
||||||
|
// use-source-cache changed. Wipe out the cache contents if it was disabled.
|
||||||
|
if (!GetUseSourceCache()) {
|
||||||
|
m_source_file_cache.Clear();
|
||||||
|
}
|
||||||
} else if (is_load_script && target_sp &&
|
} else if (is_load_script && target_sp &&
|
||||||
load_script_old_value == eLoadScriptFromSymFileWarn) {
|
load_script_old_value == eLoadScriptFromSymFileWarn) {
|
||||||
if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() ==
|
if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() ==
|
||||||
|
@ -338,6 +343,20 @@ bool Debugger::SetUseColor(bool b) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Debugger::GetUseSourceCache() const {
|
||||||
|
const uint32_t idx = ePropertyUseSourceCache;
|
||||||
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
||||||
|
nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Debugger::SetUseSourceCache(bool b) {
|
||||||
|
const uint32_t idx = ePropertyUseSourceCache;
|
||||||
|
bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
|
||||||
|
if (!ret) {
|
||||||
|
m_source_file_cache.Clear();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool Debugger::GetHighlightSource() const {
|
bool Debugger::GetHighlightSource() const {
|
||||||
const uint32_t idx = ePropertyHighlightSource;
|
const uint32_t idx = ePropertyHighlightSource;
|
||||||
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
||||||
|
|
|
@ -72,7 +72,7 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
|
||||||
FileSP file_sp;
|
FileSP file_sp;
|
||||||
if (same_as_previous)
|
if (same_as_previous)
|
||||||
file_sp = m_last_file_sp;
|
file_sp = m_last_file_sp;
|
||||||
else if (debugger_sp)
|
else if (debugger_sp && debugger_sp->GetUseSourceCache())
|
||||||
file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
|
file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
|
||||||
|
|
||||||
TargetSP target_sp(m_target_wp.lock());
|
TargetSP target_sp(m_target_wp.lock());
|
||||||
|
@ -95,7 +95,7 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
|
||||||
else
|
else
|
||||||
file_sp = std::make_shared<File>(file_spec, debugger_sp);
|
file_sp = std::make_shared<File>(file_spec, debugger_sp);
|
||||||
|
|
||||||
if (debugger_sp)
|
if (debugger_sp && debugger_sp->GetUseSourceCache())
|
||||||
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
|
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
|
||||||
}
|
}
|
||||||
return file_sp;
|
return file_sp;
|
||||||
|
|
Loading…
Reference in New Issue