Re: [Lldb-commits] [PATCH] D11790: Fix ObjC++ types Class and id being defined in C and C++ expressions.

2015-08-11 Thread Paul Herman via lldb-commits
paulherman added a comment.

The idea is that, as I user, I do not expect the identifiers "Class" and "id" 
to not be available - I don't think I've seen a warning or notice about that 
when evaluating expressions.

I believe that setting the language based on the current frame is a good guess. 
I think evaluating something in the language of the current frame is more 
common than evaluating something that is in ObjC++ and the current frame is C++.

The idea about target-level language is that it only selects a specific 
language (i.e. not the default ObjC++) if all the compile units are in the same 
language. I believe this to be right since a debugger is not a REPL, hence we 
shouldn't expect the users to evaluate something in ObjC++ if their binary 
doesn't contain anything related to that language.


http://reviews.llvm.org/D11790



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D11790: Fix ObjC++ types Class and id being defined in C and C++ expressions.

2015-08-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

This patch does exactly that. It detects the language of the frame and upgrades 
it according to the rules you said (I think I might've missed ObjC -> ObjC++, 
but that can be added).

Regarding the global setting of ObjC, I believe it is not helpful. What I mean 
is, when debugging something in ObjC the frame is probably already ObjC.

Paul


http://reviews.llvm.org/D11790



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12044: Fix resolution conflict between global and class static variables in C/C++.

2015-08-14 Thread Paul Herman via lldb-commits
paulherman created this revision.
paulherman added reviewers: clayborg, sivachandra, spyffe.
paulherman added a subscriber: lldb-commits.

Consider having a global variable 'a' and a static variable with the same name 
inside a class. This resolves the arbitrary choice when resolving the name 'a'.

http://reviews.llvm.org/D12044

Files:
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  test/lang/cpp/scope/Makefile
  test/lang/cpp/scope/TestCppScope.py
  test/lang/cpp/scope/main.cpp

Index: test/lang/cpp/scope/main.cpp
===
--- /dev/null
+++ test/lang/cpp/scope/main.cpp
@@ -0,0 +1,25 @@
+class A {
+public:
+static int a;
+int b;
+};
+
+class B {
+public:
+static int a;
+int b;
+};
+
+struct C {
+static int a;
+};
+
+int A::a = ;
+int B::a = ;
+int C::a = ;
+int a = ;
+
+int main() // break here
+{
+return 0;
+}
Index: test/lang/cpp/scope/TestCppScope.py
===
--- /dev/null
+++ test/lang/cpp/scope/TestCppScope.py
@@ -0,0 +1,76 @@
+"""
+Test scopes in C++.
+"""
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestCppScopes(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@dsym_test
+def test_with_dsym_and_run_command(self):
+self.buildDsym()
+self.check()
+
+@dwarf_test
+def test_with_dwarf_and_run_command(self):
+self.buildDwarf()
+self.check()
+
+def setUp(self):
+TestBase.setUp(self)
+
+def check(self):
+# Get main source file
+src_file = "main.cpp"
+src_file_spec = lldb.SBFileSpec(src_file)
+self.assertTrue(src_file_spec.IsValid(), "Main source file")
+
+# Get the path of the executable
+cwd = os.getcwd() 
+exe_file = "a.out"
+exe_path  = os.path.join(cwd, exe_file)
+
+# Load the executable
+target = self.dbg.CreateTarget(exe_path)
+self.assertTrue(target.IsValid(), VALID_TARGET)
+
+# Break on main function
+main_breakpoint = target.BreakpointCreateBySourceRegex("// break here", src_file_spec)
+self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+
+# Launch the process
+args = None
+env = None
+process = target.LaunchSimple(args, env, cwd)
+self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint 
+frame = thread.GetSelectedFrame()
+
+# Test result for scopes of variables 
+test_result = frame.EvaluateExpression("A::a")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == , "A::a = ")
+
+test_result = frame.EvaluateExpression("B::a")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == , "B::a = ")
+
+test_result = frame.EvaluateExpression("C::a")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == , "C::a = ")
+
+test_result = frame.EvaluateExpression("a")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == , "a = ")
+
+
+if __name__ == '__main__':
+import atexit
+lldb.SBDebugger.Initialize()
+atexit.register(lambda: lldb.SBDebugger.Terminate())
+unittest2.main()
Index: test/lang/cpp/scope/Makefile
===
--- /dev/null
+++ test/lang/cpp/scope/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -322,6 +322,12 @@
 const DWARFDebugInfoEntry *die,
 const lldb::addr_t func_low_pc);
 
+lldb::VariableSPParseGlobalVariableDIE(
+const lldb_private::SymbolContext& sc,
+DWARFCompileUnit* dwarf_cu,
+const DWARFDebugInfoEntry *die,
+const lldb::addr_t func_low_pc);
+
 size_t  ParseVariables(
 const lldb_private::SymbolContext& sc,
 DWARFCompileUnit* dwarf_cu,
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
==

Re: [Lldb-commits] [PATCH] D12044: Fix resolution conflict between global and class static variables in C++.

2015-08-17 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 32345.
paulherman added a comment.

Fix resolution conflict between global and class static variables in C++


http://reviews.llvm.org/D12044

Files:
  include/lldb/Symbol/Variable.h
  include/lldb/Symbol/VariableList.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Symbol/Variable.cpp
  source/Symbol/VariableList.cpp
  source/Target/StackFrame.cpp
  test/lang/cpp/scope/Makefile
  test/lang/cpp/scope/TestCppScope.py
  test/lang/cpp/scope/main.cpp

Index: test/lang/cpp/scope/main.cpp
===
--- /dev/null
+++ test/lang/cpp/scope/main.cpp
@@ -0,0 +1,25 @@
+class A {
+public:
+static int a;
+int b;
+};
+
+class B {
+public:
+static int a;
+int b;
+};
+
+struct C {
+static int a;
+};
+
+int A::a = ;
+int B::a = ;
+int C::a = ;
+int a = ;
+
+int main() // break here
+{
+return 0;
+}
Index: test/lang/cpp/scope/TestCppScope.py
===
--- /dev/null
+++ test/lang/cpp/scope/TestCppScope.py
@@ -0,0 +1,83 @@
+"""
+Test scopes in C++.
+"""
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestCppScopes(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@dsym_test
+def test_with_dsym_and_run_command(self):
+self.buildDsym()
+self.check()
+
+@dwarf_test
+def test_with_dwarf_and_run_command(self):
+self.buildDwarf()
+self.check()
+
+def setUp(self):
+TestBase.setUp(self)
+
+def check(self):
+# Get main source file
+src_file = "main.cpp"
+src_file_spec = lldb.SBFileSpec(src_file)
+self.assertTrue(src_file_spec.IsValid(), "Main source file")
+
+# Get the path of the executable
+cwd = os.getcwd() 
+exe_file = "a.out"
+exe_path  = os.path.join(cwd, exe_file)
+
+# Load the executable
+target = self.dbg.CreateTarget(exe_path)
+self.assertTrue(target.IsValid(), VALID_TARGET)
+
+# Break on main function
+main_breakpoint = target.BreakpointCreateBySourceRegex("// break here", src_file_spec)
+self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+
+# Launch the process
+args = None
+env = None
+process = target.LaunchSimple(args, env, cwd)
+self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint 
+frame = thread.GetSelectedFrame()
+
+# Test result for scopes of variables 
+
+global_variables = frame.GetVariables(True, True, True, False)
+global_variables_assert = { 
+'A::a': ,
+'B::a': ,
+'C::a': ,
+'::a': ,
+'a': 
+}
+
+self.assertTrue(global_variables.GetSize() == 4, "target variable returns all variables")
+for variable in global_variables:
+name = variable.GetName() 
+self.assertTrue(name in global_variables_assert, "target variable returns wrong variable " + name)
+
+for name in global_variables_assert:
+value = frame.EvaluateExpression(name)
+assert_value = global_variables_assert[name]
+self.assertTrue(value.IsValid() and value.GetValueAsSigned() == assert_value, name + " = " + str(assert_value))
+
+if __name__ == '__main__':
+import atexit
+lldb.SBDebugger.Initialize()
+atexit.register(lambda: lldb.SBDebugger.Terminate())
+unittest2.main()
Index: test/lang/cpp/scope/Makefile
===
--- /dev/null
+++ test/lang/cpp/scope/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Target/StackFrame.cpp
===
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -659,7 +659,7 @@
 else
 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
 
-var_sp = variable_list->FindVariable(name_const_string);
+var_sp = variable_list->FindVariable(name_const_string, false);
 
 bool synthetically_added_instance_object = false;
 
Index: source/Symbol/VariableList.cpp
===
--- source/Symbol/VariableList.cpp
+++ source/Symbol/VariableList.cpp
@@ -100,32 +100,38 @@
 }
 
 VariableSP
-VariableList::FindVariable(const ConstString& name)
+VariableList::FindVariable(const

[Lldb-commits] [lldb] r245380 - Test chaned function calls and imported namespaces in C++

2015-08-18 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Tue Aug 18 17:43:37 2015
New Revision: 245380

URL: http://llvm.org/viewvc/llvm-project?rev=245380&view=rev
Log:
Test chaned function calls and imported namespaces in C++

Added:
lldb/trunk/test/lang/cpp/chained-calls/
lldb/trunk/test/lang/cpp/chained-calls/Makefile
lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
lldb/trunk/test/lang/cpp/chained-calls/main.cpp
lldb/trunk/test/lang/cpp/nsimport/
lldb/trunk/test/lang/cpp/nsimport/Makefile
lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py
lldb/trunk/test/lang/cpp/nsimport/main.cpp

Added: lldb/trunk/test/lang/cpp/chained-calls/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/chained-calls/Makefile?rev=245380&view=auto
==
--- lldb/trunk/test/lang/cpp/chained-calls/Makefile (added)
+++ lldb/trunk/test/lang/cpp/chained-calls/Makefile Tue Aug 18 17:43:37 2015
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py?rev=245380&view=auto
==
--- lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py (added)
+++ lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py Tue Aug 18 
17:43:37 2015
@@ -0,0 +1,94 @@
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestCppChainedCalls(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@dsym_test
+def test_with_dsym_and_run_command(self):
+self.buildDsym()
+self.check()
+
+@dwarf_test
+def test_with_dwarf_and_run_command(self):
+self.buildDwarf()
+self.check()
+
+def setUp(self):
+TestBase.setUp(self)
+
+def check(self):
+# Get main source file
+src_file = "main.cpp"
+src_file_spec = lldb.SBFileSpec(src_file)
+self.assertTrue(src_file_spec.IsValid(), "Main source file")
+
+# Get the path of the executable
+cwd = os.getcwd() 
+exe_file = "a.out"
+exe_path  = os.path.join(cwd, exe_file)
+
+# Load the executable
+target = self.dbg.CreateTarget(exe_path)
+self.assertTrue(target.IsValid(), VALID_TARGET)
+
+# Break on main function
+main_breakpoint = target.BreakpointCreateBySourceRegex("Break here", 
src_file_spec)
+self.assertTrue(main_breakpoint.IsValid() and 
main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+
+# Launch the process
+args = None
+env = None
+process = target.LaunchSimple(args, env, cwd)
+self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, 
PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, 
lldb.eStopReasonBreakpoint)
+
+# Get frame for current thread 
+frame = thread.GetSelectedFrame()
+
+# Test chained calls
+test_result = frame.EvaluateExpression("g(f(12345))")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 12345, "g(f(12345)) = 12345")
+
+test_result = frame.EvaluateExpression("q(p()).a")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 12345678, "q(p()).a = 12345678")
+
+test_result = frame.EvaluateExpression("(p() + r()).a")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 22345678, "(p() + r()).a = 22345678")
+
+test_result = frame.EvaluateExpression("q(p() + r()).a")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 22345678, "q(p() + r()).a = 22345678")
+
+test_result = frame.EvaluateExpression("g(f(6700) + f(89))")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 6789, "g(f(6700) + f(89)) = 6789")
+
+test_result = frame.EvaluateExpression("g(f(g(f(300) + f(40))) + 
f(5))")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 345, "g(f(g(f(300) + f(40))) + f(5)) = 345")
+
+test_result = frame.EvaluateExpression("getb(makeb(), 789)")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 789, "getb(makeb(), 789) = 789")
+
+test_result = frame.EvaluateExpression("(*c).a")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 5678, "(*c).a = 5678")
+
+test_result = frame.EvaluateExpression("(*c + *c).a")
+self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 11356, "(*c + *c).a = 11356")
+
+test

