From 2ae442b91645f92542b1a8c47e31466acbaca8c7 Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Sun, 1 May 2016 11:23:04 +0000 Subject: [PATCH] Add thread numbers into ASan thread names. llvm-svn: 268192 --- .../source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp index ab21699..2ac92ea 100644 --- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -24,6 +24,8 @@ #include "Plugins/Process/Utility/HistoryThread.h" #include "lldb/Core/ValueObject.h" +#include + using namespace lldb; using namespace lldb_private; @@ -123,7 +125,7 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObject return; int count = count_sp->GetValueAsUnsigned(0); - tid_t tid = tid_sp->GetValueAsUnsigned(0); + tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1; if (count <= 0) return; @@ -144,8 +146,9 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObject HistoryThread *history_thread = new HistoryThread(*process_sp, tid, pcs, 0, false); ThreadSP new_thread_sp(history_thread); - // let's use thread name for the type of history thread, since history threads don't have names anyway - history_thread->SetThreadName(thread_name); + std::ostringstream thread_name_with_number; + thread_name_with_number << thread_name << " Thread " << tid; + history_thread->SetThreadName(thread_name_with_number.str().c_str()); // Save this in the Process' ExtendedThreadList so a strong pointer retains the object process_sp->GetExtendedThreadList().AddThread (new_thread_sp); result.push_back(new_thread_sp); @@ -198,8 +201,8 @@ MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) if (!return_value_sp) return result; - CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result); - CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result); + CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated by", result); + CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated by", result); return result; } -- 2.7.4