llvm-project/lldb/source/Core/CoreProperties.td
Greg Clayton da816ca0cb Added the ability to cache the finalized symbol tables subsequent debug sessions to start faster.
This is an updated version of the https://reviews.llvm.org/D113789 patch with the following changes:
- We no longer modify modification times of the cache files
- Use LLVM caching and cache pruning instead of making a new cache mechanism (See DataFileCache.h/.cpp)
- Add signature to start of each file since we are not using modification times so we can tell when caches are stale and remove and re-create the cache file as files are changed
- Add settings to control the cache size, disk percentage and expiration in days to keep cache size under control

This patch enables symbol tables to be cached in the LLDB index cache directory. All cache files are in a single directory and the files use unique names to ensure that files from the same path will re-use the same file as files get modified. This means as files change, their cache files will be deleted and updated. The modification time of each of the cache files is not modified so that access based pruning of the cache can be implemented.

The symbol table cache files start with a signature that uniquely identifies a file on disk and contains one or more of the following items:
- object file UUID if available
- object file mod time if available
- object name for BSD archive .o files that are in .a files if available

If none of these signature items are available, then the file will not be cached. This keeps temporary object files from expressions from being cached.

When the cache files are loaded on subsequent debug sessions, the signature is compare and if the file has been modified (uuid changes, mod time changes, or object file mod time changes) then the cache file is deleted and re-created.

Module caching must be enabled by the user before this can be used:

symbols.enable-lldb-index-cache (boolean) = false

(lldb) settings set symbols.enable-lldb-index-cache true

There is also a setting that allows the user to specify a module cache directory that defaults to a directory that defaults to being next to the symbols.clang-modules-cache-path directory in a temp directory:

(lldb) settings show symbols.lldb-index-cache-path
/var/folders/9p/472sr0c55l9b20x2zg36b91h0000gn/C/lldb/IndexCache

If this setting is enabled, the finalized symbol tables will be serialized and saved to disc so they can be quickly loaded next time you debug.

Each module can cache one or more files in the index cache directory. The cache file names must be unique to a file on disk and its architecture and object name for .o files in BSD archives. This allows universal mach-o files to support caching multuple architectures in the same module cache directory. Making the file based on the this info allows this cache file to be deleted and replaced when the file gets updated on disk. This keeps the cache from growing over time during the compile/edit/debug cycle and prevents out of space issues.

If the cache is enabled, the symbol table will be loaded from the cache the next time you debug if the module has not changed.

The cache also has settings to control the size of the cache on disk. Each time LLDB starts up with the index cache enable, the cache will be pruned to ensure it stays within the user defined settings:

(lldb) settings set symbols.lldb-index-cache-expiration-days <days>

A value of zero will disable cache files from expiring when the cache is pruned. The default value is 7 currently.

(lldb) settings set symbols.lldb-index-cache-max-byte-size <size>

A value of zero will disable pruning based on a total byte size. The default value is zero currently.
(lldb) settings set symbols.lldb-index-cache-max-percent <percentage-of-disk-space>

A value of 100 will allow the disc to be filled to the max, a value of zero will disable percentage pruning. The default value is zero.

Reviewed By: labath, wallace

Differential Revision: https://reviews.llvm.org/D115324
2021-12-16 09:59:55 -08:00

163 lines
11 KiB
TableGen

include "../../include/lldb/Core/PropertiesBase.td"
let Definition = "modulelist" in {
def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
Global,
DefaultTrue,
Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">;
def ClangModulesCachePath: Property<"clang-modules-cache-path", "FileSpec">,
Global,
DefaultStringValue<"">,
Desc<"The path to the clang modules cache directory (-fmodules-cache-path).">;
def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">,
Global,
DefaultStringValue<"">,
Desc<"Debug info path which should be resolved while parsing, relative to the host filesystem.">;
def EnableLLDBIndexCache: Property<"enable-lldb-index-cache", "Boolean">,
Global,
DefaultFalse,
Desc<"Enable caching for debug sessions in LLDB. LLDB can cache data for each module for improved performance in subsequent debug sessions.">;
def LLDBIndexCachePath: Property<"lldb-index-cache-path", "FileSpec">,
Global,
DefaultStringValue<"">,
Desc<"The path to the LLDB index cache directory.">;
def LLDBIndexCacheMaxByteSize: Property<"lldb-index-cache-max-byte-size", "UInt64">,
Global,
DefaultUnsignedValue<0>,
Desc<"The maximum size for the LLDB index cache directory in bytes. A value over the amount of available space on the disk will be reduced to the amount of available space. A value of 0 disables the absolute size-based pruning.">;
def LLDBIndexCacheMaxPercent: Property<"lldb-index-cache-max-percent", "UInt64">,
Global,
DefaultUnsignedValue<0>,
Desc<"The maximum size for the cache directory in terms of percentage of the available space on the disk. Set to 100 to indicate no limit, 50 to indicate that the cache size will not be left over half the available disk space. A value over 100 will be reduced to 100. A value of 0 disables the percentage size-based pruning.">;
def LLDBIndexCacheExpirationDays: Property<"lldb-index-cache-expiration-days", "UInt64">,
Global,
DefaultUnsignedValue<7>,
Desc<"The expiration time in days for a file. When a file hasn't been accessed for the specified amount of days, it is removed from the cache. A value of 0 disables the expiration-based pruning.">;
}
let Definition = "debugger" in {
def AutoConfirm: Property<"auto-confirm", "Boolean">,
Global,
DefaultFalse,
Desc<"If true all confirmation prompts will receive their default reply.">;
def DisassemblyFormat: Property<"disassembly-format", "FormatEntity">,
Global,
DefaultStringValue<"{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${function.changed}\\\\n{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${ansi.fg.yellow}${current-pc-arrow}${ansi.normal} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: ">,
Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
def FrameFormat: Property<"frame-format", "FormatEntity">,
Global,
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
Desc<"The default frame format string to use when displaying stack frame information for threads.">;
def NotiftVoid: Property<"notify-void", "Boolean">,
Global,
DefaultFalse,
Desc<"Notify the user explicitly if an expression returns void (default: false).">;
def Prompt: Property<"prompt", "String">,
Global,
DefaultEnumValue<"OptionValueString::eOptionEncodeCharacterEscapeSequences">,
DefaultStringValue<"(lldb) ">,
Desc<"The debugger command line prompt displayed for the user.">;
def ScriptLanguage: Property<"script-lang", "Enum">,
Global,
DefaultEnumValue<"eScriptLanguagePython">,
EnumValues<"OptionEnumValues(g_language_enumerators)">,
Desc<"The script language to be used for evaluating user-written scripts.">;
def StopDisassemblyCount: Property<"stop-disassembly-count", "SInt64">,
Global,
DefaultUnsignedValue<4>,
Desc<"The number of disassembly lines to show when displaying a stopped context.">;
def StopDisassemblyDisplay: Property<"stop-disassembly-display", "Enum">,
Global,
DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
Desc<"Control when to display disassembly when displaying a stopped context.">;
def StopDisassemblyMaxSize: Property<"stop-disassembly-max-size", "UInt64">,
Global,
DefaultUnsignedValue<32000>,
Desc<"The size limit to use when disassembling large functions (default: 32KB).">;
def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
Global,
DefaultUnsignedValue<3>,
Desc<"The number of sources lines to display that come after the current source line when displaying a stopped context.">;
def StopLineCountBefore: Property<"stop-line-count-before", "SInt64">,
Global,
DefaultUnsignedValue<3>,
Desc<"The number of sources lines to display that come before the current source line when displaying a stopped context.">;
def HighlightSource: Property<"highlight-source", "Boolean">,
Global,
DefaultTrue,
Desc<"If true, LLDB will highlight the displayed source code.">;
def StopShowColumn: Property<"stop-show-column", "Enum">,
DefaultEnumValue<"eStopShowColumnAnsiOrCaret">,
EnumValues<"OptionEnumValues(s_stop_show_column_values)">,
Desc<"If true, LLDB will use the column information from the debug info to mark the current position when displaying a stopped context.">;
def StopShowColumnAnsiPrefix: Property<"stop-show-column-ansi-prefix", "String">,
Global,
DefaultStringValue<"${ansi.underline}">,
Desc<"When displaying the column marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format at the immediately before the column to be marked.">;
def StopShowColumnAnsiSuffix: Property<"stop-show-column-ansi-suffix", "String">,
Global,
DefaultStringValue<"${ansi.normal}">,
Desc<"When displaying the column marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the column to be marked.">;
def StopShowLineMarkerAnsiPrefix: Property<"stop-show-line-ansi-prefix", "String">,
Global,
DefaultStringValue<"${ansi.fg.yellow}">,
Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format at the immediately before the line to be marked.">;
def StopShowLineMarkerAnsiSuffix: Property<"stop-show-line-ansi-suffix", "String">,
Global,
DefaultStringValue<"${ansi.normal}">,
Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the line to be marked.">;
def TerminalWidth: Property<"term-width", "SInt64">,
Global,
DefaultUnsignedValue<80>,
Desc<"The maximum number of columns to use for displaying text.">;
def ThreadFormat: Property<"thread-format", "FormatEntity">,
Global,
DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\\\\nReturn value: ${thread.return-value}}{\\\\nCompleted expression: ${thread.completed-expression}}\\\\n">,
Desc<"The default thread format string to use when displaying thread information.">;
def ThreadStopFormat: Property<"thread-stop-format", "FormatEntity">,
Global,
DefaultStringValue<"thread #${thread.index}{, name = '${thread.name}'}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\\\\nReturn value: ${thread.return-value}}{\\\\nCompleted expression: ${thread.completed-expression}}\\\\n">,
Desc<"The default thread format string to use when displaying thread information as part of the stop display.">;
def UseExternalEditor: Property<"use-external-editor", "Boolean">,
Global,
DefaultFalse,
Desc<"Whether to use an external editor or not.">;
def UseColor: Property<"use-color", "Boolean">,
Global,
DefaultTrue,
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">,
Global,
DefaultTrue,
Desc<"If true, LLDB will automatically display small structs in one-liner format (default: true).">;
def AutoIndent: Property<"auto-indent", "Boolean">,
Global,
DefaultTrue,
Desc<"If true, LLDB will auto indent/outdent code. Currently only supported in the REPL (default: true).">;
def PrintDecls: Property<"print-decls", "Boolean">,
Global,
DefaultTrue,
Desc<"If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true).">;
def TabSize: Property<"tab-size", "UInt64">,
Global,
DefaultUnsignedValue<4>,
Desc<"The tab size to use when indenting code in multi-line input mode (default: 4).">;
def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
Global,
DefaultTrue,
Desc<"If true, LLDB will automatically escape non-printable and escape characters when formatting strings.">;
def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
Global,
DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
Desc<"The default frame format string to use when displaying stack frameinformation for threads from thread backtrace unique.">;
def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
Global,
DefaultFalse,
Desc<"If true, LLDB will show suggestions to complete the command the user typed. Suggestions may be accepted using Ctrl-F.">;
}