mamai created this revision.
mamai added a reviewer: clayborg.
mamai added a subscriber: lldb-commits.
mamai set the repository for this revision to rL LLVM.

When the parent of an expression is anonymous, skip adding '.' or '->' before 
the expression name.

Repository:
  rL LLVM

http://reviews.llvm.org/D18005

Files:
  packages/Python/lldbsuite/test/functionalities/expression_path/Makefile
  
packages/Python/lldbsuite/test/functionalities/expression_path/TestExpressionPath.py
  packages/Python/lldbsuite/test/functionalities/expression_path/main.cpp
  source/Core/ValueObject.cpp

Index: source/Core/ValueObject.cpp
===================================================================
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -2536,7 +2536,7 @@
         if (!is_deref_of_parent)
         {
             ValueObject *non_base_class_parent = GetNonBaseClassParent();
-            if (non_base_class_parent)
+            if (non_base_class_parent && !non_base_class_parent->GetName().IsEmpty())
             {
                 CompilerType non_base_class_parent_compiler_type = non_base_class_parent->GetCompilerType();
                 if (non_base_class_parent_compiler_type)
Index: packages/Python/lldbsuite/test/functionalities/expression_path/main.cpp
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/expression_path/main.cpp
@@ -0,0 +1,27 @@
+//===-- main.c ------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+struct S
+{
+	union 
+	{
+		unsigned r[2];
+		struct	{
+			int x;
+			int y;
+		};
+	};
+};
+
+int main()
+{
+	struct S s = { 1, 2 };
+	return 0; // Set break point at this line.
+}
\ No newline at end of file
Index: packages/Python/lldbsuite/test/functionalities/expression_path/TestExpressionPath.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/expression_path/TestExpressionPath.py
@@ -0,0 +1,46 @@
+"""
+Test the Expression Path.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import re
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class ExpressionPathTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break inside main().
+        self.line = line_number('main.cpp', '// Set break point at this line.')
+
+    def test_expression_path(self):
+        """Test the GetExpressionPath() function of ValueObject using 'frame variable --flat' command."""
+        self.build()
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Break in main() after the variables are assigned values.
+        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['stopped', 'stop reason = breakpoint'])
+
+        # The breakpoint should have a hit count of 1.
+        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
+			
+        self.expect('frame variable s --flat',
+                    substrs = ['s.x = 1',
+                               's.y = 2'])
\ No newline at end of file
Index: packages/Python/lldbsuite/test/functionalities/expression_path/Makefile
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/expression_path/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to