[Lldb-commits] [lldb] r217816 - Fix JITLoaderGDB for 64-bit host and 32-bit target
Todd Fiala
todd.fiala at gmail.com
Mon Sep 15 12:55:27 PDT 2014
Author: tfiala
Date: Mon Sep 15 14:55:27 2014
New Revision: 217816
URL: http://llvm.org/viewvc/llvm-project?rev=217816&view=rev
Log:
Fix JITLoaderGDB for 64-bit host and 32-bit target
There are target pointer members in struct jit_code_entry and jit_descriptor.
Data layout of those structures should be decided by target, not host.
This fixes JITLoaderGDB for 64-bit host and 32-bit target.
See http://reviews.llvm.org/D5339 for more details.
Change by Tong Shen.
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=217816&r1=217815&r2=217816&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp Mon Sep 15 14:55:27 2014
@@ -36,21 +36,24 @@ typedef enum
JIT_UNREGISTER_FN
} jit_actions_t;
+#pragma pack(push, 4)
+template <typename ptr_t>
struct jit_code_entry
{
- struct jit_code_entry *next_entry;
- struct jit_code_entry *prev_entry;
- const char *symfile_addr;
+ ptr_t next_entry; // pointer
+ ptr_t prev_entry; // pointer
+ ptr_t symfile_addr; // pointer
uint64_t symfile_size;
};
-
+template <typename ptr_t>
struct jit_descriptor
{
uint32_t version;
uint32_t action_flag; // Values are jit_action_t
- struct jit_code_entry *relevant_entry;
- struct jit_code_entry *first_entry;
+ ptr_t relevant_entry; // pointer
+ ptr_t first_entry; // pointer
};
+#pragma pack(pop)
JITLoaderGDB::JITLoaderGDB (lldb_private::Process *process) :
JITLoader(process),
@@ -198,6 +201,17 @@ static void updateSectionLoadAddress(con
bool
JITLoaderGDB::ReadJITDescriptor(bool all_entries)
{
+ Target &target = m_process->GetTarget();
+ if (target.GetArchitecture().GetAddressByteSize() == 8)
+ return ReadJITDescriptorImpl<uint64_t>(all_entries);
+ else
+ return ReadJITDescriptorImpl<uint32_t>(all_entries);
+}
+
+template <typename ptr_t>
+bool
+JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries)
+{
if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS)
return false;
@@ -205,7 +219,7 @@ JITLoaderGDB::ReadJITDescriptor(bool all
Target &target = m_process->GetTarget();
ModuleList &module_list = target.GetImages();
- jit_descriptor jit_desc;
+ jit_descriptor<ptr_t> jit_desc;
const size_t jit_desc_size = sizeof(jit_desc);
Error error;
size_t bytes_read = m_process->DoReadMemory(
@@ -228,7 +242,7 @@ JITLoaderGDB::ReadJITDescriptor(bool all
while (jit_relevant_entry != 0)
{
- jit_code_entry jit_entry;
+ jit_code_entry<ptr_t> 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=217816&r1=217815&r2=217816&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h Mon Sep 15 14:55:27 2014
@@ -81,6 +81,10 @@ private:
bool
ReadJITDescriptor(bool all_entries);
+ template <typename ptr_t>
+ bool
+ ReadJITDescriptorImpl(bool all_entries);
+
static bool
JITDebugBreakpointHit(void *baton,
lldb_private::StoppointCallbackContext *context,
More information about the lldb-commits
mailing list