[Lldb-commits] [lldb] r245381 - Fix resolution conflict between global and class static variables in C++

2015-08-18 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Tue Aug 18 17:46:57 2015
New Revision: 245381

URL: http://llvm.org/viewvc/llvm-project?rev=245381&view=rev
Log:
Fix resolution conflict between global and class static variables in C++

Added:
lldb/trunk/test/lang/cpp/scope/
lldb/trunk/test/lang/cpp/scope/Makefile
lldb/trunk/test/lang/cpp/scope/TestCppScope.py
lldb/trunk/test/lang/cpp/scope/main.cpp
Modified:
lldb/trunk/include/lldb/Symbol/Variable.h
lldb/trunk/include/lldb/Symbol/VariableList.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/Variable.cpp
lldb/trunk/source/Symbol/VariableList.cpp
lldb/trunk/source/Target/StackFrame.cpp

Modified: lldb/trunk/include/lldb/Symbol/Variable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Variable.h?rev=245381&r1=245380&r2=245381&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Variable.h (original)
+++ lldb/trunk/include/lldb/Symbol/Variable.h Tue Aug 18 17:46:57 2015
@@ -36,7 +36,8 @@ public:
   Declaration* decl,
   const DWARFExpression& location,
   bool external,
-  bool artificial);
+  bool artificial,
+  bool static_member = false);
 
 virtual
 ~Variable();
@@ -99,6 +100,11 @@ public:
 return m_artificial;
 }
 
+bool IsStaticMember() const
+{
+return m_static_member;
+}
+
 DWARFExpression &
 LocationExpression()
 {
@@ -171,7 +177,8 @@ protected:
 DWARFExpression m_location; // The location of this variable that 
can be fed to DWARFExpression::Evaluate()
 uint8_t m_external:1,   // Visible outside the containing 
compile unit?
 m_artificial:1, // Non-zero if the variable is not 
explicitly declared in source
-m_loc_is_const_data:1;  // The m_location expression contains 
the constant variable value data, not a DWARF location
+m_loc_is_const_data:1,  // The m_location expression contains 
the constant variable value data, not a DWARF location
+m_static_member:1;  // Non-zero if variable is static 
member of a class or struct.
 private:
 Variable(const Variable& rhs);
 Variable& operator=(const Variable& rhs);

Modified: lldb/trunk/include/lldb/Symbol/VariableList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/VariableList.h?rev=245381&r1=245380&r2=245381&view=diff
==
--- lldb/trunk/include/lldb/Symbol/VariableList.h (original)
+++ lldb/trunk/include/lldb/Symbol/VariableList.h Tue Aug 18 17:46:57 2015
@@ -48,10 +48,10 @@ public:
 RemoveVariableAtIndex (size_t idx);
 
 lldb::VariableSP
-FindVariable (const ConstString& name);
+FindVariable (const ConstString& name, bool include_static_members = true);
 
 lldb::VariableSP
-FindVariable (const ConstString& name, lldb::ValueType value_type);
+FindVariable (const ConstString& name, lldb::ValueType value_type, bool 
include_static_members = true);
 
 uint32_t
 FindVariableIndex (const lldb::VariableSP &var_sp);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=245381&r1=245380&r2=245381&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Aug 18 
17:46:57 2015
@@ -3968,7 +3968,6 @@ SymbolFileDWARF::ParseVariablesForContex
 return 0;
 }
 
-
 VariableSP
 SymbolFileDWARF::ParseVariableDIE
 (
@@ -4124,6 +4123,9 @@ SymbolFileDWARF::ParseVariableDIE
 }
 }
 
+const DWARFDebugInfoEntry *parent_context_die = 
GetDeclContextDIEContainingDIE(dwarf_cu, die);
+bool is_static_member = die->GetParent()->Tag() == 
DW_TAG_compile_unit && (parent_context_die->Tag() == DW_TAG_class_type || 
parent_context_die->Tag() == DW_TAG_structure_type);
+
 ValueType scope = eValueTypeInvalid;
 
 const DWARFDebugInfoEntry *sc_parent_die = 
GetParentSymbolContextDIE(die);
@@ -4301,7 +4303,8 @@ SymbolFileDWARF::ParseVariableDIE
 &decl, 
 location, 
 is_external, 
-is_artificial));
+is_artificial,
+is_static_member));
 
 var_sp->SetLocationIsConstantValueData 
(location_is_const_value_data);
 }

Modified: lldb/trunk/source/

Re: [Lldb-commits] [PATCH] D11543: Fix evaluation of global operators in C++

2015-08-18 Thread Paul Herman via lldb-commits
paulherman added a comment.

Ping


http://reviews.llvm.org/D11543



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12165: Improve tests regarding imported namespaces and chained calls in C++

2015-08-19 Thread Paul Herman via lldb-commits
paulherman created this revision.
paulherman added a reviewer: sivachandra.
paulherman added a subscriber: lldb-commits.

http://reviews.llvm.org/D12165

Files:
  test/lang/cpp/chained-calls/TestCppChainedCalls.py
  test/lang/cpp/chained-calls/main.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -1,19 +1,28 @@
-namespace A {
-int x = 11;
-namespace {
-int xx = 22;
-}
+namespace N
+{
+int n;
+}
+
+namespace
+{
+int anon;
 }
 
-using namespace A;
+namespace Nested
+{
+namespace
+{
+int nested;
+}
+}
 
-namespace {
-int xxx = 33;
-};
+using namespace N;
+using namespace Nested;
 
-int main() {
-x;
-xx;
-xxx;
-return 0;
+int main()
+{
+n = 1;
+anon = 2;
+nested = 3;
+return 0; // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -43,13 +43,13 @@
 self.assertTrue(target.IsValid(), VALID_TARGET)
 
 # Break on main function
-main_breakpoint = target.BreakpointCreateByName("main")
-self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
+self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
 env = None
-process = target.LaunchSimple(args, env, self.get_process_working_directory())
+process = target.LaunchSimple(args, env, cwd)
 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
 
 # Get the thread of the process
@@ -60,14 +60,18 @@
 frame = thread.GetSelectedFrame()
 
 # Test imported namespaces
-test_result = frame.EvaluateExpression("x")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 11, "x = 11")
+test_result = frame.EvaluateExpression("n")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 1, "n = 1")
 
-test_result = frame.EvaluateExpression("xx")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 22, "xx = 22")
+test_result = frame.EvaluateExpression("N::n")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 1, "N::n = 1")
+
+test_result = frame.EvaluateExpression("nested")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "nested = 3")
+
+test_result = frame.EvaluateExpression("anon")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
-test_result = frame.EvaluateExpression("xxx")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 33, "xxx = 33")
 
 if __name__ == '__main__':
 import atexit
Index: test/lang/cpp/chained-calls/main.cpp
===
--- test/lang/cpp/chained-calls/main.cpp
+++ test/lang/cpp/chained-calls/main.cpp
@@ -1,186 +1,33 @@
-class S
-{
+class Bool {
 public:
-  S () { }
-  S (S &obj);
-
-  S operator+ (const S &s);
-
-  int a;
+Bool operator&(const Bool other)
+{
+Bool result;
+result.value = value && other.value;
+return result;
+}
+
+bool value;
 };
 
-S::S (S &obj)
+bool get(Bool object)
 {
-  a = obj.a;
+return object.value;
 }
 
-S
-S::operator+ (const S &s)
+Bool set(bool value)
 {
-  S res;
-
-  res.a = a + s.a;
-
-  return res;
+Bool result;
+result.value = value;
+return result;
 }
 
-S
-f (int i)
+int main()
 {
-  S s;
-
-  s.a = i;
-
-  return s;
-}
-
-int
-g (const S &s)
-{
-  return s.a;
-}
-
-class A
-{
-public:
-  A operator+ (const A &);
-  int a;
-};
-
-A
-A::operator+ (const A &obj)
-{
-  A n;
-
-  n.a = a + obj.a;
-
-  return n;
-}
-
-A
-p ()
-{
-  A a;
-  a.a = 12345678;
-  return a;
-}
-
-A
-r ()
-{
-  A a;
-  a.a = 1000;
-  return a;
-}
-
-A
-q (const A &a)
-{
-  return a;
-}
-
-class B
-{
-public:
-  int b[1024];
-};
-
-B
-makeb ()
-{
-  B b;
-  int i;
-
-  for (i = 0; i < 1024; i++)
-b.b[i] = i;
-
-  return b;
-}
-
-int
-getb (const B &b, int i)
-{
-  return b.b[i];
-}
-
-class C
-{
-public:
-  C ();
-  ~C ();
-
-  A operator* ();
-
-  A *a_ptr;
-};
-
-C::C ()
-{
-  a_ptr = new A;
-  a_ptr->a = 5678;
-}
-
-C::~C ()
-{
-  delete a_ptr;
-}
-
-A
-C::operator* ()
-{
-  return *a_ptr;
-}
-
-#define TYPE_INDEX 1
-
-enum type
-{
-  INT,
-  CHAR
-};
-
-union U
-{
-public:
-  U (type t);
-  type get_type ();
-
-  int a;
-  char c;
-  type tp[2];
-};
-
-U::U (ty

Re: [Lldb-commits] [PATCH] D12165: Improve tests regarding imported namespaces and chained calls in C++

2015-08-19 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 32593.
paulherman added a comment.

Improve tests regarding imported namespaces and chained calls in C++


http://reviews.llvm.org/D12165

Files:
  test/lang/cpp/chained-calls/TestCppChainedCalls.py
  test/lang/cpp/chained-calls/main.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -1,19 +1,28 @@
-namespace A {
-int x = 11;
-namespace {
-int xx = 22;
-}
+namespace N
+{
+int n;
+}
+
+namespace
+{
+int anon;
 }
 
-using namespace A;
+namespace Nested
+{
+namespace
+{
+int nested;
+}
+}
 
-namespace {
-int xxx = 33;
-};
+using namespace N;
+using namespace Nested;
 
-int main() {
-x;
-xx;
-xxx;
-return 0;
+int main()
+{
+n = 1;
+anon = 2;
+nested = 3;
+return 0; // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -34,22 +34,22 @@
 self.assertTrue(src_file_spec.IsValid(), "Main source file")
 
 # Get the path of the executable
-cwd = os.getcwd()
+cwd = self.get_process_working_directory()
 exe_file = "a.out"
 exe_path  = os.path.join(cwd, exe_file)
 
 # Load the executable
 target = self.dbg.CreateTarget(exe_path)
 self.assertTrue(target.IsValid(), VALID_TARGET)
 
 # Break on main function
-main_breakpoint = target.BreakpointCreateByName("main")
-self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
+self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
 env = None
-process = target.LaunchSimple(args, env, self.get_process_working_directory())
+process = target.LaunchSimple(args, env, cwd)
 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
 
 # Get the thread of the process
@@ -60,14 +60,18 @@
 frame = thread.GetSelectedFrame()
 
 # Test imported namespaces
-test_result = frame.EvaluateExpression("x")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 11, "x = 11")
+test_result = frame.EvaluateExpression("n")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 1, "n = 1")
 
-test_result = frame.EvaluateExpression("xx")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 22, "xx = 22")
+test_result = frame.EvaluateExpression("N::n")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 1, "N::n = 1")
+
+test_result = frame.EvaluateExpression("nested")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "nested = 3")
+
+test_result = frame.EvaluateExpression("anon")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
-test_result = frame.EvaluateExpression("xxx")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 33, "xxx = 33")
 
 if __name__ == '__main__':
 import atexit
