Per comments, fixed DWARF expressions to take an optional module, and moved
TLS handling from Process over into Thread.
http://llvm-reviews.chandlerc.com/D1944
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1944?vs=4936&id=4965#toc
Files:
include/lldb/Target/Process.h
include/lldb/Target/Thread.h
source/Expression/DWARFExpression.cpp
source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
source/Plugins/Process/POSIX/POSIXThread.cpp
source/Plugins/Process/POSIX/POSIXThread.h
source/Plugins/Process/POSIX/ProcessPOSIX.cpp
source/Plugins/Process/POSIX/ProcessPOSIX.h
source/Target/Process.cpp
source/Target/Thread.cpp
Index: include/lldb/Target/Process.h
===================================================================
--- include/lldb/Target/Process.h
+++ include/lldb/Target/Process.h
@@ -1838,38 +1838,6 @@
GetImageInfoAddress ();
//------------------------------------------------------------------
- /// Retrieves the per-thread data area.
- /// Most OSs maintain a per-thread pointer (e.g. the FS register on
- /// x64), which we return the value of here.
- ///
- /// @param[in] thread
- /// The specific thread to query data for.
- ///
- /// @return
- /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
- /// pointer value.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetThreadPointer (const lldb::ThreadSP thread);
-
- //------------------------------------------------------------------
- /// Retrieves the per-module TLS block for a given thread.
- ///
- /// @param[in] module
- /// The module to query TLS data for.
- ///
- /// @param[in] thread
- /// The specific thread to query TLS data for.
- ///
- /// @return
- /// If the given thread has TLS data allocated for the
- /// module, the address of the TLS block. Otherwise
- /// LLDB_INVALID_ADDRESS is returned.
- //------------------------------------------------------------------
- virtual lldb::addr_t
- GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread);
-
- //------------------------------------------------------------------
/// Load a shared library into this process.
///
/// Try and load a shared library into the current process. This
Index: include/lldb/Target/Thread.h
===================================================================
--- include/lldb/Target/Thread.h
+++ include/lldb/Target/Thread.h
@@ -455,6 +455,33 @@
DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
//------------------------------------------------------------------
+ /// Retrieves the per-thread data area.
+ /// Most OSs maintain a per-thread pointer (e.g. the FS register on
+ /// x64), which we return the value of here.
+ ///
+ /// @return
+ /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
+ /// pointer value.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t
+ GetThreadPointer ();
+
+ //------------------------------------------------------------------
+ /// Retrieves the per-module TLS block for a thread.
+ ///
+ /// @param[in] module
+ /// The module to query TLS data for.
+ ///
+ /// @return
+ /// If the thread has TLS data allocated for the
+ /// module, the address of the TLS block. Otherwise
+ /// LLDB_INVALID_ADDRESS is returned.
+ //------------------------------------------------------------------
+ virtual lldb::addr_t
+ GetThreadLocalData (const lldb::ModuleSP module);
+
+
+ //------------------------------------------------------------------
// Thread Plan Providers:
// This section provides the basic thread plans that the Process control
// machinery uses to run the target. ThreadPlan.h provides more details on
Index: source/Expression/DWARFExpression.cpp
===================================================================
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -38,6 +38,7 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/StackID.h"
+#include "lldb/Target/Thread.h"
using namespace lldb;
using namespace lldb_private;
@@ -238,11 +239,13 @@
DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length) :
- m_module_wp(module_sp),
+ m_module_wp(),
m_data(data, data_offset, data_length),
m_reg_kind (eRegisterKindDWARF),
m_loclist_slide(LLDB_INVALID_ADDRESS)
{
+ if (module_sp)
+ m_module_wp = module_sp;
}
//----------------------------------------------------------------------
@@ -1232,12 +1235,6 @@
) const
{
ModuleSP module_sp = m_module_wp.lock();
- if (!module_sp.get())
- {
- if (error_ptr)
- error_ptr->SetErrorString("Module was unloaded.");
- return false;
- }
if (IsLocationList())
{
@@ -2694,17 +2691,17 @@
return false;
}
- if (!exe_ctx)
+ if (!exe_ctx || !opcode_ctx)
{
if (error_ptr)
- error_ptr->SetErrorString("No thread context to evaluate TLS within.");
+ error_ptr->SetErrorString("No context to evaluate TLS within.");
return false;
}
- ThreadSP thread_sp = exe_ctx->GetThreadSP();
+ Thread *thread = exe_ctx->GetThreadPtr();
// Lookup the TLS block address for this thread and module.
- addr_t tls_addr = process->GetThreadLocalData (opcode_ctx, thread_sp);
+ addr_t tls_addr = thread->GetThreadLocalData (opcode_ctx);
if (tls_addr == LLDB_INVALID_ADDRESS)
{
Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===================================================================
--- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -584,7 +584,7 @@
return LLDB_INVALID_ADDRESS;
// Get the thread pointer.
- addr_t tp = m_process->GetThreadPointer (thread);
+ addr_t tp = thread->GetThreadPointer ();
if (tp == LLDB_INVALID_ADDRESS)
return LLDB_INVALID_ADDRESS;
Index: source/Plugins/Process/POSIX/POSIXThread.cpp
===================================================================
--- source/Plugins/Process/POSIX/POSIXThread.cpp
+++ source/Plugins/Process/POSIX/POSIXThread.cpp
@@ -230,6 +230,17 @@
return reg_ctx_sp;
}
+lldb::addr_t
+POSIXThread::GetThreadPointer ()
+{
+ ProcessMonitor &monitor = GetMonitor();
+ addr_t addr;
+ if (monitor.ReadThreadPointer (GetID(), addr))
+ return addr;
+ else
+ return LLDB_INVALID_ADDRESS;
+}
+
bool
POSIXThread::CalculateStopInfo()
{
Index: source/Plugins/Process/POSIX/POSIXThread.h
===================================================================
--- source/Plugins/Process/POSIX/POSIXThread.h
+++ source/Plugins/Process/POSIX/POSIXThread.h
@@ -59,6 +59,9 @@
virtual lldb::RegisterContextSP
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+ virtual lldb::addr_t
+ GetThreadPointer ();
+
//--------------------------------------------------------------------------
// These functions provide a mapping from the register offset
// back to the register index or name for use in debugging or log
Index: source/Plugins/Process/POSIX/ProcessPOSIX.cpp
===================================================================
--- source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -296,17 +296,6 @@
return LLDB_INVALID_ADDRESS;
}
-lldb::addr_t
-ProcessPOSIX::GetThreadPointer (const lldb::ThreadSP thread)
-{
- assert(m_monitor);
- addr_t addr;
- if (m_monitor->ReadThreadPointer (thread->GetID(), addr))
- return addr;
- else
- return LLDB_INVALID_ADDRESS;
-}
-
Error
ProcessPOSIX::DoHalt(bool &caused_stop)
{
Index: source/Plugins/Process/POSIX/ProcessPOSIX.h
===================================================================
--- source/Plugins/Process/POSIX/ProcessPOSIX.h
+++ source/Plugins/Process/POSIX/ProcessPOSIX.h
@@ -141,9 +141,6 @@
virtual lldb::addr_t
GetImageInfoAddress();
- virtual lldb::addr_t
- GetThreadPointer (const lldb::ThreadSP thread);
-
virtual size_t
PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -1780,23 +1780,6 @@
return LLDB_INVALID_ADDRESS;
}
-lldb::addr_t
-Process::GetThreadPointer (const lldb::ThreadSP thread)
-{
- return LLDB_INVALID_ADDRESS;
-}
-
-addr_t
-Process::GetThreadLocalData (const ModuleSP module, const ThreadSP thread)
-{
- DynamicLoader *loader = GetDynamicLoader();
- if (loader)
- return loader->GetThreadLocalData (module, thread);
- else
- return LLDB_INVALID_ADDRESS;
-}
-
-
//----------------------------------------------------------------------
// LoadImage
//
Index: source/Target/Thread.cpp
===================================================================
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -1857,6 +1857,24 @@
{
}
+lldb::addr_t
+Thread::GetThreadPointer ()
+{
+ return LLDB_INVALID_ADDRESS;
+}
+
+addr_t
+Thread::GetThreadLocalData (const ModuleSP module)
+{
+ // The default implementation is to ask the dynamic loader for it.
+ // This can be overridden for specific platforms.
+ DynamicLoader *loader = GetProcess()->GetDynamicLoader();
+ if (loader)
+ return loader->GetThreadLocalData (module, shared_from_this());
+ else
+ return LLDB_INVALID_ADDRESS;
+}
+
lldb::StackFrameSP
Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
{
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits