Skip to content

Commit 9ed3914

Browse files
committed
Implement feedback from Dave
1 parent a823853 commit 9ed3914

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Note that currently ELF Core files are not supported."
6464
) lldb::SBSaveCoreOptions::GetThreadsToSave;
6565

6666
%feature("docstring", "
67-
Get the current total number of bytes the core is expectd to have, excluding the overhead of the core file format.
68-
Requires both a Process and a Style to be specified."
67+
Get the current total number of bytes the core is expected to have, excluding the overhead of the core file format.
68+
Requires both a Process and a Style to be specified. An error will be returned if the provided options would result in no data being saved."
6969
) lldb::SBSaveCoreOptions::GetCurrentSizeInBytes;
7070

7171
%feature("docstring", "

lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,62 @@ def test_removing_and_adding_insertion_order(self):
105105
self.assertEqual(thread_collection.GetSize(), 3)
106106
self.assertIn(middle_thread, thread_collection)
107107

108-
def test_get_total_in_bytes(self):
108+
def test_get_current_size_in_bytes(self):
109109
"""
110-
Tests that get total in bytes properly returns an error without a process,
110+
Tests that ensures GetCurrentSizeInBytes properly returns an error without a process,
111111
and the readable regions with a process.
112112
"""
113113

114114
options = lldb.SBSaveCoreOptions()
115115
options.SetStyle(lldb.eSaveCoreCustomOnly)
116116
process = self.get_basic_process()
117117
memory_range = lldb.SBMemoryRegionInfo()
118-
process.GetMemoryRegionInfo(0x7FFF12A84030, memory_range)
118+
119+
# Add the memory range of 0x1000-0x1100
120+
process.GetMemoryRegionInfo(0x1000, memory_range)
119121
options.AddMemoryRegionToSave(memory_range)
122+
123+
# Check that we fail when we have no process set
124+
# even though we added a memory region.
120125
error = lldb.SBError()
121126
total = options.GetCurrentSizeInBytes(error)
122127
self.assertTrue(error.Fail(), error.GetCString())
128+
129+
# Check that we don't get an error now that we've added a process
123130
options.SetProcess(process)
124131
total = options.GetCurrentSizeInBytes(error)
125132
self.assertTrue(error.Success(), error.GetCString())
133+
134+
# Validate the size returned is the same size as the single region we added.
126135
expected_size = memory_range.GetRegionEnd() - memory_range.GetRegionBase()
127136
self.assertEqual(total, expected_size)
137+
138+
def test_get_total_in_bytes_missing_requirements(self):
139+
"""
140+
Tests the matrix of error responses that GetCurrentSizeInBytes
141+
"""
142+
143+
options = lldb.SBSaveCoreOptions()
144+
145+
# No process, no style returns an error.
146+
error = lldb.SBError()
147+
total = options.GetCurrentSizeInBytes(error)
148+
self.assertTrue(error.Fail(), error.GetCString())
149+
150+
# No process returns an error
151+
options.SetStyle(lldb.eSaveCoreCustomOnly)
152+
total = options.GetCurrentSizeInBytes(error)
153+
self.assertTrue(error.Fail(), error.GetCString())
154+
155+
options.Clear()
156+
157+
# No style returns an error
158+
process = self.get_basic_process()
159+
options.SetProcess(process)
160+
total = options.GetCurrentSizeInBytes(error)
161+
self.assertTrue(error.Fail(), error.GetCString())
162+
163+
# Options that result in no valid data returns an error.
164+
options.SetStyle(lldb.eSaveCoreCustomOnly)
165+
total = options.GetCurrentSizeInBytes(error)
166+
self.assertTrue(error.Fail(), error.GetCString())

lldb/test/API/python_api/sbsavecoreoptions/basic_minidump.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Streams:
3636
Content: 'BAADBEEF'
3737
- Type: Memory64List
3838
Memory Ranges:
39-
- Start of Memory Range: 0x7FFF12A84030
40-
Data Size: 0x2FD0
39+
- Start of Memory Range: 0x1000
40+
Data Size: 0x100
41+
Content : ''
42+
- Start of Memory Range: 0x2000
43+
Data Size: 0x200
4144
Content : ''

0 commit comments

Comments
 (0)