Index: test/lang/cpp/chained-calls/main.cpp
===
--- test/lang/cpp/chained-calls/main.cpp
+++ test/lang/cpp/chained-calls/main.cpp
@@ -1,186 +1,33 @@
-class S
-{
+class Bool {
 public:
-  S () { }
-  S (S &obj);
-
-  S operator+ (const S &s);
-
-  int a;
+Bool operator&(const Bool other)
+{
+Bool result;
+result.value = value && other.value;
+return result;
+}
+
+bool value;
 };
 
-S::S (S &obj)
+bool get(Bool object)
 {
-  a = obj.a;
+return object.value;
 }
 
-S
-S::operator+ (const S &s)
+Bool set(bool value)
 {
-  S res;
-
-  res.a = a + s.a;
-
-  return res;
+Bool result;
+result.value = value;
+return result;
 }
 
-S
-f (int i)
+int main()
 {
-  S s;
-
-  s.a = i;
-
-  return s;
-}
-
-int
-g (const S &s)
-{
-  return s.a;
-}
-
-class A
-{
-public:
-  A operator+ (const A &);
-  int a;
-};
-
-A
-A::operator+ (const A &obj)
-{
-  A n;
-
-  n.a = a + obj.a;
-
-  return n;
-}
-
-A
-p ()
-{
-  A a;
-  a.a = 12345678;
-  return a;
-}
-
-A
-r ()
-{
-  A a;
-  a.a = 1000;
-  return a;
-}
-
-A
-q (const A &a)
-{
-  return a;
-}
-
-class B
-{
-public:
-  int b[1024];
-};
-
-B
-makeb ()
-{
-  B b;
-  int i;
-
-  for (i = 0; i < 1024; i++)
-b.b[i] = i;
-
-  return b;
-}
-
-int
-getb (const B &b, int i)
-{
-  return b.b[i];
-}
-
-class C

[Lldb-commits] [lldb] r245505 - Improve tests regarding imported namespaces and chained calls in C++

2015-08-19 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Wed Aug 19 16:23:01 2015
New Revision: 245505

URL: http://llvm.org/viewvc/llvm-project?rev=245505&view=rev
Log:
Improve tests regarding imported namespaces and chained calls in C++

Modified:
lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
lldb/trunk/test/lang/cpp/chained-calls/main.cpp
lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py
lldb/trunk/test/lang/cpp/nsimport/main.cpp

Modified: lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py?rev=245505&r1=245504&r2=245505&view=diff
==
--- lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py (original)
+++ lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py Wed Aug 19 
16:23:01 2015
@@ -3,16 +3,15 @@ from lldbtest import *
 import lldbutil
 
 class TestCppChainedCalls(TestBase):
-
+
 mydir = TestBase.compute_mydir(__file__)
-
+
 @skipUnlessDarwin
 @dsym_test
 def test_with_dsym_and_run_command(self):
 self.buildDsym()
 self.check()
 
-@expectedFailureGcc
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 self.buildDwarf()
@@ -26,18 +25,18 @@ class TestCppChainedCalls(TestBase):
 src_file = "main.cpp"
 src_file_spec = lldb.SBFileSpec(src_file)
 self.assertTrue(src_file_spec.IsValid(), "Main source file")
-
+
 # Get the path of the executable
-cwd = os.getcwd() 
+cwd = self.get_process_working_directory()
 exe_file = "a.out"
 exe_path  = os.path.join(cwd, exe_file)
-
+
 # Load the executable
 target = self.dbg.CreateTarget(exe_path)
 self.assertTrue(target.IsValid(), VALID_TARGET)
 
 # Break on main function
-main_breakpoint = target.BreakpointCreateBySourceRegex("Break here", 
src_file_spec)
+main_breakpoint = target.BreakpointCreateBySourceRegex("break here", 
src_file_spec)
 self.assertTrue(main_breakpoint.IsValid() and 
main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
@@ -50,43 +49,39 @@ class TestCppChainedCalls(TestBase):
 self.assertTrue(process.GetState() == lldb.eStateStopped, 
PROCESS_STOPPED)
 thread = lldbutil.get_stopped_thread(process, 
lldb.eStopReasonBreakpoint)
 
-# Get frame for current thread 
+# Get frame for current thread
 frame = thread.GetSelectedFrame()
-
-# Test chained calls
-test_result = frame.EvaluateExpression("g(f(12345))")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 12345, "g(f(12345)) = 12345")
-
-test_result = frame.EvaluateExpression("q(p()).a")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 12345678, "q(p()).a = 12345678")
 
-test_result = frame.EvaluateExpression("(p() + r()).a")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 22345678, "(p() + r()).a = 22345678")
+# Test chained calls
+test_result = frame.EvaluateExpression("get(set(true))")
+self.assertTrue(test_result.IsValid() and test_result.GetValue() == 
"true", "get(set(true)) = true")
 
-test_result = frame.EvaluateExpression("q(p() + r()).a")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 22345678, "q(p() + r()).a = 22345678")
+test_result = frame.EvaluateExpression("get(set(false))")
+self.assertTrue(test_result.IsValid() and test_result.GetValue() == 
"false", "get(set(false)) = false")
 
-test_result = frame.EvaluateExpression("g(f(6700) + f(89))")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 6789, "g(f(6700) + f(89)) = 6789")
+test_result = frame.EvaluateExpression("get(t & f)")
+self.assertTrue(test_result.IsValid() and test_result.GetValue() == 
"false", "get(t & f) = false")
 
-test_result = frame.EvaluateExpression("g(f(g(f(300) + f(40))) + 
f(5))")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 345, "g(f(g(f(300) + f(40))) + f(5)) = 345")
+test_result = frame.EvaluateExpression("get(f & t)")
+self.assertTrue(test_result.IsValid() and test_result.GetValue() == 
"false", "get(f & t) = false")
 
-test_result = frame.EvaluateExpression("getb(makeb(), 789)")
-self.assertTrue(test_result.IsValid() and 
test_result.GetValueAsSigned() == 789, "getb(makeb(), 789) = 789")
+test_result = frame.EvaluateExpression("get(t & t)")
+self.assertTrue(test_result.IsValid() and test_result.GetValue() == 
"true", "get(t & t) = true")
 
-test_result = frame.EvaluateExpression("(*c).a")
-self.assertTrue(test_result.IsValid(

[Lldb-commits] [lldb] r245508 - Fix evaluation of global operators in C++

2015-08-19 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Wed Aug 19 16:44:56 2015
New Revision: 245508

URL: http://llvm.org/viewvc/llvm-project?rev=245508&view=rev
Log:
Fix evaluation of global operators in C++

Added:
lldb/trunk/test/lang/cpp/global_operators/
lldb/trunk/test/lang/cpp/global_operators/Makefile
lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py
lldb/trunk/test/lang/cpp/global_operators/main.cpp
Modified:
lldb/trunk/source/Expression/ClangASTSource.cpp

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=245508&r1=245507&r2=245508&view=diff
==
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Aug 19 16:44:56 2015
@@ -125,11 +125,10 @@ ClangASTSource::FindExternalVisibleDecls
 }
 break;
 
-// Operator names.  Not important for now.
+// Operator names.
 case DeclarationName::CXXOperatorName:
 case DeclarationName::CXXLiteralOperatorName:
-  SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
-  return false;
+break;
 
 // Using directives found in this context.
 // Tell Sema we didn't find any or we'll end up getting asked a *lot*.
@@ -1964,11 +1963,14 @@ NameSearchContext::AddFunDecl (const Com
   false);
 }
 
