summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins')
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt5
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/Makefile14
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp364
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h142
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp31
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp1
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp1
7 files changed, 544 insertions, 14 deletions
diff --git a/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt
new file mode 100644
index 00000000000..1e87e1fba64
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectFileJIT
+ ObjectFileJIT.cpp
+ )
diff --git a/lldb/source/Plugins/ObjectFile/JIT/Makefile b/lldb/source/Plugins/ObjectFile/JIT/Makefile
new file mode 100644
index 00000000000..2af3521777a
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/JIT/Makefile
@@ -0,0 +1,14 @@
+##===- source/Plugins/ObjectFile/JIT/Makefile --------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../../..
+LIBRARYNAME := lldbPluginObjectFileJIT
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
new file mode 100644
index 00000000000..530e11af22c
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -0,0 +1,364 @@
+//===-- ObjectFileJIT.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/StringRef.h"
+
+#include "ObjectFileJIT.h"
+
+#include "lldb/lldb-private-log.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RangeMap.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/Core/UUID.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+
+#ifndef __APPLE__
+#include "Utility/UuidCompatibility.h"
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+void
+ObjectFileJIT::Initialize()
+{
+ PluginManager::RegisterPlugin (GetPluginNameStatic(),
+ GetPluginDescriptionStatic(),
+ CreateInstance,
+ CreateMemoryInstance,
+ GetModuleSpecifications);
+}
+
+void
+ObjectFileJIT::Terminate()
+{
+ PluginManager::UnregisterPlugin (CreateInstance);
+}
+
+
+lldb_private::ConstString
+ObjectFileJIT::GetPluginNameStatic()
+{
+ static ConstString g_name("jit");
+ return g_name;
+}
+
+const char *
+ObjectFileJIT::GetPluginDescriptionStatic()
+{
+ return "JIT code object file";
+}
+
+ObjectFile *
+ObjectFileJIT::CreateInstance (const lldb::ModuleSP &module_sp,
+ DataBufferSP& data_sp,
+ lldb::offset_t data_offset,
+ const FileSpec* file,
+ lldb::offset_t file_offset,
+ lldb::offset_t length)
+{
+ // JIT'ed object file is backed by the ObjectFileJITDelegate, never
+ // read from a file
+ return NULL;
+}
+
+ObjectFile *
+ObjectFileJIT::CreateMemoryInstance (const lldb::ModuleSP &module_sp,
+ DataBufferSP& data_sp,
+ const ProcessSP &process_sp,
+ lldb::addr_t header_addr)
+{
+ // JIT'ed object file is backed by the ObjectFileJITDelegate, never
+ // read from memory
+ return NULL;
+}
+
+size_t
+ObjectFileJIT::GetModuleSpecifications (const lldb_private::FileSpec& file,
+ lldb::DataBufferSP& data_sp,
+ lldb::offset_t data_offset,
+ lldb::offset_t file_offset,
+ lldb::offset_t length,
+ lldb_private::ModuleSpecList &specs)
+{
+ // JIT'ed object file can't be read from a file on disk
+ return 0;
+}
+
+ObjectFileJIT::ObjectFileJIT (const lldb::ModuleSP &module_sp,
+ const ObjectFileJITDelegateSP &delegate_sp) :
+ ObjectFile(module_sp, NULL, 0, 0, DataBufferSP(), 0),
+ m_delegate_wp ()
+{
+ if (delegate_sp)
+ {
+ m_delegate_wp = delegate_sp;
+ m_data.SetByteOrder(delegate_sp->GetByteOrder());
+ m_data.SetAddressByteSize(delegate_sp->GetAddressByteSize());
+ }
+}
+
+ObjectFileJIT::~ObjectFileJIT()
+{
+}
+
+
+bool
+ObjectFileJIT::ParseHeader ()
+{
+ // JIT code is never in a file, nor is it required to have any header
+ return false;
+}
+
+ByteOrder
+ObjectFileJIT::GetByteOrder () const
+{
+ return m_data.GetByteOrder();
+}
+
+bool
+ObjectFileJIT::IsExecutable() const
+{
+ return false;
+}
+
+uint32_t
+ObjectFileJIT::GetAddressByteSize () const
+{
+ return m_data.GetAddressByteSize();
+}
+
+
+Symtab *
+ObjectFileJIT::GetSymtab()
+{
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ if (m_symtab_ap.get() == NULL)
+ {
+ m_symtab_ap.reset(new Symtab(this));
+ Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
+ ObjectFileJITDelegateSP delegate_sp (m_delegate_wp.lock());
+ if (delegate_sp)
+ delegate_sp->PopulateSymtab(this, *m_symtab_ap);
+ // TODO: get symbols from delegate
+ m_symtab_ap->Finalize ();
+ }
+ }
+ return m_symtab_ap.get();
+}
+
+bool
+ObjectFileJIT::IsStripped ()
+{
+ return false; // JIT code that is in a module is never stripped
+}
+
+void
+ObjectFileJIT::CreateSections (SectionList &unified_section_list)
+{
+ if (!m_sections_ap.get())
+ {
+ m_sections_ap.reset(new SectionList());
+ ObjectFileJITDelegateSP delegate_sp (m_delegate_wp.lock());
+ if (delegate_sp)
+ {
+ delegate_sp->PopulateSectionList(this, *m_sections_ap);
+ unified_section_list = *m_sections_ap;
+ }
+ }
+}
+
+void
+ObjectFileJIT::Dump (Stream *s)
+{
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ s->Printf("%p: ", this);
+ s->Indent();
+ s->PutCString("ObjectFileJIT");
+
+ ArchSpec arch;
+ if (GetArchitecture(arch))
+ *s << ", arch = " << arch.GetArchitectureName();
+
+ s->EOL();
+
+ SectionList *sections = GetSectionList();
+ if (sections)
+ sections->Dump(s, NULL, true, UINT32_MAX);
+
+ if (m_symtab_ap.get())
+ m_symtab_ap->Dump(s, NULL, eSortOrderNone);
+ }
+}
+
+bool
+ObjectFileJIT::GetUUID (lldb_private::UUID* uuid)
+{
+ // TODO: maybe get from delegate, not needed for first pass
+ return false;
+}
+
+
+uint32_t
+ObjectFileJIT::GetDependentModules (FileSpecList& files)
+{
+ // JIT modules don't have dependencies, but they could
+ // if external functions are called and we know where they are
+ files.Clear();
+ return 0;
+}
+
+lldb_private::Address
+ObjectFileJIT::GetEntryPointAddress ()
+{
+ return Address();
+}
+
+lldb_private::Address
+ObjectFileJIT::GetHeaderAddress ()
+{
+ return Address();
+}
+
+
+
+ObjectFile::Type
+ObjectFileJIT::CalculateType()
+{
+ return eTypeJIT;
+}
+
+ObjectFile::Strata
+ObjectFileJIT::CalculateStrata()
+{
+ return eStrataJIT;
+}
+
+
+bool
+ObjectFileJIT::GetArchitecture (ArchSpec &arch)
+{
+ ObjectFileJITDelegateSP delegate_sp (m_delegate_wp.lock());
+ if (delegate_sp)
+ return delegate_sp->GetArchitecture(arch);
+ return false;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+lldb_private::ConstString
+ObjectFileJIT::GetPluginName()
+{
+ return GetPluginNameStatic();
+}
+
+uint32_t
+ObjectFileJIT::GetPluginVersion()
+{
+ return 1;
+}
+
+
+bool
+ObjectFileJIT::SetLoadAddress (Target &target,
+ lldb::addr_t value,
+ bool value_is_offset)
+{
+ bool changed = false;
+ size_t num_loaded_sections = 0;
+ SectionList *section_list = GetSectionList ();
+ if (section_list)
+ {
+ const size_t num_sections = section_list->GetSize();
+ // "value" is an offset to apply to each top level segment
+ for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
+ {
+ // Iterate through the object file sections to find all
+ // of the sections that size on disk (to avoid __PAGEZERO)
+ // and load them
+ SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
+ if (section_sp &&
+ section_sp->GetFileSize() > 0 &&
+ section_sp->IsThreadSpecific() == false)
+ {
+ if (target.GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress() + value))
+ ++num_loaded_sections;
+ }
+ }
+ }
+ changed = num_loaded_sections > 0;
+ return num_loaded_sections > 0;
+}
+
+
+size_t
+ObjectFileJIT::ReadSectionData (const lldb_private::Section *section,
+ off_t section_offset,
+ void *dst,
+ size_t dst_len) const
+{
+ lldb::offset_t file_size = section->GetFileSize();
+ if (section_offset < file_size)
+ {
+ uint64_t src_len = file_size - section_offset;
+ if (src_len > dst_len)
+ src_len = dst_len;
+ const uint8_t *src = ((uint8_t *)(uintptr_t)section->GetFileOffset()) + section_offset;
+
+ memcpy (dst, src, src_len);
+ return src_len;
+ }
+ return 0;
+}
+size_t
+ObjectFileJIT::ReadSectionData (const lldb_private::Section *section,
+ lldb_private::DataExtractor& section_data) const
+{
+ if (section->GetFileSize())
+ {
+ const void *src = (void *)(uintptr_t)section->GetFileOffset();
+
+ DataBufferSP data_sp (new lldb_private::DataBufferHeap(src, section->GetFileSize()));
+ if (data_sp)
+ {
+ section_data.SetData (data_sp, 0, data_sp->GetByteSize());
+ section_data.SetByteOrder (GetByteOrder());
+ section_data.SetAddressByteSize (GetAddressByteSize());
+ return section_data.GetByteSize();
+ }
+ }
+ section_data.Clear();
+ return 0;
+}
+
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
new file mode 100644
index 00000000000..3a0e2ad679b
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -0,0 +1,142 @@
+//===-- ObjectFileJIT.h -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ObjectFileJIT_h_
+#define liblldb_ObjectFileJIT_h_
+
+#include "lldb/Core/Address.h"
+#include "lldb/Symbol/ObjectFile.h"
+
+
+//----------------------------------------------------------------------
+// This class needs to be hidden as eventually belongs in a plugin that
+// will export the ObjectFile protocol
+//----------------------------------------------------------------------
+class ObjectFileJIT :
+ public lldb_private::ObjectFile
+{
+public:
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void
+ Initialize();
+
+ static void
+ Terminate();
+
+ static lldb_private::ConstString
+ GetPluginNameStatic();
+
+ static const char *
+ GetPluginDescriptionStatic();
+
+ static lldb_private::ObjectFile *
+ CreateInstance (const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP& data_sp,
+ lldb::offset_t data_offset,
+ const lldb_private::FileSpec* file,
+ lldb::offset_t file_offset,
+ lldb::offset_t length);
+
+ static lldb_private::ObjectFile *
+ CreateMemoryInstance (const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP& data_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr);
+
+ static size_t
+ GetModuleSpecifications (const lldb_private::FileSpec& file,
+ lldb::DataBufferSP& data_sp,
+ lldb::offset_t data_offset,
+ lldb::offset_t file_offset,
+ lldb::offset_t length,
+ lldb_private::ModuleSpecList &specs);
+
+ //------------------------------------------------------------------
+ // Member Functions
+ //------------------------------------------------------------------
+ ObjectFileJIT (const lldb::ModuleSP &module_sp,
+ const lldb::ObjectFileJITDelegateSP &delegate_sp);
+
+ virtual
+ ~ObjectFileJIT();
+
+ virtual bool
+ ParseHeader ();
+
+ virtual bool
+ SetLoadAddress(lldb_private::Target &target,
+ lldb::addr_t value,
+ bool value_is_offset);
+
+ virtual lldb::ByteOrder
+ GetByteOrder () const;
+
+ virtual bool
+ IsExecutable () const;
+
+ virtual uint32_t
+ GetAddressByteSize () const;
+
+ virtual lldb_private::Symtab *
+ GetSymtab();
+
+ virtual bool
+ IsStripped ();
+
+ virtual void
+ CreateSections (lldb_private::SectionList &unified_section_list);
+
+ virtual void
+ Dump (lldb_private::Stream *s);
+
+ virtual bool
+ GetArchitecture (lldb_private::ArchSpec &arch);
+
+ virtual bool
+ GetUUID (lldb_private::UUID* uuid);
+
+ virtual uint32_t
+ GetDependentModules (lldb_private::FileSpecList& files);
+
+ virtual size_t
+ ReadSectionData (const lldb_private::Section *section,
+ off_t section_offset,
+ void *dst,
+ size_t dst_len) const;
+ virtual size_t
+ ReadSectionData (const lldb_private::Section *section,
+ lldb_private::DataExtractor& section_data) const;
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ virtual lldb_private::ConstString
+ GetPluginName();
+
+ virtual uint32_t
+ GetPluginVersion();
+
+ virtual lldb_private::Address
+ GetEntryPointAddress ();
+
+ virtual lldb_private::Address
+ GetHeaderAddress ();
+
+ virtual ObjectFile::Type
+ CalculateType();
+
+ virtual ObjectFile::Strata
+ CalculateStrata();
+protected:
+ lldb::ObjectFileJITDelegateWP m_delegate_wp;
+};
+
+#endif // liblldb_ObjectFileJIT_h_
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 2ab13d96707..fd0136d00b4 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -163,15 +163,17 @@ RegisterContextLLDB::InitializeZerothFrame()
UnwindLogMsg ("using architectural default unwind method");
}
- // We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us.
+ // We require either a symbol or function in the symbols context to be successfully
+ // filled in or this context is of no use to us.
+ const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
if (pc_module_sp.get()
- && (pc_module_sp->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ && (pc_module_sp->ResolveSymbolContextForAddress (m_current_pc, resolve_scope, m_sym_ctx) & resolve_scope))
{
m_sym_ctx_valid = true;
}
AddressRange addr_range;
- m_sym_ctx.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, addr_range);
+ m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range);
if (IsTrapHandlerSymbol (process, m_sym_ctx))
{
@@ -417,18 +419,20 @@ RegisterContextLLDB::InitializeNonZerothFrame()
// a function/symbol because it is beyond the bounds of the correct
// function and there's no symbol there. ResolveSymbolContextForAddress
// will fail to find a symbol, back up the pc by 1 and re-search.
+ const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
uint32_t resolved_scope = pc_module_sp->ResolveSymbolContextForAddress (m_current_pc,
- eSymbolContextFunction | eSymbolContextSymbol,
+ resolve_scope,
m_sym_ctx, resolve_tail_call_address);
- // We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us.
- if ((resolved_scope & eSymbolContextSymbol) == eSymbolContextSymbol)
+ // We require either a symbol or function in the symbols context to be successfully
+ // filled in or this context is of no use to us.
+ if (resolve_scope & resolved_scope)
{
m_sym_ctx_valid = true;
}
AddressRange addr_range;
- if (!m_sym_ctx.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, addr_range))
+ if (!m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range))
{
m_sym_ctx_valid = false;
}
@@ -461,13 +465,12 @@ RegisterContextLLDB::InitializeNonZerothFrame()
temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
m_sym_ctx.Clear(false);
m_sym_ctx_valid = false;
- if ((pc_module_sp->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
+
+ if (pc_module_sp->ResolveSymbolContextForAddress (temporary_pc, resolve_scope, m_sym_ctx) & resolve_scope)
{
- m_sym_ctx_valid = true;
- }
- if (!m_sym_ctx.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, addr_range))
- {
- m_sym_ctx_valid = false;
+ if (m_sym_ctx.GetAddressRange (resolve_scope, 0, false, addr_range))
+ m_sym_ctx_valid = true;
}
}
@@ -707,7 +710,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
// Note, if we have a symbol context & a symbol, we don't want to follow this code path. This is
// for jumping to memory regions without any information available.
- if ((!m_sym_ctx_valid || m_sym_ctx.symbol == NULL) && behaves_like_zeroth_frame && m_current_pc.IsValid())
+ if ((!m_sym_ctx_valid || (m_sym_ctx.function == NULL && m_sym_ctx.symbol == NULL)) && behaves_like_zeroth_frame && m_current_pc.IsValid())
{
uint32_t permissions;
addr_t current_pc_addr = m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr());
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 4e34a9a09a0..59689860916 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -244,6 +244,7 @@ ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name)
case ObjectFile::eTypeObjectFile:
case ObjectFile::eTypeSharedLibrary:
case ObjectFile::eTypeStubLibrary:
+ case ObjectFile::eTypeJIT:
return false;
case ObjectFile::eTypeExecutable:
case ObjectFile::eTypeDynamicLinker:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index c12dd621402..0cb2143711a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -341,6 +341,7 @@ SymbolFileDWARFDebugMap::InitOSO()
case ObjectFile::eTypeObjectFile:
case ObjectFile::eTypeStubLibrary:
case ObjectFile::eTypeUnknown:
+ case ObjectFile::eTypeJIT:
return;
case ObjectFile::eTypeExecutable:
OpenPOWER on IntegriCloud