[Lldb-commits] [lldb] r264012 - [JITLoaderGDB] Pack the jit entry struct according to the target arch.
Siva Chandra via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 21 17:35:31 PDT 2016
Author: sivachandra
Date: Mon Mar 21 19:35:31 2016
New Revision: 264012
URL: http://llvm.org/viewvc/llvm-project?rev=264012&view=rev
Log:
[JITLoaderGDB] Pack the jit entry struct according to the target arch.
Reviewers: clayborg
Subscribers: tberghammer, dsrbecky, lldb-commits
Differential Revision: http://reviews.llvm.org/D18334
Modified:
lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp?rev=264012&r1=264011&r2=264012&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp Mon Mar 21 19:35:31 2016
@@ -90,14 +90,24 @@ typedef enum
JIT_UNREGISTER_FN
} jit_actions_t;
-template <typename ptr_t>
+template <typename ptr_t, bool packed_size>
struct jit_code_entry
{
ptr_t next_entry; // pointer
ptr_t prev_entry; // pointer
ptr_t symfile_addr; // pointer
- uint64_t symfile_size;
+ uint64_t symfile_size __attribute__ ((aligned (8)));
+};
+
+template <typename ptr_t>
+struct jit_code_entry<ptr_t, true>
+{
+ ptr_t next_entry; // pointer
+ ptr_t prev_entry; // pointer
+ ptr_t symfile_addr; // pointer
+ uint64_t symfile_size __attribute__ ((packed));
};
+
template <typename ptr_t>
struct jit_descriptor
{
@@ -269,13 +279,20 @@ bool
JITLoaderGDB::ReadJITDescriptor(bool all_entries)
{
Target &target = m_process->GetTarget();
- if (target.GetArchitecture().GetAddressByteSize() == 8)
- return ReadJITDescriptorImpl<uint64_t>(all_entries);
+ const ArchSpec &arch_spec = target.GetArchitecture();
+ if (arch_spec.GetAddressByteSize() == 8)
+ return ReadJITDescriptorImpl<uint64_t, false>(all_entries);
else
- return ReadJITDescriptorImpl<uint32_t>(all_entries);
+ {
+ ArchSpec::Core core = arch_spec.GetCore();
+ if (ArchSpec::kCore_x86_32_first <= core && core <= ArchSpec::kCore_x86_32_last)
+ return ReadJITDescriptorImpl<uint32_t, true>(all_entries);
+ else
+ return ReadJITDescriptorImpl<uint32_t, false>(all_entries);
+ }
}
-template <typename ptr_t>
+template <typename ptr_t, bool packed>
bool
JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries)
{
@@ -309,7 +326,7 @@ JITLoaderGDB::ReadJITDescriptorImpl(bool
while (jit_relevant_entry != 0)
{
- jit_code_entry<ptr_t> jit_entry;
+ jit_code_entry<ptr_t, packed> jit_entry;
const size_t jit_entry_size = sizeof(jit_entry);
bytes_read = m_process->DoReadMemory(jit_relevant_entry, &jit_entry, jit_entry_size, error);
if (bytes_read != jit_entry_size || !error.Success())
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h?rev=264012&r1=264011&r2=264012&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h Mon Mar 21 19:35:31 2016
@@ -83,7 +83,7 @@ private:
bool
ReadJITDescriptor(bool all_entries);
- template <typename ptr_t>
+ template <typename ptr_t, bool packed>
bool
ReadJITDescriptorImpl(bool all_entries);
More information about the lldb-commits
mailing list