1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
"""
Make sure FindTypes finds struct types with the struct prefix.
"""
from __future__ import print_function
import os
import time
import re
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class TestFindTypesOnStructType(TestBase):
mydir = TestBase.compute_mydir(__file__)
# If your test case doesn't stress debug info, the
# set this to true. That way it won't be run once for
# each debug info format.
NO_DEBUG_INFO_TESTCASE = True
def test_find_types_struct_type(self):
"""Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
self.build()
self.do_test()
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
def do_test(self):
"""Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# Make sure this works with struct
type_list = target.FindTypes("struct mytype")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with struct")
# Make sure this works without the struct:
type_list = target.FindTypes("mytype")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without struct")
# Make sure it works with union
type_list = target.FindTypes("union myunion")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with union")
# Make sure this works without the union:
type_list = target.FindTypes("myunion")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without union")
# Make sure it works with typedef
type_list = target.FindTypes("typedef MyType")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with typedef")
# Make sure this works without the typedef:
type_list = target.FindTypes("MyType")
self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without typedef")
|