[Lldb-commits] [lldb] r252356 - Make the language specifier to "break set" actually filter the names by their language. So for
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 6 14:48:59 PST 2015
Author: jingham
Date: Fri Nov 6 16:48:59 2015
New Revision: 252356
URL: http://llvm.org/viewvc/llvm-project?rev=252356&view=rev
Log:
Make the language specifier to "break set" actually filter the names by their language. So for
instance:
break set -l c++ -r Name
will only break on C++ symbols that match Name, not ObjC or plain C symbols. This also works
for "break set -n" and there are SB API's to pass this as well.
Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/scripts/interface/SBTarget.i
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Target/LanguageRuntime.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Nov 6 16:48:59 2015
@@ -636,20 +636,41 @@ public:
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char *symbol_name[],
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
BreakpointCreateByNames (const char *symbol_name[],
uint32_t num_names,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
- BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name = nullptr);
+ BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr);
lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);
+ lldb::SBBreakpoint
+ BreakpointCreateByRegex (const char *symbol_name_regex,
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
lldb::SBBreakpoint
BreakpointCreateBySourceRegex(const char *source_regex,
const SBFileSpec &source_file,
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h Fri Nov 6 16:48:59 2015
@@ -57,6 +57,7 @@ public:
// Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex.
BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
+ lldb::LanguageType language,
bool skip_prologue);
BreakpointResolverName (Breakpoint *bkpt,
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Fri Nov 6 16:48:59 2015
@@ -117,6 +117,9 @@ public:
return m_process;
}
+ static lldb::LanguageType
+ GetLanguageForSymbolByName (Target &target, const char *symbol_name);
+
Target&
GetTargetRef()
{
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Nov 6 16:48:59 2015
@@ -791,6 +791,7 @@ public:
CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regexp,
+ lldb::LanguageType requested_language,
LazyBool skip_prologue,
bool internal,
bool request_hardware);
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile?rev=252356&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/Makefile Fri Nov 6 16:48:59 2015
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := a.c
+CXX_SOURCES := main.cpp b.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py?rev=252356&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py Fri Nov 6 16:48:59 2015
@@ -0,0 +1,85 @@
+"""
+Test that the language option for breakpoints works correctly
+parser.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+import shutil
+import subprocess
+
+class TestBreakpointLanguage(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+
+ def check_location_file (self, bp, loc, test_name):
+ bp_loc = bp.GetLocationAtIndex(loc)
+ addr = bp_loc.GetAddress()
+ comp_unit = addr.GetCompileUnit()
+ comp_name = comp_unit.GetFileSpec().GetFilename()
+ return comp_name == test_name
+
+ def test_regex_breakpoint_language(self):
+ """Test that the name regex breakpoint commands obey the language filter."""
+
+ self.build()
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ error = lldb.SBError()
+ # Don't read in dependencies so we don't come across false matches that
+ # add unwanted breakpoint hits.
+ self.target = self.dbg.CreateTarget(exe, None, None, False, error)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ cpp_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
+ self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
+
+ c_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
+ self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
+
+ objc_bp = self.target.BreakpointCreateByRegex("func_from", lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
+
+ def test_by_name_breakpoint_language(self):
+ """Test that the name regex breakpoint commands obey the language filter."""
+
+ self.build()
+ # Create a target by the debugger.
+ exe = os.path.join(os.getcwd(), "a.out")
+ error = lldb.SBError()
+ # Don't read in dependencies so we don't come across false matches that
+ # add unwanted breakpoint hits.
+ self.target = self.dbg.CreateTarget(exe, None, None, False, error)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ cpp_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(cpp_bp.GetNumLocations() == 1, "Only one C++ symbol matches")
+ self.assertTrue(self.check_location_file(cpp_bp, 0, "b.cpp"))
+
+ no_cpp_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC_plus_plus, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(no_cpp_bp.GetNumLocations() == 0, "And the C one doesn't match")
+
+ c_bp = self.target.BreakpointCreateByName("func_from_c", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(c_bp.GetNumLocations() == 1, "Only one C symbol matches")
+ self.assertTrue(self.check_location_file(c_bp, 0, "a.c"))
+
+ no_c_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(no_c_bp.GetNumLocations() == 0, "And the C++ one doesn't match")
+
+ objc_bp = self.target.BreakpointCreateByName("func_from_cpp", lldb.eFunctionNameTypeAuto, lldb.eLanguageTypeObjC, lldb.SBFileSpecList(), lldb.SBFileSpecList())
+ self.assertTrue(objc_bp.GetNumLocations() == 0, "No ObjC symbol matches")
+
+
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c?rev=252356&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/a.c Fri Nov 6 16:48:59 2015
@@ -0,0 +1,5 @@
+int
+func_from_c ()
+{
+ return 5;
+}
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp?rev=252356&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/b.cpp Fri Nov 6 16:48:59 2015
@@ -0,0 +1,5 @@
+int
+func_from_cpp()
+{
+ return 10;
+}
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp?rev=252356&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/main.cpp Fri Nov 6 16:48:59 2015
@@ -0,0 +1,11 @@
+#include <stdio.h>
+extern "C" int func_from_c();
+extern int func_from_cpp();
+
+int
+main()
+{
+ func_from_c();
+ func_from_cpp();
+ return 0;
+}
Modified: lldb/trunk/scripts/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBTarget.i?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/interface/SBTarget.i Fri Nov 6 16:48:59 2015
@@ -595,6 +595,13 @@ public:
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name,
+ uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
BreakpointCreateByNames (const char *symbol_name[],
uint32_t num_names,
uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
@@ -602,9 +609,23 @@ public:
const SBFileSpecList &comp_unit_list);
lldb::SBBreakpoint
+ BreakpointCreateByNames (const char *symbol_name[],
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
lldb::SBBreakpoint
+ BreakpointCreateByRegex (const char *symbol_name_regex,
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
lldb::SBBreakpoint
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Nov 6 16:48:59 2015
@@ -870,7 +870,7 @@ SBTarget::BreakpointCreateByName (const
const SBFileSpecList &comp_unit_list)
{
uint32_t name_type_mask = eFunctionNameTypeAuto;
- return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
+ return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
}
lldb::SBBreakpoint
@@ -879,6 +879,16 @@ SBTarget::BreakpointCreateByName (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
+ return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
+}
+
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByName (const char *symbol_name,
+ uint32_t name_type_mask,
+ LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -893,7 +903,7 @@ SBTarget::BreakpointCreateByName (const
comp_unit_list.get(),
symbol_name,
name_type_mask,
- eLanguageTypeUnknown,
+ symbol_language,
skip_prologue,
internal,
hardware);
@@ -914,6 +924,17 @@ SBTarget::BreakpointCreateByNames (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
+ return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list);
+}
+
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByNames (const char *symbol_names[],
+ uint32_t num_names,
+ uint32_t name_type_mask,
+ LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -925,14 +946,14 @@ SBTarget::BreakpointCreateByNames (const
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
- comp_unit_list.get(),
- symbol_names,
- num_names,
- name_type_mask,
- eLanguageTypeUnknown,
- skip_prologue,
- internal,
- hardware);
+ comp_unit_list.get(),
+ symbol_names,
+ num_names,
+ name_type_mask,
+ symbol_language,
+ skip_prologue,
+ internal,
+ hardware);
}
if (log)
@@ -962,37 +983,14 @@ SBBreakpoint
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
const char *module_name)
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
- SBBreakpoint sb_bp;
- TargetSP target_sp(GetSP());
- if (target_sp && symbol_name_regex && symbol_name_regex[0])
+ SBFileSpecList module_spec_list;
+ SBFileSpecList comp_unit_list;
+ if (module_name && module_name[0])
{
- Mutex::Locker api_locker (target_sp->GetAPIMutex());
- RegularExpression regexp(symbol_name_regex);
- const bool internal = false;
- const bool hardware = false;
- const LazyBool skip_prologue = eLazyBoolCalculate;
-
- if (module_name && module_name[0])
- {
- FileSpecList module_spec_list;
- module_spec_list.Append (FileSpec (module_name, false));
-
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware);
- }
- else
- {
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware);
- }
+ module_spec_list.Append (FileSpec (module_name, false));
+
}
-
- if (log)
- log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
- static_cast<void*>(target_sp.get()), symbol_name_regex,
- module_name, static_cast<void*>(sb_bp.get()));
-
- return sb_bp;
+ return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list);
}
lldb::SBBreakpoint
@@ -1000,6 +998,15 @@ SBTarget::BreakpointCreateByRegex (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
+ return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list);
+}
+
+lldb::SBBreakpoint
+SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
+ LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
@@ -1011,8 +1018,8 @@ SBTarget::BreakpointCreateByRegex (const
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
-
- *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware);
+
+ *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware);
}
if (log)
Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Fri Nov 6 16:48:59 2015
@@ -21,6 +21,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
using namespace lldb;
@@ -90,12 +91,13 @@ BreakpointResolverName::BreakpointResolv
BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
RegularExpression &func_regex,
+ lldb::LanguageType language,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_class_name (nullptr),
m_regex (func_regex),
m_match_type (Breakpoint::Regexp),
- m_language (eLanguageTypeUnknown),
+ m_language (language),
m_skip_prologue (skip_prologue)
{
}
@@ -211,6 +213,7 @@ BreakpointResolverName::SearchCallback(S
return Searcher::eCallbackReturnStop;
}
bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
+ bool filter_by_language = (m_language != eLanguageTypeUnknown);
const bool include_symbols = !filter_by_cu;
const bool include_inlines = true;
const bool append = true;
@@ -254,15 +257,48 @@ BreakpointResolverName::SearchCallback(S
}
// If the filter specifies a Compilation Unit, remove the ones that don't pass at this point.
- if (filter_by_cu)
+ if (filter_by_cu || filter_by_language)
{
+ Target &target = m_breakpoint->GetTarget();
+
uint32_t num_functions = func_list.GetSize();
for (size_t idx = 0; idx < num_functions; idx++)
{
+ bool remove_it = false;
SymbolContext sc;
func_list.GetContextAtIndex(idx, sc);
- if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
+ if (filter_by_cu)
+ {
+ if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
+ remove_it = true;
+ }
+
+ if (filter_by_language)
+ {
+ const char *name = sc.GetFunctionName(Mangled::ePreferMangled).AsCString();
+ if (name)
+ {
+ LanguageType sym_language = LanguageRuntime::GetLanguageForSymbolByName(target, name);
+ if (m_language == eLanguageTypeC)
+ {
+ // We don't currently have a way to say "This symbol name is C" so for now, C means
+ // not ObjC and not C++, etc...
+ if (sym_language == eLanguageTypeC_plus_plus
+ || sym_language == eLanguageTypeObjC
+ || sym_language == eLanguageTypeSwift)
+ {
+ remove_it = true;
+ }
+ }
+ else if (sym_language != m_language)
+ {
+ remove_it = true;
+ }
+ }
+ }
+
+ if (remove_it)
{
func_list.RemoveContextAtIndex(idx);
num_functions--;
@@ -370,6 +406,10 @@ BreakpointResolverName::GetDescription (
s->Printf ("'%s'}", m_lookups[num_names - 1].name.GetCString());
}
}
+ if (m_language != eLanguageTypeUnknown)
+ {
+ s->Printf (", language = %s", Language::GetNameForLanguageType(m_language));
+ }
}
void
Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Nov 6 16:48:59 2015
@@ -546,6 +546,7 @@ protected:
bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
&(m_options.m_filenames),
regexp,
+ m_options.m_language,
m_options.m_skip_prologue,
internal,
m_options.m_hardware).get();
@@ -717,7 +718,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 )
+#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) )
OptionDefinition
CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Fri Nov 6 16:48:59 2015
@@ -12,6 +12,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/LanguageRuntime.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Core/PluginManager.h"
@@ -343,3 +345,23 @@ LanguageRuntime::CreateExceptionSearchFi
{
return m_process->GetTarget().GetSearchFilterForModule(NULL);
}
+
+lldb::LanguageType
+LanguageRuntime::GetLanguageForSymbolByName (Target &target, const char *symbol_name)
+{
+ // This is not the right way to do this. Different targets could have different ways of mangling names
+ // from a given language. So we should ask the various LanguageRuntime plugin instances for this target
+ // to recognize the name. But right now the plugin instances depend on the process, not the target.
+ // That is unfortunate, because I want to use this for filtering breakpoints by language, and so I need to know
+ // the "language for symbol-name" prior to running. So we'd have to make a "LanguageRuntimeTarget" and
+ // "LanguageRuntimeProcess", and direct the questions that don't need a running process to the former, and that
+ // do to the latter.
+ //
+ // That's more work than I want to do for this feature.
+ if (CPlusPlusLanguage::IsCPPMangledName (symbol_name))
+ return eLanguageTypeC_plus_plus;
+ else if (ObjCLanguage::IsPossibleObjCMethodName (symbol_name))
+ return eLanguageTypeObjC;
+ else
+ return eLanguageTypeUnknown;
+}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=252356&r1=252355&r2=252356&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Nov 6 16:48:59 2015
@@ -582,6 +582,7 @@ BreakpointSP
Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
const FileSpecList *containingSourceFiles,
RegularExpression &func_regex,
+ lldb::LanguageType requested_language,
LazyBool skip_prologue,
bool internal,
bool hardware)
@@ -591,7 +592,8 @@ Target::CreateFuncRegexBreakpoint (const
(skip_prologue == eLazyBoolCalculate) ? GetSkipPrologue()
: static_cast<bool>(skip_prologue);
BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL,
- func_regex,
+ func_regex,
+ requested_language,
skip));
return CreateBreakpoint (filter_sp, resolver_sp, internal, hardware, true);
More information about the lldb-commits
mailing list