Author: Ilya Bukonkin
Date: 2020-10-29T23:44:51+03:00
New Revision: 2c0cbc47cae4e69195a883771664ef3d5a54c7d2
URL:
https://github.com/llvm/llvm-project/commit/2c0cbc47cae4e69195a883771664ef3d5a54c7d2
DIFF:
https://github.com/llvm/llvm-project/commit/2c0cbc47cae4e69195a883771664ef3d5a54c7d2.diff
LOG: GetModule, GetExeModule methods added
Added:
lldb/test/API/functionalities/type_get_module/Makefile
lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
lldb/test/API/functionalities/type_get_module/compile_unit1.c
lldb/test/API/functionalities/type_get_module/compile_unit2.c
lldb/test/API/functionalities/type_get_module/main.c
Modified:
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBModule.h
lldb/include/lldb/API/SBType.h
lldb/include/lldb/Symbol/Type.h
lldb/source/API/SBType.cpp
lldb/source/Symbol/Type.cpp
Removed:
diff --git a/lldb/bindings/interface/SBType.i
b/lldb/bindings/interface/SBType.i
index 3cd82452084b..fd2dda188454 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -277,6 +277,9 @@ public:
lldb::SBTypeEnumMemberList
GetEnumMembers();
+lldb::SBModule
+GetModule();
+
const char*
GetName();
@@ -330,6 +333,7 @@ public:
return template_args
return None
+module = property(GetModule, None, doc='''A read only property that
returns the module in which type is defined.''')
name = property(GetName, None, doc='''A read only property that
returns the name for this type as a string.''')
size = property(GetByteSize, None, doc='''A read only property that
returns size in bytes for this type as an integer.''')
is_pointer = property(IsPointerType, None, doc='''A read only property
that returns a boolean value that indicates if this type is a pointer type.''')
diff --git a/lldb/include/lldb/API/SBModule.h
b/lldb/include/lldb/API/SBModule.h
index ec6e7c21b058..dd783fe4107d 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -300,6 +300,7 @@ class LLDB_API SBModule {
friend class SBSection;
friend class SBSymbolContext;
friend class SBTarget;
+ friend class SBType;
explicit SBModule(const lldb::ModuleSP &module_sp);
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index b0af43351192..5f487aa5d258 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -185,6 +185,8 @@ class SBType {
lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx);
+ lldb::SBModule GetModule();
+
const char *GetName();
const char *GetDisplayTypeName();
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 06fc1d5da0aa..dd917cfb7ca8 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -109,12 +109,18 @@ class Type : public std::enable_shared_from_this,
public UserID {
void DumpTypeName(Stream *s);
- // Since Type instances only keep a "SymbolFile *" internally, other classes
- // like TypeImpl need make sure the module is still around before playing
- // with
- // Type instances. They can store a weak pointer to the Module;
+ /// Since Type instances only keep a "SymbolFile *" internally, other classes
+ /// like TypeImpl need make sure the module is still around before playing
+ /// with
+ /// Type instances. They can store a weak pointer to the Module;
lldb::ModuleSP GetModule();
+ /// GetModule may return module for compile unit's object file.
+ /// GetExeModule returns module for executable object file that contains
+ /// compile unit where type was actualy defined.
+ /// GetModule and GetExeModule may return the same value.
+ lldb::ModuleSP GetExeModule();
+
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name,
ExecutionContextScope *exe_scope);
@@ -261,6 +267,8 @@ class TypeImpl {
void Clear();
+ lldb::ModuleSP GetModule() const;
+
ConstString GetName() const;
ConstString GetDisplayTypeName() const;
@@ -288,8 +296,12 @@ class TypeImpl {
private:
bool CheckModule(lldb::ModuleSP &module_sp) const;
+ bool CheckExeModule(lldb::ModuleSP &module_sp) const;
+ bool CheckModuleCommon(const lldb::ModuleWP &input_module_wp,
+ lldb::ModuleSP &module_sp) const;
lldb::ModuleWP m_module_wp;
+ lldb::ModuleWP m_exe_module_wp;
CompilerType m_static_type;
CompilerType m_dynamic_type;
};
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 1c1d4e3a3ed9..772ac87145bb 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -9,6 +9,7 @@
#include "lldb/API/SBType.h"
#include "SBReproducerPrivate.h"
#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBModule.h"
#include "lldb