[Lldb-commits] [lldb] r144491 - in /lldb/trunk: include/lldb/Target/Process.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Target/Process.cpp
Greg Clayton
gclayton at apple.com
Sat Nov 12 20:45:22 PST 2011
Author: gclayton
Date: Sat Nov 12 22:45:22 2011
New Revision: 144491
URL: http://llvm.org/viewvc/llvm-project?rev=144491&view=rev
Log:
<rdar://problem/10103980>
A long time ago we started to centralized the STDOUT in lldb_private::Process
but we missed a few things still in ProcessGDBRemote.
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=144491&r1=144490&r2=144491&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Sat Nov 12 22:45:22 2011
@@ -2378,12 +2378,7 @@
/// be made to retrieve more STDOUT data.
//------------------------------------------------------------------
virtual size_t
- GetSTDOUT (char *buf, size_t buf_size, Error &error)
- {
- error.SetErrorString("stdout unsupported");
- return 0;
- }
-
+ GetSTDOUT (char *buf, size_t buf_size, Error &error);
//------------------------------------------------------------------
/// Get any available STDERR.
@@ -2407,11 +2402,7 @@
/// be made to retrieve more STDERR data.
//------------------------------------------------------------------
virtual size_t
- GetSTDERR (char *buf, size_t buf_size, Error &error)
- {
- error.SetErrorString("stderr unsupported");
- return 0;
- }
+ GetSTDERR (char *buf, size_t buf_size, Error &error);
virtual size_t
PutSTDIN (const char *buf, size_t buf_size, Error &error)
@@ -2800,6 +2791,7 @@
lldb_private::Communication m_stdio_communication;
lldb_private::Mutex m_stdio_communication_mutex;
std::string m_stdout_data;
+ std::string m_stderr_data;
MemoryCache m_memory_cache;
AllocatedMemoryCache m_allocated_memory_cache;
bool m_attached_to_process; /// Did we launch the process or attach to it?
@@ -2870,6 +2862,9 @@
void
AppendSTDOUT (const char *s, size_t len);
+ void
+ AppendSTDERR (const char *s, size_t len);
+
static void
STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=144491&r1=144490&r2=144491&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sat Nov 12 22:45:22 2011
@@ -120,7 +120,6 @@
ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
Process (target, listener),
m_flags (0),
- m_stdio_mutex (Mutex::eMutexTypeRecursive),
m_gdb_comm(false),
m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
m_debugserver_thread (LLDB_INVALID_HOST_THREAD),
@@ -1753,41 +1752,6 @@
//------------------------------------------------------------------
// Process STDIO
//------------------------------------------------------------------
-
-size_t
-ProcessGDBRemote::GetSTDOUT (char *buf, size_t buf_size, Error &error)
-{
- Mutex::Locker locker(m_stdio_mutex);
- size_t bytes_available = m_stdout_data.size();
- if (bytes_available > 0)
- {
- LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
- if (log)
- log->Printf ("ProcessGDBRemote::%s (&%p[%lu]) ...", __FUNCTION__, buf, buf_size);
- if (bytes_available > buf_size)
- {
- memcpy(buf, m_stdout_data.c_str(), buf_size);
- m_stdout_data.erase(0, buf_size);
- bytes_available = buf_size;
- }
- else
- {
- memcpy(buf, m_stdout_data.c_str(), bytes_available);
- m_stdout_data.clear();
-
- //ResetEventBits(eBroadcastBitSTDOUT);
- }
- }
- return bytes_available;
-}
-
-size_t
-ProcessGDBRemote::GetSTDERR (char *buf, size_t buf_size, Error &error)
-{
- // Can we get STDERR through the remote protocol?
- return 0;
-}
-
size_t
ProcessGDBRemote::PutSTDIN (const char *src, size_t src_len, Error &error)
{
@@ -2018,10 +1982,6 @@
{
m_flags = 0;
m_thread_list.Clear();
- {
- Mutex::Locker locker(m_stdio_mutex);
- m_stdout_data.clear();
- }
}
Error
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=144491&r1=144490&r2=144491&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Sat Nov 12 22:45:22 2011
@@ -173,12 +173,6 @@
// Process STDIO
//------------------------------------------------------------------
virtual size_t
- GetSTDOUT (char *buf, size_t buf_size, lldb_private::Error &error);
-
- virtual size_t
- GetSTDERR (char *buf, size_t buf_size, lldb_private::Error &error);
-
- virtual size_t
PutSTDIN (const char *buf, size_t buf_size, lldb_private::Error &error);
//----------------------------------------------------------------------
@@ -239,12 +233,6 @@
bool
ProcessIDIsValid ( ) const;
-// static void
-// STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
-
-// void
-// AppendSTDOUT (const char* s, size_t len);
-
void
Clear ( );
@@ -289,7 +277,6 @@
};
lldb_private::Flags m_flags; // Process specific flags (see eFlags enums)
- lldb_private::Mutex m_stdio_mutex; // Multithreaded protection for stdio
GDBRemoteCommunicationClient m_gdb_comm;
lldb::pid_t m_debugserver_pid;
lldb::thread_t m_debugserver_thread;
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144491&r1=144490&r2=144491&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sat Nov 12 22:45:22 2011
@@ -683,6 +683,7 @@
m_stdio_communication ("process.stdio"),
m_stdio_communication_mutex (Mutex::eMutexTypeRecursive),
m_stdout_data (),
+ m_stderr_data (),
m_memory_cache (*this),
m_allocated_memory_cache (*this),
m_attached_to_process (false),
@@ -3217,11 +3218,73 @@
{
Mutex::Locker locker (m_stdio_communication_mutex);
m_stdout_data.append (s, len);
-
BroadcastEventIfUnique (eBroadcastBitSTDOUT, new ProcessEventData (GetTarget().GetProcessSP(), GetState()));
}
void
+Process::AppendSTDERR (const char * s, size_t len)
+{
+ Mutex::Locker locker (m_stdio_communication_mutex);
+ m_stderr_data.append (s, len);
+ BroadcastEventIfUnique (eBroadcastBitSTDERR, new ProcessEventData (GetTarget().GetProcessSP(), GetState()));
+}
+
+//------------------------------------------------------------------
+// Process STDIO
+//------------------------------------------------------------------
+
+size_t
+Process::GetSTDOUT (char *buf, size_t buf_size, Error &error)
+{
+ Mutex::Locker locker(m_stdio_communication_mutex);
+ size_t bytes_available = m_stdout_data.size();
+ if (bytes_available > 0)
+ {
+ LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf ("Process::GetSTDOUT (buf = %p, size = %zu)", buf, buf_size);
+ if (bytes_available > buf_size)
+ {
+ memcpy(buf, m_stdout_data.c_str(), buf_size);
+ m_stdout_data.erase(0, buf_size);
+ bytes_available = buf_size;
+ }
+ else
+ {
+ memcpy(buf, m_stdout_data.c_str(), bytes_available);
+ m_stdout_data.clear();
+ }
+ }
+ return bytes_available;
+}
+
+
+size_t
+Process::GetSTDERR (char *buf, size_t buf_size, Error &error)
+{
+ Mutex::Locker locker(m_stdio_communication_mutex);
+ size_t bytes_available = m_stderr_data.size();
+ if (bytes_available > 0)
+ {
+ LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf ("Process::GetSTDERR (buf = %p, size = %zu)", buf, buf_size);
+ if (bytes_available > buf_size)
+ {
+ memcpy(buf, m_stderr_data.c_str(), buf_size);
+ m_stderr_data.erase(0, buf_size);
+ bytes_available = buf_size;
+ }
+ else
+ {
+ memcpy(buf, m_stderr_data.c_str(), bytes_available);
+ m_stderr_data.clear();
+ }
+ }
+ return bytes_available;
+}
+
+void
Process::STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len)
{
Process *process = (Process *) baton;
More information about the lldb-commits
mailing list