[Lldb-commits] [lldb] r255121 - [RenderScript] Add hook for destroyed allocations
Ewan Crawford via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 9 08:01:58 PST 2015
Author: ewancrawford
Date: Wed Dec 9 10:01:58 2015
New Revision: 255121
URL: http://llvm.org/viewvc/llvm-project?rev=255121&view=rev
Log:
[RenderScript] Add hook for destroyed allocations
New hook for rsdAllocationDestroy() which is called when allocations are deleted.
LLDB should be aware of this so we can remove the allocation from our internal list.
Modified:
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=255121&r1=255120&r2=255121&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Wed Dec 9 10:01:58 2015
@@ -556,6 +556,14 @@ const RenderScriptRuntime::HookDefn Rend
RenderScriptRuntime::eModuleKindDriver, // type
nullptr // handler
},
+ {
+ "rsdAllocationDestroy", // name
+ "_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", // symbol name 32bit
+ "_Z20rsdAllocationDestroyPKN7android12renderscript7ContextEPNS0_10AllocationE", // symbol name 64bit
+ 0, // version
+ RenderScriptRuntime::eModuleKindDriver, // type
+ &lldb_private::RenderScriptRuntime::CaptureAllocationDestroy // handler
+ },
};
const size_t RenderScriptRuntime::s_runtimeHookCount = sizeof(s_runtimeHookDefns)/sizeof(s_runtimeHookDefns[0]);
@@ -857,6 +865,43 @@ RenderScriptRuntime::CaptureAllocationIn
alloc->context = rs_context_u64;
}
+void
+RenderScriptRuntime::CaptureAllocationDestroy(RuntimeHook* hook_info, ExecutionContext& context)
+{
+ Log* log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+
+ // Context, Alloc
+ uint64_t rs_context_u64 = 0U;
+ uint64_t rs_alloc_u64 = 0U;
+
+ bool success = GetArgSimple(context, 0, &rs_context_u64) && GetArgSimple(context, 1, &rs_alloc_u64);
+ if (!success) // error case
+ {
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Error while reading the function parameters");
+ return; // abort
+ }
+
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - 0x%" PRIx64 ", 0x%" PRIx64 ".",
+ rs_context_u64, rs_alloc_u64);
+
+ for (auto iter = m_allocations.begin(); iter != m_allocations.end(); ++iter)
+ {
+ auto& allocation_ap = *iter; // get the unique pointer
+ if (allocation_ap->address.isValid() && *allocation_ap->address.get() == rs_alloc_u64)
+ {
+ m_allocations.erase(iter);
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Deleted allocation entry");
+ return;
+ }
+ }
+
+ if (log)
+ log->Printf("RenderScriptRuntime::CaptureAllocationDestroy - Couldn't find destroyed allocation");
+}
+
void
RenderScriptRuntime::CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext& context)
{
@@ -2304,7 +2349,6 @@ RenderScriptRuntime::Status(Stream &strm
strm.Indent(b.second->defn->name);
strm.EOL();
}
- strm.EOL();
}
else
{
Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=255121&r1=255120&r2=255121&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h Wed Dec 9 10:01:58 2015
@@ -326,6 +326,7 @@ private:
void CaptureScriptInit1(RuntimeHook* hook_info, ExecutionContext& context);
void CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionContext& context);
+ void CaptureAllocationDestroy(RuntimeHook* hook_info, ExecutionContext& context);
void CaptureSetGlobalVar1(RuntimeHook* hook_info, ExecutionContext& context);
AllocationDetails* FindAllocByID(Stream &strm, const uint32_t alloc_id);
More information about the lldb-commits
mailing list