+// Pass the identifier info for functions the decl_name is needed for 
operators
+clang::DeclarationName decl_name = m_decl_name.getNameKind() == 
DeclarationName::Identifier ? m_decl_name.getAsIdentifierInfo() : m_decl_name;
+
 clang::FunctionDecl *func_decl = FunctionDecl::Create (*ast,
context,
SourceLocation(),
SourceLocation(),
-   
m_decl_name.getAsIdentifierInfo(),
+   decl_name,
qual_type,
NULL,
SC_Extern,

Added: lldb/trunk/test/lang/cpp/global_operators/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/global_operators/Makefile?rev=245508&view=auto
==
--- lldb/trunk/test/lang/cpp/global_operators/Makefile (added)
+++ lldb/trunk/test/lang/cpp/global_operators/Makefile Wed Aug 19 16:44:56 2015
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py?rev=245508&view=auto
==
--- lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py (added)
+++ lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py Wed Aug 
19 16:44:56 2015
@@ -0,0 +1,72 @@
+"""
+Test that global operators are found and evaluated.
+"""
+import lldb
+from lldbtest import *
+import lldbutil
+
+class TestCppGlobalOperators(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@dsym_test
+def test_with_dsym_and_run_command(self):
+self.buildDsym()
+self.check()
+
+@dwarf_test
+def test_with_dwarf_and_run_command(self):
+self.buildDwarf()
+self.check()
+
+def setUp(self):
+TestBase.setUp(self)
+
+def check(self):
+# Get main source file
+src_file = "main.cpp"
+src_file_spec = lldb.SBFileSpec(src_file)
+self.assertTrue(src_file_spec.IsValid(), "Main source file")
+
+# Get the path of the executable
+cwd = self.get_process_working_directory()
+exe_file = "a.out"
+exe_path  = os.path.join(cwd, exe_file)
+
+# Load the executable
+target = self.dbg.CreateTarget(exe_path)
+self.assertTrue(target.IsValid(), VALID_TARGET)
+
+# Break on main function
+main_breakpoint = target.BreakpointCreateBySourceRegex("// break 
here", src_file_spec)
+self.assertTrue(main_breakpoint.IsValid() and 
main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
+
+# Launch the process
+args = None
+env = None
+process = target.LaunchSimple(args, env, cwd)
+self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, 
PROCESS_S

[Lldb-commits] [lldb] r245515 - Fix tests to work on remote targets.

2015-08-19 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Wed Aug 19 17:44:48 2015
New Revision: 245515

URL: http://llvm.org/viewvc/llvm-project?rev=245515&view=rev
Log:
Fix tests to work on remote targets.

Modified:
lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py
lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py

Modified: lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py?rev=245515&r1=245514&r2=245515&view=diff
==
--- lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py (original)
+++ lldb/trunk/test/lang/cpp/chained-calls/TestCppChainedCalls.py Wed Aug 19 
17:44:48 2015
@@ -27,7 +27,7 @@ class TestCppChainedCalls(TestBase):
 self.assertTrue(src_file_spec.IsValid(), "Main source file")
 
 # Get the path of the executable
-cwd = self.get_process_working_directory()
+cwd = os.getcwd() 
 exe_file = "a.out"
 exe_path  = os.path.join(cwd, exe_file)
 
@@ -42,7 +42,7 @@ class TestCppChainedCalls(TestBase):
 # Launch the process
 args = None
 env = None
-process = target.LaunchSimple(args, env, cwd)
+process = target.LaunchSimple(args, env, 
self.get_process_working_directory())
 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
 
 # Get the thread of the process

Modified: lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py?rev=245515&r1=245514&r2=245515&view=diff
==
--- lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py 
(original)
+++ lldb/trunk/test/lang/cpp/global_operators/TestCppGlobalOperators.py Wed Aug 
19 17:44:48 2015
@@ -30,7 +30,7 @@ class TestCppGlobalOperators(TestBase):
 self.assertTrue(src_file_spec.IsValid(), "Main source file")
 
 # Get the path of the executable
-cwd = self.get_process_working_directory()
+cwd = os.getcwd()
 exe_file = "a.out"
 exe_path  = os.path.join(cwd, exe_file)
 
@@ -45,7 +45,7 @@ class TestCppGlobalOperators(TestBase):
 # Launch the process
 args = None
 env = None
-process = target.LaunchSimple(args, env, cwd)
+process = target.LaunchSimple(args, env, 
self.get_process_working_directory())
 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
 
 # Get the thread of the process

Modified: lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py?rev=245515&r1=245514&r2=245515&view=diff
==
--- lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py (original)
+++ lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py Wed Aug 19 17:44:48 
2015
@@ -34,7 +34,7 @@ class TestCppNsImport(TestBase):
 self.assertTrue(src_file_spec.IsValid(), "Main source file")
 
 # Get the path of the executable
-cwd = self.get_process_working_directory()
+cwd = os.getcwd()
 exe_file = "a.out"
 exe_path  = os.path.join(cwd, exe_file)
 
@@ -49,7 +49,7 @@ class TestCppNsImport(TestBase):
 # Launch the process
 args = None
 env = None
-process = target.LaunchSimple(args, env, cwd)
+process = target.LaunchSimple(args, env, 
self.get_process_working_directory())
 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
 
 # Get the thread of the process


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12304: Add scope tree for variable searching

2015-08-27 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 33345.
paulherman added a comment.

Add scope tree for variable searching


http://reviews.llvm.org/D12304

Files:
  include/lldb/Symbol/Block.h
  include/lldb/Symbol/CompileUnit.h
  include/lldb/Symbol/Function.h
  include/lldb/Symbol/Symbol.h
  include/lldb/Symbol/SymbolContextScope.h
  include/lldb/Symbol/VariableTree.h
  include/lldb/lldb-forward.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/Block.cpp
  source/Symbol/CMakeLists.txt
  source/Symbol/CompileUnit.cpp
  source/Symbol/Function.cpp
  source/Symbol/Symbol.cpp
  source/Symbol/VariableTree.cpp
  source/Target/StackFrame.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,32 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+using namespace Global;
+
+int fun_var = 9;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -45,6 +45,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +74,26 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Target/StackFrame.cpp
===
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContextScope.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Symbol/VariableTree.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -606,7 +607,6 @@
 return var_list_sp;
 }
 
-
 ValueObjectSP
 StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
DynamicValueType use_dynamic,
@@ -628,13 +628,18 @@
 bool deref = false;
 bool address_of = false;
 ValueObjectSP valobj_sp;
-const bool get_file_globals = true;
 // When looking up a variable for an expression, we need only consider the
 // variables that are in scope.
-VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
-VariableList *variable_list = var_list_sp.get();
 
-if (variable_list)
+VariableTreeSP vars;
+if (m_sc.block)
+vars = m_sc.block->GetVariables();
+else if (m_sc.function)
+vars = m_sc.function->GetVariables();
+else if (m_sc.comp_unit)
+vars = m_sc.comp_unit->GetVariables();
+
+if (vars)
 {
 // If first character is a '*', then show pointer contents
 const char *var_expr = var_expr_cstr;
@@ -659,7 +664,7 @@
 else
 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
 
-

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-10 Thread Paul Herman via lldb-commits
paulherman added a comment.

Ping.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-10 Thread Paul Herman via lldb-commits
paulherman added a comment.

I agree with most of your comments and will fix them.

One thing I noticed is that Block::GetDeclContext() does not do the right thing 
(see inline comment).

About creating a CompilerDecl class, I agree with you. I used 
CompilerDeclContext since it was just a void* and it was convenient. Do you 
think that the FindVariable method should be in ClangASTContext since there is 
the need to actually interpret the CompilerDeclContext according to clang rules?

Regarding ParseImportedNamespace, it also deals with "using NS::var" 
directives. Is there a method similar to FindNamespace that I can use?



Comment at: include/lldb/Symbol/Block.h:362-366
@@ -360,1 +361,7 @@
 
+CompilerDeclContext 
+GetClangDecl()
+{
+return m_clang_decl_context;
+}
+

clayborg wrote:
> Why did you add this function? See the function just above it? Why did you 
> not use that one? This should be removed and it should be lazily determined 
> by Block::GetDeclContext(). The current implementation should be all you need.
This function is needed as currently it returns the block of the function, not 
the block of the variable. See example below:


```
void function() 
{ // block 1 start
...
{ // block 2 start
{ // block 3 start
 // if we ask GetDeclContext() it returns the decl context of block 
1 instead of block 2
} // block 3 end
} // block 2 end
} // block 1 end
```


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-10 Thread Paul Herman via lldb-commits
paulherman added a comment.

I believe that the approach of CompilerDeclContext::FindDecls could be better. 
But then this kind of forces CompilerDeclContext to inherit CompilerDecl (a 
function is both a DeclContext and a Decl) and I believe that creating a class 
for each possible entity is an overkill.

I started looking at SymbolFileDWARF. In order to not have "clang::___", I 
believe that ParseVariableDIE and ParseFunctionBlocks should be moved to 
DWARFASTParser.

I don't really understand what Sean and Jim mean. I believe that ClangASTSource 
implements the interface ExternalASTSource and ClangExpressionDeclMap (which 
does the actual search) inherits ClangASTSource, so it should be already 
alright...?


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-11 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34609.
paulherman added a comment.

[WIP] Search variables based on clang::DeclContext and clang::Decl tree

This revision fixes some of the comments. There are some things I'm not sure 
about. The problem is that at some point there will be the need to link decls 
with the object they represent (Function, Variable, CompileUnit, etc). Is the 
approach of getting the VariableSP from the TypeSystem the right one? Also, 
should ParseVariableDIE be moved to DWARFASTParser in order to create the decl 
there or should there only be a method CreateVariableDecl(VariableSP var)?


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/Block.h
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,49 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -45,6 +45,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +74,32 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ABI.

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-11 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34616.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree

I believe I fixed most of the comments. I removed the handling of using 
declarations for now and made the test an expected failure because of this. I 
think it would be better if the parsing of DW_TAG_imported_declaration and 
DW_TAG_imported_module is handled in a different diff because and let this one 
as is.


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,7 @@
 self.buildDsym()
 self.check()
 
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +46,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +75,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
-

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34711.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree

I think this fixes the comments. It also adds a cache for clang::decl so that 
there is no memory wasted.


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,8 @@
 self.buildDsym()
 self.check()
 
+# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +47,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +76,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -15,9 +15,1

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

In http://reviews.llvm.org/D12658#245466, @clayborg wrote:

> In http://reviews.llvm.org/D12658#244710, @paulherman wrote:
>
> > [WIP] Search variables based on clang::DeclContext and clang::Decl tree
> >
> > This revision fixes some of the comments. There are some things I'm not 
> > sure about. The problem is that at some point there will be the need to 
> > link decls with the object they represent (Function, Variable, CompileUnit, 
> > etc). Is the approach of getting the VariableSP from the TypeSystem the 
> > right one?
>
>
> It is fine because each TypeSystem does have a link to its SymbolFile, so yes 
> this will work.
>
> > Also, should ParseVariableDIE be moved to DWARFASTParser in order to create 
> > the decl there or should there only be a method 
> > CreateVariableDecl(VariableSP var)?
>
>
> No. ParseVariableDIE shouldn't be making the CompilerDecl at all. We should 
> do this only when we call the "Variable::GetDecl()". It should then route 
> this through the TypeSystem from the variable type and ask the type system 
> for the CompilerDecl. This will get routed to the SymbolFile and then to that 
> will get routed to the DWARFASTParser (DWARFASTParserClang for this case).


ParseVariableDIE does need at some point to get the CompilerDecl (but it gets 
it from Variable::GetDecl which calls DWARFASTParser) in order to link the Decl 
to the Variable. Is there a better solution to do this? Also, I think you're 
not looking at the latest diff as most of these have been addressed.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

I think the only concern left might be the call to DeclLinkToObject in 
ParseVariableDIE. It doesn't have anything to do with clang but I feel like 
there should be a way to do this lazily.

Otherwise, I believe that the comments have been addressed.

Thank you!


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

Are you suggesting that the DeclLinkToObject is moved inside the GetDecl call 
and I only remove that? This is the only place where GetDecl is called, so it 
would be equivalent from a computational point of view.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

If I move the call to DeclLinkDeclToObject inside any of the GetDeclXXX 
methods, then there is no way to access the VariableSP needed for the call and 
it is probably harder to reconstruct the parameters needed for ParseVariableDIE 
starting from just the DIE itself.

Also, the call is already lazy since ParseVariableDIE is lazy (i.e. whenever 
the VariableSP is needed, the Decl is needed). I don't think there is any way 
to separate the call to DeclLinkDeclToObject from ParseVariableDIE, only to 
make sure that DeclLinkDeclToObject doesn't do any work if it is called with a 
previously encountered variable.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

I thought about the problem a bit more and I believe that having the call to 
DeclLinkDeclToObject inside ParseVariableDIE makes sense since this gets called 
only when the variable will actually be used in a search together with its 
context. Also, since ParseVariableDIE is lazy, this makes the linking to be 
lazy.

I don't really see how one could do this inside GetClangDeclForDIE or inside 
Variable::GetDecl as there is no access to the VariableSP in there.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

In http://reviews.llvm.org/D12658#245851, @clayborg wrote:

> So I don't like it in ParseVariableDIE() because it means we must create the 
> decl right away for the variable when parsing it. ParseVariableDIE is used to 
> parse all variables everywhere and we don't need the CompilerDecl in order to 
> display the Variable, so we don't need to create it right away. We can always 
> associate it in the Variable::GetDecl() call.


Okay, I understand that. In order to accomplish this, Variable should probably 
inherit from std::enable_shared_from_this so that we only have one SP to the 
variable. Is this acceptable?


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman added a comment.

I just ran a grep through the source. It seems that everywhere it is created as 
a shared_ptr. In a previous attempt I tried storing it in the TypeSystem map 
from decl to object as Variable* instead of VariableSP and it seemed like at 
some point between launching a query and getting the value of a variable there 
were no references so the pointer got deleted. Hence, I guess it is kinda 
needed here.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-14 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34768.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree

Moved the DeclLinkToObject inside Variable::GetDecl.


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/GoASTContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,8 @@
 self.buildDsym()
 self.check()
 
+# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +47,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +76,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ sour

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34808.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/GoASTContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,8 @@
 self.buildDsym()
 self.check()
 
+# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +47,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +76,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -15,9 +15,12 @@
 #include "l

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34823.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree

This adds handling of imported declarations, but there is no call to actually 
process them as I am not sure where to do this. I believe that the right place 
is in SymbolFileDWARF::ParseVariablesForContext.


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/GoASTContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,8 @@
 self.buildDsym()
 self.check()
 
+# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +47,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +76,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34850.
paulherman added a comment.

Search variables based on clang::DeclContext and clang::Decl tree

Rebased the patch.


http://reviews.llvm.org/D12658

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerDecl.h
  include/lldb/Symbol/CompilerDeclContext.h
  include/lldb/Symbol/GoASTContext.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Symbol/Variable.h
  include/lldb/lldb-forward.h
  source/Expression/ClangASTSource.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/CMakeLists.txt
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerDecl.cpp
  source/Symbol/CompilerDeclContext.cpp
  source/Symbol/Variable.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py
  test/lang/cpp/nsimport/main.cpp

Index: test/lang/cpp/nsimport/main.cpp
===
--- test/lang/cpp/nsimport/main.cpp
+++ test/lang/cpp/nsimport/main.cpp
@@ -16,13 +16,57 @@
 }
 }
 
-using namespace N;
-using namespace Nested;
+namespace Global
+{
+int global;
+}
+
+namespace Fun
+{
+int fun_var;
+int fun()
+{
+fun_var = 5;
+return 0; // break 1
+}
+}
+
+namespace Single
+{
+int single = 3;
+}
+
+namespace NotImportedBefore
+{
+int not_imported = 45;
+}
+
+using namespace Global;
+
+int not_imported = 35;
+int fun_var = 9;
+
+namespace NotImportedAfter
+{
+int not_imported = 55;
+}
+
+namespace Imported
+{
+int imported = 99;
+}
+
+int imported = 89;
 
 int main()
 {
+using namespace N;
+using namespace Nested;
+using namespace Imported;
+using Single::single;
 n = 1;
 anon = 2;
 nested = 3;
-return 0; // break 0
+global = 4;
+return Fun::fun(); // break 0
 }
Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,6 +16,8 @@
 self.buildDsym()
 self.check()
 
+# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
+@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -45,6 +47,8 @@
 # Break on main function
 break_0 = target.BreakpointCreateBySourceRegex("// break 0", src_file_spec)
 self.assertTrue(break_0.IsValid() and break_0.GetNumLocations() >= 1, VALID_BREAKPOINT)
+break_1 = target.BreakpointCreateBySourceRegex("// break 1", src_file_spec)
+self.assertTrue(break_1.IsValid() and break_1.GetNumLocations() >= 1, VALID_BREAKPOINT)
 
 # Launch the process
 args = None
@@ -72,6 +76,35 @@
 test_result = frame.EvaluateExpression("anon")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 2, "anon = 2")
 
+test_result = frame.EvaluateExpression("global")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 4, "global = 4")
+
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
+
+test_result = frame.EvaluateExpression("not_imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
+
+test_result = frame.EvaluateExpression("single")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
+
+# Continue to second breakpoint
+process.Continue()
+
+# Get the thread of the process
+self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
+thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+
+# Get current fream of the thread at the breakpoint
+frame = thread.GetSelectedFrame()
+
+# Test function inside namespace
+test_result = frame.EvaluateExpression("fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 5, "fun_var = 5")
+
 
 if __name__ == '__main__':
 import atexit
Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -15,9 +1

[Lldb-commits] [lldb] r247746 - Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Tue Sep 15 18:44:17 2015
New Revision: 247746

URL: http://llvm.org/viewvc/llvm-project?rev=247746&view=rev
Log:
Search variables based on clang::DeclContext and clang::Decl tree

Summary: SymbolFileDWARF now creates VarDecl and BlockDecl and adds them to the 
Decl tree. Then, in ClangExpressionDeclMap it uses the Decl tree to search for 
a variable. This fixes lots of variable scoping problems.

Reviewers: sivachandra, chaoren, spyffe, clayborg

Subscribers: tberghammer, jingham, lldb-commits

Differential Revision: http://reviews.llvm.org/D12658

Added:
lldb/trunk/include/lldb/Symbol/CompilerDecl.h
lldb/trunk/source/Symbol/CompilerDecl.cpp
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h
lldb/trunk/include/lldb/Symbol/GoASTContext.h
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/include/lldb/Symbol/TypeSystem.h
lldb/trunk/include/lldb/Symbol/Variable.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Expression/ClangASTSource.cpp
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Symbol/CMakeLists.txt
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/CompilerDeclContext.cpp
lldb/trunk/source/Symbol/Variable.cpp
lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py
lldb/trunk/test/lang/cpp/nsimport/main.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=247746&r1=247745&r2=247746&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Sep 15 18:44:17 2015
@@ -507,8 +507,23 @@ public:
  llvm::DenseMap &vbase_offsets);
 
 //--
+// CompilerDecl override functions
+//--
+lldb::VariableSP
+DeclGetVariable (void *opaque_decl) override;
+
+void
+DeclLinkToObject (void *opaque_decl, std::shared_ptr object) 
override;
+
+ConstString
+DeclGetName (void *opaque_decl) override;
+
+//--
 // CompilerDeclContext override functions
 //--
+
+std::vector
+DeclContextFindDeclByName (void *opaque_decl_ctx, ConstString name);
 
 bool
 DeclContextIsStructUnionOrClass (void *opaque_decl_ctx) override;
@@ -1070,6 +1085,17 @@ public:
 int tag_decl_kind,
 const ClangASTContext::TemplateParameterInfos 
&template_param_infos);
 
+clang::BlockDecl *
+CreateBlockDeclaration (clang::DeclContext *ctx);
+
+clang::UsingDirectiveDecl *
+CreateUsingDirectiveDeclaration (clang::DeclContext *decl_ctx, 
clang::NamespaceDecl *ns_decl);
+
+clang::UsingDecl *
+CreateUsingDeclaration (clang::DeclContext *current_decl_ctx, 
clang::NamedDecl *target);
+
+clang::VarDecl *
+CreateVariableDeclaration (clang::DeclContext *decl_context, const char 
*name, clang::QualType type);
 protected:
 static clang::QualType
 GetQualType (void *type)
@@ -1110,6 +1136,7 @@ protected:
 uint32_tm_pointer_byte_size;
 boolm_ast_owned;
 boolm_can_evaluate_expressions;
+std::map> m_decl_objects;
 
 private:
 //--

Added: lldb/trunk/include/lldb/Symbol/CompilerDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerDecl.h?rev=247746&view=auto
==
--- lldb/trunk/include/lldb/Symbol/CompilerDecl.h (added)
+++ lldb/trunk/include/lldb/Symbol/CompilerDecl.h Tue Sep 15 18:44:17 2015
@@ -0,0 +1,116 @@
+//===-- CompilerDecl.h --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+

