aprantl created this revision. aprantl added reviewers: jingham, jasonmolenda, clayborg. Herald added a subscriber: llvm-commits.
I recently had to add a new property and was annoyed by how much repetitive code I needed to write manually. This patch applies a common pattern used all over LLVM to auto-generate most of the definitions and accessors for target properties from a central definition file. The change is mostly NFC and should result in a small reduction of code size. This is by no means done, and there are many other things that could be derived in a similar way, but I would like to get the discussion started before sinking too much time into this refactoring. It does affect the realtive ordering of the properties though. Let me know what you think! Repository: rL LLVM https://reviews.llvm.org/D43647 Files: include/lldb/Target/Properties.def include/lldb/Target/Target.h source/Target/Target.cpp
Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -3360,211 +3360,19 @@ {0, nullptr, nullptr}}; static PropertyDefinition g_properties[] = { - {"default-arch", OptionValue::eTypeArch, true, 0, nullptr, nullptr, - "Default architecture to choose, when there's a choice."}, - {"move-to-nearest-code", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Move breakpoints to nearest code."}, - {"language", OptionValue::eTypeLanguage, false, eLanguageTypeUnknown, - nullptr, nullptr, - "The language to use when interpreting expressions entered in commands."}, - {"expr-prefix", OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, - "Path to a file containing expressions to be prepended to all " - "expressions."}, - {"prefer-dynamic-value", OptionValue::eTypeEnum, false, - eDynamicDontRunTarget, nullptr, g_dynamic_value_types, - "Should printed values be shown as their dynamic value."}, - {"enable-synthetic-value", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Should synthetic values be used by default whenever available."}, - {"skip-prologue", OptionValue::eTypeBoolean, false, true, nullptr, nullptr, - "Skip function prologues when setting breakpoints by name."}, - {"source-map", OptionValue::eTypePathMap, false, 0, nullptr, nullptr, - "Source path remappings are used to track the change of location between " - "a source file when built, and " - "where it exists on the current system. It consists of an array of " - "duples, the first element of each duple is " - "some part (starting at the root) of the path to the file when it was " - "built, " - "and the second is where the remainder of the original build hierarchy is " - "rooted on the local system. " - "Each element of the array is checked in order and the first one that " - "results in a match wins."}, - {"exec-search-paths", OptionValue::eTypeFileSpecList, false, 0, nullptr, - nullptr, "Executable search paths to use when locating executable files " - "whose paths don't match the local file system."}, - {"debug-file-search-paths", OptionValue::eTypeFileSpecList, false, 0, - nullptr, nullptr, - "List of directories to be searched when locating debug symbol files."}, - {"clang-module-search-paths", OptionValue::eTypeFileSpecList, false, 0, - nullptr, nullptr, - "List of directories to be searched when locating modules for Clang."}, - {"auto-import-clang-modules", OptionValue::eTypeBoolean, false, true, - nullptr, nullptr, - "Automatically load Clang modules referred to by the program."}, - {"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Automatically apply fix-it hints to expressions."}, - {"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Print the fixed expression text."}, - {"save-jit-objects", OptionValue::eTypeBoolean, false, false, nullptr, - nullptr, "Save intermediate object files generated by the LLVM JIT"}, - {"max-children-count", OptionValue::eTypeSInt64, false, 256, nullptr, - nullptr, "Maximum number of children to expand in any level of depth."}, - {"max-string-summary-length", OptionValue::eTypeSInt64, false, 1024, - nullptr, nullptr, - "Maximum number of characters to show when using %s in summary strings."}, - {"max-memory-read-size", OptionValue::eTypeSInt64, false, 1024, nullptr, - nullptr, "Maximum number of bytes that 'memory read' will fetch before " - "--force must be specified."}, - {"breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean, false, - true, nullptr, nullptr, "Consult the platform module avoid list when " - "setting non-module specific breakpoints."}, - {"arg0", OptionValue::eTypeString, false, 0, nullptr, nullptr, - "The first argument passed to the program in the argument array which can " - "be different from the executable itself."}, - {"run-args", OptionValue::eTypeArgs, false, 0, nullptr, nullptr, - "A list containing all the arguments to be passed to the executable when " - "it is run. Note that this does NOT include the argv[0] which is in " - "target.arg0."}, - {"env-vars", OptionValue::eTypeDictionary, false, OptionValue::eTypeString, - nullptr, nullptr, "A list of all the environment variables to be passed " - "to the executable's environment, and their values."}, - {"inherit-env", OptionValue::eTypeBoolean, false, true, nullptr, nullptr, - "Inherit the environment from the process that is running LLDB."}, - {"input-path", OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, - "The file/path to be used by the executable program for reading its " - "standard input."}, - {"output-path", OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, - "The file/path to be used by the executable program for writing its " - "standard output."}, - {"error-path", OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, - "The file/path to be used by the executable program for writing its " - "standard error."}, - {"detach-on-error", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "debugserver will detach (rather than killing) a process if it " - "loses connection with lldb."}, - {"preload-symbols", OptionValue::eTypeBoolean, false, true, nullptr, nullptr, - "Enable loading of symbol tables before they are needed."}, - {"disable-aslr", OptionValue::eTypeBoolean, false, true, nullptr, nullptr, - "Disable Address Space Layout Randomization (ASLR)"}, - {"disable-stdio", OptionValue::eTypeBoolean, false, false, nullptr, nullptr, - "Disable stdin/stdout for process (e.g. for a GUI application)"}, - {"inline-breakpoint-strategy", OptionValue::eTypeEnum, false, - eInlineBreakpointsAlways, nullptr, g_inline_breakpoint_enums, - "The strategy to use when settings breakpoints by file and line. " - "Breakpoint locations can end up being inlined by the compiler, so that a " - "compile unit 'a.c' might contain an inlined function from another source " - "file. " - "Usually this is limited to breakpoint locations from inlined functions " - "from header or other include files, or more accurately " - "non-implementation source files. " - "Sometimes code might #include implementation files and cause inlined " - "breakpoint locations in inlined implementation files. " - "Always checking for inlined breakpoint locations can be expensive " - "(memory and time), so if you have a project with many headers " - "and find that setting breakpoints is slow, then you can change this " - "setting to headers. " - "This setting allows you to control exactly which strategy is used when " - "setting " - "file and line breakpoints."}, - // FIXME: This is the wrong way to do per-architecture settings, but we - // don't have a general per architecture settings system in place yet. - {"x86-disassembly-flavor", OptionValue::eTypeEnum, false, - eX86DisFlavorDefault, nullptr, g_x86_dis_flavor_value_types, - "The default disassembly flavor to use for x86 or x86-64 targets."}, - {"use-hex-immediates", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Show immediates in disassembly as hexadecimal."}, - {"hex-immediate-style", OptionValue::eTypeEnum, false, - Disassembler::eHexStyleC, nullptr, g_hex_immediate_style_values, - "Which style to use for printing hexadecimal disassembly values."}, - {"use-fast-stepping", OptionValue::eTypeBoolean, false, true, nullptr, - nullptr, "Use a fast stepping algorithm based on running from branch to " - "branch rather than instruction single-stepping."}, - {"load-script-from-symbol-file", OptionValue::eTypeEnum, false, - eLoadScriptFromSymFileWarn, nullptr, g_load_script_from_sym_file_values, - "Allow LLDB to load scripting resources embedded in symbol files when " - "available."}, - {"load-cwd-lldbinit", OptionValue::eTypeEnum, false, eLoadCWDlldbinitWarn, - nullptr, g_load_current_working_dir_lldbinit_values, - "Allow LLDB to .lldbinit files from the current directory automatically."}, - {"memory-module-load-level", OptionValue::eTypeEnum, false, - eMemoryModuleLoadLevelComplete, nullptr, g_memory_module_load_level_values, - "Loading modules from memory can be slow as reading the symbol tables and " - "other data can take a long time depending on your connection to the " - "debug target. " - "This setting helps users control how much information gets loaded when " - "loading modules from memory." - "'complete' is the default value for this setting which will load all " - "sections and symbols by reading them from memory (slowest, most " - "accurate). " - "'partial' will load sections and attempt to find function bounds without " - "downloading the symbol table (faster, still accurate, missing symbol " - "names). " - "'minimal' is the fastest setting and will load section data with no " - "symbols, but should rarely be used as stack frames in these memory " - "regions will be inaccurate and not provide any context (fastest). "}, - {"display-expression-in-crashlogs", OptionValue::eTypeBoolean, false, false, - nullptr, nullptr, "Expressions that crash will show up in crash logs if " - "the host system supports executable specific crash log " - "strings and this setting is set to true."}, - {"trap-handler-names", OptionValue::eTypeArray, true, - OptionValue::eTypeString, nullptr, nullptr, - "A list of trap handler function names, e.g. a common Unix user process " - "one is _sigtramp."}, - {"clang-modules-cache-path", - OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, - "The path to the clang modules cache directory (-fmodules-cache-path)."}, - {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false, - nullptr, nullptr, "If true, LLDB will show variables that are meant to " - "support the operation of a language's runtime " - "support."}, - {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, nullptr, - "Disable lock-step debugging, instead control threads independently."}, - {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}}; - -enum { - ePropertyDefaultArch, - ePropertyMoveToNearestCode, - ePropertyLanguage, - ePropertyExprPrefix, - ePropertyPreferDynamic, - ePropertyEnableSynthetic, - ePropertySkipPrologue, - ePropertySourceMap, - ePropertyExecutableSearchPaths, - ePropertyDebugFileSearchPaths, - ePropertyClangModuleSearchPaths, - ePropertyAutoImportClangModules, - ePropertyAutoApplyFixIts, - ePropertyNotifyAboutFixIts, - ePropertySaveObjects, - ePropertyMaxChildrenCount, - ePropertyMaxSummaryLength, - ePropertyMaxMemReadSize, - ePropertyBreakpointUseAvoidList, - ePropertyArg0, - ePropertyRunArgs, - ePropertyEnvVars, - ePropertyInheritEnv, - ePropertyInputPath, - ePropertyOutputPath, - ePropertyErrorPath, - ePropertyDetachOnError, - ePropertyPreloadSymbols, - ePropertyDisableASLR, - ePropertyDisableSTDIO, - ePropertyInlineStrategy, - ePropertyDisassemblyFlavor, - ePropertyUseHexImmediates, - ePropertyHexImmediateStyle, - ePropertyUseFastStepping, - ePropertyLoadScriptFromSymbolFile, - ePropertyLoadCWDlldbinitFile, - ePropertyMemoryModuleLoadLevel, - ePropertyDisplayExpressionsInCrashlogs, - ePropertyTrapHandlerNames, - ePropertyClangModulesCachePath, - ePropertyDisplayRuntimeSupportValues, - ePropertyNonStopModeEnabled, - ePropertyExperimental +#define HANDLE_PROPERTY(ID, NAME, TYPE, GLOBAL, IDEF, SDEF, ENUMVALS, DESC) \ + {NAME, TYPE, GLOBAL, IDEF, SDEF, ENUMVALS, DESC}, +#define HANDLE_PROPERTY_INT(ID, NAME, GLOBAL, DEFAULT, DESC) \ + {NAME, OptionValue::eTypeSInt64, GLOBAL, DEFAULT, nullptr, nullptr, DESC}, +#define HANDLE_PROPERTY_BOOL(ID, NAME, GLOBAL, DEFAULT, DESC) \ + {NAME, OptionValue::eTypeBoolean, GLOBAL, DEFAULT, nullptr, nullptr, DESC}, +#define HANDLE_PROPERTY_STRING(ID, NAME, GLOBAL, DEFAULT, DESC) \ + {NAME, OptionValue::eTypeString, GLOBAL, 0, DEFAULT, nullptr, DESC}, +#define HANDLE_PROPERTY_FILESPEC(ID, NAME, GLOBAL, DEFAULT, DESC) \ + {NAME, OptionValue::eTypeFileSpec, GLOBAL, 0, DEFAULT, nullptr, DESC}, +#define HANDLE_PROPERTY_FILESPECLIST(ID, NAME, GLOBAL, DEFAULT, DESC) \ + {NAME, OptionValue::eTypeFileSpecList, GLOBAL, 0, nullptr, nullptr, DESC}, +#include "lldb/Target/Properties.def" }; class TargetOptionValueProperties : public OptionValueProperties { @@ -3740,6 +3548,44 @@ TargetProperties::~TargetProperties() = default; +uint32_t TargetProperties::GetInt(uint32_t idx) const { + return m_collection_sp->GetPropertyAtIndexAsSInt64( + nullptr, idx, g_properties[idx].default_uint_value); +} + +void TargetProperties::SetInt(uint32_t idx, uint32_t i) { + m_collection_sp->SetPropertyAtIndexAsSInt64(nullptr, idx, i); +} + +bool TargetProperties::GetBool(uint32_t idx) const { + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, idx, g_properties[idx].default_uint_value != 0); +} + +void TargetProperties::SetBool(uint32_t idx, bool b) { + m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); +} + +FileSpec TargetProperties::GetFileSpec(uint32_t idx) const { + return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); +} + +FileSpecList &TargetProperties::GetFileSpecList(uint32_t idx) const { + OptionValueFileSpecList *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr, + false, idx); + assert(option_value); + return option_value->GetCurrentValue(); +} + +llvm::StringRef TargetProperties::GetString(uint32_t idx) const { + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, llvm::StringRef()); +} + +void TargetProperties::SetString(uint32_t idx, llvm::StringRef string) { + m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, string); +} + bool TargetProperties::GetInjectLocalVariables( ExecutionContext *exe_ctx) const { const Property *exp_property = m_collection_sp->GetPropertyAtIndex( @@ -3791,12 +3637,6 @@ return value->SetCurrentValue(arch, true); } -bool TargetProperties::GetMoveToNearestCode() const { - const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const { const uint32_t idx = ePropertyPreferDynamic; return (lldb::DynamicValueType) @@ -3809,50 +3649,6 @@ return m_collection_sp->SetPropertyAtIndexAsEnumeration(nullptr, idx, d); } -bool TargetProperties::GetPreloadSymbols() const { - const uint32_t idx = ePropertyPreloadSymbols; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -void TargetProperties::SetPreloadSymbols(bool b) { - const uint32_t idx = ePropertyPreloadSymbols; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - -bool TargetProperties::GetDisableASLR() const { - const uint32_t idx = ePropertyDisableASLR; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -void TargetProperties::SetDisableASLR(bool b) { - const uint32_t idx = ePropertyDisableASLR; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - -bool TargetProperties::GetDetachOnError() const { - const uint32_t idx = ePropertyDetachOnError; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -void TargetProperties::SetDetachOnError(bool b) { - const uint32_t idx = ePropertyDetachOnError; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - -bool TargetProperties::GetDisableSTDIO() const { - const uint32_t idx = ePropertyDisableSTDIO; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -void TargetProperties::SetDisableSTDIO(bool b) { - const uint32_t idx = ePropertyDisableSTDIO; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - const char *TargetProperties::GetDisassemblyFlavor() const { const uint32_t idx = ePropertyDisassemblyFlavor; const char *return_value; @@ -3870,11 +3666,6 @@ nullptr, idx, g_properties[idx].default_uint_value); } -llvm::StringRef TargetProperties::GetArg0() const { - const uint32_t idx = ePropertyArg0; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, llvm::StringRef()); -} - void TargetProperties::SetArg0(llvm::StringRef arg) { const uint32_t idx = ePropertyArg0; m_collection_sp->SetPropertyAtIndexAsString( @@ -3908,12 +3699,6 @@ m_launch_info.GetEnvironment() = std::move(env); } -bool TargetProperties::GetSkipPrologue() const { - const uint32_t idx = ePropertySkipPrologue; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - PathMappingList &TargetProperties::GetSourcePathMap() const { const uint32_t idx = ePropertySourceMap; OptionValuePathMappings *option_value = @@ -4067,24 +3852,6 @@ nullptr, idx, g_properties[idx].default_uint_value != 0); } -bool TargetProperties::GetUseHexImmediates() const { - const uint32_t idx = ePropertyUseHexImmediates; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -bool TargetProperties::GetUseFastStepping() const { - const uint32_t idx = ePropertyUseFastStepping; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - -bool TargetProperties::GetDisplayExpressionsInCrashlogs() const { - const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_properties[idx].default_uint_value != 0); -} - LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const { const uint32_t idx = ePropertyLoadScriptFromSymbolFile; return (LoadScriptFromSymFile) @@ -4122,26 +3889,6 @@ m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args); } -bool TargetProperties::GetDisplayRuntimeSupportValues() const { - const uint32_t idx = ePropertyDisplayRuntimeSupportValues; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); -} - -void TargetProperties::SetDisplayRuntimeSupportValues(bool b) { - const uint32_t idx = ePropertyDisplayRuntimeSupportValues; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - -bool TargetProperties::GetNonStopModeEnabled() const { - const uint32_t idx = ePropertyNonStopModeEnabled; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); -} - -void TargetProperties::SetNonStopModeEnabled(bool b) { - const uint32_t idx = ePropertyNonStopModeEnabled; - m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); -} - const ProcessLaunchInfo &TargetProperties::GetProcessLaunchInfo() { m_launch_info.SetArg0(GetArg0()); // FIXME: Arg0 callback doesn't work return m_launch_info; Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -60,6 +60,20 @@ eLoadCWDlldbinitWarn } LoadCWDlldbinitFile; +enum { +# define HANDLE_PROPERTY(ID, NAME, TYPE, GLOBAL, IDEF, SDEF, ENUMVALS, DESC) \ + eProperty ## ID, +# define HANDLE_PROPERTY_INT(ID, NAME, GLOBAL, DEFAULT, DESC) \ + eProperty ## ID, +# define HANDLE_PROPERTY_BOOL(ID, NAME, GLOBAL, DEFAULT, DESC) \ + eProperty ## ID, +# define HANDLE_PROPERTY_FILESPEC(ID, NAME, GLOBAL, DEFAULT, DESC) \ + eProperty ## ID, +# define HANDLE_PROPERTY_FILESPECLIST(ID, NAME, GLOBAL, DEFAULT, DESC) \ + eProperty ## ID, +# include "lldb/Target/Properties.def" +}; + //---------------------------------------------------------------------- // TargetProperties //---------------------------------------------------------------------- @@ -69,45 +83,51 @@ }; class TargetProperties : public Properties { + uint32_t GetInt(uint32_t idx) const; + void SetInt(uint32_t idx, uint32_t i); + bool GetBool(uint32_t idx) const; + void SetBool(uint32_t idx, bool b); + llvm::StringRef GetString(uint32_t idx) const; + void SetString(uint32_t idx, llvm::StringRef s); + FileSpec GetFileSpec(uint32_t idx) const; + FileSpecList &GetFileSpecList(uint32_t idx) const; public: TargetProperties(Target *target); ~TargetProperties() override; + /// Autogenerated property accessors. + /// @{ +#define HANDLE_PROPERTY_INT(ID, NAME, GLOBAL, DEFAULT, DESC) \ + uint32_t Get##ID() const { return GetInt(eProperty##ID); } \ + void Set##ID(uint32_t i) { SetInt(eProperty##ID, i); } +#define HANDLE_PROPERTY_BOOL(ID, NAME, GLOBAL, DEFAULT, DESC) \ + bool Get##ID() const { return GetBool(eProperty##ID); } \ + void Set##ID(bool b) { SetBool(eProperty##ID, b); } +#define HANDLE_PROPERTY_FILESPEC(ID, NAME, GLOBAL, DEFAULT, DESC) \ + FileSpec Get##ID() const { return GetFileSpec(eProperty##ID); } \ + void Set##ID(llvm::StringRef path) { SetString(eProperty##ID, path); } +#define HANDLE_PROPERTY_FILESPECLIST(ID, NAME, GLOBAL, DEFAULT, DESC) \ + FileSpecList &Get##ID() const { return GetFileSpecList(eProperty##ID); } +#include "lldb/Target/Properties.def" + /// @} + ArchSpec GetDefaultArchitecture() const; void SetDefaultArchitecture(const ArchSpec &arch); - bool GetMoveToNearestCode() const; - lldb::DynamicValueType GetPreferDynamicValue() const; bool SetPreferDynamicValue(lldb::DynamicValueType d); - bool GetPreloadSymbols() const; - - void SetPreloadSymbols(bool b); - - bool GetDisableASLR() const; - - void SetDisableASLR(bool b); - - bool GetDetachOnError() const; - - void SetDetachOnError(bool b); - - bool GetDisableSTDIO() const; - - void SetDisableSTDIO(bool b); - const char *GetDisassemblyFlavor() const; // void // SetDisassemblyFlavor(const char *flavor); InlineStrategy GetInlineStrategy() const; - llvm::StringRef GetArg0() const; + llvm::StringRef GetArg0() const { return GetString(ePropertyArg0); } void SetArg0(llvm::StringRef arg); @@ -118,8 +138,6 @@ Environment GetEnvironment() const; void SetEnvironment(Environment env); - bool GetSkipPrologue() const; - PathMappingList &GetSourcePathMap() const; FileSpecList &GetExecutableSearchPaths(); @@ -164,12 +182,6 @@ llvm::StringRef GetExpressionPrefixContents(); - bool GetUseHexImmediates() const; - - bool GetUseFastStepping() const; - - bool GetDisplayExpressionsInCrashlogs() const; - LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const; LoadCWDlldbinitFile GetLoadCWDlldbinitFile() const; @@ -182,14 +194,6 @@ void SetUserSpecifiedTrapHandlerNames(const Args &args); - bool GetNonStopModeEnabled() const; - - void SetNonStopModeEnabled(bool b); - - bool GetDisplayRuntimeSupportValues() const; - - void SetDisplayRuntimeSupportValues(bool b); - const ProcessLaunchInfo &GetProcessLaunchInfo(); void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); Index: include/lldb/Target/Properties.def =================================================================== --- /dev/null +++ include/lldb/Target/Properties.def @@ -0,0 +1,240 @@ +//===-- Properties.def ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if !(defined HANDLE_PROPERTY || defined HANDLE_PROPERTY_INT || \ + defined HANDLE_PROPERTY_BOOL || defined HANDLE_PROPERTY_FILESPEC || \ + defined HANDLE_PROPERTY_FILESPECLIST) +#error "Missing macro definition of HANDLE_PROPERTY_*" +#endif + +#ifndef HANDLE_PROPERTY +#define HANDLE_PROPERTY(ID, NAME, TYPE, GLOBAL, INT_DEFAULT, STR_DEFAULT, ENUMVALS, DESCRIPTION) +#endif + +HANDLE_PROPERTY(DefaultArch, "default-arch", OptionValue::eTypeArch, true, 0, + nullptr, nullptr, + "Default architecture to choose, when there's a choice.") +HANDLE_PROPERTY(Language, "language", OptionValue::eTypeLanguage, false, + eLanguageTypeUnknown, nullptr, nullptr, + "The language to use when interpreting expressions entered " + "in commands.") +HANDLE_PROPERTY(ExprPrefix, "expr-prefix", OptionValue::eTypeFileSpec, false, 0, + nullptr, nullptr, + "Path to a file containing expressions to be prepended to all " + "expressions.") +HANDLE_PROPERTY(PreferDynamic, "prefer-dynamic-value", OptionValue::eTypeEnum, + false, eDynamicDontRunTarget, nullptr, g_dynamic_value_types, + "Should printed values be shown as their dynamic value.") +HANDLE_PROPERTY(SourceMap, "source-map", OptionValue::eTypePathMap, false, 0, + nullptr, nullptr, + "Source path remappings are used to track the change of " + "location between a source file when built, and where " + "it exists on the current system. It consists of an array of " + "pairs, the first element of each pair is " + "some part (starting at the root) of the path to the file when " + "it was built, and the second is where the remainder of the " + "original build hierarchy is rooted on the local system. " + "Each element of the array is checked in order and the first " + "one that results in a match wins.") +HANDLE_PROPERTY(RunArgs, "run-args", OptionValue::eTypeArgs, false, 0, nullptr, + nullptr, + "A list containing all the arguments to be passed " + "to the executable when it is run. Note that this does " + "NOT include the argv[0] which is in target.arg0.") +HANDLE_PROPERTY(Arg0, "arg0", OptionValue::eTypeString, false, 0, nullptr, + nullptr, + "The first argument passed to the program in " + "the argument array which can " + "be different from the executable itself.") +HANDLE_PROPERTY(InlineStrategy, "inline-breakpoint-strategy", + OptionValue::eTypeEnum, false, eInlineBreakpointsAlways, + nullptr, g_inline_breakpoint_enums, + "The strategy to use when settings breakpoints by file " + "and line. Breakpoint locations can end up being inlined " + "by the compiler, so that a compile unit 'a.c' might contain " + "an inlined function from another source file. " + "Usually this is limited to breakpoint locations from " + "inlined functions from header or other include files, " + "or more accurately non-implementation source files. " + "Sometimes code might #include implementation files and cause " + "inlined breakpoint locations in inlined implementation files. " + "Always checking for inlined breakpoint locations can be " + "expensive (memory and time), so if you have a project with " + "many headers and find that setting breakpoints is slow, " + "then you can change this setting to headers. " + "This setting allows you to control exactly which strategy " + "is used when setting file and line breakpoints.") +// FIXME: This is the wrong way to do per-architecture settings, but we +// don't have a general per architecture settings system in place yet. +HANDLE_PROPERTY(DisassemblyFlavor, "x86-disassembly-flavor", + OptionValue::eTypeEnum, false, eX86DisFlavorDefault, nullptr, + g_x86_dis_flavor_value_types, + "The default disassembly flavor to use for " + "x86 or x86-64 targets.") +HANDLE_PROPERTY(HexImmediateStyle, "hex-immediate-style", + OptionValue::eTypeEnum, false, Disassembler::eHexStyleC, + nullptr, g_hex_immediate_style_values, + "Which style to use for printing hexadecimal " + "disassembly values.") +HANDLE_PROPERTY(LoadScriptFromSymbolFile, "load-script-from-symbol-file", + OptionValue::eTypeEnum, false, eLoadScriptFromSymFileWarn, + nullptr, g_load_script_from_sym_file_values, + "Allow LLDB to load scripting resources embedded in " + "symbol files when available.") +HANDLE_PROPERTY(LoadCWDlldbinitFile, "load-cwd-lldbinit", + OptionValue::eTypeEnum, false, eLoadCWDlldbinitWarn, nullptr, + g_load_current_working_dir_lldbinit_values, + "Allow LLDB to .lldbinit files from the current directory " + "automatically.") +HANDLE_PROPERTY(MemoryModuleLoadLevel, "memory-module-load-level", + OptionValue::eTypeEnum, false, eMemoryModuleLoadLevelComplete, + nullptr, g_memory_module_load_level_values, + "Loading modules from memory can be slow as reading " + "the symbol tables and other data can take a long time " + "depending on your connection to the debug target. " + "This setting helps users control how much information " + "gets loaded when loading modules from memory." + "'complete' is the default value for this setting " + "which will load all sections and symbols by reading them " + "from memory (slowest, most accurate). " + "'partial' will load sections and attempt to find function " + "bounds without downloading the symbol table (faster, " + "still accurate, missing symbol names). " + "'minimal' is the fastest setting and will load " + "section data with no symbols, but should rarely be used as " + "stack frames in these memory regions will be inaccurate and " + "not provide any context (fastest). ") +HANDLE_PROPERTY(EnvVars, "env-vars", OptionValue::eTypeDictionary, false, + OptionValue::eTypeString, nullptr, nullptr, + "A list of all the environment variables to be passed " + "to the executable's environment, and their values.") +HANDLE_PROPERTY(TrapHandlerNames, "trap-handler-names", OptionValue::eTypeArray, + true, OptionValue::eTypeString, nullptr, nullptr, + "A list of trap handler function names, " + "e.g. a common Unix user process one is _sigtramp.") +HANDLE_PROPERTY(Experimental, nullptr, OptionValue::eTypeInvalid, false, 0, + nullptr, nullptr, nullptr) + + +#ifndef HANDLE_PROPERTY_INT +#define HANDLE_PROPERTY_INT(ID, NAME, GLOBAL, DEFAULT, DESC) +#endif +HANDLE_PROPERTY_INT(MaxChildrenCount, "max-children-count", false, 256, + "Maximum number of children to expand in any level " + "of depth.") +HANDLE_PROPERTY_INT(MaxSummaryLength, "max-string-summary-length", false, 1024, + "Maximum number of characters to show when using %s in " + "summary strings.") +HANDLE_PROPERTY_INT(MaxMemReadSize, "max-memory-read-size", false, 1024, + "Maximum number of bytes that 'memory read' will " + "fetch before --force must be specified.") + +#ifndef HANDLE_PROPERTY_BOOL +#define HANDLE_PROPERTY_BOOL(ID, NAME, GLOBAL, IDEF, DESC) +#endif +HANDLE_PROPERTY_BOOL(MoveToNearestCode, "move-to-nearest-code", false, true, + "Move breakpoints to nearest code.") +HANDLE_PROPERTY_BOOL(EnableSynthetic, "enable-synthetic-value", false, true, + "Should synthetic values be used by default whenever " + "available.") +HANDLE_PROPERTY_BOOL(SkipPrologue, "skip-prologue", false, true, + "Skip function prologues when setting breakpoints by " + "name.") +HANDLE_PROPERTY_BOOL(AutoImportClangModules, "auto-import-clang-modules", false, + true, + "Automatically load Clang modules referred to by the " + "program.") +HANDLE_PROPERTY_BOOL(AutoApplyFixIts, "auto-apply-fixits", false, true, + "Automatically apply fix-it hints to expressions.") +HANDLE_PROPERTY_BOOL(NotifyAboutFixIts, "notify-about-fixits", false, true, + "Print the fixed expression text.") +HANDLE_PROPERTY_BOOL(SaveObjects, "save-jit-objects", false, false, + "Save intermediate object files generated by the LLVM JIT") +HANDLE_PROPERTY_BOOL(BreakpointUseAvoidList, + "breakpoints-use-platform-avoid-list", false, true, + "Consult the platform module avoid list when " + "setting non-module specific breakpoints.") +HANDLE_PROPERTY_BOOL(InheritEnv, "inherit-env", false, true, + "Inherit the environment from the process " + "that is running LLDB.") +HANDLE_PROPERTY_BOOL(DetachOnError, "detach-on-error", false, true, + "debugserver will detach (rather than killing) a process " + "if it loses connection with lldb.") +HANDLE_PROPERTY_BOOL(PreloadSymbols, "preload-symbols", false, true, + "Enable loading of symbol tables before they are needed.") +HANDLE_PROPERTY_BOOL(DisableASLR, "disable-aslr", false, true, + "Disable Address Space Layout Randomization (ASLR)") +HANDLE_PROPERTY_BOOL(DisableSTDIO, "disable-stdio", false, false, + "Disable stdin/stdout for process " + "(e.g. for a GUI application)") +HANDLE_PROPERTY_BOOL(UseHexImmediates, "use-hex-immediates", false, true, + "Show immediates in disassembly as hexadecimal.") +HANDLE_PROPERTY_BOOL(UseFastStepping, "use-fast-stepping", false, true, + "Use a fast stepping algorithm based on running from " + "branch to branch rather than instruction " + "single-stepping.") +HANDLE_PROPERTY_BOOL(DisplayExpressionsInCrashlogs, + "display-expression-in-crashlogs", false, false, + "Expressions that crash will show up in crash logs if " + "the host system supports executable specific crash log " + "strings and this setting is set to true.") +HANDLE_PROPERTY_BOOL(DisplayRuntimeSupportValues, + "display-runtime-support-values", false, false, + "If true, LLDB will show variables that are meant to " + "support the operation of a language's runtime " + "support.") +HANDLE_PROPERTY_BOOL(NonStopModeEnabled, "non-stop-mode", false, 0, + "Disable lock-step debugging, instead control " + "threads independently.") + + +#ifndef HANDLE_PROPERTY_STRING +#define HANDLE_PROPERTY_STRING(ID, NAME, GLOBAL, DEFAULT, DESC) +#endif + +#ifndef HANDLE_PROPERTY_FILESPEC +#define HANDLE_PROPERTY_FILESPEC(ID, NAME, GLOBAL, DEFAULT, DESC) +#endif +HANDLE_PROPERTY_FILESPEC(InputPath, "input-path", false, nullptr, + "The file/path to be used by the executable program " + "for reading its standard input.") +HANDLE_PROPERTY_FILESPEC(OutputPath, "output-path", false, nullptr, + "The file/path to be used by the executable program " + "for writing its standard output.") +HANDLE_PROPERTY_FILESPEC(ErrorPath, "error-path", false, nullptr, + "The file/path to be used by the executable program " + "for writing its standard error.") +HANDLE_PROPERTY_FILESPEC(ClangModulesCachePath, "clang-modules-cache-path", + false, nullptr, + "The path to the clang modules cache directory " + "(-fmodules-cache-path).") + +#ifndef HANDLE_PROPERTY_FILESPECLIST +#define HANDLE_PROPERTY_FILESPECLIST(ID, NAME, GLOBAL, DEFAULT, DESC) +#endif +HANDLE_PROPERTY_FILESPECLIST(ExecutableSearchPaths, "exec-search-paths", false, + nullptr, + "Executable search paths to use when locating " + "executable files whose paths don't match the " + "local file system.") +HANDLE_PROPERTY_FILESPECLIST(DebugFileSearchPaths, "debug-file-search-paths", + false, nullptr, + "List of directories to be searched " + "when locating debug symbol files.") +HANDLE_PROPERTY_FILESPECLIST(ClangModuleSearchPaths, + "clang-module-search-paths", false, nullptr, + "List of directories to be searched " + "when locating modules for Clang.") + +#undef HANDLE_PROPERTY +#undef HANDLE_PROPERTY_INT +#undef HANDLE_PROPERTY_BOOL +#undef HANDLE_PROPERTY_STRING +#undef HANDLE_PROPERTY_FILESPEC +#undef HANDLE_PROPERTY_FILESPECLIST
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits