summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Core/ConnectionFileDescriptor.cpp24
-rw-r--r--lldb/source/Core/Log.cpp4
-rw-r--r--lldb/source/Host/common/TimeValue.cpp18
-rw-r--r--lldb/source/Host/windows/Condition.cpp11
-rw-r--r--lldb/source/Host/windows/Mutex.cpp18
-rw-r--r--lldb/source/Host/windows/ProcessRunLock.cpp1
6 files changed, 43 insertions, 33 deletions
diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp
index 77645d2194c..e61f744dba9 100644
--- a/lldb/source/Core/ConnectionFileDescriptor.cpp
+++ b/lldb/source/Core/ConnectionFileDescriptor.cpp
@@ -16,6 +16,7 @@
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Host/Config.h"
+#include "lldb/Host/SocketAddress.h"
// C Includes
#include <errno.h>
@@ -33,6 +34,11 @@
#include <termios.h>
#include <unistd.h>
#endif
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -87,7 +93,7 @@ ConnectionFileDescriptor::ConnectionFileDescriptor () :
m_fd_recv (-1),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
- m_udp_send_sockaddr (),
+ m_udp_send_sockaddr (new SocketAddress()),
m_should_close_fd (false),
m_socket_timeout_usec(0),
m_pipe_read(-1),
@@ -106,7 +112,7 @@ ConnectionFileDescriptor::ConnectionFileDescriptor (int fd, bool owns_fd) :
m_fd_recv (fd),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
- m_udp_send_sockaddr (),
+ m_udp_send_sockaddr (new SocketAddress()),
m_should_close_fd (owns_fd),
m_socket_timeout_usec(0),
m_pipe_read(-1),
@@ -568,15 +574,15 @@ ConnectionFileDescriptor::Write (const void *src, size_t src_len, ConnectionStat
break;
case eFDTypeSocketUDP: // Unconnected UDP socket requiring sendto/recvfrom
- assert (m_udp_send_sockaddr.GetFamily() != 0);
+ assert (m_udp_send_sockaddr->GetFamily() != 0);
do
{
bytes_sent = ::sendto (m_fd_send,
(char*)src,
src_len,
0,
- m_udp_send_sockaddr,
- m_udp_send_sockaddr.GetLength());
+ *m_udp_send_sockaddr,
+ m_udp_send_sockaddr->GetLength());
} while (bytes_sent < 0 && errno == EINTR);
break;
}
@@ -686,7 +692,8 @@ ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_pt
{
TimeValue time_value;
time_value.OffsetWithMicroSeconds (timeout_usec);
- tv = time_value.GetAsTimeVal();
+ tv.tv_sec = time_value.seconds();
+ tv.tv_usec = time_value.microseconds();
tv_ptr = &tv;
}
@@ -836,7 +843,8 @@ ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_pt
{
TimeValue time_value;
time_value.OffsetWithMicroSeconds (timeout_usec);
- tv = time_value.GetAsTimeVal();
+ tv.tv_sec = time_value.seconds();
+ tv.tv_usec = time_value.microseconds();
tv_ptr = &tv;
}
@@ -1446,7 +1454,7 @@ ConnectionFileDescriptor::ConnectUDP (const char *host_and_port, Error *error_pt
if (m_fd_send != -1)
{
- m_udp_send_sockaddr = service_info_ptr;
+ *m_udp_send_sockaddr = service_info_ptr;
break;
}
else
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index 8b403677ffc..9b06ab78174 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -99,8 +99,8 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
// Timestamp if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
{
- struct timeval tv = TimeValue::Now().GetAsTimeVal();
- header.Printf ("%9ld.%6.6d ", tv.tv_sec, (int32_t)tv.tv_usec);
+ TimeValue now = TimeValue::Now();
+ header.Printf ("%9ld.%6.6d ", now.seconds(), now.nanoseconds());
}
// Add the process and thread if requested
diff --git a/lldb/source/Host/common/TimeValue.cpp b/lldb/source/Host/common/TimeValue.cpp
index 0858255cc45..5debd9eade4 100644
--- a/lldb/source/Host/common/TimeValue.cpp
+++ b/lldb/source/Host/common/TimeValue.cpp
@@ -43,8 +43,8 @@ TimeValue::TimeValue(const struct timespec& ts) :
{
}
-TimeValue::TimeValue(const struct timeval& tv) :
- m_nano_seconds ((uint64_t) tv.tv_sec * NanoSecPerSec + (uint64_t) tv.tv_usec * NanoSecPerMicroSec)
+TimeValue::TimeValue(uint32_t seconds, uint32_t nanos) :
+ m_nano_seconds((uint64_t) seconds * NanoSecPerSec + nanos)
{
}
@@ -85,15 +85,6 @@ TimeValue::GetAsTimeSpec () const
return ts;
}
-struct timeval
-TimeValue::GetAsTimeVal () const
-{
- struct timeval tv;
- tv.tv_sec = m_nano_seconds / NanoSecPerSec;
- tv.tv_usec = (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
- return tv;
-}
-
void
TimeValue::Clear ()
{
@@ -127,9 +118,12 @@ TimeValue::OffsetWithNanoSeconds (uint64_t nsec)
TimeValue
TimeValue::Now()
{
+ uint32_t seconds, nanoseconds;
struct timeval tv;
gettimeofday(&tv, NULL);
- TimeValue now(tv);
+ seconds = tv.tv_sec;
+ nanoseconds = tv.tv_usec * NanoSecPerMicroSec;
+ TimeValue now(seconds, nanoseconds);
return now;
}
diff --git a/lldb/source/Host/windows/Condition.cpp b/lldb/source/Host/windows/Condition.cpp
index efece6d7519..72f0e38028d 100644
--- a/lldb/source/Host/windows/Condition.cpp
+++ b/lldb/source/Host/windows/Condition.cpp
@@ -11,6 +11,7 @@
#include "lldb/Host/Condition.h"
#include "lldb/Host/TimeValue.h"
+#include "lldb/Host/windows/windows.h"
using namespace lldb_private;
@@ -24,7 +25,8 @@ using namespace lldb_private;
Condition::Condition () :
m_condition()
{
- InitializeConditionVariable(&m_condition);
+ m_condition = static_cast<PCONDITION_VARIABLE>(malloc(sizeof(CONDITION_VARIABLE)));
+ InitializeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
}
//----------------------------------------------------------------------
@@ -34,6 +36,7 @@ Condition::Condition () :
//----------------------------------------------------------------------
Condition::~Condition ()
{
+ free(m_condition);
}
//----------------------------------------------------------------------
@@ -42,7 +45,7 @@ Condition::~Condition ()
int
Condition::Broadcast ()
{
- WakeAllConditionVariable(&m_condition);
+ WakeAllConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
return 0;
}
@@ -52,7 +55,7 @@ Condition::Broadcast ()
int
Condition::Signal ()
{
- WakeConditionVariable(&m_condition);
+ WakeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
return 0;
}
@@ -80,7 +83,7 @@ Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
wait = wval;
}
- int err = SleepConditionVariableCS(&m_condition, &mutex.m_mutex, wait);
+ int err = SleepConditionVariableCS(static_cast<PCONDITION_VARIABLE>(m_condition), static_cast<PCRITICAL_SECTION>(mutex.m_mutex), wait);
if (timed_out != NULL)
{
diff --git a/lldb/source/Host/windows/Mutex.cpp b/lldb/source/Host/windows/Mutex.cpp
index 602ca1a3477..ed90f46eb54 100644
--- a/lldb/source/Host/windows/Mutex.cpp
+++ b/lldb/source/Host/windows/Mutex.cpp
@@ -9,6 +9,7 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/windows/windows.h"
#include <string.h>
#include <stdio.h>
@@ -33,7 +34,8 @@ using namespace lldb_private;
Mutex::Mutex () :
m_mutex()
{
- InitializeCriticalSection(&m_mutex);
+ m_mutex = static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
+ InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
}
//----------------------------------------------------------------------
@@ -44,7 +46,8 @@ Mutex::Mutex () :
Mutex::Mutex (Mutex::Type type) :
m_mutex()
{
- InitializeCriticalSection(&m_mutex);
+ m_mutex = static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
+ InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
}
//----------------------------------------------------------------------
@@ -54,7 +57,8 @@ Mutex::Mutex (Mutex::Type type) :
//----------------------------------------------------------------------
Mutex::~Mutex()
{
- DeleteCriticalSection(&m_mutex);
+ DeleteCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
+ free(m_mutex);
}
//----------------------------------------------------------------------
@@ -68,9 +72,9 @@ Mutex::~Mutex()
int
Mutex::Lock()
{
- DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), &m_mutex);
+ DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), m_mutex);
- EnterCriticalSection(&m_mutex);
+ EnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
return 0;
}
@@ -85,7 +89,7 @@ Mutex::Lock()
int
Mutex::TryLock(const char *failure_message)
{
- return TryEnterCriticalSection(&m_mutex) == 0;
+ return TryEnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex)) == 0;
}
//----------------------------------------------------------------------
@@ -100,6 +104,6 @@ Mutex::TryLock(const char *failure_message)
int
Mutex::Unlock()
{
- LeaveCriticalSection(&m_mutex);
+ LeaveCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
return 0;
}
diff --git a/lldb/source/Host/windows/ProcessRunLock.cpp b/lldb/source/Host/windows/ProcessRunLock.cpp
index ae9a9733c16..97ec0ebce15 100644
--- a/lldb/source/Host/windows/ProcessRunLock.cpp
+++ b/lldb/source/Host/windows/ProcessRunLock.cpp
@@ -1,6 +1,7 @@
#ifdef _WIN32
#include "lldb/Host/ProcessRunLock.h"
+#include "lldb/Host/windows/windows.h"
namespace lldb_private {
OpenPOWER on IntegriCloud