[Lldb-commits] [lldb] r242844 - Add support for specifying a language to use when parsing breakpoints.
Dawn Perchik
dawn at burble.org
Tue Jul 21 15:05:07 PDT 2015
Author: dperchik
Date: Tue Jul 21 17:05:07 2015
New Revision: 242844
URL: http://llvm.org/viewvc/llvm-project?rev=242844&view=rev
Log:
Add support for specifying a language to use when parsing breakpoints.
Target and breakpoints options were added:
breakpoint set --language lang --name func
settings set target.language pascal
These specify the Language to use when interpreting the breakpoint's
expression (note: currently only implemented for breakpoints on
identifiers). If the breakpoint language is not set, the target.language
setting is used.
This support is required by Pascal, for example, to set breakpoint at 'ns.foo'
for function 'foo' in namespace 'ns'.
Tests on the language were also added to Module::PrepareForFunctionNameLookup
for efficiency.
Reviewed by: clayborg
Subscribers: jingham, lldb-commits
Differential Revision: http://reviews.llvm.org/D11119
Added:
lldb/trunk/test/functionalities/breakpoint/breakpoint_options/foo.cpp
lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.cpp
- copied, changed from r242821, lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c
Removed:
lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c
Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
lldb/trunk/source/Interpreter/OptionValueProperties.cpp
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Target/LanguageRuntime.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/test/functionalities/breakpoint/breakpoint_options/Makefile
lldb/trunk/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
lldb/trunk/test/settings/TestSettings.py
lldb/trunk/test/tools/lldb-mi/breakpoint/TestMiBreak.py
lldb/trunk/test/tools/lldb-mi/breakpoint/main.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h Tue Jul 21 17:05:07 2015
@@ -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
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Tue Jul 21 17:05:07 2015
@@ -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);
Modified: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h Tue Jul 21 17:05:07 2015
@@ -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;
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Tue Jul 21 17:05:07 2015
@@ -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()
{
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Jul 21 17:05:07 2015
@@ -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);
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Tue Jul 21 17:05:07 2015
@@ -847,11 +847,11 @@ SBTarget::BreakpointCreateByName (const
{
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
comp_unit_list.get(),
symbol_name,
name_type_mask,
+ eLanguageTypeUnknown,
skip_prologue,
internal,
hardware);
@@ -927,6 +928,7 @@ SBTarget::BreakpointCreateByNames (const
symbol_names,
num_names,
name_type_mask,
+ eLanguageTypeUnknown,
skip_prologue,
internal,
hardware);
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Tue Jul 21 17:05:07 2015
@@ -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::BreakpointResolv
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::BreakpointResolv
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::BreakpointResolv
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::BreakpointResolv
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::BreakpointResolv
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 (c
{
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);
}
}
Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Jul 21 17:05:07 2015
@@ -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::CommandOptio
// { 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." },
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Tue Jul 21 17:05:07 2015
@@ -778,6 +778,7 @@ Module::FindFunctions (const ConstString
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,
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 (co
{
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);
Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Tue Jul 21 17:05:07 2015
@@ -372,6 +372,7 @@ ModuleList::FindFunctions (const ConstSt
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 C
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);
Modified: lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueLanguage.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueLanguage.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueLanguage.cpp Tue Jul 21 17:05:07 2015
@@ -47,9 +47,21 @@ OptionValueLanguage::SetValueFromString
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;
Modified: lldb/trunk/source/Interpreter/OptionValueProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueProperties.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueProperties.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueProperties.cpp Tue Jul 21 17:05:07 2015
@@ -311,6 +311,15 @@ OptionValueProperties::GetPropertyAtInde
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
{
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Tue Jul 21 17:05:07 2015
@@ -1546,6 +1546,7 @@ DynamicLoaderDarwinKernel::SetNotificati
NULL,
"OSKextLoadedKextSummariesUpdated",
eFunctionNameTypeFull,
+ eLanguageTypeUnknown,
skip_prologue,
internal_bp,
hardware).get();
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Tue Jul 21 17:05:07 2015
@@ -420,6 +420,7 @@ ItaniumABILanguageRuntime::CreateExcepti
exception_names.data(),
exception_names.size(),
eFunctionNameTypeBase,
+ eLanguageTypeC_plus_plus,
eLazyBoolNo));
return resolver_sp;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Tue Jul 21 17:05:07 2015
@@ -132,6 +132,7 @@ AppleObjCRuntimeV1::CreateExceptionResol
resolver_sp.reset (new BreakpointResolverName (bkpt,
"objc_exception_throw",
eFunctionNameTypeBase,
+ eLanguageTypeObjC,
Breakpoint::Exact,
eLazyBoolNo));
// FIXME: don't do catch yet.
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Jul 21 17:05:07 2015
@@ -714,6 +714,7 @@ AppleObjCRuntimeV2::CreateExceptionResol
resolver_sp.reset (new BreakpointResolverName (bkpt,
"objc_exception_throw",
eFunctionNameTypeBase,
+ eLanguageTypeObjC,
Breakpoint::Exact,
eLazyBoolNo));
// FIXME: We don't do catch breakpoints for ObjC yet.
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Jul 21 17:05:07 2015
@@ -1144,6 +1144,7 @@ PlatformDarwin::SetThreadCreationBreakpo
g_bp_names,
llvm::array_lengthof(g_bp_names),
eFunctionNameTypeFull,
+ eLanguageTypeUnknown,
skip_prologue,
internal,
hardware);
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Tue Jul 21 17:05:07 2015
@@ -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);
@@ -417,6 +418,46 @@ LanguageRuntime::LanguageIsCPlusPlus (La
return true;
default:
return false;
+ }
+}
+
+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;
}
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Jul 21 17:05:07 2015
@@ -371,6 +371,7 @@ Target::CreateBreakpoint (const FileSpec
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 FileSpec
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 FileSpec
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 FileSpec
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 FileSpec
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 FileSpec
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 (
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 ()
{
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_options/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_options/Makefile?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_options/Makefile (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_options/Makefile Tue Jul 21 17:05:07 2015
@@ -1,5 +1,5 @@
LEVEL = ../../../make
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp foo.cpp
include $(LEVEL)/Makefile.rules
Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py Tue Jul 21 17:05:07 2015
@@ -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")
@@ -63,6 +63,33 @@ class BreakpointOptionsTestCase(TestBase
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"])
+
+ 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")
Added: lldb/trunk/test/functionalities/breakpoint/breakpoint_options/foo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_options/foo.cpp?rev=242844&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_options/foo.cpp (added)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_options/foo.cpp Tue Jul 21 17:05:07 2015
@@ -0,0 +1,12 @@
+
+namespace ns {
+ int func(void)
+ {
+ return 0;
+ }
+}
+
+extern "C" int foo(void)
+{
+ return ns::func();
+}
Removed: lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c?rev=242843&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c (removed)
@@ -1,7 +0,0 @@
-// Set break point at this line.
-
-int
-main (int argc, char **argv)
-{
- return 0;
-}
Copied: lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.cpp (from r242821, lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.cpp?p2=lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.cpp&p1=lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c&r1=242821&r2=242844&rev=242844&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.c (original)
+++ lldb/trunk/test/functionalities/breakpoint/breakpoint_options/main.cpp Tue Jul 21 17:05:07 2015
@@ -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();
}
Modified: lldb/trunk/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/test/settings/TestSettings.py (original)
+++ lldb/trunk/test/settings/TestSettings.py Tue Jul 21 17:05:07 2015
@@ -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",
Modified: lldb/trunk/test/tools/lldb-mi/breakpoint/TestMiBreak.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/breakpoint/TestMiBreak.py?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/breakpoint/TestMiBreak.py (original)
+++ lldb/trunk/test/tools/lldb-mi/breakpoint/TestMiBreak.py Tue Jul 21 17:05:07 2015
@@ -206,6 +206,22 @@ class MiBreakTestCase(lldbmi_testcase.Mi
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")
Modified: lldb/trunk/test/tools/lldb-mi/breakpoint/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/breakpoint/main.cpp?rev=242844&r1=242843&r2=242844&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/breakpoint/main.cpp (original)
+++ lldb/trunk/test/tools/lldb-mi/breakpoint/main.cpp Tue Jul 21 17:05:07 2015
@@ -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
}
More information about the lldb-commits
mailing list