-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LLDB][SBSaveCore] Sbsavecore subregions bug #138206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
91ce099
Change custom regions to be intersections, add test cases for sub reg…
Jlalond 024254e
GCF
Jlalond 200533a
Py formatting
Jlalond 811f64c
Clean up code duplication and use the existing functions on Range
Jlalond afb0a6a
Move test validation into helper method, do validation of expected an…
Jlalond 510cca8
Add test for a region that covers more than one actual region, plus o…
Jlalond 185d49f
Fix bug with the test helper method
Jlalond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidumpYaml.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| """ | ||
| Test saving a mini dump, from yamilized examples. | ||
| """ | ||
|
|
||
| import os | ||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| from lldbsuite.test.lldbtest import * | ||
| from lldbsuite.test import lldbutil | ||
|
|
||
|
|
||
dmpots marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class ProcessSaveCoreMinidumpTestCaseYaml(TestBase): | ||
| def process_from_yaml(self, yaml_file): | ||
| minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp") | ||
| self.yaml2obj(yaml_file, minidump_path) | ||
| self.target = self.dbg.CreateTarget(None) | ||
| self.process = self.target.LoadCore(minidump_path) | ||
| return self.process | ||
|
|
||
| def test_saving_sub_memory_range(self): | ||
| """ | ||
| Validate we can save a Minidump for a subsection of a memory range. | ||
| I.E. | ||
| If our memory range is 0x1000-0x2000 nd the user specifies 0x1200-0x1800 | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| we should still capture 0x1200 to 0x1800 | ||
| """ | ||
| yaml = "minidump_mem64.yaml" | ||
| proc = self.process_from_yaml(yaml) | ||
| new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") | ||
| options = lldb.SBSaveCoreOptions() | ||
| options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) | ||
| options.SetPluginName("minidump") | ||
| options.SetStyle(lldb.eSaveCoreCustomOnly) | ||
|
|
||
| size = 8 | ||
| begin = 0x7FFF12A84030 | ||
| end = begin + size | ||
| custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) | ||
| options.AddMemoryRegionToSave(custom_range) | ||
|
|
||
| error = proc.SaveCore(options) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
| core_target = self.dbg.CreateTarget(None) | ||
| core_process = core_target.LoadCore(new_minidump_path) | ||
|
|
||
| error = lldb.SBError() | ||
| core_process.ReadMemory(begin, size, error) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
|
|
||
| # Try to read 1 byte past the end | ||
| core_process.ReadMemory(end + 1, 1, error) | ||
| self.assertTrue(error.Fail(), error.GetCString()) | ||
|
|
||
| def test_saving_super_memory_range(self): | ||
| """ | ||
| Validate we can save a Minidump for a subsection of a memory range. | ||
| I.E. | ||
| If our memory range is 0x1000-0x2000 nd the user specifies 0x0800-0x2800 | ||
| we should still capture 0x1000-0x2000 | ||
| """ | ||
| yaml = "minidump_mem64.yaml" | ||
| proc = self.process_from_yaml(yaml) | ||
| new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") | ||
| options = lldb.SBSaveCoreOptions() | ||
| options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) | ||
| options.SetPluginName("minidump") | ||
| options.SetStyle(lldb.eSaveCoreCustomOnly) | ||
|
|
||
| size = 0x2FD0 | ||
| begin = 0x7FFF12A84030 | ||
| end = begin + size | ||
| custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end + 16, 3, True, False) | ||
| options.AddMemoryRegionToSave(custom_range) | ||
|
|
||
| error = proc.SaveCore(options) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
| core_target = self.dbg.CreateTarget(None) | ||
| core_process = core_target.LoadCore(new_minidump_path) | ||
|
|
||
| error = lldb.SBError() | ||
| core_process.ReadMemory(begin, size, error) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def test_region_that_goes_out_of_bounds(self): | ||
| """ | ||
| Validate we can save a Minidump for a custom region | ||
| that includes an end that enters an invalid (---) page. | ||
| """ | ||
| yaml = "minidump_mem64.yaml" | ||
| proc = self.process_from_yaml(yaml) | ||
| new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") | ||
| options = lldb.SBSaveCoreOptions() | ||
| options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) | ||
| options.SetPluginName("minidump") | ||
| options.SetStyle(lldb.eSaveCoreCustomOnly) | ||
|
|
||
| size = 1024 | ||
| begin = 0x00007FFF12A8FFFF | ||
| end = begin + size | ||
| custom_range = lldb.SBMemoryRegionInfo("", begin, end, 3, True, False) | ||
| options.AddMemoryRegionToSave(custom_range) | ||
|
|
||
| error = proc.SaveCore(options) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
| core_target = self.dbg.CreateTarget(None) | ||
| core_process = core_target.LoadCore(new_minidump_path) | ||
|
|
||
| error = lldb.SBError() | ||
| core_process.ReadMemory(begin, 0x00000020, error) | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.assertTrue(error.Success(), error.GetCString()) | ||
|
|
||
| # Whole region should be unavailable | ||
| core_process.ReadMemory(end, 1, error) | ||
Jlalond marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.assertTrue(error.Fail(), error.GetCString()) | ||
|
|
||
| def test_region_that_starts_out_of_bounds(self): | ||
| """ | ||
| Validate we can save a Minidump for a custom region | ||
| that includes a start in a (---) page but ends in a valid page. | ||
| """ | ||
| yaml = "minidump_mem64.yaml" | ||
| proc = self.process_from_yaml(yaml) | ||
| new_minidump_path = self.getBuildArtifact(__name__ + ".dmp") | ||
| options = lldb.SBSaveCoreOptions() | ||
| options.SetOutputFile(lldb.SBFileSpec(new_minidump_path)) | ||
| options.SetPluginName("minidump") | ||
| options.SetStyle(lldb.eSaveCoreCustomOnly) | ||
|
|
||
| size = 0x00000020 | ||
| begin = 0x00007FFF12A8FFFF | ||
| end = begin + size | ||
| custom_range = lldb.SBMemoryRegionInfo("", begin - 16, end, 3, True, False) | ||
| options.AddMemoryRegionToSave(custom_range) | ||
|
|
||
| error = proc.SaveCore(options) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
| core_target = self.dbg.CreateTarget(None) | ||
| core_process = core_target.LoadCore(new_minidump_path) | ||
|
|
||
| error = lldb.SBError() | ||
| core_process.ReadMemory(begin, 0x00000020, error) | ||
| self.assertTrue(error.Success(), error.GetCString()) | ||
Jlalond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
35 changes: 35 additions & 0 deletions
35
lldb/test/API/functionalities/process_save_core_minidump/minidump_mem64.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- !minidump | ||
| Streams: | ||
| - Type: SystemInfo | ||
| Processor Arch: AMD64 | ||
| Processor Level: 6 | ||
| Processor Revision: 15876 | ||
| Number of Processors: 40 | ||
| Platform ID: Linux | ||
| CSD Version: 'Linux 3.13.0-91-generic' | ||
| CPU: | ||
| Vendor ID: GenuineIntel | ||
| Version Info: 0x00000000 | ||
| Feature Info: 0x00000000 | ||
| - Type: ThreadList | ||
| Threads: | ||
| - Thread Id: 0x2896BB | ||
| Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700100000000000FFFFFFFF0000FFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B040A812FF7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050D0A75BBA7F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | ||
| Stack: | ||
| Start of Memory Range: 0x0 | ||
| Content: '' | ||
| - Type: Memory64List | ||
| Memory Ranges: | ||
| - Start of Memory Range: 0x7FFF12A84030 | ||
| Data Size: 0x2FD0 | ||
| Content : '' | ||
| - Start of Memory Range: 0x00007fff12a87000 | ||
| Data Size: 0x00000018 | ||
| Content : '' | ||
| - Start of Memory Range: 0x00007fff12a87018 | ||
| Data Size: 0x00000400 | ||
| Content : '' | ||
| - Start of Memory Range: 0x00007fff12a8ffff | ||
| Data Size: 0x00000020 | ||
| Content : '' | ||
| ... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.