[Lldb-commits] [lldb] r247759 - Fix missing include in CompilerDeclContext.h

2015-09-15 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Tue Sep 15 19:26:12 2015
New Revision: 247759

URL: http://llvm.org/viewvc/llvm-project?rev=247759&view=rev
Log:
Fix missing include in CompilerDeclContext.h

Modified:
lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h

Modified: lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h?rev=247759&r1=247758&r2=247759&view=diff
==
--- lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h Tue Sep 15 19:26:12 
2015
@@ -14,6 +14,7 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Core/ConstString.h"
+#include 
 
 namespace lldb_private {
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r247760 - Fix double include in CompilerDeclContext.h

2015-09-15 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Tue Sep 15 19:29:10 2015
New Revision: 247760

URL: http://llvm.org/viewvc/llvm-project?rev=247760&view=rev
Log:
Fix double include in CompilerDeclContext.h

Modified:
lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h

Modified: lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h?rev=247760&r1=247759&r2=247760&view=diff
==
--- lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerDeclContext.h Tue Sep 15 19:29:10 
2015
@@ -14,7 +14,6 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Core/ConstString.h"
-#include 
 
 namespace lldb_private {
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
paulherman added a comment.

The test was supposed to be marked as an XFAIL. I'm currently writing a fix for 
this that reports ambiguity in a context and deals with imported decls.


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12897: Add using directives to the clang::DeclContext and fix decls for variables inside namespaces

2015-09-15 Thread Paul Herman via lldb-commits
paulherman created this revision.
paulherman added reviewers: sivachandra, chaoren, clayborg.
paulherman added a subscriber: lldb-commits.

Supports the parsing of the "using namespace XXX" and "using XXX::XXX" 
directives. Added ambiguity errors when it two decls with the same name are 
encountered (see comments in TestCppNsImport). Fixes using directives being 
duplicated for anonymous namespaces. Fixes GetDeclForUID for specification DIEs.

http://reviews.llvm.org/D12897

Files:
  include/lldb/Symbol/SymbolFile.h
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ClangASTContext.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py

Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -16,8 +16,6 @@
 self.buildDsym()
 self.check()
 
-# This test is expected to fail because DW_TAG_imported_declaration and DW_TAG_imported_module are not parsed in SymbolFileDWARF
-@expectedFailureAll
 @dwarf_test
 def test_with_dwarf_and_run_command(self):
 """Tests imported namespaces in C++."""
@@ -82,18 +80,21 @@
 test_result = frame.EvaluateExpression("fun_var")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
 
+test_result = frame.EvaluateExpression("Fun::fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 0, "Fun::fun_var = 0")
+
 test_result = frame.EvaluateExpression("not_imported")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
 
-# Disabled the "imported" test since it isn't valid. It should actually test for ambiguity
-#test_result = frame.EvaluateExpression("imported")
-#self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
-
-test_result = frame.EvaluateExpression("::imported")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 89, "::imported = 89")
+# Currently there is no way to distinguish between "::imported" and "imported" in ClangExpressionDeclMap so this fails
+#test_result = frame.EvaluateExpression("::imported")
+#self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 89, "::imported = 89")
 
 test_result = frame.EvaluateExpression("Imported::imported")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "Imported::imported = 99")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetError().Fail(), "imported is ambiguous")
 
 test_result = frame.EvaluateExpression("single")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -1730,24 +1730,6 @@
 // BAD!!!
 }
 }
-
-
-if (namespace_decl)
-{
-// If we make it here, we are creating the anonymous namespace decl
-// for the first time, so we need to do the using directive magic
-// like SEMA does
-UsingDirectiveDecl* using_directive_decl = UsingDirectiveDecl::Create (*ast, 
-   decl_ctx, 
-   SourceLocation(),
-   SourceLocation(),
-   NestedNameSpecifierLoc(),
-   SourceLocation(),
-   namespace_decl,
-   decl_ctx);
-using_directive_decl->setImplicit();
-decl_ctx->addDecl(using_directive_decl);
-}
 }
 #ifdef LLDB_CONFIGURATION_DEBUG
 VerifyDecl(namespace_decl);
@@ -1768,20 +1750,37 @@
 return nullptr;
 }
 
+clang::DeclContext *
+FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
+{
+if (r

Re: [Lldb-commits] [PATCH] D12658: Search variables based on clang::DeclContext and clang::Decl tree

2015-09-15 Thread Paul Herman via lldb-commits
paulherman added a comment.

Please also look at http://reviews.llvm.org/D12897

It fixes the imported decls and some bugs that I have missed (evaluating 
Fun::fun_var reports an error in TestCppNsImport). Unfortunately I don't think 
there is a way to report ambiguity without for "imported" without breaking 
"::imported" (details in the diff above).


http://reviews.llvm.org/D12658



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12897: Add using directives to the clang::DeclContext and fix decls for variables inside namespaces

2015-09-16 Thread Paul Herman via lldb-commits
paulherman added a comment.

The need for ParseDeclsInContext is to get a list of namespaces that are 
contained within a using-directive. This does not actually parse anything but 
DW_TAG_imported_namespace and DW_TAG_imported_decl. The actual contents of the 
namespace are parsed only when the search reaches it.

About having the using-directives in the source that is passed to clang, I 
don't think that will work since there is a comment in 
ClangASTSource::FindExternalDeclsByName:

  // Using directives found in this context.
  // Tell Sema we didn't find any or we'll end up getting asked a *lot*.
  case DeclarationName::CXXUsingDirective:
SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
return false;


http://reviews.llvm.org/D12897



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12897: Add using directives to the clang::DeclContext and fix decls for variables inside namespaces

2015-09-16 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 34911.
paulherman added a comment.

Add using directives to the clang::DeclContext and fix decls for variables 
inside namespaces

Rebased the patch.


http://reviews.llvm.org/D12897

Files:
  include/lldb/Symbol/SymbolFile.h
  source/Expression/ClangExpressionDeclMap.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Symbol/ClangASTContext.cpp
  test/lang/cpp/nsimport/TestCppNsImport.py

Index: test/lang/cpp/nsimport/TestCppNsImport.py
===
--- test/lang/cpp/nsimport/TestCppNsImport.py
+++ test/lang/cpp/nsimport/TestCppNsImport.py
@@ -80,18 +80,21 @@
 test_result = frame.EvaluateExpression("fun_var")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 9, "fun_var = 9")
 
+test_result = frame.EvaluateExpression("Fun::fun_var")
+self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 0, "Fun::fun_var = 0")
+
 test_result = frame.EvaluateExpression("not_imported")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 35, "not_imported = 35")
 
-# Disabled the "imported" test since it isn't valid. It should actually test for ambiguity
-#test_result = frame.EvaluateExpression("imported")
-#self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "imported = 99")
-
-test_result = frame.EvaluateExpression("::imported")
-self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 89, "::imported = 89")
+# Currently there is no way to distinguish between "::imported" and "imported" in ClangExpressionDeclMap so this fails
+#test_result = frame.EvaluateExpression("::imported")
+#self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 89, "::imported = 89")
 
 test_result = frame.EvaluateExpression("Imported::imported")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 99, "Imported::imported = 99")
+
+test_result = frame.EvaluateExpression("imported")
+self.assertTrue(test_result.IsValid() and test_result.GetError().Fail(), "imported is ambiguous")
 
 test_result = frame.EvaluateExpression("single")
 self.assertTrue(test_result.IsValid() and test_result.GetValueAsSigned() == 3, "single = 3")
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -1730,24 +1730,6 @@
 // BAD!!!
 }
 }
