From 31862ae54168899c009193ed63f6837b81a51845 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 26 Nov 2014 07:39:03 +0000 Subject: [PATCH] [MCJIT] Re-enable GDB registration (temporarily disabled in r222811), but check that we actually have an object to register first. For MachO objects, RuntimeDyld::LoadedObjectInfo::getObjectForDebug returns an empty OwningBinary which was causing crashes in the GDB registration code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222812 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 1 + lib/ExecutionEngine/RuntimeDyld/GDBRegistrationListener.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 490fbb3df99..58cf4e5e6dd 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -75,6 +75,7 @@ MCJIT::MCJIT(std::unique_ptr M, std::unique_ptr tm, OwnedModules.addModule(std::move(First)); setDataLayout(TM->getSubtargetImpl()->getDataLayout()); + RegisterJITEventListener(JITEventListener::createGDBRegistrationListener()); } MCJIT::~MCJIT() { diff --git a/lib/ExecutionEngine/RuntimeDyld/GDBRegistrationListener.cpp b/lib/ExecutionEngine/RuntimeDyld/GDBRegistrationListener.cpp index 641d3a26270..13d5672a82b 100644 --- a/lib/ExecutionEngine/RuntimeDyld/GDBRegistrationListener.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/GDBRegistrationListener.cpp @@ -151,6 +151,11 @@ void GDBJITRegistrationListener::NotifyObjectEmitted( const RuntimeDyld::LoadedObjectInfo &L) { OwningBinary DebugObj = L.getObjectForDebug(Object); + + // Bail out if debug objects aren't supported. + if (!DebugObj.getBinary()) + return; + const char *Buffer = DebugObj.getBinary()->getMemoryBufferRef().getBufferStart(); size_t Size = DebugObj.getBinary()->getMemoryBufferRef().getBufferSize();