diff options
Diffstat (limited to 'lldb')
26 files changed, 244 insertions, 18 deletions
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h index c2a5b180f28..f6fed41f0ef 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h @@ -34,6 +34,7 @@ public: BreakpointResolverName (Breakpoint *bkpt, const char *name, uint32_t name_type_mask, + lldb::LanguageType language, Breakpoint::MatchType type, bool skip_prologue); @@ -42,12 +43,14 @@ public: const char *names[], size_t num_names, uint32_t name_type_mask, + lldb::LanguageType language, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. BreakpointResolverName (Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask, + lldb::LanguageType language, bool skip_prologue); // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex. @@ -114,6 +117,7 @@ protected: ConstString m_class_name; RegularExpression m_regex; Breakpoint::MatchType m_match_type; + lldb::LanguageType m_language; bool m_skip_prologue; void diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 127ddaeb9fd..ebbf692a54a 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -1067,6 +1067,10 @@ public: /// The mask of bits from lldb::FunctionNameType enumerations /// that tell us what kind of name we are looking for. /// + /// @param[out] language + /// If known, the language to use for determining the + /// lookup_name_type_mask. + /// /// @param[out] lookup_name /// The actual name that will be used when calling /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols() @@ -1087,6 +1091,7 @@ public: static void PrepareForFunctionNameLookup (const ConstString &name, uint32_t name_type_mask, + lldb::LanguageType language, ConstString &lookup_name, uint32_t &lookup_name_type_mask, bool &match_name_after_lookup); diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 405beefff6d..a4eda43239b 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -171,6 +171,9 @@ public: OptionValueArch * GetPropertyAtIndexAsOptionValueArch (const ExecutionContext *exe_ctx, uint32_t idx) const; + OptionValueLanguage * + GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const; + bool GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const; diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index d8e5ada6c96..7ef9207a78a 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -105,6 +105,15 @@ public: static bool LanguageIsCPlusPlus (lldb::LanguageType language); + static bool + LanguageIsObjC (lldb::LanguageType language); + + static bool + LanguageIsC (lldb::LanguageType language); + + static bool + LanguageIsPascal (lldb::LanguageType language); + Process * GetProcess() { diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 427f68e4c5d..f7110d58325 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -169,6 +169,9 @@ public: bool GetBreakpointsConsultPlatformAvoidList (); + lldb::LanguageType + GetLanguage () const; + const char * GetExpressionPrefixContentsAsCString (); @@ -770,6 +773,7 @@ public: const FileSpecList *containingSourceFiles, const char *func_name, uint32_t func_name_type_mask, + lldb::LanguageType language, LazyBool skip_prologue, bool internal, bool request_hardware); @@ -792,6 +796,7 @@ public: const char *func_names[], size_t num_names, uint32_t func_name_type_mask, + lldb::LanguageType language, LazyBool skip_prologue, bool internal, bool request_hardware); @@ -801,6 +806,7 @@ public: const FileSpecList *containingSourceFiles, const std::vector<std::string> &func_names, uint32_t func_name_type_mask, + lldb::LanguageType language, LazyBool skip_prologue, bool internal, bool request_hardware); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 6597d4e77c7..f80ed8cb8e2 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -847,11 +847,11 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware); + *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware); } else { - *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware); + *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware); } } @@ -892,6 +892,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, comp_unit_list.get(), symbol_name, name_type_mask, + eLanguageTypeUnknown, skip_prologue, internal, hardware); @@ -927,6 +928,7 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[], symbol_names, num_names, name_type_mask, + eLanguageTypeUnknown, skip_prologue, internal, hardware); diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 581f7b01617..136cea022d1 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -30,12 +30,14 @@ using namespace lldb_private; BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, const char *name_cstr, uint32_t name_type_mask, + LanguageType language, Breakpoint::MatchType type, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_class_name (), m_regex (), m_match_type (type), + m_language (language), m_skip_prologue (skip_prologue) { @@ -59,9 +61,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, const char *names[], size_t num_names, uint32_t name_type_mask, + LanguageType language, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_match_type (Breakpoint::Exact), + m_language (language), m_skip_prologue (skip_prologue) { for (size_t i = 0; i < num_names; i++) @@ -73,9 +77,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask, + LanguageType language, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_match_type (Breakpoint::Exact), + m_language (language), m_skip_prologue (skip_prologue) { for (const std::string& name : names) @@ -91,6 +97,7 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, m_class_name (NULL), m_regex (func_regex), m_match_type (Breakpoint::Regexp), + m_language (eLanguageTypeUnknown), m_skip_prologue (skip_prologue) { } @@ -107,6 +114,7 @@ BreakpointResolverName::BreakpointResolverName m_class_name (class_name), m_regex (), m_match_type (type), + m_language (eLanguageTypeUnknown), m_skip_prologue (skip_prologue) { LookupInfo lookup; @@ -127,6 +135,7 @@ BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs m_class_name(rhs.m_class_name), m_regex(rhs.m_regex), m_match_type (rhs.m_match_type), + m_language (rhs.m_language), m_skip_prologue (rhs.m_skip_prologue) { @@ -154,7 +163,7 @@ BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_ty { LookupInfo lookup; lookup.name = name; - Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup); + Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, m_language, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup); m_lookups.push_back (lookup); } } diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 162bfb4b5a7..b61a2561990 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -111,6 +111,7 @@ public: m_throw_bp (true), m_hardware (false), m_exception_language (eLanguageTypeUnknown), + m_language (lldb::eLanguageTypeUnknown), m_skip_prologue (eLazyBoolCalculate), m_one_shot (false), m_all_files (false), @@ -249,6 +250,12 @@ public: break; } + case 'L': + m_language = LanguageRuntime::GetLanguageTypeFromString (option_arg); + if (m_language == eLanguageTypeUnknown) + error.SetErrorStringWithFormat ("Unknown language type: '%s' for breakpoint", option_arg); + break; + case 'm': { bool success; @@ -370,6 +377,7 @@ public: m_throw_bp = true; m_hardware = false; m_exception_language = eLanguageTypeUnknown; + m_language = lldb::eLanguageTypeUnknown; m_skip_prologue = eLazyBoolCalculate; m_one_shot = false; m_use_dummy = false; @@ -411,6 +419,7 @@ public: bool m_throw_bp; bool m_hardware; // Request to use hardware breakpoints lldb::LanguageType m_exception_language; + lldb::LanguageType m_language; LazyBool m_skip_prologue; bool m_one_shot; bool m_use_dummy; @@ -516,6 +525,7 @@ protected: &(m_options.m_filenames), m_options.m_func_names, name_type_mask, + m_options.m_language, m_options.m_skip_prologue, internal, m_options.m_hardware).get(); @@ -709,6 +719,7 @@ private: #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) #define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) ) #define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 ) +#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) & ~LLDB_OPT_SET_7 ) OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = @@ -800,6 +811,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = // { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName, // "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" }, + { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, + "Specifies the Language to use when interpreting the breakpoint's expression (note: currently only implemented for breakpoints identifiers). If not set the target.language setting is used." }, + { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." }, diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index eb0359d02d5..5c5379b991e 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -778,6 +778,7 @@ Module::FindFunctions (const ConstString &name, bool match_name_after_lookup = false; Module::PrepareForFunctionNameLookup (name, name_type_mask, + eLanguageTypeUnknown, // TODO: add support lookup_name, lookup_name_type_mask, match_name_after_lookup); @@ -1739,6 +1740,7 @@ Module::GetVersion (uint32_t *versions, uint32_t num_versions) void Module::PrepareForFunctionNameLookup (const ConstString &name, uint32_t name_type_mask, + LanguageType language, ConstString &lookup_name, uint32_t &lookup_name_type_mask, bool &match_name_after_lookup) @@ -1754,11 +1756,19 @@ Module::PrepareForFunctionNameLookup (const ConstString &name, { if (CPPLanguageRuntime::IsCPPMangledName (name_cstr)) lookup_name_type_mask = eFunctionNameTypeFull; - else if (ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr)) + else if ((language == eLanguageTypeUnknown || + LanguageRuntime::LanguageIsObjC(language)) && + ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr)) lookup_name_type_mask = eFunctionNameTypeFull; + else if (LanguageRuntime::LanguageIsC(language)) + { + lookup_name_type_mask = eFunctionNameTypeFull; + } else { - if (ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr)) + if ((language == eLanguageTypeUnknown || + LanguageRuntime::LanguageIsObjC(language)) && + ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr)) lookup_name_type_mask |= eFunctionNameTypeSelector; CPPLanguageRuntime::MethodName cpp_method (name); diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 669b3d9274c..6b4aa047e12 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -372,6 +372,7 @@ ModuleList::FindFunctions (const ConstString &name, uint32_t lookup_name_type_mask = 0; bool match_name_after_lookup = false; Module::PrepareForFunctionNameLookup (name, name_type_mask, + eLanguageTypeUnknown, // TODO: add support lookup_name, lookup_name_type_mask, match_name_after_lookup); @@ -436,6 +437,7 @@ ModuleList::FindFunctionSymbols (const ConstString &name, uint32_t lookup_name_type_mask = 0; bool match_name_after_lookup = false; Module::PrepareForFunctionNameLookup (name, name_type_mask, + eLanguageTypeUnknown, // TODO: add support lookup_name, lookup_name_type_mask, match_name_after_lookup); diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp index fd46553dabd..f1105c764cd 100644 --- a/lldb/source/Interpreter/OptionValueLanguage.cpp +++ b/lldb/source/Interpreter/OptionValueLanguage.cpp @@ -47,9 +47,21 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT case eVarSetOperationReplace: case eVarSetOperationAssign: { - LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(value.data()); - m_value_was_set = true; - m_current_value = new_type; + ConstString lang_name(value.trim()); + LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(lang_name.GetCString()); + if (new_type) + { + m_value_was_set = true; + m_current_value = new_type; + } + else + { + StreamString error_strm; + error_strm.Printf("invalid language type '%s', ", value.str().c_str()); + error_strm.Printf("valid values are:\n"); + LanguageRuntime::PrintAllLanguages(error_strm, " ", "\n"); + error.SetErrorString(error_strm.GetData()); + } } break; diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index e8d870a99cf..a3c28f70270 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -311,6 +311,15 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueArch (const ExecutionConte return nullptr; } +OptionValueLanguage * +OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage (const ExecutionContext *exe_ctx, uint32_t idx) const +{ + const Property *property = GetPropertyAtIndex (exe_ctx, false, idx); + if (property) + return property->GetValue()->GetAsLanguage(); + return nullptr; +} + bool OptionValueProperties::GetPropertyAtIndexAsArgs (const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const { diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 32f2d01f5e6..bec5ca4098e 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -1546,6 +1546,7 @@ DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded () NULL, "OSKextLoadedKextSummariesUpdated", eFunctionNameTypeFull, + eLanguageTypeUnknown, skip_prologue, internal_bp, hardware).get(); diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 3a3878ef09a..0fd70ded1f5 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -420,6 +420,7 @@ ItaniumABILanguageRuntime::CreateExceptionResolver (Breakpoint *bkpt, bool catch exception_names.data(), exception_names.size(), eFunctionNameTypeBase, + eLanguageTypeC_plus_plus, eLazyBoolNo)); return resolver_sp; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 9f0f6aa3c48..a84807dc5ba 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -132,6 +132,7 @@ AppleObjCRuntimeV1::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bo resolver_sp.reset (new BreakpointResolverName (bkpt, "objc_exception_throw", eFunctionNameTypeBase, + eLanguageTypeObjC, Breakpoint::Exact, eLazyBoolNo)); // FIXME: don't do catch yet. diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 54a253c8200..d0138a50a73 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -714,6 +714,7 @@ AppleObjCRuntimeV2::CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bo resolver_sp.reset (new BreakpointResolverName (bkpt, "objc_exception_throw", eFunctionNameTypeBase, + eLanguageTypeObjC, Breakpoint::Exact, eLazyBoolNo)); // FIXME: We don't do catch breakpoints for ObjC yet. diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index eb83081c0d8..b4711bc29c5 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1144,6 +1144,7 @@ PlatformDarwin::SetThreadCreationBreakpoint (Target &target) g_bp_names, llvm::array_lengthof(g_bp_names), eFunctionNameTypeFull, + eLanguageTypeUnknown, skip_prologue, internal, hardware); diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp index 9c7b441d4c5..1bec2063ad0 100644 --- a/lldb/source/Target/LanguageRuntime.cpp +++ b/lldb/source/Target/LanguageRuntime.cpp @@ -371,7 +371,8 @@ struct language_name_pair language_names[] = { "renderscript", eLanguageTypeExtRenderScript}, // Now synonyms, in arbitrary order { "objc", eLanguageTypeObjC }, - { "objc++", eLanguageTypeObjC_plus_plus } + { "objc++", eLanguageTypeObjC_plus_plus }, + { "pascal", eLanguageTypePascal83 } }; static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair); @@ -420,6 +421,46 @@ LanguageRuntime::LanguageIsCPlusPlus (LanguageType language) } } +bool +LanguageRuntime::LanguageIsObjC (LanguageType language) +{ + switch (language) + { + case eLanguageTypeObjC: + case eLanguageTypeObjC_plus_plus: + return true; + default: + return false; + } +} + +bool +LanguageRuntime::LanguageIsC (LanguageType language) +{ + switch (language) + { + case eLanguageTypeC: + case eLanguageTypeC89: + case eLanguageTypeC99: + case eLanguageTypeC11: + return true; + default: + return false; + } +} + +bool +LanguageRuntime::LanguageIsPascal (LanguageType language) +{ + switch (language) + { + case eLanguageTypePascal83: + return true; + default: + return false; + } +} + void LanguageRuntime::InitializeCommands (CommandObject* parent) { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 6ba09f4ee94..f67e74fc4b9 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -371,6 +371,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const char *func_name, uint32_t func_name_type_mask, + LanguageType language, LazyBool skip_prologue, bool internal, bool hardware) @@ -382,10 +383,13 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, if (skip_prologue == eLazyBoolCalculate) skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo; + if (language == lldb::eLanguageTypeUnknown) + language = GetLanguage(); BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_name, func_name_type_mask, + language, Breakpoint::Exact, skip_prologue)); bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true); @@ -398,6 +402,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector<std::string> &func_names, uint32_t func_name_type_mask, + LanguageType language, LazyBool skip_prologue, bool internal, bool hardware) @@ -410,10 +415,13 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, if (skip_prologue == eLazyBoolCalculate) skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo; + if (language == lldb::eLanguageTypeUnknown) + language = GetLanguage(); BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_names, func_name_type_mask, + language, skip_prologue)); bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true); } @@ -426,6 +434,7 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, const char *func_names[], size_t num_names, uint32_t func_name_type_mask, + LanguageType language, LazyBool skip_prologue, bool internal, bool hardware) @@ -437,11 +446,15 @@ Target::CreateBreakpoint (const FileSpecList *containingModules, if (skip_prologue == eLazyBoolCalculate) skip_prologue = GetSkipPrologue() ? eLazyBoolYes : eLazyBoolNo; + if (language == lldb::eLanguageTypeUnknown) + language = GetLanguage(); + BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_names, num_names, func_name_type_mask, + language, skip_prologue)); bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true); } @@ -2938,6 +2951,7 @@ g_properties[] = { { "default-arch" , OptionValue::eTypeArch , true , 0 , NULL, NULL, "Default architecture to choose, when there's a choice." }, { "move-to-nearest-code" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Move breakpoints to nearest code." }, + { "language" , OptionValue::eTypeLanguage , false, eLanguageTypeUnknown , NULL, NULL, "The language to use when interpreting expressions entered in commands (note: currently only implemented for breakpoints identifiers)." }, { "expr-prefix" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "Path to a file containing expressions to be prepended to all expressions." }, { "prefer-dynamic-value" , OptionValue::eTypeEnum , false, eDynamicDontRunTarget , NULL, g_dynamic_value_types, "Should printed values be shown as their dynamic value." }, { "enable-synthetic-value" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Should synthetic values be used by default whenever available." }, @@ -2996,6 +3010,7 @@ enum { ePropertyDefaultArch, ePropertyMoveToNearestCode, + ePropertyLanguage, ePropertyExprPrefix, ePropertyPreferDynamic, ePropertyEnableSynthetic, @@ -3444,6 +3459,15 @@ TargetProperties::GetStandardErrorPath () const return m_collection_sp->GetPropertyAtIndexAsFileSpec(NULL, idx); } +LanguageType +TargetProperties::GetLanguage () const +{ + OptionValueLanguage *value = m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage (NULL, ePropertyLanguage); + if (value) + return value->GetCurrentValue(); + return LanguageType(); +} + const char * TargetProperties::GetExpressionPrefixContentsAsCString () { diff --git a/lldb/test/functionalities/breakpoint/breakpoint_options/Makefile b/lldb/test/functionalities/breakpoint/breakpoint_options/Makefile index b09a579159d..457c4972f2d 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_options/Makefile +++ b/lldb/test/functionalities/breakpoint/breakpoint_options/Makefile @@ -1,5 +1,5 @@ LEVEL = ../../../make -C_SOURCES := main.c +CXX_SOURCES := main.cpp foo.cpp include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/lldb/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py index b8704bda7d8..e86cdec7786 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ b/lldb/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -29,7 +29,7 @@ class BreakpointOptionsTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). - self.line = line_number('main.c', '// Set break point at this line.') + self.line = line_number('main.cpp', '// Set break point at this line.') def breakpoint_options_test(self): """Test breakpoint command for different options.""" @@ -37,11 +37,11 @@ class BreakpointOptionsTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, extra_options = "-K 1", num_expected_locations = 1) - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, extra_options = "-K 0", num_expected_locations = 1) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 1", num_expected_locations = 1) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-K 0", num_expected_locations = 1) # This should create a breakpoint 0 locations. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, extra_options = "-m 0", num_expected_locations = 0) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, extra_options = "-m 0", num_expected_locations = 0) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -52,9 +52,9 @@ class BreakpointOptionsTestCase(TestBase): # Check the list of breakpoint. self.expect("breakpoint list -f", "Breakpoint locations shown correctly", - substrs = ["1: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line, - "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line, - "3: file = 'main.c', line = %d, exact_match = 1, locations = 0" % self.line]) + substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line, + "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.line, + "3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" % self.line]) # Continue the program, there should be another stop. self.runCmd("process continue") @@ -70,6 +70,33 @@ class BreakpointOptionsTestCase(TestBase): self.expect("process status", "Process exited successfully", patterns = ["^Process [0-9]+ exited with status = 0"]) + def breakpoint_options_language_test(self): + """Test breakpoint command for language option.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # This should create a breakpoint with 1 locations. + lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c++", num_expected_locations=1) + + # This should create a breakpoint 0 locations. + lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, extra_options = "-L c", num_expected_locations=0) + self.runCmd("settings set target.language c") + lldbutil.run_break_set_by_symbol (self, 'ns::func', sym_exact=False, num_expected_locations=0) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # Stopped once. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + substrs = ["stop reason = breakpoint 1."]) + + # Continue the program, we should exit. + self.runCmd("process continue") + + # We should exit. + self.expect("process status", "Process exited successfully", + patterns = ["^Process [0-9]+ exited with status = 0"]) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/functionalities/breakpoint/breakpoint_options/foo.cpp b/lldb/test/functionalities/breakpoint/breakpoint_options/foo.cpp new file mode 100644 index 00000000000..e5d0e09803e --- /dev/null +++ b/lldb/test/functionalities/breakpoint/breakpoint_options/foo.cpp @@ -0,0 +1,12 @@ + +namespace ns { + int func(void) + { + return 0; + } +} + +extern "C" int foo(void) +{ + return ns::func(); +} diff --git a/lldb/test/functionalities/breakpoint/breakpoint_options/main.c b/lldb/test/functionalities/breakpoint/breakpoint_options/main.cpp index 359e977cd39..363b90003d7 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_options/main.c +++ b/lldb/test/functionalities/breakpoint/breakpoint_options/main.cpp @@ -1,7 +1,8 @@ // Set break point at this line. +extern "C" int foo(void); int main (int argc, char **argv) { - return 0; + return foo(); } diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py index f6af0d201a9..8ecd8b21730 100644 --- a/lldb/test/settings/TestSettings.py +++ b/lldb/test/settings/TestSettings.py @@ -405,6 +405,12 @@ class SettingsCommandTestCase(TestBase): self.expect ("settings show stop-disassembly-display", SETTING_MSG("stop-disassembly-display"), startstr = 'stop-disassembly-display (enum) = always') self.runCmd("settings clear stop-disassembly-display", check=False) + # language + self.runCmd ("settings set target.language c89") # Set to known value + self.runCmd ("settings set target.language pascal ") # Set to new value with trailing whitespace + self.expect ("settings show target.language", SETTING_MSG("target.language"), + startstr = "target.language (language) = pascal") + self.runCmd("settings clear target.language", check=False) # arguments self.runCmd ("settings set target.run-args 1 2 3") # Set to known value self.runCmd ("settings set target.run-args 3 4 5 ") # Set to new value with trailing whitespaces @@ -461,6 +467,7 @@ class SettingsCommandTestCase(TestBase): "target.default-arch", "target.move-to-nearest-code", "target.expr-prefix", + "target.language", "target.prefer-dynamic-value", "target.enable-synthetic-value", "target.skip-prologue", diff --git a/lldb/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/lldb/test/tools/lldb-mi/breakpoint/TestMiBreak.py index ac71e428b4c..4cb253d2b65 100644 --- a/lldb/test/tools/lldb-mi/breakpoint/TestMiBreak.py +++ b/lldb/test/tools/lldb-mi/breakpoint/TestMiBreak.py @@ -206,6 +206,22 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"") + # Test that the target.language=pascal setting works and that BP #5 is not set + self.runCmd("-interpreter-exec console \"settings set target.language c\"") + self.expect("\^done") + self.runCmd("-break-insert ns.foo1") + self.expect("\^error") + + # Test that the target.language=c++ setting works and that BP #6 is hit + # FIXME: lldb-mi interprets 'ns::func' as file:func where file='ns:'. + #self.runCmd("-interpreter-exec console \"settings set target.language c++\"") + #self.expect("\^done") + #self.runCmd("-break-insert ns::foo1") + #self.expect("\^done,bkpt={number=\"6\"") + #self.runCmd("-exec-run") + #self.expect("\^running") + #self.expect("\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"") + # Test that BP #1 and #2 weren't set by running to program exit self.runCmd("-exec-continue") self.expect("\^running") diff --git a/lldb/test/tools/lldb-mi/breakpoint/main.cpp b/lldb/test/tools/lldb-mi/breakpoint/main.cpp index bf64faefd5e..9416a0d01c7 100644 --- a/lldb/test/tools/lldb-mi/breakpoint/main.cpp +++ b/lldb/test/tools/lldb-mi/breakpoint/main.cpp @@ -9,11 +9,19 @@ #include <cstdio> +namespace ns +{ + int foo1(void) { printf("In foo1\n"); return 1; } + int foo2(void) { printf("In foo2\n"); return 2; } +} + // BP_before_main +int x; int main(int argc, char const *argv[]) { printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]); + x = ns::foo1() + ns::foo2(); return 0; // BP_return } |