diff options
| author | Med Ismail Bennani <medismail.bennani@gmail.com> | 2021-12-13 10:34:49 -0800 |
|---|---|---|
| committer | Med Ismail Bennani <medismail.bennani@gmail.com> | 2021-12-13 11:05:06 -0800 |
| commit | 72e25978f93f0bf7577593aba9591c727526423c (patch) | |
| tree | cbe54cbfd98c40d32edc7ed0c549c114ab7776be /lldb/test/API/python_api | |
| parent | bbfaf0b170b6070e08f1dc22419dfedc75b9a0fe (diff) | |
| download | llvm-72e25978f93f0bf7577593aba9591c727526423c.zip llvm-72e25978f93f0bf7577593aba9591c727526423c.tar.gz llvm-72e25978f93f0bf7577593aba9591c727526423c.tar.bz2 | |
[lldb/API] Add SetDataWithOwnership method to SBData
This patch introduces a new method to SBData: SetDataWithOwnership.
Instead of referencing the pointer to the data, this method copies the
data buffer into lldb's heap memory.
This can prevent having the underlying DataExtractor object point to
freed/garbage-collected memory.
Differential Revision: https://reviews.llvm.org/D115652
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/sbdata/TestSBData.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/sbdata/TestSBData.py b/lldb/test/API/python_api/sbdata/TestSBData.py index b845c0a..1b20cf2 100644 --- a/lldb/test/API/python_api/sbdata/TestSBData.py +++ b/lldb/test/API/python_api/sbdata/TestSBData.py @@ -39,6 +39,17 @@ class SBDataAPICase(TestBase): addr = data.GetAddress(error, 0) self.assertEqual(addr, 0x8877665544332211); + def test_byte_order_and_address_byte_size_with_ownership(self): + """Test the SBData::SetDataWithOwnership() to ensure the byte order + and address byte size are obeyed even when source date is released""" + addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88' + error = lldb.SBError() + data = lldb.SBData() + data.SetDataWithOwnership(error, addr_data, lldb.eByteOrderBig, 8) + del addr_data + addr = data.GetAddress(error, 0) + self.assertEqual(addr, 0x1122334455667788); + def test_with_run_command(self): """Test the SBData APIs.""" self.build() |
