summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-11-13 04:45:22 +0000
committerGreg Clayton <gclayton@apple.com>2011-11-13 04:45:22 +0000
commit93e8619ded45e1f185df62acbbc20d6b6bab3df3 (patch)
tree8131bb242a13c0cf41baea62e5fdc96830fda620
parent5196efdf363f22d468b1eee23da8f48d2b04d268 (diff)
downloadbcm5719-llvm-93e8619ded45e1f185df62acbbc20d6b6bab3df3.tar.gz
bcm5719-llvm-93e8619ded45e1f185df62acbbc20d6b6bab3df3.zip
<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. llvm-svn: 144491
-rw-r--r--lldb/include/lldb/Target/Process.h17
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp40
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h13
-rw-r--r--lldb/source/Target/Process.cpp65
4 files changed, 70 insertions, 65 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 93a2e527cf8..e002932750a 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2378,12 +2378,7 @@ public:
/// 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 @@ public:
/// 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 @@ protected:
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 @@ protected:
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);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index dbe81aea2ff..4f77d924564 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -120,7 +120,6 @@ ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name)
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 @@ ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr)
//------------------------------------------------------------------
// 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 @@ ProcessGDBRemote::Clear()
{
m_flags = 0;
m_thread_list.Clear();
- {
- Mutex::Locker locker(m_stdio_mutex);
- m_stdout_data.clear();
- }
}
Error
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index be0f95a7dc9..5207231134c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -173,12 +173,6 @@ public:
// 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 @@ protected:
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 @@ protected:
};
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;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index d22c79d3e08..6ee9dbf85de 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -683,6 +683,7 @@ Process::Process(Target &target, Listener &listener) :
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 @@ Process::AppendSTDOUT (const char * s, size_t len)
{
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;
OpenPOWER on IntegriCloud