From e69df38282957733ad88ff44089892013318f7b4 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Wed, 9 Dec 2015 16:01:58 +0000 Subject: [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. llvm-svn: 255121 --- .../RenderScriptRuntime/RenderScriptRuntime.cpp | 46 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp') diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index be839b9e576a..6b8e64b9d7ca 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -556,6 +556,14 @@ const RenderScriptRuntime::HookDefn RenderScriptRuntime::s_runtimeHookDefns[] = 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::CaptureAllocationInit1(RuntimeHook* hook_info, ExecutionCon 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) const strm.Indent(b.second->defn->name); strm.EOL(); } - strm.EOL(); } else { -- cgit v1.2.3