From aa794b38fedea0f2e99519975acab0b289714b41 Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 23 Jul 2014 19:35:02 +0000 Subject: MFC r262528: Update LLDB snapshot to upstream r202189 Highlights include (upstream revs in parens): - Improvements to the remote GDB protocol client (r196610, r197579, r197857, r200072, and others) - Bug fixes for big-endian targets (r196808) - Initial support for libdispatch (GCD) queues in the debuggee (r197190) - Add "step-avoid-libraries" setting (r199943) - IO subsystem improvements (including initial work on a curses gui) (r200263) - Support hardware watchpoints on FreeBSD (r201706) - Improved unwinding through hand-written assembly functions (r201839) - Handle DW_TAG_unspecified_parameters for variadic functions (r202061) - Fix Ctrl+C interrupting a running inferior process (r202086, r202154) - Various bug fixes for memory leaks, LLDB segfaults, the C++ demangler, ELF core files, DWARF debug info, and others. Sponsored by: DARPA, AFRL --- .../Python/OperatingSystemPython.cpp | 35 +++++++++++++++++----- .../OperatingSystem/Python/OperatingSystemPython.h | 1 + 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python') diff --git a/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 37b3241..7ca337e 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -190,6 +190,13 @@ OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list, auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive PythonList threads_list(m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp)); + + const uint32_t num_cores = core_thread_list.GetSize(false); + + // Make a map so we can keep track of which cores were used from the + // core_thread list. Any real threads/cores that weren't used should + // later be put back into the "new_thread_list". + std::vector core_used_map(num_cores, false); if (threads_list) { if (log) @@ -207,18 +214,26 @@ OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list, PythonDictionary thread_dict(threads_list.GetItemAtIndex(i)); if (thread_dict) { - ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_dict, core_thread_list, old_thread_list, NULL)); + ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_dict, core_thread_list, old_thread_list, core_used_map, NULL)); if (thread_sp) new_thread_list.AddThread(thread_sp); } } } } - - // No new threads added from the thread info array gotten from python, just - // display the core threads. - if (new_thread_list.GetSize(false) == 0) - new_thread_list = core_thread_list; + + // Any real core threads that didn't end up backing a memory thread should + // still be in the main thread list, and they should be inserted at the beginning + // of the list + uint32_t insert_idx = 0; + for (uint32_t core_idx = 0; core_idx < num_cores; ++core_idx) + { + if (core_used_map[core_idx] == false) + { + new_thread_list.InsertThread (core_thread_list.GetThreadAtIndex(core_idx, false), insert_idx); + ++insert_idx; + } + } return new_thread_list.GetSize(false) > 0; } @@ -227,6 +242,7 @@ ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict, ThreadList &core_thread_list, ThreadList &old_thread_list, + std::vector &core_used_map, bool *did_create_ptr) { ThreadSP thread_sp; @@ -282,6 +298,10 @@ OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict ThreadSP core_thread_sp (core_thread_list.GetThreadAtIndex(core_number, false)); if (core_thread_sp) { + // Keep track of which cores were set as the backing thread for memory threads... + if (core_number < core_used_map.size()) + core_used_map[core_number] = true; + ThreadSP backing_core_thread_sp (core_thread_sp->GetBackingThread()); if (backing_core_thread_sp) { @@ -398,12 +418,13 @@ OperatingSystemPython::CreateThread (lldb::tid_t tid, addr_t context) auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive PythonDictionary thread_info_dict (m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context)); + std::vector core_used_map; if (thread_info_dict) { ThreadList core_threads(m_process); ThreadList &thread_list = m_process->GetThreadList(); bool did_create = false; - ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_info_dict, core_threads, thread_list, &did_create)); + ThreadSP thread_sp (CreateThreadFromThreadInfo (thread_info_dict, core_threads, thread_list, core_used_map, &did_create)); if (did_create) thread_list.AddThread(thread_sp); return thread_sp; diff --git a/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h index 077039e..3b7dd26 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h +++ b/contrib/llvm/tools/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h @@ -93,6 +93,7 @@ protected: CreateThreadFromThreadInfo (lldb_private::PythonDictionary &thread_dict, lldb_private::ThreadList &core_thread_list, lldb_private::ThreadList &old_thread_list, + std::vector &core_used_map, bool *did_create_ptr); DynamicRegisterInfo * -- cgit v1.1