-
-
-if (namespace_decl)
-{
-// If we make it here, we are creating the anonymous namespace decl
-// for the first time, so we need to do the using directive magic
-// like SEMA does
-UsingDirectiveDecl* using_directive_decl = UsingDirectiveDecl::Create (*ast, 
-   decl_ctx, 
-   SourceLocation(),
-   SourceLocation(),
-   NestedNameSpecifierLoc(),
-   SourceLocation(),
-   namespace_decl,
-   decl_ctx);
-using_directive_decl->setImplicit();
-decl_ctx->addDecl(using_directive_decl);
-}
 }
 #ifdef LLDB_CONFIGURATION_DEBUG
 VerifyDecl(namespace_decl);
@@ -1768,20 +1750,37 @@
 return nullptr;
 }
 
+clang::DeclContext *
+FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
+{
+if (root == nullptr)
+return nullptr;
+
+std::set path_left;
+for (clang::DeclContext *d = left; d != nullptr; d = d->getParent())
+path_left.insert(d);
+
+for (clang::DeclContext *d = right; d != nullptr; d = d->getParent())
+if (path_left.find(d) != path_left.end())
+return d;
+
+return nullptr;
+}
+
 clang::UsingDirectiveDecl *
 ClangASTContext::CreateUsingDirectiveDeclaration (clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl)
 {
 if (decl_ctx != nullptr && ns_decl != nullptr)
 {
-// TODO: run LCA between decl_tx 

[Lldb-commits] [lldb] r247836 - Add using directives to the clang::DeclContext and fix decls for variables inside namespaces

2015-09-16 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Wed Sep 16 13:48:30 2015
New Revision: 247836

URL: http://llvm.org/viewvc/llvm-project?rev=247836&view=rev
Log:
Add using directives to the clang::DeclContext and fix decls for variables 
inside namespaces

Summary: Supports the parsing of the "using namespace XXX" and "using XXX::XXX" 
directives. Added ambiguity errors when it two decls with the same name are 
encountered (see comments in TestCppNsImport). Fixes using directives being 
duplicated for anonymous namespaces. Fixes GetDeclForUID for specification DIEs.

Reviewers: sivachandra, chaoren, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D12897

Modified:
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/test/lang/cpp/nsimport/TestCppNsImport.py

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=247836&r1=247835&r2=247836&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Wed Sep 16 13:48:30 2015
@@ -131,6 +131,7 @@ public:
 virtual size_t  ParseVariablesForContext (const SymbolContext& sc) 
= 0;
 virtual Type*   ResolveTypeUID (lldb::user_id_t type_uid) = 0;
 virtual boolCompleteType (CompilerType &clang_type) = 0;
+virtual voidParseDeclsForContext (CompilerDeclContext 
decl_ctx) {}
 virtual CompilerDeclGetDeclForUID (lldb::user_id_t uid) { return 
CompilerDecl(); }
 virtual CompilerDeclContext GetDeclContextForUID (lldb::user_id_t uid) { 
return CompilerDeclContext(); }
 virtual CompilerDeclContext GetDeclContextContainingUID (lldb::user_id_t 
uid) { return CompilerDeclContext(); }

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=247836&r1=247835&r2=247836&view=diff
==
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 16 13:48:30 
2015
@@ -1351,7 +1351,6 @@ ClangExpressionDeclMap::FindExternalVisi
 {
 ValueObjectSP valobj;
 VariableSP var;
-Error err;
 
 if (frame && !namespace_decl)
 {
@@ -1366,17 +1365,21 @@ ClangExpressionDeclMap::FindExternalVisi
 
 // Search for declarations matching the name
 std::vector found_decls = 
compiler_decl_context.FindDeclByName(name);
+
+bool variable_found = false;
 for (CompilerDecl decl : found_decls)
 {
 var = decl.GetAsVariable();
 if (var)
 {
+variable_found = true;
 valobj = ValueObjectVariable::Create(frame, var);
 AddOneVariable(context, var, valobj, current_id);
 context.m_found.variable = true;
-return;
 }
 }
+if (variable_found)
+return;
 }
 }
 if (target)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h?rev=247836&r1=247835&r2=247836&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h Wed Sep 16 
13:48:30 2015
@@ -45,6 +45,9 @@ public:
 
 virtual lldb_private::CompilerDeclContext
 GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) = 0;
+
+virtual std::vector
+GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) = 0;
 };
 
 #endif  // SymbolFileDWARF_DWARFASTParser_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=247836&r1=247835&r2=247836&view=diff
==
--- lldb/trunk/source/Plu

[Lldb-commits] [PATCH] D12942: Fix caching for clang::Decl in DWARFASTParserClang

2015-09-17 Thread Paul Herman via lldb-commits
paulherman created this revision.
paulherman added reviewers: sivachandra, chaoren, tberghammer, clayborg.
paulherman added a subscriber: lldb-commits.

http://reviews.llvm.org/D12942

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,19 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = 
GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = m_die_to_decl[die.GetDIE()];
 switch (die.Tag())
 {
 case DW_TAG_variable:


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,19 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = m_die_to_decl[die.GetDIE()];
 switch (die.Tag())
 {
 case DW_TAG_variable:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12942: Fix caching for clang::Decl in DWARFASTParserClang

2015-09-17 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 35017.
paulherman added a comment.

Fix caching for clang::Decl in DWARFASTParserClang


http://reviews.llvm.org/D12942

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+const std::set tags_with_decls { DW_TAG_variable, 
DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, 
DW_TAG_imported_declaration };
+if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+return nullptr;
+
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = 
GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+const std::set tags_with_decls { DW_TAG_variable, DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, DW_TAG_imported_declaration };
+if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+return nullptr;
+
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12942: Fix caching for clang::Decl in DWARFASTParserClang

2015-09-17 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 35019.
paulherman added a comment.

Fix caching for clang::Decl in DWARFASTParserClang

Fixed small mistakes from previous commit.


http://reviews.llvm.org/D12942

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+const std::set tags_with_decls { DW_TAG_variable, 
DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, 
DW_TAG_imported_declaration };
+if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+return nullptr;
+
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(spec_die);
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+const std::set tags_with_decls { DW_TAG_variable, DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, DW_TAG_imported_declaration };
+if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+return nullptr;
+
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(spec_die);
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12942: Fix caching for clang::Decl in DWARFASTParserClang

2015-09-17 Thread Paul Herman via lldb-commits
paulherman updated this revision to Diff 35026.
paulherman added a comment.

Fix caching for clang::Decl in DWARFASTParserClang

Changed from std::set to switch. Rebased the patch.


http://reviews.llvm.org/D12942

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,31 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+switch (die.Tag())
+{
+case DW_TAG_variable:
+case DW_TAG_constant:
+case DW_TAG_formal_parameter:
+case DW_TAG_imported_declaration:
+case DW_TAG_imported_module:
+break;
+default:
+return nullptr;
+}
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
+
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(spec_die);
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,31 @@
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+switch (die.Tag())
+{
+case DW_TAG_variable:
+case DW_TAG_constant:
+case DW_TAG_formal_parameter:
+case DW_TAG_imported_declaration:
+case DW_TAG_imported_module:
+break;
+default:
+return nullptr;
+}
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
+
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(spec_die);
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r247923 - Fix caching for clang::Decl in DWARFASTParserClang

2015-09-17 Thread Paul Herman via lldb-commits
Author: paulherman
Date: Thu Sep 17 14:32:02 2015
New Revision: 247923

URL: http://llvm.org/viewvc/llvm-project?rev=247923&view=rev
Log:
Fix caching for clang::Decl in DWARFASTParserClang

Reviewers: sivachandra, chaoren, clayborg, tberghammer

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D12942

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=247923&r1=247922&r2=247923&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Sep 
17 14:32:02 2015
@@ -3225,13 +3225,31 @@ DWARFASTParserClang::GetClangDeclForDIE
 if (!die)
 return nullptr;
 
-if (die.GetReferencedDIE(DW_AT_specification))
-return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+switch (die.Tag())
+{
+case DW_TAG_variable:
+case DW_TAG_constant:
+case DW_TAG_formal_parameter:
+case DW_TAG_imported_declaration:
+case DW_TAG_imported_module:
+break;
+default:
+return nullptr;
+}
 
-clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-if (decl != nullptr)
+DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+if (cache_pos != m_die_to_decl.end())
+return cache_pos->second;
+
+if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+{
+clang::Decl *decl = GetClangDeclForDIE(spec_die);
+m_die_to_decl[die.GetDIE()] = decl;
+m_decl_to_die[decl].insert(die.GetDIE());
 return decl;
+}
 
+clang::Decl *decl = nullptr;
 switch (die.Tag())
 {
 case DW_TAG_variable:


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits