|
8 | 8 | from lldbsuite.test.lldbtest import * |
9 | 9 | from lldbsuite.test import lldbutil |
10 | 10 |
|
| 11 | + |
11 | 12 | class ProcessSaveCoreMinidumpTestCaseYaml(TestBase): |
12 | | - def process_from_yaml(self, yaml_file): |
13 | | - minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp") |
14 | | - self.yaml2obj(yaml_file, minidump_path) |
15 | | - self.target = self.dbg.CreateTarget(None) |
16 | | - self.process = self.target.LoadCore(minidump_path) |
17 | | - return self.process |
18 | | - |
19 | | - def test_saving_sub_memory_range(self): |
20 | | - """ |
21 | | - Validate we can save a Minidump for a subsection of a memory range. |
22 | | - I.E. |
23 | | - If our memory range is 0x1000-0x2000 nd the user specifies 0x1200-0x1800 |
24 | | - we should still capture 0x1200 to 0x1800 |
25 | | - """ |
26 | | - yaml = "minidump_mem64.yaml" |
27 | | - proc = self.process_from_yaml(yaml) |
28 | | - new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
29 | | - options = lldb.SBSaveCoreOptions() |
30 | | - options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
31 | | - options.SetPluginName("minidump") |
32 | | - options.SetStyle(lldb.eSaveCoreCustomOnly) |
33 | | - |
34 | | - size = 8 |
35 | | - begin = 0x7FFF12A84030 |
36 | | - end = begin + size |
37 | | - custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) |
38 | | - options.AddMemoryRegionToSave(custom_range) |
39 | | - |
40 | | - error = proc.SaveCore(options) |
41 | | - self.assertTrue(error.Success(), error.GetCString()) |
42 | | - core_target = self.dbg.CreateTarget(None) |
43 | | - core_process = core_target.LoadCore(new_minidump_path) |
44 | | - |
45 | | - error = lldb.SBError() |
46 | | - core_process.ReadMemory(begin, size, error) |
47 | | - self.assertTrue(error.Success(), error.GetCString()) |
48 | | - |
49 | | - # Try to read 1 byte past the end |
50 | | - core_process.ReadMemory(end + 1, 1, error) |
51 | | - self.assertTrue(error.Fail(), error.GetCString()) |
52 | | - |
53 | | - def test_saving_super_memory_range(self): |
54 | | - """ |
55 | | - Validate we can save a Minidump for a subsection of a memory range. |
56 | | - I.E. |
57 | | - If our memory range is 0x1000-0x2000 nd the user specifies 0x0800-0x2800 |
58 | | - we should still capture 0x1000-0x2000 |
59 | | - """ |
60 | | - yaml = "minidump_mem64.yaml" |
61 | | - proc = self.process_from_yaml(yaml) |
62 | | - new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
63 | | - options = lldb.SBSaveCoreOptions() |
64 | | - options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
65 | | - options.SetPluginName("minidump") |
66 | | - options.SetStyle(lldb.eSaveCoreCustomOnly) |
67 | | - |
68 | | - size = 0x2FD0 |
69 | | - begin = 0x7FFF12A84030 |
70 | | - end = begin + size |
71 | | - custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end + 16, 3, True, False) |
72 | | - options.AddMemoryRegionToSave(custom_range) |
73 | | - |
74 | | - error = proc.SaveCore(options) |
75 | | - self.assertTrue(error.Success(), error.GetCString()) |
76 | | - core_target = self.dbg.CreateTarget(None) |
77 | | - core_process = core_target.LoadCore(new_minidump_path) |
78 | | - |
79 | | - error = lldb.SBError() |
80 | | - core_process.ReadMemory(begin, size, error) |
81 | | - self.assertTrue(error.Success(), error.GetCString()) |
82 | | - |
83 | | - |
84 | | - def test_region_that_goes_out_of_bounds(self): |
85 | | - """ |
86 | | - Validate we can save a Minidump for a custom region |
87 | | - that includes an end that enters an invalid (---) page. |
88 | | - """ |
89 | | - yaml = "minidump_mem64.yaml" |
90 | | - proc = self.process_from_yaml(yaml) |
91 | | - new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
92 | | - options = lldb.SBSaveCoreOptions() |
93 | | - options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
94 | | - options.SetPluginName("minidump") |
95 | | - options.SetStyle(lldb.eSaveCoreCustomOnly) |
96 | | - |
97 | | - size = 1024 |
98 | | - begin = 0x00007fff12a8ffff |
99 | | - end = begin + size |
100 | | - custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) |
101 | | - options.AddMemoryRegionToSave(custom_range) |
102 | | - |
103 | | - error = proc.SaveCore(options) |
104 | | - self.assertTrue(error.Success(), error.GetCString()) |
105 | | - core_target = self.dbg.CreateTarget(None) |
106 | | - core_process = core_target.LoadCore(new_minidump_path) |
107 | | - |
108 | | - error = lldb.SBError() |
109 | | - core_process.ReadMemory(begin, 0x00000020, error) |
110 | | - self.assertTrue(error.Success(), error.GetCString()) |
111 | | - |
112 | | - # Whole region should be unavailable |
113 | | - core_process.ReadMemory(end, 1, error) |
114 | | - self.assertTrue(error.Fail(), error.GetCString()) |
115 | | - |
116 | | - def test_region_that_starts_out_of_bounds(self): |
117 | | - """ |
118 | | - Validate we can save a Minidump for a custom region |
119 | | - that includes a start in a (---) page but ends in a valid page. |
120 | | - """ |
121 | | - yaml = "minidump_mem64.yaml" |
122 | | - proc = self.process_from_yaml(yaml) |
123 | | - new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
124 | | - options = lldb.SBSaveCoreOptions() |
125 | | - options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
126 | | - options.SetPluginName("minidump") |
127 | | - options.SetStyle(lldb.eSaveCoreCustomOnly) |
128 | | - |
129 | | - size = 0x00000020 |
130 | | - begin = 0x00007fff12a8ffff |
131 | | - end = begin + size |
132 | | - custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end, 3, True, False) |
133 | | - options.AddMemoryRegionToSave(custom_range) |
134 | | - |
135 | | - error = proc.SaveCore(options) |
136 | | - self.assertTrue(error.Success(), error.GetCString()) |
137 | | - core_target = self.dbg.CreateTarget(None) |
138 | | - core_process = core_target.LoadCore(new_minidump_path) |
139 | | - |
140 | | - error = lldb.SBError() |
141 | | - core_process.ReadMemory(begin, 0x00000020, error) |
142 | | - self.assertTrue(error.Success(), error.GetCString()) |
| 13 | + def process_from_yaml(self, yaml_file): |
| 14 | + minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp") |
| 15 | + self.yaml2obj(yaml_file, minidump_path) |
| 16 | + self.target = self.dbg.CreateTarget(None) |
| 17 | + self.process = self.target.LoadCore(minidump_path) |
| 18 | + return self.process |
| 19 | + |
| 20 | + def test_saving_sub_memory_range(self): |
| 21 | + """ |
| 22 | + Validate we can save a Minidump for a subsection of a memory range. |
| 23 | + I.E. |
| 24 | + If our memory range is 0x1000-0x2000 nd the user specifies 0x1200-0x1800 |
| 25 | + we should still capture 0x1200 to 0x1800 |
| 26 | + """ |
| 27 | + yaml = "minidump_mem64.yaml" |
| 28 | + proc = self.process_from_yaml(yaml) |
| 29 | + new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
| 30 | + options = lldb.SBSaveCoreOptions() |
| 31 | + options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
| 32 | + options.SetPluginName("minidump") |
| 33 | + options.SetStyle(lldb.eSaveCoreCustomOnly) |
| 34 | + |
| 35 | + size = 8 |
| 36 | + begin = 0x7FFF12A84030 |
| 37 | + end = begin + size |
| 38 | + custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) |
| 39 | + options.AddMemoryRegionToSave(custom_range) |
| 40 | + |
| 41 | + error = proc.SaveCore(options) |
| 42 | + self.assertTrue(error.Success(), error.GetCString()) |
| 43 | + core_target = self.dbg.CreateTarget(None) |
| 44 | + core_process = core_target.LoadCore(new_minidump_path) |
| 45 | + |
| 46 | + error = lldb.SBError() |
| 47 | + core_process.ReadMemory(begin, size, error) |
| 48 | + self.assertTrue(error.Success(), error.GetCString()) |
| 49 | + |
| 50 | + # Try to read 1 byte past the end |
| 51 | + core_process.ReadMemory(end + 1, 1, error) |
| 52 | + self.assertTrue(error.Fail(), error.GetCString()) |
| 53 | + |
| 54 | + def test_saving_super_memory_range(self): |
| 55 | + """ |
| 56 | + Validate we can save a Minidump for a subsection of a memory range. |
| 57 | + I.E. |
| 58 | + If our memory range is 0x1000-0x2000 nd the user specifies 0x0800-0x2800 |
| 59 | + we should still capture 0x1000-0x2000 |
| 60 | + """ |
| 61 | + yaml = "minidump_mem64.yaml" |
| 62 | + proc = self.process_from_yaml(yaml) |
| 63 | + new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
| 64 | + options = lldb.SBSaveCoreOptions() |
| 65 | + options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
| 66 | + options.SetPluginName("minidump") |
| 67 | + options.SetStyle(lldb.eSaveCoreCustomOnly) |
| 68 | + |
| 69 | + size = 0x2FD0 |
| 70 | + begin = 0x7FFF12A84030 |
| 71 | + end = begin + size |
| 72 | + custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end + 16, 3, True, False) |
| 73 | + options.AddMemoryRegionToSave(custom_range) |
| 74 | + |
| 75 | + error = proc.SaveCore(options) |
| 76 | + self.assertTrue(error.Success(), error.GetCString()) |
| 77 | + core_target = self.dbg.CreateTarget(None) |
| 78 | + core_process = core_target.LoadCore(new_minidump_path) |
| 79 | + |
| 80 | + error = lldb.SBError() |
| 81 | + core_process.ReadMemory(begin, size, error) |
| 82 | + self.assertTrue(error.Success(), error.GetCString()) |
| 83 | + |
| 84 | + def test_region_that_goes_out_of_bounds(self): |
| 85 | + """ |
| 86 | + Validate we can save a Minidump for a custom region |
| 87 | + that includes an end that enters an invalid (---) page. |
| 88 | + """ |
| 89 | + yaml = "minidump_mem64.yaml" |
| 90 | + proc = self.process_from_yaml(yaml) |
| 91 | + new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
| 92 | + options = lldb.SBSaveCoreOptions() |
| 93 | + options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
| 94 | + options.SetPluginName("minidump") |
| 95 | + options.SetStyle(lldb.eSaveCoreCustomOnly) |
| 96 | + |
| 97 | + size = 1024 |
| 98 | + begin = 0x00007FFF12A8FFFF |
| 99 | + end = begin + size |
| 100 | + custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) |
| 101 | + options.AddMemoryRegionToSave(custom_range) |
| 102 | + |
| 103 | + error = proc.SaveCore(options) |
| 104 | + self.assertTrue(error.Success(), error.GetCString()) |
| 105 | + core_target = self.dbg.CreateTarget(None) |
| 106 | + core_process = core_target.LoadCore(new_minidump_path) |
| 107 | + |
| 108 | + error = lldb.SBError() |
| 109 | + core_process.ReadMemory(begin, 0x00000020, error) |
| 110 | + self.assertTrue(error.Success(), error.GetCString()) |
| 111 | + |
| 112 | + # Whole region should be unavailable |
| 113 | + core_process.ReadMemory(end, 1, error) |
| 114 | + self.assertTrue(error.Fail(), error.GetCString()) |
| 115 | + |
| 116 | + def test_region_that_starts_out_of_bounds(self): |
| 117 | + """ |
| 118 | + Validate we can save a Minidump for a custom region |
| 119 | + that includes a start in a (---) page but ends in a valid page. |
| 120 | + """ |
| 121 | + yaml = "minidump_mem64.yaml" |
| 122 | + proc = self.process_from_yaml(yaml) |
| 123 | + new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") |
| 124 | + options = lldb.SBSaveCoreOptions() |
| 125 | + options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) |
| 126 | + options.SetPluginName("minidump") |
| 127 | + options.SetStyle(lldb.eSaveCoreCustomOnly) |
| 128 | + |
| 129 | + size = 0x00000020 |
| 130 | + begin = 0x00007FFF12A8FFFF |
| 131 | + end = begin + size |
| 132 | + custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end, 3, True, False) |
| 133 | + options.AddMemoryRegionToSave(custom_range) |
| 134 | + |
| 135 | + error = proc.SaveCore(options) |
| 136 | + self.assertTrue(error.Success(), error.GetCString()) |
| 137 | + core_target = self.dbg.CreateTarget(None) |
| 138 | + core_process = core_target.LoadCore(new_minidump_path) |
| 139 | + |
| 140 | + error = lldb.SBError() |
| 141 | + core_process.ReadMemory(begin, 0x00000020, error) |
| 142 | + self.assertTrue(error.Success(), error.GetCString()) |
0 commit comments