1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.lldbtest import * 9import lldbsuite.test.lldbutil as lldbutil 10 11 12class Radar9974002DataFormatterTestCase(TestBase): 13 14 # test for rdar://problem/9974002 () 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to break at. 21 self.line = line_number('main.cpp', '// Set break point at this line.') 22 23 def test_with_run_command(self): 24 """Test that that file and class static variables display correctly.""" 25 self.build() 26 if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion(): 27 self.skipTest( 28 "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") 29 30 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 31 32 lldbutil.run_break_set_by_file_and_line( 33 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 34 35 self.runCmd("run", RUN_SUCCEEDED) 36 37 # The stop reason of the thread should be breakpoint. 38 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 39 substrs=['stopped', 40 'stop reason = breakpoint']) 41 42 # This is the function to remove the custom formats in order to have a 43 # clean slate for the next test case. 44 def cleanup(): 45 self.runCmd('type summary clear', check=False) 46 47 # Execute the cleanup function during test case tear down. 48 self.addTearDownHook(cleanup) 49 50 self.runCmd( 51 "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") 52 53 self.expect('frame variable mine', 54 substrs=['mine = ', 55 '1', '<parent is NULL>']) 56 57 self.runCmd( 58 "type summary add -s \"${var.scalar} and ${var.pointer}\" container") 59 60 self.expect('frame variable mine', 61 substrs=['mine = ', 62 '1', '0x000000']) 63 64 self.runCmd( 65 "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") 66 67 self.expect('frame variable mine', 68 substrs=['mine = ', 69 '1', '0x000000']) 70 71 self.runCmd("type summary add -s foo contained") 72 73 self.expect('frame variable mine', 74 substrs=['mine = ', 75 '1', 'foo']) 76 77 self.runCmd( 78 "type summary add -s \"${var.scalar} and ${var.pointer}\" container") 79 80 self.expect('frame variable mine', 81 substrs=['mine = ', 82 '1', 'foo']) 83 84 self.runCmd( 85 "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") 86 87 self.expect('frame variable mine', 88 substrs=['mine = ', 89 '1', '0x000000']) 90 91 self.runCmd( 92 "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") 93 94 self.expect('frame variable mine', 95 substrs=['mine = ', 96 '1', '<parent is NULL>']) 97 98 self.runCmd("type summary delete contained") 99 self.runCmd("n") 100 101 self.expect('frame variable mine', 102 substrs=['mine = ', 103 '1', '<parent is NULL>']) 104 105 self.runCmd( 106 "type summary add -s \"${var.scalar} and ${var.pointer}\" container") 107 108 self.expect('frame variable mine', 109 substrs=['mine = ', 110 '1', '0x000000']) 111 112 self.runCmd( 113 "type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") 114 115 self.expect('frame variable mine', 116 substrs=['mine = ', 117 '1', '0x000000']) 118 119 self.runCmd("type summary add -s foo contained") 120 121 self.expect('frame variable mine', 122 substrs=['mine = ', 123 '1', 'foo']) 124 125 self.runCmd( 126 "type summary add -s \"${var.scalar} and ${var.pointer}\" container") 127 128 self.expect('frame variable mine', 129 substrs=['mine = ', 130 '1', 'foo']) 131 132 self.runCmd( 133 "type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") 134 135 self.expect('frame variable mine', 136 substrs=['mine = ', 137 '1', '0x000000']) 138 139 self.runCmd( 140 "type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") 141 142 self.expect('frame variable mine', 143 substrs=['mine = ', 144 '1', '<parent is NULL>']) 145