[Lldb-commits] [lldb] r170445 - in /lldb/trunk/source/Plugins/Process: FreeBSD/ProcessMonitor.cpp FreeBSD/ProcessMonitor.h Linux/ProcessMonitor.cpp Linux/ProcessMonitor.h POSIX/RegisterContext_i386.cpp POSIX/RegisterContext_x86_64.cpp
Daniel Malea
daniel.malea at intel.com
Tue Dec 18 11:50:15 PST 2012
Author: dmalea
Date: Tue Dec 18 13:50:15 2012
New Revision: 170445
URL: http://llvm.org/viewvc/llvm-project?rev=170445&view=rev
Log:
Allow reading registers by thread ID in ProcessMonitor (Linux implementation)
- make FreeBSD ProcessMonitor API thread-ready
Patch by Matt Kopec!
Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp
lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp
Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Tue Dec 18 13:50:15 2012
@@ -1410,7 +1410,8 @@
}
bool
-ProcessMonitor::ReadRegisterValue(unsigned offset, unsigned size, RegisterValue &value)
+ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset,
+ unsigned size, RegisterValue &value)
{
bool result;
ReadRegOperation op(offset, size, value, result);
@@ -1419,7 +1420,8 @@
}
bool
-ProcessMonitor::WriteRegisterValue(unsigned offset, const RegisterValue &value)
+ProcessMonitor::WriteRegisterValue(lldb::tid_t tid, unsigned offset,
+ const RegisterValue &value)
{
bool result;
WriteRegOperation op(offset, value, result);
@@ -1428,7 +1430,7 @@
}
bool
-ProcessMonitor::ReadGPR(void *buf)
+ProcessMonitor::ReadGPR(lldb::tid_t tid, void *buf)
{
bool result;
ReadGPROperation op(buf, result);
@@ -1437,7 +1439,7 @@
}
bool
-ProcessMonitor::ReadFPR(void *buf)
+ProcessMonitor::ReadFPR(lldb::tid_t tid, void *buf)
{
bool result;
ReadFPROperation op(buf, result);
@@ -1446,7 +1448,7 @@
}
bool
-ProcessMonitor::WriteGPR(void *buf)
+ProcessMonitor::WriteGPR(lldb::tid_t tid, void *buf)
{
bool result;
WriteGPROperation op(buf, result);
@@ -1455,7 +1457,7 @@
}
bool
-ProcessMonitor::WriteFPR(void *buf)
+ProcessMonitor::WriteFPR(lldb::tid_t tid, void *buf)
{
bool result;
WriteFPROperation op(buf, result);
Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h Tue Dec 18 13:50:15 2012
@@ -103,31 +103,45 @@
/// dependent) offset.
///
/// This method is provided for use by RegisterContextFreeBSD derivatives.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- ReadRegisterValue(unsigned offset, unsigned size, lldb_private::RegisterValue &value);
+ ReadRegisterValue(lldb::tid_t tid, unsigned offset,
+ unsigned size, lldb_private::RegisterValue &value);
/// Writes the given value to the register identified by the given
/// (architecture dependent) offset.
///
/// This method is provided for use by RegisterContextFreeBSD derivatives.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- WriteRegisterValue(unsigned offset, const lldb_private::RegisterValue &value);
+ WriteRegisterValue(lldb::tid_t tid, unsigned offset,
+ const lldb_private::RegisterValue &value);
/// Reads all general purpose registers into the specified buffer.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- ReadGPR(void *buf);
+ ReadGPR(lldb::tid_t tid, void *buf);
/// Reads all floating point registers into the specified buffer.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- ReadFPR(void *buf);
+ ReadFPR(lldb::tid_t tid, void *buf);
/// Writes all general purpose registers into the specified buffer.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- WriteGPR(void *buf);
+ WriteGPR(lldb::tid_t tid, void *buf);
/// Writes all floating point registers into the specified buffer.
+ /// FIXME: The FreeBSD implementation of this function should use tid in order
+ /// to enable support for debugging threaded programs.
bool
- WriteFPR(void *buf);
+ WriteFPR(lldb::tid_t tid, void *buf);
/// Writes a siginfo_t structure corresponding to the given thread ID to the
/// memory region pointed to by @p siginfo.
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Dec 18 13:50:15 2012
@@ -412,13 +412,16 @@
class ReadRegOperation : public Operation
{
public:
- ReadRegOperation(unsigned offset, RegisterValue &value, bool &result)
- : m_offset(offset), m_value(value), m_result(result)
+ ReadRegOperation(lldb::tid_t tid, unsigned offset,
+ RegisterValue &value, bool &result)
+ : m_tid(tid), m_offset(offset),
+ m_value(value), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
uintptr_t m_offset;
RegisterValue &m_value;
bool &m_result;
@@ -427,12 +430,11 @@
void
ReadRegOperation::Execute(ProcessMonitor *monitor)
{
- lldb::pid_t pid = monitor->GetPID();
LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
// Set errno to zero so that we can detect a failed peek.
errno = 0;
- lldb::addr_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL);
+ lldb::addr_t data = PTRACE(PTRACE_PEEKUSER, m_tid, (void*)m_offset, NULL);
if (data == -1UL && errno)
m_result = false;
else
@@ -451,13 +453,16 @@
class WriteRegOperation : public Operation
{
public:
- WriteRegOperation(unsigned offset, const RegisterValue &value, bool &result)
- : m_offset(offset), m_value(value), m_result(result)
+ WriteRegOperation(lldb::tid_t tid, unsigned offset,
+ const RegisterValue &value, bool &result)
+ : m_tid(tid), m_offset(offset),
+ m_value(value), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
uintptr_t m_offset;
const RegisterValue &m_value;
bool &m_result;
@@ -467,7 +472,6 @@
WriteRegOperation::Execute(ProcessMonitor *monitor)
{
void* buf;
- lldb::pid_t pid = monitor->GetPID();
LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS));
#if __WORDSIZE == 32
@@ -479,7 +483,7 @@
if (log)
log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__,
POSIXThread::GetRegisterNameFromOffset(m_offset), buf);
- if (PTRACE(PTRACE_POKEUSER, pid, (void*)m_offset, buf))
+ if (PTRACE(PTRACE_POKEUSER, m_tid, (void*)m_offset, buf))
m_result = false;
else
m_result = true;
@@ -491,13 +495,14 @@
class ReadGPROperation : public Operation
{
public:
- ReadGPROperation(void *buf, bool &result)
- : m_buf(buf), m_result(result)
+ ReadGPROperation(lldb::tid_t tid, void *buf, bool &result)
+ : m_tid(tid), m_buf(buf), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
void *m_buf;
bool &m_result;
};
@@ -505,7 +510,7 @@
void
ReadGPROperation::Execute(ProcessMonitor *monitor)
{
- if (PTRACE(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0)
+ if (PTRACE(PTRACE_GETREGS, m_tid, NULL, m_buf) < 0)
m_result = false;
else
m_result = true;
@@ -517,13 +522,14 @@
class ReadFPROperation : public Operation
{
public:
- ReadFPROperation(void *buf, bool &result)
- : m_buf(buf), m_result(result)
+ ReadFPROperation(lldb::tid_t tid, void *buf, bool &result)
+ : m_tid(tid), m_buf(buf), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
void *m_buf;
bool &m_result;
};
@@ -531,7 +537,7 @@
void
ReadFPROperation::Execute(ProcessMonitor *monitor)
{
- if (PTRACE(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0)
+ if (PTRACE(PTRACE_GETFPREGS, m_tid, NULL, m_buf) < 0)
m_result = false;
else
m_result = true;
@@ -543,13 +549,14 @@
class WriteGPROperation : public Operation
{
public:
- WriteGPROperation(void *buf, bool &result)
- : m_buf(buf), m_result(result)
+ WriteGPROperation(lldb::tid_t tid, void *buf, bool &result)
+ : m_tid(tid), m_buf(buf), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
void *m_buf;
bool &m_result;
};
@@ -557,7 +564,7 @@
void
WriteGPROperation::Execute(ProcessMonitor *monitor)
{
- if (PTRACE(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0)
+ if (PTRACE(PTRACE_SETREGS, m_tid, NULL, m_buf) < 0)
m_result = false;
else
m_result = true;
@@ -569,13 +576,14 @@
class WriteFPROperation : public Operation
{
public:
- WriteFPROperation(void *buf, bool &result)
- : m_buf(buf), m_result(result)
+ WriteFPROperation(lldb::tid_t tid, void *buf, bool &result)
+ : m_tid(tid), m_buf(buf), m_result(result)
{ }
void Execute(ProcessMonitor *monitor);
private:
+ lldb::tid_t m_tid;
void *m_buf;
bool &m_result;
};
@@ -583,7 +591,7 @@
void
WriteFPROperation::Execute(ProcessMonitor *monitor)
{
- if (PTRACE(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0)
+ if (PTRACE(PTRACE_SETFPREGS, m_tid, NULL, m_buf) < 0)
m_result = false;
else
m_result = true;
@@ -1572,55 +1580,55 @@
}
bool
-ProcessMonitor::ReadRegisterValue(unsigned offset, unsigned size, RegisterValue &value)
+ProcessMonitor::ReadRegisterValue(lldb::tid_t tid, unsigned offset, unsigned size, RegisterValue &value)
{
bool result;
- ReadRegOperation op(offset, value, result);
+ ReadRegOperation op(tid, offset, value, result);
DoOperation(&op);
return result;
}
bool
-ProcessMonitor::WriteRegisterValue(unsigned offset, const RegisterValue &value)
+ProcessMonitor::WriteRegisterValue(lldb::tid_t tid, unsigned offset, const RegisterValue &value)
{
bool result;
- WriteRegOperation op(offset, value, result);
+ WriteRegOperation op(tid, offset, value, result);
DoOperation(&op);
return result;
}
bool
-ProcessMonitor::ReadGPR(void *buf)
+ProcessMonitor::ReadGPR(lldb::tid_t tid, void *buf)
{
bool result;
- ReadGPROperation op(buf, result);
+ ReadGPROperation op(tid, buf, result);
DoOperation(&op);
return result;
}
bool
-ProcessMonitor::ReadFPR(void *buf)
+ProcessMonitor::ReadFPR(lldb::tid_t tid, void *buf)
{
bool result;
- ReadFPROperation op(buf, result);
+ ReadFPROperation op(tid, buf, result);
DoOperation(&op);
return result;
}
bool
-ProcessMonitor::WriteGPR(void *buf)
+ProcessMonitor::WriteGPR(lldb::tid_t tid, void *buf)
{
bool result;
- WriteGPROperation op(buf, result);
+ WriteGPROperation op(tid, buf, result);
DoOperation(&op);
return result;
}
bool
-ProcessMonitor::WriteFPR(void *buf)
+ProcessMonitor::WriteFPR(lldb::tid_t tid, void *buf)
{
bool result;
- WriteFPROperation op(buf, result);
+ WriteFPROperation op(tid, buf, result);
DoOperation(&op);
return result;
}
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Dec 18 13:50:15 2012
@@ -106,30 +106,32 @@
///
/// This method is provided for use by RegisterContextLinux derivatives.
bool
- ReadRegisterValue(unsigned offset, unsigned size, lldb_private::RegisterValue &value);
+ ReadRegisterValue(lldb::tid_t tid, unsigned offset,
+ unsigned size, lldb_private::RegisterValue &value);
/// Writes the given value to the register identified by the given
/// (architecture dependent) offset.
///
/// This method is provided for use by RegisterContextLinux derivatives.
bool
- WriteRegisterValue(unsigned offset, const lldb_private::RegisterValue &value);
+ WriteRegisterValue(lldb::tid_t tid, unsigned offset,
+ const lldb_private::RegisterValue &value);
/// Reads all general purpose registers into the specified buffer.
bool
- ReadGPR(void *buf);
+ ReadGPR(lldb::tid_t tid, void *buf);
/// Reads all floating point registers into the specified buffer.
bool
- ReadFPR(void *buf);
+ ReadFPR(lldb::tid_t tid, void *buf);
/// Writes all general purpose registers into the specified buffer.
bool
- WriteGPR(void *buf);
+ WriteGPR(lldb::tid_t tid, void *buf);
/// Writes all floating point registers into the specified buffer.
bool
- WriteFPR(void *buf);
+ WriteFPR(lldb::tid_t tid, void *buf);
/// Writes a siginfo_t structure corresponding to the given thread ID to the
/// memory region pointed to by @p siginfo.
Modified: lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_i386.cpp Tue Dec 18 13:50:15 2012
@@ -437,7 +437,7 @@
{
const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
ProcessMonitor &monitor = GetMonitor();
- return monitor.ReadRegisterValue(GetRegOffset(reg), GetRegSize(reg), value);
+ return monitor.ReadRegisterValue(m_thread.GetID(), GetRegOffset(reg), GetRegSize(reg), value);
}
bool
@@ -451,7 +451,7 @@
{
const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
ProcessMonitor &monitor = GetMonitor();
- return monitor.WriteRegisterValue(GetRegOffset(reg), value);
+ return monitor.WriteRegisterValue(m_thread.GetID(), GetRegOffset(reg), value);
}
bool
@@ -631,7 +631,7 @@
bool result;
ProcessMonitor &monitor = GetMonitor();
- result = monitor.ReadGPR(&user.regs);
+ result = monitor.ReadGPR(m_thread.GetID(), &user.regs);
LogGPR("RegisterContext_i386::ReadGPR()");
return result;
}
@@ -640,5 +640,5 @@
RegisterContext_i386::ReadFPR()
{
ProcessMonitor &monitor = GetMonitor();
- return monitor.ReadFPR(&user.i387);
+ return monitor.ReadFPR(m_thread.GetID(), &user.i387);
}
Modified: lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp?rev=170445&r1=170444&r2=170445&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp Tue Dec 18 13:50:15 2012
@@ -511,7 +511,7 @@
}
else {
ProcessMonitor &monitor = GetMonitor();
- return monitor.ReadRegisterValue(GetRegOffset(reg),GetRegSize(reg), value);
+ return monitor.ReadRegisterValue(m_thread.GetID(), GetRegOffset(reg),GetRegSize(reg), value);
}
if (reg_info->encoding == eEncodingVector) {
@@ -585,7 +585,7 @@
{
const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
ProcessMonitor &monitor = GetMonitor();
- return monitor.WriteRegisterValue(GetRegOffset(reg), value);
+ return monitor.WriteRegisterValue(m_thread.GetID(), GetRegOffset(reg), value);
}
bool
@@ -788,26 +788,26 @@
RegisterContext_x86_64::ReadGPR()
{
ProcessMonitor &monitor = GetMonitor();
- return monitor.ReadGPR(&user.regs);
+ return monitor.ReadGPR(m_thread.GetID(), &user.regs);
}
bool
RegisterContext_x86_64::ReadFPR()
{
ProcessMonitor &monitor = GetMonitor();
- return monitor.ReadFPR(&user.i387);
+ return monitor.ReadFPR(m_thread.GetID(), &user.i387);
}
bool
RegisterContext_x86_64::WriteGPR()
{
ProcessMonitor &monitor = GetMonitor();
- return monitor.WriteGPR(&user.regs);
+ return monitor.WriteGPR(m_thread.GetID(), &user.regs);
}
bool
RegisterContext_x86_64::WriteFPR()
{
ProcessMonitor &monitor = GetMonitor();
- return monitor.WriteFPR(&user.i387);
+ return monitor.WriteFPR(m_thread.GetID(), &user.i387);
}
More information about the lldb-commits
mailing list