mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[lldb][LocateModuleCallback] Update SBFileSpec/SBModuleSpec
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580 SBFileSpec and SBModuleSpec will be used for locate module callback as Python function arguments. This diff allows these things. - Can be instantiated from SBPlatform. - Can be passed to/from Python. - Can be accessed for object offset and size. Differential Revision: https://reviews.llvm.org/D153733
This commit is contained in:
committed by
Kazuki Sakamoto
parent
e9877eca40
commit
c4fa6fafc4
@@ -120,5 +120,15 @@ ScopedPythonObject<lldb::SBEvent> SWIGBridge::ToSWIGWrapper(Event *event) {
|
||||
SWIGTYPE_p_lldb__SBEvent);
|
||||
}
|
||||
|
||||
PythonObject SWIGBridge::ToSWIGWrapper(
|
||||
std::unique_ptr<lldb::SBFileSpec> file_spec_sb) {
|
||||
return ToSWIGHelper(file_spec_sb.release(), SWIGTYPE_p_lldb__SBFileSpec);
|
||||
}
|
||||
|
||||
PythonObject SWIGBridge::ToSWIGWrapper(
|
||||
std::unique_ptr<lldb::SBModuleSpec> module_spec_sb) {
|
||||
return ToSWIGHelper(module_spec_sb.release(), SWIGTYPE_p_lldb__SBModuleSpec);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace lldb_private
|
||||
|
||||
@@ -77,13 +77,24 @@ public:
|
||||
|
||||
bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len);
|
||||
|
||||
uint64_t GetObjectOffset();
|
||||
|
||||
void SetObjectOffset(uint64_t object_offset);
|
||||
|
||||
uint64_t GetObjectSize();
|
||||
|
||||
void SetObjectSize(uint64_t object_size);
|
||||
|
||||
bool GetDescription(lldb::SBStream &description);
|
||||
|
||||
private:
|
||||
friend class SBModuleSpecList;
|
||||
friend class SBModule;
|
||||
friend class SBPlatform;
|
||||
friend class SBTarget;
|
||||
|
||||
SBModuleSpec(const lldb_private::ModuleSpec &module_spec);
|
||||
|
||||
std::unique_ptr<lldb_private::ModuleSpec> m_opaque_up;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) {
|
||||
m_opaque_up = clone(rhs.m_opaque_up);
|
||||
}
|
||||
|
||||
SBModuleSpec::SBModuleSpec(const lldb_private::ModuleSpec &module_spec)
|
||||
: m_opaque_up(new lldb_private::ModuleSpec(module_spec)) {
|
||||
LLDB_INSTRUMENT_VA(this, module_spec);
|
||||
}
|
||||
|
||||
const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
|
||||
LLDB_INSTRUMENT_VA(this, rhs);
|
||||
|
||||
@@ -145,6 +150,30 @@ bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t SBModuleSpec::GetObjectOffset() {
|
||||
LLDB_INSTRUMENT_VA(this);
|
||||
|
||||
return m_opaque_up->GetObjectOffset();
|
||||
}
|
||||
|
||||
void SBModuleSpec::SetObjectOffset(uint64_t object_offset) {
|
||||
LLDB_INSTRUMENT_VA(this, object_offset);
|
||||
|
||||
m_opaque_up->SetObjectOffset(object_offset);
|
||||
}
|
||||
|
||||
uint64_t SBModuleSpec::GetObjectSize() {
|
||||
LLDB_INSTRUMENT_VA(this);
|
||||
|
||||
return m_opaque_up->GetObjectSize();
|
||||
}
|
||||
|
||||
void SBModuleSpec::SetObjectSize(uint64_t object_size) {
|
||||
LLDB_INSTRUMENT_VA(this, object_size);
|
||||
|
||||
m_opaque_up->SetObjectSize(object_size);
|
||||
}
|
||||
|
||||
SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) {
|
||||
LLDB_INSTRUMENT_VA(this);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class SBCommandReturnObject;
|
||||
class SBValue;
|
||||
class SBStream;
|
||||
class SBStructuredData;
|
||||
class SBFileSpec;
|
||||
class SBModuleSpec;
|
||||
} // namespace lldb
|
||||
|
||||
namespace lldb_private {
|
||||
@@ -102,6 +104,10 @@ public:
|
||||
static PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb);
|
||||
static PythonObject
|
||||
ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb);
|
||||
static PythonObject
|
||||
ToSWIGWrapper(std::unique_ptr<lldb::SBFileSpec> file_spec_sb);
|
||||
static PythonObject
|
||||
ToSWIGWrapper(std::unique_ptr<lldb::SBModuleSpec> module_spec_sb);
|
||||
|
||||
static python::ScopedPythonObject<lldb::SBCommandReturnObject>
|
||||
ToSWIGWrapper(CommandReturnObject &cmd_retobj);
|
||||
|
||||
24
lldb/test/API/python_api/module_spec/TestModuleSpec.py
Normal file
24
lldb/test/API/python_api/module_spec/TestModuleSpec.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
Test some SBModuleSpec APIs.
|
||||
"""
|
||||
|
||||
import lldb
|
||||
from lldbsuite.test.decorators import *
|
||||
from lldbsuite.test.lldbtest import *
|
||||
|
||||
|
||||
class ModuleSpecAPIsTestCase(TestBase):
|
||||
def test_object_offset_and_size(self):
|
||||
module_spec = lldb.SBModuleSpec()
|
||||
self.assertEqual(module_spec.GetObjectOffset(), 0)
|
||||
self.assertEqual(module_spec.GetObjectSize(), 0)
|
||||
|
||||
module_spec.SetObjectOffset(4096)
|
||||
self.assertEqual(module_spec.GetObjectOffset(), 4096)
|
||||
|
||||
module_spec.SetObjectSize(3600)
|
||||
self.assertEqual(module_spec.GetObjectSize(), 3600)
|
||||
|
||||
module_spec.Clear()
|
||||
self.assertEqual(module_spec.GetObjectOffset(), 0)
|
||||
self.assertEqual(module_spec.GetObjectSize(), 0)
|
||||
Reference in New Issue
Block a user