diff options
author | Greg Clayton <gclayton@apple.com> | 2011-02-15 00:19:15 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-02-15 00:19:15 +0000 |
commit | e576ab2996b5fa4facf2bf7e73cc4679cb17c133 (patch) | |
tree | bdcafd5e6a9f09adf5a3e9d3b7e92f9d693b939c /lldb/source/Plugins/Process/gdb-remote | |
parent | 91c08ad14a81cc40769442c19a23addfba28371e (diff) | |
download | bcm5719-llvm-e576ab2996b5fa4facf2bf7e73cc4679cb17c133.tar.gz bcm5719-llvm-e576ab2996b5fa4facf2bf7e73cc4679cb17c133.zip |
All UnwindPlan objects are now passed around as shared pointers.
ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture
instead of being leaked for every frame.
Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and
ArchDefaultUnwindPlan_i386 interfaces.
There were sporadic crashes that were due to something leaking or being
destroyed when doing stack crawls. This patch should clear up these issues.
llvm-svn: 125541
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
5 files changed, 39 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 0e29f2f368f..873974f0a1d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -178,11 +178,12 @@ GDBRemoteRegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value) return false; } -void +bool GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - assert (reg_info); + if (reg_info == NULL) + return false; // Invalidate if needed InvalidateIfNeeded(false); @@ -200,6 +201,7 @@ GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor // leave it as it was. m_reg_valid[reg] = false; } + return success; } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h index 72c640ff7a8..ac6bbe5c95d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h @@ -228,7 +228,7 @@ public: protected: friend class ThreadGDBRemote; - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); void diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 87bc0b9a67f..cee2d3d1dee 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -642,7 +642,6 @@ ProcessGDBRemote::DidLaunchOrAttach () StreamString strm; - ; // See if the GDB server supports the qHostInfo information const char *vendor = m_gdb_comm.GetVendorString().AsCString(); const char *os_type = m_gdb_comm.GetOSString().AsCString(); @@ -1176,6 +1175,18 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) case 'T': case 'S': { + if (GetStopID() == 0) + { + // Our first stop, make sure we have a process ID, and also make + // sure we know about our registers + if (GetID() == LLDB_INVALID_PROCESS_ID) + { + lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID (1); + if (pid != LLDB_INVALID_PROCESS_ID) + SetID (pid); + } + BuildDynamicRegisterInfo (true); + } // Stop with signal and thread info const uint8_t signo = stop_packet.GetHexU8(); std::string name; @@ -1209,7 +1220,14 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) { // thread in big endian hex tid = Args::StringToUInt32 (value.c_str(), 0, 16); + Mutex::Locker locker (m_thread_list.GetMutex ()); thread_sp = m_thread_list.FindThreadByID(tid, false); + if (!thread_sp) + { + // Create the thread if we need to + thread_sp.reset (new ThreadGDBRemote (*this, tid)); + m_thread_list.AddThread(thread_sp); + } } else if (name.compare("hexname") == 0) { @@ -1242,7 +1260,15 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) StringExtractor reg_value_extractor; // Swap "value" over into "reg_value_extractor" reg_value_extractor.GetStringRef().swap(value); - static_cast<ThreadGDBRemote *> (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor); + if (!static_cast<ThreadGDBRemote *> (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor)) + { + Host::SetCrashDescriptionWithFormat("Setting thread register '%s' (decoded to %u (0x%x)) with value '%s' for stop packet: '%s'", + name.c_str(), + reg, + reg, + reg_value_extractor.GetStringRef().c_str(), + stop_packet.GetStringRef().c_str()); + } } } } diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 6acefff3216..635c00c7438 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -26,7 +26,7 @@ #include "Plugins/Process/Utility/UnwindLLDB.h" #include "Utility/StringExtractorGDBRemote.h" -#ifdef __APPLE__ +#if defined(__APPLE__) #include "UnwindMacOSXFrameBackchain.h" #endif @@ -98,6 +98,7 @@ ThreadGDBRemote::WillResume (StateType resume_state) { case eStateSuspended: case eStateStopped: + // Don't append anything for threads that should stay stopped. break; case eStateRunning: @@ -145,7 +146,7 @@ ThreadGDBRemote::GetUnwinder () { m_unwinder_ap.reset (new UnwindLLDB (*this)); } -#ifdef __APPLE__ +#if defined(__APPLE__) else { m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); @@ -207,12 +208,12 @@ ThreadGDBRemote::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } -void +bool ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { GDBRemoteRegisterContext *gdb_reg_ctx = static_cast<GDBRemoteRegisterContext *>(GetRegisterContext ().get()); assert (gdb_reg_ctx); - gdb_reg_ctx->PrivateSetRegisterValue (reg, response); + return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } bool diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index bf708485d73..c085b6c1485 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -105,7 +105,7 @@ protected: virtual bool RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); |