Index: include/lldb/Host/windows/win32.h =================================================================== --- include/lldb/Host/windows/win32.h +++ include/lldb/Host/windows/win32.h @@ -57,6 +57,7 @@ int usleep(uint32_t useconds); char* getcwd(char* path, int max); +int chdir(const char* path); char* basename(char *path); char *dirname(char *path); Index: source/Host/windows/Windows.cpp =================================================================== --- source/Host/windows/Windows.cpp +++ source/Host/windows/Windows.cpp @@ -20,6 +20,13 @@ #include #include +// These prototypes are defined in , but it also defines chdir() and getcwd(), giving multiply defined errors +extern "C" +{ + char *_getcwd(char *buffer, int maxlen); + int _chdir(const char *path); +} + int vasprintf(char **ret, const char *fmt, va_list ap) { char *buf; @@ -157,11 +164,16 @@ return &l1[1]; } +// use _getcwd() instead of GetCurrentDirectory() because it updates errno char* getcwd(char* path, int max) { - if (GetCurrentDirectory(max, path) == 0) - return path; - return NULL; + return _getcwd(path, max); +} + +// use _chdir() instead of SetCurrentDirectory() because it updates errno +int chdir(const char* path) +{ + return _chdir(path); } char *dirname(char *path) Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -217,15 +217,10 @@ std::string path; packet.GetHexByteString (path); -#ifdef _WIN32 - // Not implemented on Windows - return SendUnimplementedResponse ("GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir unimplemented"); -#else // If this packet is sent to a platform, then change the current working directory if (::chdir(path.c_str()) != 0) return SendErrorResponse (errno); return SendOKResponse (); -#endif } GDBRemoteCommunication::PacketResult Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -870,17 +870,12 @@ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("Platform::SetWorkingDirectory('%s')", path.GetCString()); -#ifdef _WIN32 - // Not implemented on Windows - return false; -#else if (path) { if (chdir(path.GetCString()) == 0) return true; } return false; -#endif } else {