[Lldb-commits] [lldb] r163822 - in /lldb/branches/windows: ./ include/ scripts/ source/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Host/ source/Host/common/ source/Host/linux/ source/Host/windows/ source/Interpreter/ source/Plugins/ source/Plugins/ABI/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/Disassembler/ source/Plugins/Disassembler/llvm/ source/Plugins/DynamicLoader/ source/Plugins/DynamicLoader/Static/ source/Plugins/Instruction/ source/Plugins/LanguageRuntime/ sourc...
Carlo Kok
ck at remobjects.com
Thu Sep 13 11:40:54 PDT 2012
Author: carlokok
Date: Thu Sep 13 13:40:53 2012
New Revision: 163822
URL: http://llvm.org/viewvc/llvm-project?rev=163822&view=rev
Log:
All other missing files for the lldb Windows branch (from Initial windows patch from Joao Matos)
Added:
lldb/branches/windows/CMakeLists.txt
lldb/branches/windows/include/dirent.h
lldb/branches/windows/scripts/CMakeLists.txt
lldb/branches/windows/source/API/CMakeLists.txt
lldb/branches/windows/source/Breakpoint/CMakeLists.txt
lldb/branches/windows/source/CMakeLists.txt
lldb/branches/windows/source/Commands/CMakeLists.txt
lldb/branches/windows/source/Core/CMakeLists.txt
lldb/branches/windows/source/Core/Windows.cpp
lldb/branches/windows/source/Core/getopt.c
lldb/branches/windows/source/Expression/CMakeLists.txt
lldb/branches/windows/source/Host/CMakeLists.txt
lldb/branches/windows/source/Host/common/CMakeLists.txt
lldb/branches/windows/source/Host/linux/CMakeLists.txt
lldb/branches/windows/source/Host/windows/
lldb/branches/windows/source/Host/windows/CMakeLists.txt
lldb/branches/windows/source/Host/windows/Host.cpp
lldb/branches/windows/source/Host/windows/ReadWriteLock.cpp
lldb/branches/windows/source/Interpreter/CMakeLists.txt
lldb/branches/windows/source/Plugins/ABI/CMakeLists.txt
lldb/branches/windows/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
lldb/branches/windows/source/Plugins/CMakeLists.txt
lldb/branches/windows/source/Plugins/Disassembler/CMakeLists.txt
lldb/branches/windows/source/Plugins/Disassembler/llvm/CMakeLists.txt
lldb/branches/windows/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/branches/windows/source/Plugins/DynamicLoader/Static/CMakeLists.txt
lldb/branches/windows/source/Plugins/Instruction/CMakeLists.txt
lldb/branches/windows/source/Plugins/LanguageRuntime/CMakeLists.txt
lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectContainer/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectFile/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectFile/ELF/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt
lldb/branches/windows/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
lldb/branches/windows/source/Plugins/OperatingSystem/CMakeLists.txt
lldb/branches/windows/source/Plugins/OperatingSystem/Darwin-Kernel/CMakeLists.txt
lldb/branches/windows/source/Plugins/Platform/CMakeLists.txt
lldb/branches/windows/source/Plugins/Platform/Windows/
lldb/branches/windows/source/Plugins/Platform/Windows/CMakeLists.txt
lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/branches/windows/source/Plugins/Platform/gdb-server/CMakeLists.txt
lldb/branches/windows/source/Plugins/Process/CMakeLists.txt
lldb/branches/windows/source/Plugins/Process/Utility/CMakeLists.txt
lldb/branches/windows/source/Plugins/Process/gdb-remote/CMakeLists.txt
lldb/branches/windows/source/Plugins/SymbolFile/CMakeLists.txt
lldb/branches/windows/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/branches/windows/source/Plugins/SymbolFile/Symtab/CMakeLists.txt
lldb/branches/windows/source/Plugins/SymbolVendor/CMakeLists.txt
lldb/branches/windows/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
lldb/branches/windows/source/Plugins/UnwindAssembly/CMakeLists.txt
lldb/branches/windows/source/Symbol/CMakeLists.txt
lldb/branches/windows/source/Target/CMakeLists.txt
lldb/branches/windows/source/Utility/CMakeLists.txt
lldb/branches/windows/tools/CMakeLists.txt
lldb/branches/windows/tools/driver/CMakeLists.txt
lldb/branches/windows/tools/driver/DriverEvents.cpp
lldb/branches/windows/tools/driver/DriverOptions.cpp
lldb/branches/windows/tools/driver/DriverPosix.cpp
Added: lldb/branches/windows/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/CMakeLists.txt (added)
+++ lldb/branches/windows/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,159 @@
+# If we are not building as a part of LLVM, build LLDB as an
+# standalone project, using LLVM as an external library:
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ project(lldb)
+ cmake_minimum_required(VERSION 2.8)
+
+ set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
+ "Path to LLVM source code. Not necessary if using an installed LLVM.")
+ set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
+ "Path to the directory where LLVM was built or installed.")
+
+ set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
+ "Path to Clang source code. Not necessary if using an installed Clang.")
+ set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
+ "Path to the directory where Clang was built or installed.")
+
+ set(LLDB_DISABLE_PYTHON 1 BOOL "Disables the Python scripting integration.")
+
+ if (LLDB_PATH_TO_LLVM_SOURCE)
+ if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
+ message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
+ "directory of LLVM source code.")
+ else()
+ get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
+ ABSOLUTE)
+ list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+ endif()
+ endif()
+
+ if (LLDB_PATH_TO_CLANG_SOURCE)
+ get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
+ ABSOLUTE)
+ endif()
+
+ list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
+
+ get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
+ ABSOLUTE)
+
+ get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
+ ABSOLUTE)
+
+ include(AddLLVM)
+ include("${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
+ include(HandleLLVMOptions)
+
+ set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
+
+ set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
+ set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
+
+ set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
+
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
+ include_directories("${PATH_TO_LLVM_BUILD}/include"
+ "${LLVM_MAIN_INCLUDE_DIR}"
+ "${PATH_TO_CLANG_BUILD}/include"
+ "${CLANG_MAIN_INCLUDE_DIR}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source")
+ link_directories("${PATH_TO_LLVM_BUILD}/lib"
+ "${PATH_TO_CLANG_BUILD}/lib")
+
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+
+ set(LLDB_BUILT_STANDALONE 1)
+
+ if (LLDB_DISABLE_PYTHON)
+ add_definitions( -DLLDB_DISABLE_PYTHON )
+ endif()
+endif()
+
+macro(add_lldb_definitions)
+ # We don't want no semicolons on LLDB_DEFINITIONS:
+ foreach(arg ${ARGN})
+ set(LLDB_DEFINITIONS "${LLVM_DEFINITIONS} ${arg}")
+ endforeach(arg)
+ add_definitions( ${ARGN} )
+endmacro(add_lldb_definitions)
+
+# Disable MSVC warnings
+if( MSVC )
+ add_lldb_definitions(
+ -wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch'
+ -wd4068 # Suppress 'warning C4068: unknown pragma'
+ -wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type'
+ -wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified'
+ )
+endif()
+
+set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
+"the makefiles distributed with LLDB. Please create a directory and run cmake "
+"from there, passing the path to this source directory as the last argument. "
+"This process created the file `CMakeCache.txt' and the directory "
+"`CMakeFiles'. Please delete them.")
+endif()
+
+macro(add_lldb_library name)
+ llvm_process_sources(srcs ${ARGN})
+ if (MSVC_IDE OR XCODE)
+ string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
+ list(GET split_path -1 dir)
+ file(GLOB_RECURSE headers
+ ../../include/lldb${dir}/*.h)
+ set(srcs ${srcs} ${headers})
+ endif()
+ if (MODULE)
+ set(libkind MODULE)
+ elseif (SHARED_LIBRARY)
+ set(libkind SHARED)
+ else()
+ set(libkind)
+ endif()
+ add_library(${name} ${libkind} ${srcs})
+ if (LLVM_COMMON_DEPENDS)
+ add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
+ endif()
+
+ target_link_libraries(${name} ${LLVM_USED_LIBS})
+ llvm_config(${name} ${LLVM_LINK_COMPONENTS})
+ target_link_libraries(${name} ${LLVM_COMMON_LIBS})
+ #target_link_libraries(${name} ${CLANG_USED_LIBS})
+ link_system_libs(${name})
+
+ install(TARGETS ${name}
+ LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+ set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
+endmacro(add_lldb_library)
+
+macro(add_lldb_executable name)
+ add_llvm_executable(${name} ${ARGN})
+ target_link_libraries(${name} ${LLDB_USED_LIBS})
+ target_link_libraries(${name} ${CLANG_USED_LIBS})
+ set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
+endmacro(add_lldb_executable)
+
+include_directories(BEFORE
+ ${CMAKE_CURRENT_BINARY_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ )
+
+install(DIRECTORY include/
+ DESTINATION include
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN ".svn" EXCLUDE
+ )
+
+#add_subdirectory(include)
+#add_subdirectory(scripts)
+add_subdirectory(source)
+#add_subdirectory(test)
+add_subdirectory(tools)
Added: lldb/branches/windows/include/dirent.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/dirent.h?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/include/dirent.h (added)
+++ lldb/branches/windows/include/dirent.h Thu Sep 13 13:40:53 2012
@@ -0,0 +1,395 @@
+/*****************************************************************************
+ * dirent.h - dirent API for Microsoft Visual Studio
+ *
+ * Copyright (C) 2006 Toni Ronkko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Added d_type and d_namlen fields to dirent structure. The former is
+ * especially useful for determining whether directory entry represents a
+ * file or a directory. For more information, see
+ * http://www.delorie.com/gnu/docs/glibc/libc_270.html
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Improved conformance to the standards. For example, errno is now set
+ * properly on failure and assert() is never used. Thanks to Peter Brockam
+ * for suggestions.
+ *
+ * Aug 11, 2010, Toni Ronkko
+ * Fixed a bug in rewinddir(): when using relative directory names, change
+ * of working directory no longer causes rewinddir() to fail.
+ *
+ * Dec 15, 2009, John Cunningham
+ * Added rewinddir member function
+ *
+ * Jan 18, 2008, Toni Ronkko
+ * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
+ * between multi-byte and unicode representations. This makes the
+ * code simpler and also allows the code to be compiled under MingW. Thanks
+ * to Azriel Fasten for the suggestion.
+ *
+ * Mar 4, 2007, Toni Ronkko
+ * Bug fix: due to the strncpy_s() function this file only compiled in
+ * Visual Studio 2005. Using the new string functions only when the
+ * compiler version allows.
+ *
+ * Nov 2, 2006, Toni Ronkko
+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
+ * simplify the file, updated the code to compile cleanly on Visual
+ * Studio 2005 with both unicode and multi-byte character strings,
+ * removed rewinddir() as it had a bug.
+ *
+ * Aug 20, 2006, Toni Ronkko
+ * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
+ * comments by removing SGML tags.
+ *
+ * May 14 2002, Toni Ronkko
+ * Embedded the function definitions directly to the header so that no
+ * source modules need to be included in the Visual Studio project. Removed
+ * all the dependencies to other projects so that this very header can be
+ * used independently.
+ *
+ * May 28 1998, Toni Ronkko
+ * First version.
+ *****************************************************************************/
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+/* File type and permission flags for stat() */
+#if defined(_MSC_VER) && !defined(S_IREAD)
+# define S_IFMT _S_IFMT /* file type mask */
+# define S_IFDIR _S_IFDIR /* directory */
+# define S_IFCHR _S_IFCHR /* character device */
+# define S_IFFIFO _S_IFFIFO /* pipe */
+# define S_IFREG _S_IFREG /* regular file */
+# define S_IREAD _S_IREAD /* read permission */
+# define S_IWRITE _S_IWRITE /* write permission */
+# define S_IEXEC _S_IEXEC /* execute permission */
+#endif
+
+#ifndef S_IFBLK
+#define S_IFBLK 0060000 /* block device */
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK 0120000 /* link */
+#endif
+
+#ifndef S_IFSOCK
+#define S_IFSOCK 0140000 /* socket */
+#endif
+
+#ifndef S_IFIFO
+#define S_IFIFO 0010000 /* fifo */
+#endif
+
+#if defined(_MSC_VER)
+# define S_IRUSR S_IREAD /* read, user */
+# define S_IWUSR S_IWRITE /* write, user */
+# define S_IXUSR 0 /* execute, user */
+# define S_IRGRP 0 /* read, group */
+# define S_IWGRP 0 /* write, group */
+# define S_IXGRP 0 /* execute, group */
+# define S_IROTH 0 /* read, others */
+# define S_IWOTH 0 /* write, others */
+# define S_IXOTH 0 /* execute, others */
+#endif
+
+/* Indicates that d_type field is available in dirent structure */
+#define _DIRENT_HAVE_D_TYPE
+
+/* File type flags for d_type */
+#define DT_UNKNOWN 0
+#define DT_REG S_IFREG
+#define DT_DIR S_IFDIR
+#define DT_FIFO S_IFIFO
+#define DT_SOCK S_IFSOCK
+#define DT_CHR S_IFCHR
+#define DT_BLK S_IFBLK
+#define DT_LNK S_IFLNK
+
+/* Macros for converting between st_mode and d_type */
+#define IFTODT(mode) ((mode) & S_IFMT)
+#define DTTOIF(type) (type)
+
+/*
+ * File type macros. Note that block devices, sockets and links cannot be
+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
+ * only defined for compatibility. These macros should always return false
+ * on Windows.
+ */
+
+#ifndef S_ISFIFO
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+
+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
+
+#ifndef S_ISCHR
+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
+#endif
+
+#ifndef S_ISBLK
+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct dirent
+{
+ char d_name[MAX_PATH + 1]; /* File name */
+ size_t d_namlen; /* Length of name without \0 */
+ int d_type; /* File type */
+} dirent;
+
+
+typedef struct DIR
+{
+ dirent curentry; /* Current directory entry */
+ WIN32_FIND_DATAA find_data; /* Private file data */
+ int cached; /* True if data is valid */
+ HANDLE search_handle; /* Win32 search handle */
+ char patt[MAX_PATH + 3]; /* Initial directory name */
+} DIR;
+
+
+/* Forward declarations */
+static DIR *opendir(const char *dirname);
+static struct dirent *readdir(DIR *dirp);
+static int closedir(DIR *dirp);
+static void rewinddir(DIR* dirp);
+
+
+/* Use the new safe string functions introduced in Visual Studio 2005 */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
+#else
+# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
+#endif
+
+/* Set errno variable */
+#if defined(_MSC_VER)
+#define DIRENT_SET_ERRNO(x) _set_errno (x)
+#else
+#define DIRENT_SET_ERRNO(x) (errno = (x))
+#endif
+
+
+/*****************************************************************************
+ * Open directory stream DIRNAME for read and return a pointer to the
+ * internal working area that is used to retrieve individual directory
+ * entries.
+ */
+static DIR *opendir(const char *dirname)
+{
+ DIR *dirp;
+
+ /* ensure that the resulting search pattern will be a valid file name */
+ if (dirname == NULL) {
+ DIRENT_SET_ERRNO (ENOENT);
+ return NULL;
+ }
+ if (strlen (dirname) + 3 >= MAX_PATH) {
+ DIRENT_SET_ERRNO (ENAMETOOLONG);
+ return NULL;
+ }
+
+ /* construct new DIR structure */
+ dirp = (DIR*) malloc (sizeof (struct DIR));
+ if (dirp != NULL) {
+ int error;
+
+ /*
+ * Convert relative directory name to an absolute directory one. This
+ * allows rewinddir() to function correctly when the current working
+ * directory is changed between opendir() and rewinddir().
+ */
+ if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
+ char *p;
+
+ /* append the search pattern "\\*\0" to the directory name */
+ p = strchr (dirp->patt, '\0');
+ if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
+ *p++ = '\\';
+ }
+ *p++ = '*';
+ *p = '\0';
+
+ /* open directory stream and retrieve the first entry */
+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ /* a directory entry is now waiting in memory */
+ dirp->cached = 1;
+ error = 0;
+ } else {
+ /* search pattern is not a directory name? */
+ DIRENT_SET_ERRNO (ENOENT);
+ error = 1;
+ }
+ } else {
+ /* buffer too small */
+ DIRENT_SET_ERRNO (ENOMEM);
+ error = 1;
+ }
+
+ if (error) {
+ free (dirp);
+ dirp = NULL;
+ }
+ }
+
+ return dirp;
+}
+
+
+/*****************************************************************************
+ * Read a directory entry, and return a pointer to a dirent structure
+ * containing the name of the entry in d_name field. Individual directory
+ * entries returned by this very function include regular files,
+ * sub-directories, pseudo-directories "." and "..", but also volume labels,
+ * hidden files and system files may be returned.
+ */
+static struct dirent *readdir(DIR *dirp)
+{
+ DWORD attr;
+ if (dirp == NULL) {
+ /* directory stream did not open */
+ DIRENT_SET_ERRNO (EBADF);
+ return NULL;
+ }
+
+ /* get next directory entry */
+ if (dirp->cached != 0) {
+ /* a valid directory entry already in memory */
+ dirp->cached = 0;
+ } else {
+ /* get the next directory entry from stream */
+ if (dirp->search_handle == INVALID_HANDLE_VALUE) {
+ return NULL;
+ }
+ if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
+ /* the very last entry has been processed or an error occured */
+ FindClose (dirp->search_handle);
+ dirp->search_handle = INVALID_HANDLE_VALUE;
+ return NULL;
+ }
+ }
+
+ /* copy as a multibyte character string */
+ DIRENT_STRNCPY ( dirp->curentry.d_name,
+ dirp->find_data.cFileName,
+ sizeof(dirp->curentry.d_name) );
+ dirp->curentry.d_name[MAX_PATH] = '\0';
+
+ /* compute the length of name */
+ dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
+
+ /* determine file type */
+ attr = dirp->find_data.dwFileAttributes;
+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
+ dirp->curentry.d_type = DT_CHR;
+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ dirp->curentry.d_type = DT_DIR;
+ } else {
+ dirp->curentry.d_type = DT_REG;
+ }
+ return &dirp->curentry;
+}
+
+
+/*****************************************************************************
+ * Close directory stream opened by opendir() function. Close of the
+ * directory stream invalidates the DIR structure as well as any previously
+ * read directory entry.
+ */
+static int closedir(DIR *dirp)
+{
+ if (dirp == NULL) {
+ /* invalid directory stream */
+ DIRENT_SET_ERRNO (EBADF);
+ return -1;
+ }
+
+ /* release search handle */
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->search_handle);
+ dirp->search_handle = INVALID_HANDLE_VALUE;
+ }
+
+ /* release directory structure */
+ free (dirp);
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Resets the position of the directory stream to which dirp refers to the
+ * beginning of the directory. It also causes the directory stream to refer
+ * to the current state of the corresponding directory, as a call to opendir()
+ * would have done. If dirp does not refer to a directory stream, the effect
+ * is undefined.
+ */
+static void rewinddir(DIR* dirp)
+{
+ if (dirp != NULL) {
+ /* release search handle */
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ FindClose (dirp->search_handle);
+ }
+
+ /* open new search handle and retrieve the first entry */
+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
+ /* a directory entry is now waiting in memory */
+ dirp->cached = 1;
+ } else {
+ /* failed to re-open directory: no directory entry in memory */
+ dirp->cached = 0;
+ }
+ }
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*DIRENT_H*/
Added: lldb/branches/windows/scripts/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/scripts/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/scripts/CMakeLists.txt (added)
+++ lldb/branches/windows/scripts/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,12 @@
+set(LLVM_NO_RTTI 1)
+
+add_custom_command(
+ OUTPUT ${LLDB_SOURCE_DIR}/source/LLDBWrapPython.cpp
+ DEPENDS ${LLDB_SOURCE_DIR}/scripts/lldb.swig
+ COMMAND swig -c++ -shadow -python -I${LLDB_SOURCE_DIR}/include -I./. -outdir ${LLDB_SOURCE_DIR}/scripts/Python -o ${LLDB_SOURCE_DIR}/source/LLDBWrapPython.cpp ${LLDB_SOURCE_DIR}/scripts/lldb.swig
+ COMMENT "Building lldb pyhton wrapper")
+set_source_files_properties(${LLDB_SOURCE_DIR}/source/LLDBWrapPython.cpp PROPERTIES GENERATED 1)
+
+ADD_CUSTOM_TARGET(swig_wrapper ALL echo
+ DEPENDS ${LLDB_SOURCE_DIR}/source/LLDBWrapPython.cpp
+ )
Added: lldb/branches/windows/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/API/CMakeLists.txt (added)
+++ lldb/branches/windows/source/API/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,48 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbAPI
+ SBAddress.cpp
+ SBBlock.cpp
+ SBBreakpoint.cpp
+ SBBreakpointLocation.cpp
+ SBBroadcaster.cpp
+ SBCommandInterpreter.cpp
+ SBCommandReturnObject.cpp
+ SBCommunication.cpp
+ SBCompileUnit.cpp
+ SBData.cpp
+ SBDebugger.cpp
+ SBError.cpp
+ SBEvent.cpp
+ SBFileSpec.cpp
+ SBFileSpecList.cpp
+ SBFrame.cpp
+ SBFunction.cpp
+ SBHostOS.cpp
+ SBInputReader.cpp
+ SBInstruction.cpp
+ SBInstructionList.cpp
+ SBLineEntry.cpp
+ SBListener.cpp
+ SBModule.cpp
+ SBProcess.cpp
+ SBSection.cpp
+ SBSourceManager.cpp
+ SBStream.cpp
+ SBStringList.cpp
+ SBSymbol.cpp
+ SBSymbolContext.cpp
+ SBSymbolContextList.cpp
+ SBTarget.cpp
+ SBThread.cpp
+ SBType.cpp
+ SBTypeCategory.cpp
+ SBTypeFilter.cpp
+ SBTypeFormat.cpp
+ SBTypeNameSpecifier.cpp
+ SBTypeSummary.cpp
+ SBTypeSynthetic.cpp
+ SBValue.cpp
+ SBValueList.cpp
+ SBWatchpoint.cpp
+ )
Added: lldb/branches/windows/source/Breakpoint/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Breakpoint/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Breakpoint/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,25 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbBreakpoint
+ Breakpoint.cpp
+ BreakpointID.cpp
+ BreakpointIDList.cpp
+ BreakpointList.cpp
+ BreakpointLocation.cpp
+ BreakpointLocationCollection.cpp
+ BreakpointLocationList.cpp
+ BreakpointOptions.cpp
+ BreakpointResolver.cpp
+ BreakpointResolverAddress.cpp
+ BreakpointResolverFileLine.cpp
+ BreakpointResolverFileRegex.cpp
+ BreakpointResolverName.cpp
+ BreakpointSite.cpp
+ BreakpointSiteList.cpp
+ Stoppoint.cpp
+ StoppointCallbackContext.cpp
+ StoppointLocation.cpp
+ Watchpoint.cpp
+ WatchpointList.cpp
+ WatchpointOptions.cpp
+ )
Added: lldb/branches/windows/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/CMakeLists.txt (added)
+++ lldb/branches/windows/source/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,16 @@
+add_subdirectory(API)
+add_subdirectory(Breakpoint)
+add_subdirectory(Commands)
+add_subdirectory(Core)
+add_subdirectory(Expression)
+add_subdirectory(Host)
+add_subdirectory(Interpreter)
+add_subdirectory(Plugins)
+add_subdirectory(Symbol)
+add_subdirectory(Target)
+add_subdirectory(Utility)
+
+add_lldb_library(lldbInitAndLog
+ lldb.cpp
+ lldb-log.cpp
+ )
Added: lldb/branches/windows/source/Commands/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Commands/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Commands/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,31 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbCommands
+ CommandCompletions.cpp
+ CommandObjectApropos.cpp
+ CommandObjectArgs.cpp
+ CommandObjectBreakpoint.cpp
+ CommandObjectBreakpointCommand.cpp
+ CommandObjectCommands.cpp
+ CommandObjectCrossref.cpp
+ CommandObjectDisassemble.cpp
+ CommandObjectExpression.cpp
+ CommandObjectFrame.cpp
+ CommandObjectHelp.cpp
+ CommandObjectLog.cpp
+ CommandObjectMemory.cpp
+ CommandObjectMultiword.cpp
+ CommandObjectPlatform.cpp
+ CommandObjectProcess.cpp
+ CommandObjectQuit.cpp
+ CommandObjectRegister.cpp
+ CommandObjectSettings.cpp
+ CommandObjectSource.cpp
+ CommandObjectSyntax.cpp
+ CommandObjectTarget.cpp
+ CommandObjectThread.cpp
+ CommandObjectType.cpp
+ CommandObjectVersion.cpp
+ CommandObjectWatchpoint.cpp
+ CommandObjectWatchpointCommand.cpp
+ )
Added: lldb/branches/windows/source/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Core/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,79 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbCore
+ Address.cpp
+ AddressRange.cpp
+ AddressResolver.cpp
+ AddressResolverFileLine.cpp
+ AddressResolverName.cpp
+ ArchSpec.cpp
+ Baton.cpp
+ Broadcaster.cpp
+ Communication.cpp
+ Connection.cpp
+ ConnectionFileDescriptor.cpp
+ ConnectionMachPort.cpp
+ ConnectionSharedMemory.cpp
+ ConstString.cpp
+ cxa_demangle.cpp
+ CXXFormatterFunctions.cpp
+ DataBufferHeap.cpp
+ DataBufferMemoryMap.cpp
+ DataEncoder.cpp
+ DataExtractor.cpp
+ DataVisualization.cpp
+ Debugger.cpp
+ Disassembler.cpp
+ DynamicLoader.cpp
+ EmulateInstruction.cpp
+ Error.cpp
+ Event.cpp
+ FileLineResolver.cpp
+ FileSpecList.cpp
+ FormatClasses.cpp
+ FormatManager.cpp
+ History.cpp
+ InputReader.cpp
+ InputReaderEZ.cpp
+ InputReaderStack.cpp
+ Language.cpp
+ Listener.cpp
+ Log.cpp
+ Mangled.cpp
+ Module.cpp
+ ModuleChild.cpp
+ ModuleList.cpp
+ Opcode.cpp
+ PluginManager.cpp
+ RegisterValue.cpp
+ RegularExpression.cpp
+ Scalar.cpp
+ SearchFilter.cpp
+ Section.cpp
+ SourceManager.cpp
+ State.cpp
+ Stream.cpp
+ StreamAsynchronousIO.cpp
+ StreamCallback.cpp
+ StreamFile.cpp
+ StreamString.cpp
+ StringList.cpp
+ Timer.cpp
+ UserID.cpp
+ UserSettingsController.cpp
+ UUID.cpp
+ Value.cpp
+ ValueObject.cpp
+ ValueObjectChild.cpp
+ ValueObjectConstResult.cpp
+ ValueObjectConstResultChild.cpp
+ ValueObjectConstResultImpl.cpp
+ ValueObjectDynamicValue.cpp
+ ValueObjectList.cpp
+ ValueObjectMemory.cpp
+ ValueObjectRegister.cpp
+ ValueObjectSyntheticFilter.cpp
+ ValueObjectVariable.cpp
+ VMRange.cpp
+ Windows.cpp
+ )
Added: lldb/branches/windows/source/Core/Windows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Windows.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/Windows.cpp (added)
+++ lldb/branches/windows/source/Core/Windows.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,191 @@
+//===-- Windows.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// This file provides Windows support functions
+
+#include <ctype.h>
+#include <cstring>
+#include <cstdarg>
+#include <cstdlib>
+#include <cstdio>
+#include <cerrno>
+
+int strcasecmp(const char* s1, const char* s2)
+{
+ while (*s1 != '\0' && tolower(*s1) == tolower(*s2))
+ {
+ s1++;
+ s2++;
+ }
+
+ return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+}
+
+int strncasecmp(const char* s1, const char* s2, size_t n)
+{
+ if (n == 0)
+ return 0;
+
+ while (n-- != 0 && tolower(*s1) == tolower(*s2))
+ {
+ if (n == 0 || *s1 == '\0' || *s2 == '\0')
+ break;
+ s1++;
+ s2++;
+ }
+
+ return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+}
+
+char * strcasestr(const char *s, const char* find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return 0;
+ } while ((char)tolower((unsigned char)sc) != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+
+int vasprintf(char **ret, const char *fmt, va_list ap)
+{
+ char *buf;
+ int len;
+ size_t buflen;
+ va_list ap2;
+
+#if defined(_MSC_VER) || defined(__MINGW64)
+ ap2 = ap;
+ len = _vscprintf(fmt, ap2);
+#else
+ va_copy(ap2, ap);
+ len = vsnprintf(NULL, 0, fmt, ap2);
+#endif
+
+ if (len >= 0 && (buf = (char*) malloc ((buflen = (size_t) (len + 1)))) != NULL) {
+ len = vsnprintf(buf, buflen, fmt, ap);
+ *ret = buf;
+ } else {
+ *ret = NULL;
+ len = -1;
+ }
+
+ va_end(ap2);
+ return len;
+}
+
+int access(const char *path, int amode)
+{
+ return 0;
+}
+
+char* __cdecl realpath( const char * name, char * resolved )
+{
+ char *retname = NULL; /* we will return this, if we fail */
+
+ /* SUSv3 says we must set `errno = EINVAL', and return NULL,
+ * if `name' is passed as a NULL pointer.
+ */
+
+ if( name == NULL )
+ errno = EINVAL;
+
+ /* Otherwise, `name' must refer to a readable filesystem object,
+ * if we are going to resolve its absolute path name.
+ */
+
+ else if( access( name, 4 ) == 0 )
+ {
+ /* If `name' didn't point to an existing entity,
+ * then we don't get to here; we simply fall past this block,
+ * returning NULL, with `errno' appropriately set by `access'.
+ *
+ * When we _do_ get to here, then we can use `_fullpath' to
+ * resolve the full path for `name' into `resolved', but first,
+ * check that we have a suitable buffer, in which to return it.
+ */
+
+ if( (retname = resolved) == NULL )
+ {
+ /* Caller didn't give us a buffer, so we'll exercise the
+ * option granted by SUSv3, and allocate one.
+ *
+ * `_fullpath' would do this for us, but it uses `malloc', and
+ * Microsoft's implementation doesn't set `errno' on failure.
+ * If we don't do this explicitly ourselves, then we will not
+ * know if `_fullpath' fails on `malloc' failure, or for some
+ * other reason, and we want to set `errno = ENOMEM' for the
+ * `malloc' failure case.
+ */
+
+ retname = (char*) malloc( _MAX_PATH );
+ }
+
+ /* By now, we should have a valid buffer.
+ * If we don't, then we know that `malloc' failed,
+ * so we can set `errno = ENOMEM' appropriately.
+ */
+
+ if( retname == NULL )
+ errno = ENOMEM;
+
+ /* Otherwise, when we do have a valid buffer,
+ * `_fullpath' should only fail if the path name is too long.
+ */
+
+ else if( (retname = _fullpath( retname, name, _MAX_PATH )) == NULL )
+ errno = ENAMETOOLONG;
+ }
+
+ /* By the time we get to here,
+ * `retname' either points to the required resolved path name,
+ * or it is NULL, with `errno' set appropriately, either of which
+ * is our required return condition.
+ */
+
+ return retname;
+}
+
+long long int strtoll(const char *nptr, char **endptr, int base)
+{
+ return 0;
+}
+
+unsigned long long int strtoull(const char *nptr, char **endptr, int base)
+{
+ return 0;
+}
+
+//char* realpath( const char * name, char * resolved )
+//{
+// return 0;
+//}
+
+char* basename(char *path)
+{
+ return 0;
+}
+
+char *dirname(char *path)
+{
+ return 0;
+}
+
+#include "lldb/lldb-windows.h"
+
+#include "getopt.c"
Added: lldb/branches/windows/source/Core/getopt.c
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/getopt.c?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/getopt.c (added)
+++ lldb/branches/windows/source/Core/getopt.c Thu Sep 13 13:40:53 2012
@@ -0,0 +1,511 @@
+/* $OpenBSD: getopt_long.c,v 1.25 2011/03/05 22:10:11 guenther Exp $ */
+/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
+
+/*
+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller at courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+int opterr = 1; /* if error message should be printed */
+int optind = 1; /* index into parent argv vector */
+int optopt = '?'; /* character checked for validity */
+int optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define PRINT_ERROR ((opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
+#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
+
+/* return values */
+#define BADCH (int)'?'
+#define BADARG ((*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+static int getopt_internal(int, char * const *, const char *,
+ const struct option *, int *, int);
+static int parse_long_options(char * const *, const char *,
+ const struct option *, int *, int);
+static int gcd(int, int);
+static void permute_args(int, int, int, char * const *);
+
+static char *place = EMSG; /* option letter processing */
+
+/* XXX: set optreset to 1 rather than these two */
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1; /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptchar[] = "unknown option -- %c";
+static const char illoptstring[] = "unknown option -- %s";
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(int a, int b)
+{
+ int c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return (b);
+}
+
+static void pass() {}
+#define warnx(a, ...) pass();
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(int panonopt_start, int panonopt_end, int opt_end,
+ char * const *nargv)
+{
+ int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+ char *swap;
+
+ /*
+ * compute lengths of blocks and number and size of cycles
+ */
+ nnonopts = panonopt_end - panonopt_start;
+ nopts = opt_end - panonopt_end;
+ ncycle = gcd(nnonopts, nopts);
+ cyclelen = (opt_end - panonopt_start) / ncycle;
+
+ for (i = 0; i < ncycle; i++) {
+ cstart = panonopt_end+i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++) {
+ if (pos >= panonopt_end)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = nargv[pos];
+ /* LINTED const cast */
+ ((char **) nargv)[pos] = nargv[cstart];
+ /* LINTED const cast */
+ ((char **)nargv)[cstart] = swap;
+ }
+ }
+}
+
+/*
+ * parse_long_options --
+ * Parse long options in argc/argv argument vector.
+ * Returns -1 if short_too is set and the option does not match long_options.
+ */
+static int
+parse_long_options(char * const *nargv, const char *options,
+ const struct option *long_options, int *idx, int short_too)
+{
+ char *current_argv, *has_equal;
+ size_t current_argv_len;
+ int i, match;
+
+ current_argv = place;
+ match = -1;
+
+ optind++;
+
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ /* argument found (--option=arg) */
+ current_argv_len = has_equal - current_argv;
+ has_equal++;
+ } else
+ current_argv_len = strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ /* find matching long option */
+ if (strncmp(current_argv, long_options[i].name,
+ current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) == current_argv_len) {
+ /* exact match */
+ match = i;
+ break;
+ }
+ /*
+ * If this is a known short option, don't allow
+ * a partial match of a single character.
+ */
+ if (short_too && current_argv_len == 1)
+ continue;
+
+ if (match == -1) /* partial match */
+ match = i;
+ else {
+ /* ambiguous abbreviation */
+ if (PRINT_ERROR)
+ warnx(ambig, (int)current_argv_len,
+ current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ }
+ if (match != -1) { /* option found */
+ if (long_options[match].has_arg == no_argument
+ && has_equal) {
+ if (PRINT_ERROR)
+ warnx(noarg, (int)current_argv_len,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ return (BADARG);
+ }
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = has_equal;
+ else if (long_options[match].has_arg ==
+ required_argument) {
+ /*
+ * optional argument doesn't use next nargv
+ */
+ optarg = nargv[optind++];
+ }
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument; leading ':' indicates no error
+ * should be generated.
+ */
+ if (PRINT_ERROR)
+ warnx(recargstring,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ --optind;
+ return (BADARG);
+ }
+ } else { /* unknown option */
+ if (short_too) {
+ --optind;
+ return (-1);
+ }
+ if (PRINT_ERROR)
+ warnx(illoptstring, current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ if (idx)
+ *idx = match;
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ return (0);
+ } else
+ return (long_options[match].val);
+}
+
+/*
+ * getopt_internal --
+ * Parse argc/argv argument vector. Called by user level routines.
+ */
+static int
+getopt_internal(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx, int flags)
+{
+ const char *oli; /* option letter list index */
+ int optchar, short_too;
+ static int posixly_correct = -1;
+
+ if (options == NULL)
+ return (-1);
+
+ /*
+ * XXX Some GNU programs (like cvs) set optind to 0 instead of
+ * XXX using optreset. Work around this braindamage.
+ */
+ if (optind == 0)
+ optind = optreset = 1;
+
+ /*
+ * Disable GNU extensions if POSIXLY_CORRECT is set or options
+ * string begins with a '+'.
+ */
+ if (posixly_correct == -1 || optreset)
+ posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+ if (*options == '-')
+ flags |= FLAG_ALLARGS;
+ else if (posixly_correct || *options == '+')
+ flags &= ~FLAG_PERMUTE;
+ if (*options == '+' || *options == '-')
+ options++;
+
+ optarg = NULL;
+ if (optreset)
+ nonopt_start = nonopt_end = -1;
+start:
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc) { /* end of argument vector */
+ place = EMSG;
+ if (nonopt_end != -1) {
+ /* do permutation, if we have to */
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ else if (nonopt_start != -1) {
+ /*
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
+ optind = nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ if (*(place = nargv[optind]) != '-' ||
+ (place[1] == '\0' && strchr(options, '-') == NULL)) {
+ place = EMSG; /* found non-option */
+ if (flags & FLAG_ALLARGS) {
+ /*
+ * GNU extension:
+ * return non-option as argument to option 1
+ */
+ optarg = nargv[optind++];
+ return (INORDER);
+ }
+ if (!(flags & FLAG_PERMUTE)) {
+ /*
+ * If no permutation wanted, stop parsing
+ * at first non-option.
+ */
+ return (-1);
+ }
+ /* do permutation */
+ if (nonopt_start == -1)
+ nonopt_start = optind;
+ else if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ nonopt_start = optind -
+ (nonopt_end - nonopt_start);
+ nonopt_end = -1;
+ }
+ optind++;
+ /* process next argument */
+ goto start;
+ }
+ if (nonopt_start != -1 && nonopt_end == -1)
+ nonopt_end = optind;
+
+ /*
+ * If we have "-" do nothing, if "--" we are done.
+ */
+ if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+ optind++;
+ place = EMSG;
+ /*
+ * We found an option (--), so if we skipped
+ * non-options, we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ }
+
+ /*
+ * Check long options if:
+ * 1) we were passed some
+ * 2) the arg is not just "-"
+ * 3) either the arg starts with -- we are getopt_long_only()
+ */
+ if (long_options != NULL && place != nargv[optind] &&
+ (*place == '-' || (flags & FLAG_LONGONLY))) {
+ short_too = 0;
+ if (*place == '-')
+ place++; /* --foo long option */
+ else if (*place != ':' && strchr(options, *place) != NULL)
+ short_too = 1; /* could be short option too */
+
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, short_too);
+ if (optchar != -1) {
+ place = EMSG;
+ return (optchar);
+ }
+ }
+
+ if ((optchar = (int)*place++) == (int)':' ||
+ (optchar == (int)'-' && *place != '\0') ||
+ (oli = strchr(options, optchar)) == NULL) {
+ /*
+ * If the user specified "-" and '-' isn't listed in
+ * options, return -1 (non-option) as per POSIX.
+ * Otherwise, it is an unknown option character (or ':').
+ */
+ if (optchar == (int)'-' && *place == '\0')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (PRINT_ERROR)
+ warnx(illoptchar, optchar);
+ optopt = optchar;
+ return (BADCH);
+ }
+ if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+ /* -W long-option */
+ if (*place) /* no space */
+ /* NOTHING */;
+ else if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ } else /* white space */
+ place = nargv[optind];
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, 0);
+ place = EMSG;
+ return (optchar);
+ }
+ if (*++oli != ':') { /* doesn't take argument */
+ if (!*place)
+ ++optind;
+ } else { /* takes (optional) argument */
+ optarg = NULL;
+ if (*place) /* no white space */
+ optarg = place;
+ else if (oli[1] != ':') { /* arg not optional */
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ } else
+ optarg = nargv[optind];
+ }
+ place = EMSG;
+ ++optind;
+ }
+ /* dump back option letter */
+ return (optchar);
+}
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the BSD getopt]
+ */
+int
+getopt(int nargc, char * const *nargv, const char *options)
+{
+
+ /*
+ * We don't pass FLAG_PERMUTE to getopt_internal() since
+ * the BSD getopt(3) (unlike GNU) has never done this.
+ *
+ * Furthermore, since many privileged programs call getopt()
+ * before dropping privileges it makes sense to keep things
+ * as simple (and bug-free) as possible.
+ */
+ return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+}
+
+/*
+ * getopt_long --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx)
+{
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE));
+}
+
+/*
+ * getopt_long_only --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long_only(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx)
+{
+
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE|FLAG_LONGONLY));
+}
\ No newline at end of file
Added: lldb/branches/windows/source/Expression/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Expression/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Expression/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,22 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbExpression
+ ASTDumper.cpp
+ ASTResultSynthesizer.cpp
+ ASTStructExtractor.cpp
+ ClangASTSource.cpp
+ ClangExpressionDeclMap.cpp
+ ClangExpressionParser.cpp
+ ClangExpressionVariable.cpp
+ ClangFunction.cpp
+ ClangPersistentVariables.cpp
+ ClangUserExpression.cpp
+ ClangUtilityFunction.cpp
+ DWARFExpression.cpp
+ ExpressionSourceCode.cpp
+ IRDynamicChecks.cpp
+ IRForTarget.cpp
+ IRInterpreter.cpp
+ ProcessDataAllocator.cpp
+ RecordingMemoryManager.cpp
+ )
Added: lldb/branches/windows/source/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Host/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,3 @@
+add_subdirectory(common)
+#add_subdirectory(linux)
+add_subdirectory(windows)
Added: lldb/branches/windows/source/Host/common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/common/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/common/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Host/common/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,13 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbHostCommon
+ Condition.cpp
+ File.cpp
+ FileSpec.cpp
+ Host.cpp
+ Mutex.cpp
+ SocketAddress.cpp
+ Symbols.cpp
+ Terminal.cpp
+ TimeValue.cpp
+ )
Added: lldb/branches/windows/source/Host/linux/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/linux/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/linux/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Host/linux/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbHostLinux
+ Host.cpp
+ )
Added: lldb/branches/windows/source/Host/windows/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/windows/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/windows/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Host/windows/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,6 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbHostWindows
+ Host.cpp
+ ReadWriteLock.cpp
+ )
Added: lldb/branches/windows/source/Host/windows/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/windows/Host.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/windows/Host.cpp (added)
+++ lldb/branches/windows/source/Host/windows/Host.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,59 @@
+//===-- source/Host/linux/Host.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Target/Process.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool
+Host::GetOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update)
+{
+ OSVERSIONINFOEX info;
+
+ ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+ if (GetVersionEx((LPOSVERSIONINFO) &info) == 0) {
+ return false;
+ }
+
+ major = (uint32_t) info.dwMajorVersion;
+ minor = (uint32_t) info.dwMinorVersion;
+ update = (uint32_t) info.wServicePackMajor;
+
+ return true;
+}
+
+Error
+Host::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+ Error error;
+ assert(!"Not implemented yet!!!");
+ return error;
+}
+
+lldb::DataBufferSP
+Host::GetAuxvData(lldb_private::Process *process)
+{
+ return 0;
+}
Added: lldb/branches/windows/source/Host/windows/ReadWriteLock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/windows/ReadWriteLock.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Host/windows/ReadWriteLock.cpp (added)
+++ lldb/branches/windows/source/Host/windows/ReadWriteLock.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,173 @@
+#include "lldb/Host/ReadWriteLock.h"
+
+namespace lldb_private {
+
+// Windows has slim read-writer lock support on Vista and higher, so we
+// will attempt to load the APIs. If they exist, we will use them, and
+// if not, we will fall back on critical sections. When we drop support
+// for XP, we can stop lazy-loading these APIs and just use them directly.
+#if defined(__MINGW32__)
+ // Taken from WinNT.h
+ typedef struct _RTL_SRWLOCK {
+ PVOID Ptr;
+ } RTL_SRWLOCK, *PRTL_SRWLOCK;
+
+ // Taken from WinBase.h
+ typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
+#endif
+
+
+typedef struct Win32RWLOCK {
+ unsigned long int readlockcount;
+ HANDLE writable;
+ CRITICAL_SECTION writelock;
+} Win32RWLOCK;
+
+typedef Win32RWLOCK* PWin32RWLOCK;
+
+static VOID (WINAPI *fpInitializeSRWLock)(PSRWLOCK lock) = NULL;
+static VOID (WINAPI *fpAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+static VOID (WINAPI *fpAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+static VOID (WINAPI *fpReleaseSRWLockExclusive)(PSRWLOCK lock) = NULL;
+static VOID (WINAPI *fpReleaseSRWLockShared)(PSRWLOCK lock) = NULL;
+static BOOL (WINAPI *fpTryAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+static BOOL (WINAPI *fpTryAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+
+static bool sHasSRW = false;
+
+static bool loadSRW() {
+ static bool sChecked = false;
+ if (!sChecked) {
+ sChecked = true;
+
+ HMODULE hLib = ::LoadLibrary(TEXT("Kernel32"));
+ if (hLib) {
+ fpInitializeSRWLock =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "InitializeSRWLock");
+ fpAcquireSRWLockExclusive =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "AcquireSRWLockExclusive");
+ fpAcquireSRWLockShared =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "AcquireSRWLockShared");
+ fpReleaseSRWLockExclusive =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "ReleaseSRWLockExclusive");
+ fpReleaseSRWLockShared =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "ReleaseSRWLockShared");
+ fpTryAcquireSRWLockExclusive =
+ (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "TryAcquireSRWLockExclusive");
+ fpTryAcquireSRWLockShared =
+ (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "TryAcquireSRWLockShared");
+
+ ::FreeLibrary(hLib);
+
+ if (fpInitializeSRWLock != NULL) {
+ sHasSRW = true;
+ }
+ }
+ }
+ return sHasSRW;
+}
+
+ReadWriteLock::ReadWriteLock () {
+ if (loadSRW()) {
+ m_data = calloc(1, sizeof(SRWLOCK));
+ fpInitializeSRWLock(static_cast<PSRWLOCK>(m_data));
+ } else {
+ m_data = calloc(1, sizeof(Win32RWLOCK));
+ static_cast<PWin32RWLOCK>(m_data)->readlockcount = 0;
+ static_cast<PWin32RWLOCK>(m_data)->writable = CreateEvent(NULL, true, true, NULL);
+ InitializeCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ }
+}
+
+ReadWriteLock::~ReadWriteLock () {
+ if (!sHasSRW) {
+ CloseHandle(static_cast<PWin32RWLOCK>(m_data)->writable);
+ DeleteCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ }
+ free(m_data);
+}
+
+bool ReadWriteLock::ReadLock () {
+ if (sHasSRW) {
+ fpAcquireSRWLockShared(static_cast<PSRWLOCK>(m_data));
+ return true;
+ } else {
+ EnterCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ InterlockedIncrement(&static_cast<PWin32RWLOCK>(m_data)->readlockcount);
+ ResetEvent(static_cast<PWin32RWLOCK>(m_data)->writable);
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ return true;
+ }
+}
+
+bool ReadWriteLock::ReadTryLock () {
+ if (sHasSRW) {
+ return fpTryAcquireSRWLockShared(static_cast<PSRWLOCK>(m_data)) != 0;
+ } else {
+ if (TryEnterCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock)) {
+ InterlockedIncrement(&static_cast<PWin32RWLOCK>(m_data)->readlockcount);
+ ResetEvent(static_cast<PWin32RWLOCK>(m_data)->writable);
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ return true;
+ }
+ return false;
+ }
+}
+
+bool ReadWriteLock::ReadUnlock () {
+ if (sHasSRW) {
+ fpReleaseSRWLockShared(static_cast<PSRWLOCK>(m_data));
+ return true;
+ } else {
+ if (InterlockedDecrement(&static_cast<PWin32RWLOCK>(m_data)->readlockcount) == 0)
+ SetEvent(static_cast<PWin32RWLOCK>(m_data)->writable);
+ return true;
+ }
+}
+
+bool ReadWriteLock::WriteLock () {
+ if (sHasSRW) {
+ fpAcquireSRWLockExclusive(static_cast<PSRWLOCK>(m_data));
+ return true;
+ } else {
+ EnterCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ WaitForSingleObject(static_cast<PWin32RWLOCK>(m_data)->writable, INFINITE);
+ return true;
+ }
+}
+
+bool ReadWriteLock::WriteTryLock () {
+ if (sHasSRW) {
+ return fpTryAcquireSRWLockExclusive(static_cast<PSRWLOCK>(m_data)) != 0;
+ } else {
+ if (TryEnterCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock)) {
+ if (!WaitForSingleObject(static_cast<PWin32RWLOCK>(m_data)->writable, 0)) {
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+}
+
+bool ReadWriteLock::WriteUnlock () {
+ if (sHasSRW) {
+ fpReleaseSRWLockExclusive(static_cast<PSRWLOCK>(m_data));
+ return true;
+ } else {
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(m_data)->writelock);
+ return true;
+ }
+}
+
+
+
+}
Added: lldb/branches/windows/source/Interpreter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Interpreter/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Interpreter/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Interpreter/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,44 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbInterpreter
+ Args.cpp
+ CommandInterpreter.cpp
+ CommandObject.cpp
+ CommandObjectRegexCommand.cpp
+ CommandObjectScript.cpp
+ CommandReturnObject.cpp
+ OptionGroupArchitecture.cpp
+ OptionGroupBoolean.cpp
+ OptionGroupFile.cpp
+ OptionGroupFormat.cpp
+ OptionGroupOutputFile.cpp
+ OptionGroupPlatform.cpp
+ OptionGroupUInt64.cpp
+ OptionGroupUUID.cpp
+ OptionGroupValueObjectDisplay.cpp
+ OptionValue.cpp
+ OptionValueArch.cpp
+ OptionValueArgs.cpp
+ OptionValueArray.cpp
+ OptionValueBoolean.cpp
+ OptionValueDictionary.cpp
+ OptionValueEnumeration.cpp
+ OptionValueFileSpec.cpp
+ OptionValueFileSpecLIst.cpp
+ OptionValueFormat.cpp
+ OptionValuePathMappings.cpp
+ OptionValueProperties.cpp
+ OptionValueRegex.cpp
+ OptionValueSInt64.cpp
+ OptionValueString.cpp
+ OptionValueUInt64.cpp
+ OptionValueUUID.cpp
+ OptionGroupVariable.cpp
+ OptionGroupWatchpoint.cpp
+ Options.cpp
+ Property.cpp
+ PythonDataObjects.cpp
+ ScriptInterpreter.cpp
+ ScriptInterpreterNone.cpp
+ ScriptInterpreterPython.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ABI/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ABI/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ABI/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ABI/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1 @@
+add_subdirectory(SysV-x86_64)
Added: lldb/branches/windows/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginABISysV_x86_64
+ ABISysV_x86_64.cpp
+ )
Added: lldb/branches/windows/source/Plugins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,13 @@
+add_subdirectory(ABI)
+add_subdirectory(Disassembler)
+add_subdirectory(DynamicLoader)
+add_subdirectory(Instruction)
+add_subdirectory(LanguageRuntime)
+add_subdirectory(ObjectContainer)
+add_subdirectory(ObjectFile)
+add_subdirectory(OperatingSystem)
+add_subdirectory(Platform)
+add_subdirectory(Process)
+add_subdirectory(SymbolFile)
+add_subdirectory(SymbolVendor)
+add_subdirectory(UnwindAssembly)
Added: lldb/branches/windows/source/Plugins/Disassembler/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Disassembler/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Disassembler/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Disassembler/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1 @@
+add_subdirectory(llvm)
Added: lldb/branches/windows/source/Plugins/Disassembler/llvm/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Disassembler/llvm/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Disassembler/llvm/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Disassembler/llvm/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,6 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginDisassemblerLLVM
+ DisassemblerLLVM.cpp
+ DisassemblerLLVMC.cpp
+ )
Added: lldb/branches/windows/source/Plugins/DynamicLoader/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/DynamicLoader/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/DynamicLoader/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/DynamicLoader/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,4 @@
+#add_subdirectory(Darwin-Kernel)
+#add_subdirectory(MacOSX-DYLD)
+#add_subdirectory(POSIX-DYLD)
+add_subdirectory(Static)
Added: lldb/branches/windows/source/Plugins/DynamicLoader/Static/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/DynamicLoader/Static/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/DynamicLoader/Static/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/DynamicLoader/Static/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginDynamicLoaderStatic
+ DynamicLoaderStatic.cpp
+ )
Added: lldb/branches/windows/source/Plugins/Instruction/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Instruction/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Instruction/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Instruction/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1 @@
+#add_subdirectory(ARM)
Added: lldb/branches/windows/source/Plugins/LanguageRuntime/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+add_subdirectory(CPlusPlus)
+#add_subdirectory(ObjC)
Added: lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+add_subdirectory(ItaniumABI)
+#add_subdirectory(MicrosoftABI)
Added: lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginCXXItaniumABI
+ ItaniumABILanguageRuntime.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectContainerBSDArchive
+ ObjectContainerBSDArchive.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ObjectContainer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectContainer/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectContainer/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectContainer/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+add_subdirectory(BSD-Archive)
+add_subdirectory(Universal-Mach-O)
Added: lldb/branches/windows/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectContainerMachOArchive
+ ObjectContainerUniversalMachO.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ObjectFile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectFile/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectFile/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectFile/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,3 @@
+add_subdirectory(ELF)
+add_subdirectory(Mach-O)
+add_subdirectory(PECOFF)
Added: lldb/branches/windows/source/Plugins/ObjectFile/ELF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectFile/ELF/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectFile/ELF/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectFile/ELF/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,6 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectFileELF
+ ELFHeader.cpp
+ ObjectFileELF.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectFileMachO
+ ObjectFileMachO.cpp
+ )
Added: lldb/branches/windows/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginObjectFilePECOFF
+ ObjectFilePECOFF.cpp
+ )
Added: lldb/branches/windows/source/Plugins/OperatingSystem/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/OperatingSystem/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/OperatingSystem/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/OperatingSystem/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1 @@
+#add_subdirectory(Darwin-Kernel)
Added: lldb/branches/windows/source/Plugins/OperatingSystem/Darwin-Kernel/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/OperatingSystem/Darwin-Kernel/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/OperatingSystem/Darwin-Kernel/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/OperatingSystem/Darwin-Kernel/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginOSDarwinKernel
+ OperatingSystemDarwinKernel.cpp
+ )
Added: lldb/branches/windows/source/Plugins/Platform/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Platform/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Platform/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Platform/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+#add_subdirectory(FreeBSD)
+add_subdirectory(gdb-server)
+#add_subdirectory(Linux)
+#add_subdirectory(MacOSX)
+add_subdirectory(Windows)
Added: lldb/branches/windows/source/Plugins/Platform/Windows/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Platform/Windows/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Platform/Windows/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Platform/Windows/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginPlatformWindows
+ PlatformWindows.cpp
+ )
Added: lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.cpp (added)
+++ lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,648 @@
+//===-- PlatformWindows.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformWindows.h"
+
+// C Includes
+#include <stdio.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Module.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+Platform *
+PlatformWindows::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
+{
+ // The only time we create an instance is when we are creating a remote
+ // windows platform
+ const bool is_host = false;
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor())
+ {
+ case llvm::Triple::PC:
+ create = true;
+ break;
+
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
+
+ default:
+ break;
+ }
+
+ if (create)
+ {
+ switch (triple.getOS())
+ {
+ case llvm::Triple::Win32:
+ case llvm::Triple::MinGW32:
+ break;
+
+ case llvm::Triple::UnknownOS:
+ create = arch->TripleOSWasSpecified();
+ break;
+
+ default:
+ create = false;
+ break;
+ }
+ }
+ }
+ if (create)
+ return new PlatformWindows (is_host);
+ return NULL;
+
+}
+
+const char *
+PlatformWindows::GetPluginNameStatic()
+{
+ return "plugin.platform.windows";
+}
+
+const char *
+PlatformWindows::GetShortPluginNameStatic (bool is_host)
+{
+ if (is_host)
+ return Platform::GetHostPlatformName ();
+ else
+ return "remote-windows";
+}
+
+const char *
+PlatformWindows::GetDescriptionStatic (bool is_host)
+{
+ if (is_host)
+ return "Local Windows user platform plug-in.";
+ else
+ return "Remote Windows user platform plug-in.";
+}
+
+static uint32_t g_initialize_count = 0;
+
+void
+PlatformWindows::Initialize ()
+{
+ if (g_initialize_count++ == 0)
+ {
+#if defined (_WIN32)
+ // Force a host flag to true for the default platform object.
+ PlatformSP default_platform_sp (new PlatformWindows(true));
+ default_platform_sp->SetSystemArchitecture (Host::GetArchitecture());
+ Platform::SetDefaultPlatform (default_platform_sp);
+#endif
+ PluginManager::RegisterPlugin(PlatformWindows::GetShortPluginNameStatic(false),
+ PlatformWindows::GetDescriptionStatic(false),
+ PlatformWindows::CreateInstance);
+ }
+}
+
+void
+PlatformWindows::Terminate ()
+{
+ if (g_initialize_count > 0 && --g_initialize_count == 0)
+ PluginManager::UnregisterPlugin (PlatformWindows::CreateInstance);
+}
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformWindows::PlatformWindows (bool is_host) :
+Platform(is_host)
+{
+}
+
+//------------------------------------------------------------------
+/// Destructor.
+///
+/// The destructor is virtual since this class is designed to be
+/// inherited from by the plug-in instance.
+//------------------------------------------------------------------
+PlatformWindows::~PlatformWindows()
+{
+}
+
+
+Error
+PlatformWindows::ResolveExecutable (const FileSpec &exe_file,
+ const ArchSpec &exe_arch,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr)
+{
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ FileSpec resolved_exe_file (exe_file);
+
+ if (IsHost())
+ {
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ if (!resolved_exe_file.Exists())
+ {
+ exe_file.GetPath(exe_path, sizeof(exe_path));
+ resolved_exe_file.SetFile(exe_path, true);
+ }
+
+ if (!resolved_exe_file.Exists())
+ resolved_exe_file.ResolveExecutableLocation ();
+
+ if (resolved_exe_file.Exists())
+ error.Clear();
+ else
+ {
+ exe_file.GetPath(exe_path, sizeof(exe_path));
+ error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
+ }
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ {
+ error = m_remote_platform_sp->ResolveExecutable (exe_file,
+ exe_arch,
+ exe_module_sp,
+ module_search_paths_ptr);
+ }
+ else
+ {
+ // We may connect to a process and use the provided executable (Don't use local $PATH).
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle (resolved_exe_file);
+
+ if (resolved_exe_file.Exists()) {
+ error.Clear();
+ }
+ else
+ {
+ exe_file.GetPath(exe_path, sizeof(exe_path));
+ error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
+ }
+ }
+ }
+
+
+ if (error.Success())
+ {
+ ModuleSpec module_spec (resolved_exe_file, exe_arch);
+ if (module_spec.GetArchitecture().IsValid())
+ {
+ error = ModuleList::GetSharedModule (module_spec,
+ exe_module_sp,
+ module_search_paths_ptr,
+ NULL,
+ NULL);
+
+ if (exe_module_sp->GetObjectFile() == NULL)
+ {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""),
+ exe_arch.GetArchitectureName());
+ }
+ }
+ else
+ {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+ {
+ error = ModuleList::GetSharedModule (module_spec,
+ exe_module_sp,
+ module_search_paths_ptr,
+ NULL,
+ NULL);
+ // Did we find an executable using one of the
+ if (error.Success())
+ {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString (", ");
+ arch_names.PutCString (platform_arch.GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp)
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""),
+ GetShortPluginName(),
+ arch_names.GetString().c_str());
+ }
+ }
+ }
+ else
+ {
+ error.SetErrorStringWithFormat ("'%s%s%s' does not exist",
+ exe_file.GetDirectory().AsCString(""),
+ exe_file.GetDirectory() ? "/" : "",
+ exe_file.GetFilename().AsCString(""));
+ }
+
+ return error;
+}
+
+size_t
+PlatformWindows::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
+{
+ ArchSpec arch = target.GetArchitecture();
+ const uint8_t *trap_opcode = NULL;
+ size_t trap_opcode_size = 0;
+
+ switch (arch.GetCore())
+ {
+ default:
+ assert(false && "Unhandled architecture in PlatformWindows::GetSoftwareBreakpointTrapOpcode()");
+ break;
+
+ case ArchSpec::eCore_x86_32_i386:
+ case ArchSpec::eCore_x86_64_x86_64:
+ {
+ static const uint8_t g_i386_opcode[] = { 0xCC };
+ trap_opcode = g_i386_opcode;
+ trap_opcode_size = sizeof(g_i386_opcode);
+ }
+ break;
+ }
+
+ if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+ return trap_opcode_size;
+
+ return 0;
+}
+
+bool
+PlatformWindows::GetRemoteOSVersion ()
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetOSVersion (m_major_os_version,
+ m_minor_os_version,
+ m_update_os_version);
+ return false;
+}
+
+bool
+PlatformWindows::GetRemoteOSBuildString (std::string &s)
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString (s);
+ s.clear();
+ return false;
+}
+
+bool
+PlatformWindows::GetRemoteOSKernelDescription (std::string &s)
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription (s);
+ s.clear();
+ return false;
+}
+
+// Remote Platform subclasses need to override this function
+ArchSpec
+PlatformWindows::GetRemoteSystemArchitecture ()
+{
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture ();
+ return ArchSpec();
+}
+
+
+const char *
+PlatformWindows::GetHostname ()
+{
+ if (IsHost())
+ return Platform::GetHostname();
+
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname ();
+ return NULL;
+}
+
+bool
+PlatformWindows::IsConnected () const
+{
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+Error
+PlatformWindows::ConnectRemote (Args& args)
+{
+ Error error;
+ if (IsHost())
+ {
+ error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetShortPluginName());
+ }
+ else
+ {
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp = Platform::Create ("remote-gdb-server", error);
+
+ if (m_remote_platform_sp)
+ {
+ if (error.Success())
+ {
+ if (m_remote_platform_sp)
+ {
+ error = m_remote_platform_sp->ConnectRemote (args);
+ }
+ else
+ {
+ error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
+ }
+ }
+ }
+ else
+ error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
+
+ if (error.Fail())
+ m_remote_platform_sp.reset();
+ }
+
+ return error;
+}
+
+Error
+PlatformWindows::DisconnectRemote ()
+{
+ Error error;
+
+ if (IsHost())
+ {
+ error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetShortPluginName());
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->DisconnectRemote ();
+ else
+ error.SetErrorString ("the platform is not currently connected");
+ }
+ return error;
+}
+
+bool
+PlatformWindows::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
+{
+ bool success = false;
+ if (IsHost())
+ {
+ success = Platform::GetProcessInfo (pid, process_info);
+ }
+ else if (m_remote_platform_sp)
+ {
+ success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
+ }
+ return success;
+}
+
+
+
+uint32_t
+PlatformWindows::FindProcesses (const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos)
+{
+ uint32_t match_count = 0;
+ if (IsHost())
+ {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses (match_info, process_infos);
+ }
+ else
+ {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
+ }
+ return match_count;
+}
+
+Error
+PlatformWindows::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+ Error error;
+ if (IsHost())
+ {
+ error = Platform::LaunchProcess (launch_info);
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess (launch_info);
+ else
+ error.SetErrorString ("the platform is not currently connected");
+ }
+ return error;
+}
+
+lldb::ProcessSP
+PlatformWindows::Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger,
+ Target *target,
+ Listener &listener,
+ Error &error)
+{
+ lldb::ProcessSP process_sp;
+ if (IsHost())
+ {
+ if (target == NULL)
+ {
+ TargetSP new_target_sp;
+ FileSpec emptyFileSpec;
+ ArchSpec emptyArchSpec;
+
+ error = debugger.GetTargetList().CreateTarget (debugger,
+ emptyFileSpec,
+ emptyArchSpec,
+ false,
+ m_remote_platform_sp,
+ new_target_sp);
+ target = new_target_sp.get();
+ }
+ else
+ error.Clear();
+
+ if (target && error.Success())
+ {
+ debugger.GetTargetList().SetSelectedTarget(target);
+ // The freebsd always currently uses the GDB remote debugger plug-in
+ // so even when debugging locally we are debugging remotely!
+ // Just like the darwin plugin.
+ process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
+
+ if (process_sp)
+ error = process_sp->Attach (attach_info);
+ }
+ }
+ else
+ {
+ if (m_remote_platform_sp)
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+ else
+ error.SetErrorString ("the platform is not currently connected");
+ }
+ return process_sp;
+}
+
+const char *
+PlatformWindows::GetUserName (uint32_t uid)
+{
+ // Check the cache in Platform in case we have already looked this uid up
+ const char *user_name = Platform::GetUserName(uid);
+ if (user_name)
+ return user_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserName(uid);
+ return NULL;
+}
+
+const char *
+PlatformWindows::GetGroupName (uint32_t gid)
+{
+ const char *group_name = Platform::GetGroupName(gid);
+ if (group_name)
+ return group_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetGroupName(gid);
+ return NULL;
+}
+
+Error
+PlatformWindows::GetFile (const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file)
+{
+ if (IsRemote())
+ {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file);
+ }
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
+}
+
+Error
+PlatformWindows::GetSharedModule (const ModuleSpec &module_spec,
+ ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr)
+{
+ Error error;
+ module_sp.reset();
+
+ if (IsRemote())
+ {
+ // If we have a remote platform always, let it try and locate
+ // the shared module first.
+ if (m_remote_platform_sp)
+ {
+ error = m_remote_platform_sp->GetSharedModule (module_spec,
+ module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr,
+ did_create_ptr);
+ }
+ }
+
+ if (!module_sp)
+ {
+ // Fall back to the local platform and find the file locally
+ error = Platform::GetSharedModule (module_spec,
+ module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr,
+ did_create_ptr);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return error;
+}
+
+
+bool
+PlatformWindows::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+ // From macosx;s plugin code. For FreeBSD we may want to support more archs.
+ if (idx == 0)
+ {
+ arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+ return arch.IsValid();
+ }
+ else if (idx == 1)
+ {
+ ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
+ ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
+ if (platform_arch == platform_arch64)
+ {
+ // This freebsd platform supports both 32 and 64 bit. Since we already
+ // returned the 64 bit arch for idx == 0, return the 32 bit arch
+ // for idx == 1
+ arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+ return arch.IsValid();
+ }
+ }
+ return false;
+}
+
+void
+PlatformWindows::GetStatus (Stream &strm)
+{
+ OSVERSIONINFO info;
+
+ ZeroMemory(&info, sizeof(OSVERSIONINFO));
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (GetVersionEx(&info) == 0) {
+ strm << "Windows";
+ return;
+ }
+
+ strm << "Host: Windows " << (int) info.dwMajorVersion
+ << '.' << (int) info.dwMinorVersion
+ << " Build: " << (int) info.dwBuildNumber << '\n';
+
+ Platform::GetStatus(strm);
+}
Added: lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.h?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.h (added)
+++ lldb/branches/windows/source/Plugins/Platform/Windows/PlatformWindows.h Thu Sep 13 13:40:53 2012
@@ -0,0 +1,166 @@
+//===-- PlatformWindows.h --------------------------------------/*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_PlatformWindows_h_
+#define liblldb_PlatformWindows_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Platform.h"
+
+class PlatformWindows : public lldb_private::Platform
+{
+public:
+
+ //------------------------------------------------------------
+ // Class functions
+ //------------------------------------------------------------
+ static lldb_private::Platform*
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
+
+ static void
+ Initialize ();
+
+ static void
+ Terminate ();
+
+ static const char *
+ GetPluginNameStatic();
+
+ static const char *
+ GetShortPluginNameStatic(bool is_host);
+
+ static const char *
+ GetDescriptionStatic(bool is_host);
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformWindows (bool is_host);
+
+ virtual
+ ~PlatformWindows();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ virtual const char *
+ GetPluginName()
+ {
+ return GetPluginNameStatic();
+ }
+
+ virtual const char *
+ GetShortPluginName()
+ {
+ return GetShortPluginNameStatic (IsHost());
+ }
+
+ virtual uint32_t
+ GetPluginVersion()
+ {
+ return 1;
+ }
+
+ virtual const char *
+ GetDescription ()
+ {
+ return GetDescriptionStatic(IsHost());
+ }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ virtual lldb_private::Error
+ ResolveExecutable (const lldb_private::FileSpec &exe_file,
+ const lldb_private::ArchSpec &arch,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr);
+
+ virtual size_t
+ GetSoftwareBreakpointTrapOpcode (lldb_private::Target &target,
+ lldb_private::BreakpointSite *bp_site);
+
+ virtual bool
+ GetRemoteOSVersion ();
+
+ virtual bool
+ GetRemoteOSBuildString (std::string &s);
+
+ virtual bool
+ GetRemoteOSKernelDescription (std::string &s);
+
+ // Remote Platform subclasses need to override this function
+ virtual lldb_private::ArchSpec
+ GetRemoteSystemArchitecture ();
+
+ virtual bool
+ IsConnected () const;
+
+ virtual lldb_private::Error
+ ConnectRemote (lldb_private::Args& args);
+
+ virtual lldb_private::Error
+ DisconnectRemote ();
+
+ virtual const char *
+ GetHostname ();
+
+ virtual const char *
+ GetUserName (uint32_t uid);
+
+ virtual const char *
+ GetGroupName (uint32_t gid);
+
+ virtual bool
+ GetProcessInfo (lldb::pid_t pid,
+ lldb_private::ProcessInstanceInfo &proc_info);
+
+ virtual uint32_t
+ FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos);
+
+ virtual lldb_private::Error
+ LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info);
+
+ virtual lldb::ProcessSP
+ Attach(lldb_private::ProcessAttachInfo &attach_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Listener &listener,
+ lldb_private::Error &error);
+
+ // FIXME: Only on PlatformMacOSX:
+ virtual lldb_private::Error
+ GetFile (const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule (const lldb_private::ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr);
+
+ virtual bool
+ GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
+
+ virtual void
+ GetStatus (lldb_private::Stream &strm);
+
+protected:
+ lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote freebsd OS
+
+private:
+ DISALLOW_COPY_AND_ASSIGN (PlatformWindows);
+};
+
+#endif // liblldb_PlatformWindows_h_
Added: lldb/branches/windows/source/Plugins/Platform/gdb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Platform/gdb-server/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Platform/gdb-server/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Platform/gdb-server/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginPlatformGDB
+ PlatformRemoteGDBServer.cpp
+ )
Added: lldb/branches/windows/source/Plugins/Process/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Process/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,7 @@
+#add_subdirectory(FreeBSD)
+add_subdirectory(gdb-remote)
+#add_subdirectory(Linux)
+#add_subdirectory(mach-core)
+#add_subdirectory(MacOSx-Kernel)
+#add_subdirectory(POSIX)
+add_subdirectory(Utility)
Added: lldb/branches/windows/source/Plugins/Process/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/Utility/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/Utility/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Process/Utility/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,19 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginProcessUtility
+ DynamicRegisterInfo.cpp
+ InferiorCallPOSIX.cpp
+ RegisterContextDarwin_arm.cpp
+ RegisterContextDarwin_i386.cpp
+ RegisterContextDarwin_x86_64.cpp
+ RegisterContextLLDB.cpp
+ RegisterContextMach_arm.cpp
+ RegisterContextMach_i386.cpp
+ RegisterContextMach_x86_64.cpp
+ RegisterContextMacOSXFrameBackchain.cpp
+ RegisterContextMemory.cpp
+ StopInfoMachException.cpp
+ ThreadMemory.cpp
+ UnwindLLDB.cpp
+ UnwindMacOSXFrameBackchain.cpp
+ )
\ No newline at end of file
Added: lldb/branches/windows/source/Plugins/Process/gdb-remote/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/gdb-remote/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/gdb-remote/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/Process/gdb-remote/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,11 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginProcessGDBRemote
+ GDBRemoteCommunication.cpp
+ GDBRemoteCommunicationClient.cpp
+ GDBRemoteCommunicationServer.cpp
+ GDBRemoteRegisterContext.cpp
+ ProcessGDBRemote.cpp
+ ProcessGDBRemoteLog.cpp
+ ThreadGDBRemote.cpp
+ )
\ No newline at end of file
Added: lldb/branches/windows/source/Plugins/SymbolFile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolFile/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolFile/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/SymbolFile/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+add_subdirectory(DWARF)
+add_subdirectory(Symtab)
Added: lldb/branches/windows/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolFile/DWARF/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolFile/DWARF/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/SymbolFile/DWARF/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,28 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginSymbolFileDWARF
+ DWARFAbbreviationDeclaration.cpp
+ DWARFCompileUnit.cpp
+ DWARFDebugAbbrev.cpp
+ DWARFDebugAranges.cpp
+ DWARFDebugArangeSet.cpp
+ DWARFDebugInfo.cpp
+ DWARFDebugInfoEntry.cpp
+ DWARFDebugLine.cpp
+ DWARFDebugMacinfo.cpp
+ DWARFDebugMacinfoEntry.cpp
+ DWARFDebugPubnames.cpp
+ DWARFDebugPubnamesSet.cpp
+ DWARFDebugRanges.cpp
+ DWARFDeclContext.cpp
+ DWARFDefines.cpp
+ DWARFDIECollection.cpp
+ DWARFFormValue.cpp
+ DWARFLocationDescription.cpp
+ DWARFLocationList.cpp
+ LogChannelDWARF.cpp
+ NameToDIE.cpp
+ SymbolFileDWARF.cpp
+ SymbolFileDWARFDebugMap.cpp
+ UniqueDWARFASTType.cpp
+ )
Added: lldb/branches/windows/source/Plugins/SymbolFile/Symtab/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolFile/Symtab/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolFile/Symtab/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/SymbolFile/Symtab/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginSymbolFileSymtab
+ SymbolFileSymtab.cpp
+ )
Added: lldb/branches/windows/source/Plugins/SymbolVendor/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolVendor/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolVendor/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/SymbolVendor/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1 @@
+#add_subdirectory(MacOSX)
Added: lldb/branches/windows/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,5 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbPluginSymbolVendorMacOSX
+ SymbolVendorMacOSX.cpp
+ )
Added: lldb/branches/windows/source/Plugins/UnwindAssembly/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/UnwindAssembly/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Plugins/UnwindAssembly/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Plugins/UnwindAssembly/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+#add_subdirectory(InstEmulation)
+#add_subdirectory(x86)
Added: lldb/branches/windows/source/Symbol/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Symbol/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Symbol/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Symbol/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,32 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbSymbol
+ Block.cpp
+ ClangASTContext.cpp
+ ClangASTImporter.cpp
+ ClangASTType.cpp
+ ClangExternalASTSourceCallbacks.cpp
+ ClangExternalASTSourceCommon.cpp
+ ClangNamespaceDecl.cpp
+ CompileUnit.cpp
+ Declaration.cpp
+ DWARFCallFrameInfo.cpp
+ Function.cpp
+ FuncUnwinders.cpp
+ LineEntry.cpp
+ LineTable.cpp
+ ObjectFile.cpp
+ Symbol.cpp
+ SymbolContext.cpp
+ SymbolFile.cpp
+ SymbolVendor.cpp
+ Symtab.cpp
+ Type.cpp
+ TypeHierarchyNavigator.cpp
+ TypeList.cpp
+ UnwindPlan.cpp
+ UnwindTable.cpp
+ Variable.cpp
+ VariableList.cpp
+ VerifyDecl.cpp
+ )
Added: lldb/branches/windows/source/Target/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Target/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Target/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Target/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,42 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbTarget
+ ABI.cpp
+ CPPLanguageRuntime.cpp
+ ExecutionContext.cpp
+ LanguageRuntime.cpp
+ Memory.cpp
+ ObjCLanguageRuntime.cpp
+ OperatingSystem.cpp
+ PathMappingList.cpp
+ Platform.cpp
+ Process.cpp
+ RegisterContext.cpp
+ SectionLoadList.cpp
+ StackFrame.cpp
+ StackFrameList.cpp
+ StackID.cpp
+ StopInfo.cpp
+ Target.cpp
+ TargetList.cpp
+ Thread.cpp
+ ThreadList.cpp
+ ThreadPlan.cpp
+ ThreadPlanBase.cpp
+ ThreadPlanCallFunction.cpp
+ ThreadPlanCallUserExpression.cpp
+ ThreadPlanRunToAddress.cpp
+ ThreadPlanShouldStopHere.cpp
+ ThreadPlanStepInRange.cpp
+ ThreadPlanStepInstruction.cpp
+ ThreadPlanStepOut.cpp
+ ThreadPlanStepOverBreakpoint.cpp
+ ThreadPlanStepOverRange.cpp
+ ThreadPlanStepRange.cpp
+ ThreadPlanStepThrough.cpp
+ ThreadPlanStepUntil.cpp
+ ThreadPlanTracer.cpp
+ ThreadSpec.cpp
+ UnixSignals.cpp
+ UnwindAssembly.cpp
+ )
Added: lldb/branches/windows/source/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Utility/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/source/Utility/CMakeLists.txt (added)
+++ lldb/branches/windows/source/Utility/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,10 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbUtility
+ ARM_DWARF_Registers.cpp
+ PseudoTerminal.cpp
+ RefCounter.cpp
+ SharingPtr.cpp
+ StringExtractor.cpp
+ StringExtractorGDBRemote.cpp
+ )
Added: lldb/branches/windows/tools/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/tools/CMakeLists.txt (added)
+++ lldb/branches/windows/tools/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,2 @@
+#add_subdirectory(debugserver)
+add_subdirectory(driver)
Added: lldb/branches/windows/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/driver/CMakeLists.txt?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/tools/driver/CMakeLists.txt (added)
+++ lldb/branches/windows/tools/driver/CMakeLists.txt Thu Sep 13 13:40:53 2012
@@ -0,0 +1,90 @@
+set(LLVM_NO_RTTI 1)
+
+set( LLDB_USED_LIBS
+ lldbAPI
+ lldbBreakpoint
+ lldbCommands
+ lldbCore
+ lldbExpression
+ lldbHostCommon
+ lldbInitAndLog
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+
+ # Plugins
+ lldbPluginDisassemblerLLVM
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFileSymtab
+ lldbPluginDynamicLoaderStatic
+
+ lldbPluginObjectFileMachO
+ lldbPluginObjectFileELF
+ lldbPluginObjectContainerBSDArchive
+ lldbPluginObjectContainerMachOArchive
+ lldbPluginProcessGDBRemote
+ lldbPluginProcessUtility
+ lldbPluginPlatformGDB
+ lldbPluginObjectFileMachO
+ lldbPluginObjectContainerMachOArchive
+ lldbPluginObjectContainerBSDArchive
+
+ # Windows
+ lldbHostWindows
+ lldbPluginPlatformWindows
+ lldbPluginObjectFilePECOFF
+
+ # Linux
+ #lldbHostLinux
+
+ Ws2_32
+ )
+
+set( CLANG_USED_LIBS
+ clangAnalysis
+ clangAST
+ clangBasic
+ clangCodeGen
+ clangDriver
+ clangEdit
+ clangFrontend
+ clangLex
+ clangParse
+ clangRewriteCore
+ clangRewriteFrontend
+ clangSema
+ clangSerialization
+ )
+
+set( LLDB_DRIVER_LIBS
+ #edit
+ #python2.6
+ )
+
+set( LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ jit
+ interpreter
+ nativecodegen
+ asmparser
+ bitreader
+ bitwriter
+ codegen
+ ipo
+ selectiondag
+ bitreader
+ mc
+ core
+ )
+
+add_lldb_executable(lldb
+ Driver.cpp
+ DriverEvents.cpp
+ DriverOptions.cpp
+ DriverPosix.cpp
+ IOChannel.cpp
+ )
+
+install(TARGETS lldb
+ RUNTIME DESTINATION bin)
Added: lldb/branches/windows/tools/driver/DriverEvents.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/driver/DriverEvents.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/tools/driver/DriverEvents.cpp (added)
+++ lldb/branches/windows/tools/driver/DriverEvents.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,413 @@
+//===-- Driver.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Driver.h"
+
+#ifdef _WIN32
+#include "lldb/lldb-windows.h"
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <fcntl.h>
+
+#include "IOChannel.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBCommunication.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEvent.h"
+#include "lldb/API/SBHostOS.h"
+#include "lldb/API/SBListener.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+#include "lldb/API/SBProcess.h"
+
+using namespace lldb;
+
+// This function handles events that were broadcast by the process.
+void
+Driver::HandleBreakpointEvent (const SBEvent &event)
+{
+ const uint32_t event_type = SBBreakpoint::GetBreakpointEventTypeFromEvent (event);
+
+ if (event_type & eBreakpointEventTypeAdded
+ || event_type & eBreakpointEventTypeRemoved
+ || event_type & eBreakpointEventTypeEnabled
+ || event_type & eBreakpointEventTypeDisabled
+ || event_type & eBreakpointEventTypeCommandChanged
+ || event_type & eBreakpointEventTypeConditionChanged
+ || event_type & eBreakpointEventTypeIgnoreChanged
+ || event_type & eBreakpointEventTypeLocationsResolved)
+ return;
+ // Don't do anything about these events, since the breakpoint commands already echo these actions.
+
+ if (event_type & eBreakpointEventTypeLocationsAdded)
+ {
+ uint32_t num_new_locations = SBBreakpoint::GetNumBreakpointLocationsFromEvent(event);
+ if (num_new_locations > 0)
+ {
+ SBBreakpoint breakpoint = SBBreakpoint::GetBreakpointFromEvent(event);
+
+ char message[256];
+ int message_len = ::snprintf (message, sizeof(message), "%d location%s added to breakpoint %d\n",
+ num_new_locations,
+ num_new_locations == 1 ? " " : "s ",
+ breakpoint.GetID());
+ m_io_channel_ap->OutWrite(message, message_len, ASYNC);
+ }
+ }
+ else if (event_type & eBreakpointEventTypeLocationsRemoved)
+ {
+ // These locations just get disabled, not sure it is worth spamming folks about this on the command line.
+ }
+ else if (event_type & eBreakpointEventTypeLocationsResolved)
+ {
+ // This might be an interesting thing to note, but I'm going to leave it quiet for now, it just looked noisy.
+ }
+}
+
+// This function handles events that were broadcast by the process.
+void
+Driver::HandleProcessEvent (const SBEvent &event)
+{
+ using namespace lldb;
+ const uint32_t event_type = event.GetType();
+
+ if (event_type & SBProcess::eBroadcastBitSTDOUT)
+ {
+ // The process has stdout available, get it and write it out to the
+ // appropriate place.
+ GetProcessSTDOUT ();
+ }
+ else if (event_type & SBProcess::eBroadcastBitSTDERR)
+ {
+ // The process has stderr available, get it and write it out to the
+ // appropriate place.
+ GetProcessSTDERR ();
+ }
+ else if (event_type & SBProcess::eBroadcastBitStateChanged)
+ {
+ // Drain all stout and stderr so we don't see any output come after
+ // we print our prompts
+ GetProcessSTDOUT ();
+ GetProcessSTDERR ();
+ // Something changed in the process; get the event and report the process's current status and location to
+ // the user.
+ StateType event_state = SBProcess::GetStateFromEvent (event);
+ if (event_state == eStateInvalid)
+ return;
+
+ SBProcess process (SBProcess::GetProcessFromEvent (event));
+ assert (process.IsValid());
+
+ switch (event_state)
+ {
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateConnected:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateStepping:
+ case eStateDetached:
+ {
+ char message[1024];
+ int message_len = ::snprintf (message, sizeof(message), "Process %llu %s\n", process.GetProcessID(),
+ m_debugger.StateAsCString (event_state));
+ m_io_channel_ap->OutWrite(message, message_len, ASYNC);
+ }
+ break;
+
+ case eStateRunning:
+ // Don't be chatty when we run...
+ break;
+
+ case eStateExited:
+ {
+ SBCommandReturnObject result;
+ m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false);
+ m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize(), ASYNC);
+ m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), ASYNC);
+ }
+ break;
+
+ case eStateStopped:
+ case eStateCrashed:
+ case eStateSuspended:
+ // Make sure the program hasn't been auto-restarted:
+ if (SBProcess::GetRestartedFromEvent (event))
+ {
+ // FIXME: Do we want to report this, or would that just be annoyingly chatty?
+ char message[1024];
+ int message_len = ::snprintf (message, sizeof(message), "Process %llu stopped and was programmatically restarted.\n",
+ process.GetProcessID());
+ m_io_channel_ap->OutWrite(message, message_len, ASYNC);
+ }
+ else
+ {
+ if (GetDebugger().GetSelectedTarget() == process.GetTarget())
+ {
+ SBCommandReturnObject result;
+ UpdateSelectedThread ();
+ m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false);
+ m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize(), ASYNC);
+ m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), ASYNC);
+ }
+ else
+ {
+ SBStream out_stream;
+ uint32_t target_idx = GetDebugger().GetIndexOfTarget(process.GetTarget());
+ if (target_idx != UINT32_MAX)
+ out_stream.Printf ("Target %d: (", target_idx);
+ else
+ out_stream.Printf ("Target <unknown index>: (");
+ process.GetTarget().GetDescription (out_stream, eDescriptionLevelBrief);
+ out_stream.Printf (") stopped.\n");
+ m_io_channel_ap->OutWrite (out_stream.GetData(), out_stream.GetSize(), ASYNC);
+ }
+ }
+ break;
+ }
+ }
+}
+
+// This function handles events broadcast by the IOChannel (HasInput, UserInterrupt, or ThreadShouldExit).
+
+bool
+Driver::HandleIOEvent (const SBEvent &event)
+{
+ bool quit = false;
+
+ const uint32_t event_type = event.GetType();
+
+ if (event_type & IOChannel::eBroadcastBitHasUserInput)
+ {
+ // We got some input (i.e. a command string) from the user; pass it off to the command interpreter for
+ // handling.
+
+ const char *command_string = SBEvent::GetCStringFromEvent(event);
+ if (command_string == NULL)
+ command_string = "";
+ SBCommandReturnObject result;
+
+ // We don't want the result to bypass the OutWrite function in IOChannel, as this can result in odd
+ // output orderings and problems with the prompt.
+ m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true);
+
+ if (result.GetOutputSize() > 0)
+ m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), NO_ASYNC);
+
+ if (result.GetErrorSize() > 0)
+ m_io_channel_ap->OutWrite (result.GetError(), result.GetErrorSize(), NO_ASYNC);
+
+ // We are done getting and running our command, we can now clear the
+ // m_waiting_for_command so we can get another one.
+ m_waiting_for_command = false;
+
+ // If our editline input reader is active, it means another input reader
+ // got pushed onto the input reader and caused us to become deactivated.
+ // When the input reader above us gets popped, we will get re-activated
+ // and our prompt will refresh in our callback
+ if (m_editline_reader.IsActive())
+ {
+ ReadyForCommand ();
+ }
+ }
+ else if (event_type & IOChannel::eBroadcastBitUserInterrupt)
+ {
+ // This is here to handle control-c interrupts from the user. It has not yet really been implemented.
+ // TO BE DONE: PROPERLY HANDLE CONTROL-C FROM USER
+ //m_io_channel_ap->CancelInput();
+ // Anything else? Send Interrupt to process?
+ }
+ else if ((event_type & IOChannel::eBroadcastBitThreadShouldExit) ||
+ (event_type & IOChannel::eBroadcastBitThreadDidExit))
+ {
+ // If the IOChannel thread is trying to go away, then it is definitely
+ // time to end the debugging session.
+ quit = true;
+ }
+
+ return quit;
+}
+
+void
+Driver::MasterThreadBytesReceived (void *baton, const void *src, size_t src_len)
+{
+ Driver *driver = (Driver*)baton;
+ driver->GetFromMaster ((const char *)src, src_len);
+}
+
+void
+Driver::GetFromMaster (const char *src, size_t src_len)
+{
+ // Echo the characters back to the Debugger's stdout, that way if you
+ // type characters while a command is running, you'll see what you've typed.
+ FILE *out_fh = m_debugger.GetOutputFileHandle();
+ if (out_fh)
+ ::fwrite (src, 1, src_len, out_fh);
+}
+
+size_t
+Driver::EditLineInputReaderCallback
+(
+ void *baton,
+ SBInputReader *reader,
+ InputReaderAction notification,
+ const char *bytes,
+ size_t bytes_len
+)
+{
+ Driver *driver = (Driver *)baton;
+
+ switch (notification)
+ {
+ case eInputReaderActivate:
+ break;
+
+ case eInputReaderReactivate:
+ driver->ReadyForCommand();
+ break;
+
+ case eInputReaderDeactivate:
+ break;
+
+ case eInputReaderAsynchronousOutputWritten:
+ if (driver->m_io_channel_ap.get() != NULL)
+ driver->m_io_channel_ap->RefreshPrompt();
+ break;
+
+ case eInputReaderInterrupt:
+ if (driver->m_io_channel_ap.get() != NULL)
+ {
+ SBProcess process = driver->GetDebugger().GetSelectedTarget().GetProcess();
+ if (!driver->m_io_channel_ap->EditLineHasCharacters()
+ && process.IsValid() && process.GetState() == lldb::eStateRunning)
+ {
+ process.Stop();
+ }
+ else
+ {
+ driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC);
+ // I wish I could erase the entire input line, but there's no public API for that.
+ driver->m_io_channel_ap->EraseCharsBeforeCursor();
+ driver->m_io_channel_ap->RefreshPrompt();
+ }
+ }
+ break;
+
+ case eInputReaderEndOfFile:
+ if (driver->m_io_channel_ap.get() != NULL)
+ {
+ driver->m_io_channel_ap->OutWrite ("^D\n", 3, NO_ASYNC);
+ driver->m_io_channel_ap->RefreshPrompt ();
+ }
+#ifdef __unix__
+ write (driver->m_editline_pty.GetMasterFileDescriptor(), "quit\n", 5);
+#endif
+ break;
+
+ case eInputReaderGotToken:
+#ifdef __unix__
+ write (driver->m_editline_pty.GetMasterFileDescriptor(), bytes, bytes_len);
+#endif
+ break;
+
+ case eInputReaderDone:
+ break;
+ }
+ return bytes_len;
+}
+
+void
+Driver::AttachToProcess()
+{
+ std::string command_str("process attach ");
+ if (m_option_data.m_process_pid != LLDB_INVALID_PROCESS_ID)
+ {
+ command_str.append("-p ");
+ char pid_buffer[32];
+ ::snprintf (pid_buffer, sizeof(pid_buffer), "%llu", m_option_data.m_process_pid);
+ command_str.append(pid_buffer);
+ }
+ else
+ {
+ command_str.append("-n \"");
+ command_str.append(m_option_data.m_process_name);
+ command_str.push_back('\"');
+ if (m_option_data.m_wait_for)
+ command_str.append(" -w");
+ }
+
+ if (m_debugger.GetOutputFileHandle())
+ ::fprintf (m_debugger.GetOutputFileHandle(),
+ "Attaching to process with:\n %s\n",
+ command_str.c_str());
+
+ // Force the attach to be synchronous:
+ bool orig_async = m_debugger.GetAsync();
+ m_debugger.SetAsync(true);
+ m_debugger.HandleCommand(command_str.c_str());
+ m_debugger.SetAsync(orig_async);
+}
+
+void
+Driver::ProcessEvent(SBEvent& event)
+{
+ if (!event.GetBroadcaster().IsValid())
+ return;
+
+ uint32_t event_type = event.GetType();
+ if (event.BroadcasterMatchesRef (*m_io_channel_ap))
+ {
+ if ((event_type & IOChannel::eBroadcastBitThreadShouldExit) ||
+ (event_type & IOChannel::eBroadcastBitThreadDidExit))
+ {
+ SetIsDone();
+ if (event_type & IOChannel::eBroadcastBitThreadDidExit)
+ iochannel_thread_exited = true;
+ }
+ else
+ {
+ if (HandleIOEvent (event))
+ SetIsDone();
+ }
+ }
+ else if (SBProcess::EventIsProcessEvent (event))
+ {
+ HandleProcessEvent (event);
+ }
+ else if (SBBreakpoint::EventIsBreakpointEvent (event))
+ {
+ HandleBreakpointEvent (event);
+ }
+ else if (event.BroadcasterMatchesRef (m_interpreter->GetBroadcaster()))
+ {
+ // TODO: deprecate the eBroadcastBitQuitCommandReceived event
+ // now that we have SBCommandInterpreter::SetCommandOverrideCallback()
+ // that can take over a command
+ if (event_type & SBCommandInterpreter::eBroadcastBitQuitCommandReceived)
+ {
+ SetIsDone();
+ }
+ else if (event_type & SBCommandInterpreter::eBroadcastBitAsynchronousErrorData)
+ {
+ const char *data = SBEvent::GetCStringFromEvent (event);
+ m_io_channel_ap->ErrWrite (data, strlen(data), ASYNC);
+ }
+ else if (event_type & SBCommandInterpreter::eBroadcastBitAsynchronousOutputData)
+ {
+ const char *data = SBEvent::GetCStringFromEvent (event);
+ m_io_channel_ap->OutWrite (data, strlen(data), ASYNC);
+ }
+ }
+}
Added: lldb/branches/windows/tools/driver/DriverOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/driver/DriverOptions.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/tools/driver/DriverOptions.cpp (added)
+++ lldb/branches/windows/tools/driver/DriverOptions.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,664 @@
+//===-- Driver.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Driver.h"
+
+#ifdef _WIN32
+#include "lldb/lldb-windows.h"
+#endif
+
+#include "lldb/API/SBHostOS.h"
+using namespace lldb;
+
+typedef struct
+{
+ uint32_t usage_mask; // Used to mark options that can be used together. If (1 << n & usage_mask) != 0
+ // then this option belongs to option set n.
+ bool required; // This option is required (in the current usage level)
+ const char * long_option; // Full name for this option.
+ char short_option; // Single character for this option.
+ int option_has_arg; // no_argument, required_argument or optional_argument
+ uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
+ lldb::CommandArgumentType argument_type; // Type of argument this option takes
+ const char * usage_text; // Full text explaining what this options does and what (if any) argument to
+ // pass it.
+} OptionDefinition;
+
+#define LLDB_3_TO_5 LLDB_OPT_SET_3|LLDB_OPT_SET_4|LLDB_OPT_SET_5
+#define LLDB_4_TO_5 LLDB_OPT_SET_4|LLDB_OPT_SET_5
+
+static OptionDefinition g_options[] =
+{
+ { LLDB_OPT_SET_1, true , "help" , 'h', no_argument , NULL, eArgTypeNone,
+ "Prints out the usage information for the LLDB debugger." },
+ { LLDB_OPT_SET_2, true , "version" , 'v', no_argument , NULL, eArgTypeNone,
+ "Prints out the current version number of the LLDB debugger." },
+ { LLDB_OPT_SET_3, true , "arch" , 'a', required_argument, NULL, eArgTypeArchitecture,
+ "Tells the debugger to use the specified architecture when starting and running the program. <architecture> must "
+ "be one of the architectures for which the program was compiled." },
+ { LLDB_OPT_SET_3, true , "file" , 'f', required_argument, NULL, eArgTypeFilename,
+ "Tells the debugger to use the file <filename> as the program to be debugged." },
+ { LLDB_OPT_SET_4, true , "attach-name" , 'n', required_argument, NULL, eArgTypeProcessName,
+ "Tells the debugger to attach to a process with the given name." },
+ { LLDB_OPT_SET_4, true , "wait-for" , 'w', no_argument , NULL, eArgTypeNone,
+ "Tells the debugger to wait for a process with the given pid or name to launch before attaching." },
+ { LLDB_OPT_SET_5, true , "attach-pid" , 'p', required_argument, NULL, eArgTypePid,
+ "Tells the debugger to attach to a process with the given pid." },
+ { LLDB_3_TO_5, false, "script-language", 'l', required_argument, NULL, eArgTypeScriptLang,
+ "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default. "
+ "Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python "
+ "extensions have been implemented." },
+ { LLDB_3_TO_5, false, "debug" , 'd', no_argument , NULL, eArgTypeNone,
+ "Tells the debugger to print out extra information for debugging itself." },
+ { LLDB_3_TO_5, false, "source" , 's', required_argument, NULL, eArgTypeFilename,
+ "Tells the debugger to read in and execute the file <file>, which should contain lldb commands." },
+ { LLDB_3_TO_5, false, "editor" , 'e', no_argument , NULL, eArgTypeNone,
+ "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
+ { LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , NULL, eArgTypeNone,
+ "Do not automatically parse any '.lldbinit' files." },
+ { 0, false, NULL , 0 , 0 , NULL, eArgTypeNone, NULL }
+};
+
+static const uint32_t last_option_set_with_args = 2;
+
+// This function takes INDENT, which tells how many spaces to output at the front
+// of each line; TEXT, which is the text that is to be output. It outputs the
+// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the
+// front of each line. It breaks lines on spaces, tabs or newlines, shortening
+// the line if necessary to not break in the middle of a word. It assumes that
+// each output line should contain a maximum of OUTPUT_MAX_COLUMNS characters.
+
+void
+OutputFormattedUsageText (FILE *out, int indent, const char *text, int output_max_columns)
+{
+ int len = strlen (text);
+ std::string text_string (text);
+
+ // Force indentation to be reasonable.
+ if (indent >= output_max_columns)
+ indent = 0;
+
+ // Will it all fit on one line?
+
+ if (len + indent < output_max_columns)
+ // Output as a single line
+ fprintf (out, "%*s%s\n", indent, "", text);
+ else
+ {
+ // We need to break it up into multiple lines.
+ int text_width = output_max_columns - indent - 1;
+ int start = 0;
+ int end = start;
+ int final_end = len;
+ int sub_len;
+
+ while (end < final_end)
+ {
+ // Dont start the 'text' on a space, since we're already outputting the indentation.
+ while ((start < final_end) && (text[start] == ' '))
+ start++;
+
+ end = start + text_width;
+ if (end > final_end)
+ end = final_end;
+ else
+ {
+ // If we're not at the end of the text, make sure we break the line on white space.
+ while (end > start
+ && text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
+ end--;
+ }
+ sub_len = end - start;
+ std::string substring = text_string.substr (start, sub_len);
+ fprintf (out, "%*s%s\n", indent, "", substring.c_str());
+ start = end + 1;
+ }
+ }
+}
+
+void
+ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
+{
+ uint32_t screen_width = 80;
+ uint32_t indent_level = 0;
+ const char *name = "lldb";
+
+ fprintf (out, "\nUsage:\n\n");
+
+ indent_level += 2;
+
+
+ // First, show each usage level set of options, e.g. <cmd> [options-for-level-0]
+ // <cmd> [options-for-level-1]
+ // etc.
+
+ uint32_t num_options;
+ uint32_t num_option_sets = 0;
+
+ for (num_options = 0; option_table[num_options].long_option != NULL; ++num_options)
+ {
+ uint32_t this_usage_mask = option_table[num_options].usage_mask;
+ if (this_usage_mask == LLDB_OPT_SET_ALL)
+ {
+ if (num_option_sets == 0)
+ num_option_sets = 1;
+ }
+ else
+ {
+ for (uint32_t j = 0; j < LLDB_MAX_NUM_OPTION_SETS; j++)
+ {
+ if (this_usage_mask & 1 << j)
+ {
+ if (num_option_sets <= j)
+ num_option_sets = j + 1;
+ }
+ }
+ }
+ }
+
+ for (uint32_t opt_set = 0; opt_set < num_option_sets; opt_set++)
+ {
+ uint32_t opt_set_mask;
+
+ opt_set_mask = 1 << opt_set;
+
+ if (opt_set > 0)
+ fprintf (out, "\n");
+ fprintf (out, "%*s%s", indent_level, "", name);
+ bool is_help_line = false;
+
+ for (uint32_t i = 0; i < num_options; ++i)
+ {
+ if (option_table[i].usage_mask & opt_set_mask)
+ {
+ CommandArgumentType arg_type = option_table[i].argument_type;
+ const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
+ // This is a bit of a hack, but there's no way to say certain options don't have arguments yet...
+ // so we do it by hand here.
+ if (option_table[i].short_option == 'h')
+ is_help_line = true;
+
+ if (option_table[i].required)
+ {
+ if (option_table[i].option_has_arg == required_argument)
+ fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name);
+ else if (option_table[i].option_has_arg == optional_argument)
+ fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name);
+ else
+ fprintf (out, " -%c", option_table[i].short_option);
+ }
+ else
+ {
+ if (option_table[i].option_has_arg == required_argument)
+ fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name);
+ else if (option_table[i].option_has_arg == optional_argument)
+ fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name);
+ else
+ fprintf (out, " [-%c]", option_table[i].short_option);
+ }
+ }
+ }
+ if (!is_help_line && (opt_set <= last_option_set_with_args))
+ fprintf (out, " [[--] <PROGRAM-ARG-1> [<PROGRAM_ARG-2> ...]]");
+ }
+
+ fprintf (out, "\n\n");
+
+ // Now print out all the detailed information about the various options: long form, short form and help text:
+ // -- long_name <argument>
+ // - short <argument>
+ // help text
+
+ // This variable is used to keep track of which options' info we've printed out, because some options can be in
+ // more than one usage level, but we only want to print the long form of its information once.
+
+ Driver::OptionData::OptionSet options_seen;
+ Driver::OptionData::OptionSet::iterator pos;
+
+ indent_level += 5;
+
+ for (uint32_t i = 0; i < num_options; ++i)
+ {
+ // Only print this option if we haven't already seen it.
+ pos = options_seen.find (option_table[i].short_option);
+ if (pos == options_seen.end())
+ {
+ CommandArgumentType arg_type = option_table[i].argument_type;
+ const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
+
+ options_seen.insert (option_table[i].short_option);
+ fprintf (out, "%*s-%c ", indent_level, "", option_table[i].short_option);
+ if (arg_type != eArgTypeNone)
+ fprintf (out, "<%s>", arg_name);
+ fprintf (out, "\n");
+ fprintf (out, "%*s--%s ", indent_level, "", option_table[i].long_option);
+ if (arg_type != eArgTypeNone)
+ fprintf (out, "<%s>", arg_name);
+ fprintf (out, "\n");
+ indent_level += 5;
+ OutputFormattedUsageText (out, indent_level, option_table[i].usage_text, screen_width);
+ indent_level -= 5;
+ fprintf (out, "\n");
+ }
+ }
+
+ indent_level -= 5;
+
+ fprintf (out, "\n%*s(If you don't provide -f then the first argument will be the file to be debugged"
+ "\n%*s so '%s -- <filename> [<ARG1> [<ARG2>]]' also works."
+ "\n%*s Remember to end the options with \"--\" if any of your arguments have a \"-\" in them.)\n\n",
+ indent_level, "",
+ indent_level, "",
+ name,
+ indent_level, "");
+}
+
+void
+BuildGetOptTable (OptionDefinition *expanded_option_table, std::vector<struct option> &getopt_table,
+ uint32_t num_options)
+{
+ if (num_options == 0)
+ return;
+
+ uint32_t i;
+ uint32_t j;
+ std::bitset<256> option_seen;
+
+ getopt_table.resize (num_options + 1);
+
+ for (i = 0, j = 0; i < num_options; ++i)
+ {
+ char short_opt = expanded_option_table[i].short_option;
+
+ if (option_seen.test(short_opt) == false)
+ {
+ getopt_table[j].name = expanded_option_table[i].long_option;
+ getopt_table[j].has_arg = expanded_option_table[i].option_has_arg;
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = expanded_option_table[i].short_option;
+ option_seen.set(short_opt);
+ ++j;
+ }
+ }
+
+ getopt_table[j].name = NULL;
+ getopt_table[j].has_arg = 0;
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = 0;
+
+}
+
+Driver::OptionData::OptionData () :
+ m_args(),
+ m_script_lang (lldb::eScriptLanguageDefault),
+ m_crash_log (),
+ m_source_command_files (),
+ m_debug_mode (false),
+ m_print_version (false),
+ m_print_help (false),
+ m_wait_for(false),
+ m_process_name(),
+ m_process_pid(LLDB_INVALID_PROCESS_ID),
+ m_use_external_editor(false),
+ m_seen_options()
+{
+}
+
+Driver::OptionData::~OptionData ()
+{
+}
+
+void
+Driver::OptionData::Clear ()
+{
+ m_args.clear ();
+ m_script_lang = lldb::eScriptLanguageDefault;
+ m_source_command_files.clear ();
+ m_debug_mode = false;
+ m_print_help = false;
+ m_print_version = false;
+ m_use_external_editor = false;
+ m_wait_for = false;
+ m_process_name.erase();
+ m_process_pid = LLDB_INVALID_PROCESS_ID;
+}
+
+void
+Driver::ResetOptionValues ()
+{
+ m_option_data.Clear ();
+}
+
+// Check the arguments that were passed to this program to make sure they are valid and to get their
+// argument values (if any). Return a boolean value indicating whether or not to start up the full
+// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR
+// if the user only wanted help or version information.
+
+SBError
+Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
+{
+ ResetOptionValues ();
+
+ SBCommandReturnObject result;
+
+ SBError error;
+ std::string option_string;
+ struct option *long_options = NULL;
+ std::vector<struct option> long_options_vector;
+ uint32_t num_options;
+
+ for (num_options = 0; g_options[num_options].long_option != NULL; ++num_options)
+ /* Do Nothing. */;
+
+ if (num_options == 0)
+ {
+ if (argc > 1)
+ error.SetErrorStringWithFormat ("invalid number of options");
+ return error;
+ }
+
+ BuildGetOptTable (g_options, long_options_vector, num_options);
+
+ if (long_options_vector.empty())
+ long_options = NULL;
+ else
+ long_options = &long_options_vector.front();
+
+ if (long_options == NULL)
+ {
+ error.SetErrorStringWithFormat ("invalid long options");
+ return error;
+ }
+
+ // Build the option_string argument for call to getopt_long.
+
+ for (int i = 0; long_options[i].name != NULL; ++i)
+ {
+ if (long_options[i].flag == NULL)
+ {
+ option_string.push_back ((char) long_options[i].val);
+ switch (long_options[i].has_arg)
+ {
+ default:
+ case no_argument:
+ break;
+ case required_argument:
+ option_string.push_back (':');
+ break;
+ case optional_argument:
+ option_string.append ("::");
+ break;
+ }
+ }
+ }
+
+ // This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't
+ // know at that point whether we should read in init files yet. So we don't read them in in the
+ // Driver constructor, then set the flags back to "read them in" here, and then if we see the
+ // "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the
+ // main loop.
+
+ m_debugger.SkipLLDBInitFiles (false);
+ m_debugger.SkipAppInitFiles (false);
+
+ // Prepare for & make calls to getopt_long.
+#if __GLIBC__
+ optind = 0;
+#else
+ optreset = 1;
+ optind = 1;
+#endif
+ int val;
+ while (1)
+ {
+ int long_options_index = -1;
+ val = ::getopt_long (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index);
+
+ if (val == -1)
+ break;
+ else if (val == '?')
+ {
+ m_option_data.m_print_help = true;
+ error.SetErrorStringWithFormat ("unknown or ambiguous option");
+ break;
+ }
+ else if (val == 0)
+ continue;
+ else
+ {
+ m_option_data.m_seen_options.insert ((char) val);
+ if (long_options_index == -1)
+ {
+ for (int i = 0;
+ long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val;
+ ++i)
+ {
+ if (long_options[i].val == val)
+ {
+ long_options_index = i;
+ break;
+ }
+ }
+ }
+
+ if (long_options_index >= 0)
+ {
+ const char short_option = (char) g_options[long_options_index].short_option;
+
+ switch (short_option)
+ {
+ case 'h':
+ m_option_data.m_print_help = true;
+ break;
+
+ case 'v':
+ m_option_data.m_print_version = true;
+ break;
+
+ case 'c':
+ m_option_data.m_crash_log = optarg;
+ break;
+
+ case 'e':
+ m_option_data.m_use_external_editor = true;
+ break;
+
+ case 'x':
+ m_debugger.SkipLLDBInitFiles (true);
+ m_debugger.SkipAppInitFiles (true);
+ break;
+
+ case 'f':
+ {
+ SBFileSpec file(optarg);
+ if (file.Exists())
+ {
+ m_option_data.m_args.push_back (optarg);
+ }
+ else if (file.ResolveExecutableLocation())
+ {
+ char path[PATH_MAX];
+ file.GetPath (path, sizeof(path));
+ m_option_data.m_args.push_back (path);
+ }
+ else
+ error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg);
+ }
+ break;
+
+ case 'a':
+ if (!m_debugger.SetDefaultArchitecture (optarg))
+ error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", optarg);
+ break;
+
+ case 'l':
+ m_option_data.m_script_lang = m_debugger.GetScriptingLanguage (optarg);
+ break;
+
+ case 'd':
+ m_option_data.m_debug_mode = true;
+ break;
+
+ case 'n':
+ m_option_data.m_process_name = optarg;
+ break;
+
+ case 'w':
+ m_option_data.m_wait_for = true;
+ break;
+
+ case 'p':
+ {
+ char *remainder;
+ m_option_data.m_process_pid = strtol (optarg, &remainder, 0);
+ if (remainder == optarg || *remainder != '\0')
+ error.SetErrorStringWithFormat ("Could not convert process PID: \"%s\" into a pid.",
+ optarg);
+ }
+ break;
+ case 's':
+ {
+ SBFileSpec file(optarg);
+ if (file.Exists())
+ m_option_data.m_source_command_files.push_back (optarg);
+ else if (file.ResolveExecutableLocation())
+ {
+ char final_path[PATH_MAX];
+ file.GetPath (final_path, sizeof(final_path));
+ std::string path_str (final_path);
+ m_option_data.m_source_command_files.push_back (path_str);
+ }
+ else
+ error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
+ }
+ break;
+
+ default:
+ m_option_data.m_print_help = true;
+ error.SetErrorStringWithFormat ("unrecognized option %c", short_option);
+ break;
+ }
+ }
+ else
+ {
+ error.SetErrorStringWithFormat ("invalid option with value %i", val);
+ }
+ if (error.Fail())
+ {
+ return error;
+ }
+ }
+ }
+
+ if (error.Fail() || m_option_data.m_print_help)
+ {
+ ShowUsage (out_fh, g_options, m_option_data);
+ exit = true;
+ }
+ else if (m_option_data.m_print_version)
+ {
+ ::fprintf (out_fh, "%s\n", m_debugger.GetVersionString());
+ exit = true;
+ }
+ else if (! m_option_data.m_crash_log.empty())
+ {
+ // Handle crash log stuff here.
+ }
+ else if (m_option_data.m_process_name.empty() && m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID)
+ {
+ // Any arguments that are left over after option parsing are for
+ // the program. If a file was specified with -f then the filename
+ // is already in the m_option_data.m_args array, and any remaining args
+ // are arguments for the inferior program. If no file was specified with
+ // -f, then what is left is the program name followed by any arguments.
+
+ // Skip any options we consumed with getopt_long
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ {
+ for (int arg_idx=0; arg_idx<argc; ++arg_idx)
+ {
+ const char *arg = argv[arg_idx];
+ if (arg)
+ m_option_data.m_args.push_back (arg);
+ }
+ }
+
+ }
+ else
+ {
+ // Skip any options we consumed with getopt_long
+ argc -= optind;
+ //argv += optind; // Commented out to keep static analyzer happy
+
+ if (argc > 0)
+ ::fprintf (out_fh, "Warning: program arguments are ignored when attaching.\n");
+ }
+
+ return error;
+}
+
+void
+Driver::HandleCommandLine(SBCommandReturnObject& result)
+{
+ // Now we handle options we got from the command line
+ char command_string[PATH_MAX * 2];
+ const size_t num_source_command_files = GetNumSourceCommandFiles();
+ if (num_source_command_files > 0)
+ {
+ for (size_t i=0; i < num_source_command_files; ++i)
+ {
+ const char *command_file = GetSourceCommandFileAtIndex(i);
+ ::snprintf (command_string, sizeof(command_string), "command source '%s'", command_file);
+ m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, false);
+ if (GetDebugMode())
+ {
+ result.PutError (m_debugger.GetErrorFileHandle());
+ result.PutOutput (m_debugger.GetOutputFileHandle());
+ }
+ }
+ }
+
+ const size_t num_args = m_option_data.m_args.size();
+
+ if (!num_args)
+ return;
+
+ char arch_name[64];
+ if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
+ ::snprintf (command_string,
+ sizeof (command_string),
+ "target create --arch=%s \"%s\"",
+ arch_name,
+ m_option_data.m_args[0].c_str());
+ else
+ ::snprintf (command_string,
+ sizeof(command_string),
+ "target create \"%s\"",
+ m_option_data.m_args[0].c_str());
+
+ m_debugger.HandleCommand (command_string);
+
+ if (num_args > 1)
+ {
+ m_debugger.HandleCommand ("settings clear target.run-args");
+ char arg_cstr[1024];
+ for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
+ {
+ ::snprintf (arg_cstr,
+ sizeof(arg_cstr),
+ "settings append target.run-args \"%s\"",
+ m_option_data.m_args[arg_idx].c_str());
+ m_debugger.HandleCommand (arg_cstr);
+ }
+ }
+}
+
Added: lldb/branches/windows/tools/driver/DriverPosix.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/driver/DriverPosix.cpp?rev=163822&view=auto
==============================================================================
--- lldb/branches/windows/tools/driver/DriverPosix.cpp (added)
+++ lldb/branches/windows/tools/driver/DriverPosix.cpp Thu Sep 13 13:40:53 2012
@@ -0,0 +1,257 @@
+//===-- Driver.cpp ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Driver.h"
+
+#ifdef _POSIX_SOURCE
+#include <getopt.h>
+#include <libgen.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <unistd.h>
+#endif
+
+#ifdef __unix__
+static void reset_stdin_termios ();
+static bool g_old_stdin_termios_is_valid = false;
+static struct termios g_old_stdin_termios;
+#endif
+
+// In the Driver::MainLoop, we change the terminal settings. This function is
+// added as an atexit handler to make sure we clean them up.
+static void
+reset_stdin_termios ()
+{
+#ifdef _POSIX_SOURCE
+ if (g_old_stdin_termios_is_valid)
+ {
+ g_old_stdin_termios_is_valid = false;
+ ::tcsetattr (STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
+ }
+#endif
+}
+
+void
+Driver::InitializePseudoTerminal()
+{
+#ifndef _WIN32
+ char error_str[1024];
+ if (m_editline_pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY, error_str, sizeof(error_str)) == false)
+ {
+ ::fprintf (stderr, "error: failed to open driver pseudo terminal : %s", error_str);
+ exit(1);
+ }
+ else
+ {
+ const char *driver_slave_name = m_editline_pty.GetSlaveName (error_str, sizeof(error_str));
+ if (driver_slave_name == NULL)
+ {
+ ::fprintf (stderr, "error: failed to get slave name for driver pseudo terminal : %s", error_str);
+ exit(2);
+ }
+ else
+ {
+ m_editline_slave_fh = ::fopen (driver_slave_name, "r+");
+ if (m_editline_slave_fh == NULL)
+ {
+ SBError error;
+ error.SetErrorToErrno();
+ ::fprintf (stderr, "error: failed to get open slave for driver pseudo terminal : %s",
+ error.GetCString());
+ exit(3);
+ }
+
+ ::setbuf (m_editline_slave_fh, NULL);
+ }
+ }
+
+ lldb_utility::PseudoTerminal editline_output_pty;
+ FILE *editline_output_slave_fh = NULL;
+
+ if (editline_output_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, error_str, sizeof (error_str)) == false)
+ {
+ ::fprintf (stderr, "error: failed to open output pseudo terminal : %s", error_str);
+ exit(1);
+ }
+ else
+ {
+ const char *output_slave_name = editline_output_pty.GetSlaveName (error_str, sizeof(error_str));
+ if (output_slave_name == NULL)
+ {
+ ::fprintf (stderr, "error: failed to get slave name for output pseudo terminal : %s", error_str);
+ exit(2);
+ }
+ else
+ {
+ editline_output_slave_fh = ::fopen (output_slave_name, "r+");
+ if (editline_output_slave_fh == NULL)
+ {
+ SBError error;
+ error.SetErrorToErrno();
+ ::fprintf (stderr, "error: failed to get open slave for output pseudo terminal : %s",
+ error.GetCString());
+ exit(3);
+ }
+ ::setbuf (editline_output_slave_fh, NULL);
+ }
+ }
+
+ struct termios stdin_termios;
+
+ if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
+ {
+ g_old_stdin_termios_is_valid = true;
+ atexit (reset_stdin_termios);
+ }
+
+ ::setbuf (stdin, NULL);
+ ::setbuf (stdout, NULL);
+#endif
+}
+
+void
+Driver::InitializeEditLineIO()
+{
+#ifndef _WIN32
+ // You have to drain anything that comes to the master side of the PTY. master_out_comm is
+ // for that purpose. The reason you need to do this is a curious reason... editline will echo
+ // characters to the PTY when it gets characters while el_gets is not running, and then when
+ // you call el_gets (or el_getc) it will try to reset the terminal back to raw mode which blocks
+ // if there are unconsumed characters in the out buffer.
+ // However, you don't need to do anything with the characters, since editline will dump these
+ // unconsumed characters after printing the prompt again in el_gets.
+
+ SBCommunication master_out_comm("driver.editline");
+ master_out_comm.SetCloseOnEOF (false);
+ master_out_comm.AdoptFileDesriptor(m_editline_pty.GetMasterFileDescriptor(), false);
+ master_out_comm.SetReadThreadBytesReceivedCallback(Driver::MasterThreadBytesReceived, this);
+
+ if (master_out_comm.ReadThreadStart () == false)
+ {
+ ::fprintf (stderr, "error: failed to start master out read thread");
+ exit(5);
+ }
+
+ m_io_channel_ap.reset (new IOChannel(m_editline_slave_fh, editline_output_slave_fh, stdout, stderr, this));
+
+ SBCommunication out_comm_2("driver.editline_output");
+ out_comm_2.SetCloseOnEOF (false);
+ out_comm_2.AdoptFileDesriptor (editline_output_pty.GetMasterFileDescriptor(), false);
+ out_comm_2.SetReadThreadBytesReceivedCallback (IOChannel::LibeditOutputBytesReceived, m_io_channel_ap.get());
+
+ if (out_comm_2.ReadThreadStart () == false)
+ {
+ ::fprintf (stderr, "error: failed to start libedit output read thread");
+ exit (5);
+ }
+
+ struct winsize window_size;
+ if (isatty (STDIN_FILENO)
+ && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
+ {
+ if (window_size.ws_col > 0)
+ m_debugger.SetTerminalWidth (window_size.ws_col);
+ }
+
+ // Since input can be redirected by the debugger, we must insert our editline
+ // input reader in the queue so we know when our reader should be active
+ // and so we can receive bytes only when we are supposed to.
+ SBError err (m_editline_reader.Initialize (m_debugger,
+ Driver::EditLineInputReaderCallback, // callback
+ this, // baton
+ eInputReaderGranularityByte, // token_size
+ NULL, // end token - NULL means never done
+ NULL, // prompt - taken care of elsewhere
+ false)); // echo input - don't need Debugger
+ // to do this, we handle it elsewhere
+
+ if (err.Fail())
+ {
+ ::fprintf (stderr, "error: %s", err.GetCString());
+ exit (6);
+ }
+
+ m_debugger.PushInputReader (m_editline_reader);
+#endif
+}
+
+void
+Driver::DestroyPseudoTerminal()
+{
+#ifndef _WIN32
+ editline_output_pty.CloseMasterFileDescriptor();
+ master_out_comm.Disconnect();
+ out_comm_2.Disconnect();
+ reset_stdin_termios();
+ fclose (stdin);
+#endif
+}
+
+void
+Driver::CloseIOChannelFile ()
+{
+#ifdef __unix__
+ // Write an End of File sequence to the file descriptor to ensure any
+ // read functions can exit.
+ char eof_str[] = "\x04";
+ ::write (m_editline_pty.GetMasterFileDescriptor(), eof_str, strlen(eof_str));
+
+ m_editline_pty.CloseMasterFileDescriptor();
+
+ if (m_editline_slave_fh)
+ {
+ ::fclose (m_editline_slave_fh);
+ m_editline_slave_fh = NULL;
+ }
+#endif
+}
+
+#ifdef __unix__
+void
+sigwinch_handler (int signo)
+{
+ struct winsize window_size;
+ if (isatty (STDIN_FILENO)
+ && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
+ {
+ if ((window_size.ws_col > 0) && g_driver != NULL)
+ {
+ g_driver->GetDebugger().SetTerminalWidth (window_size.ws_col);
+ }
+ }
+}
+
+void
+sigint_handler (int signo)
+{
+ static bool g_interrupt_sent = false;
+ if (g_driver)
+ {
+ if (!g_interrupt_sent)
+ {
+ g_interrupt_sent = true;
+ g_driver->GetDebugger().DispatchInputInterrupt();
+ g_interrupt_sent = false;
+ return;
+ }
+ }
+
+ exit (signo);
+}
+#endif
+
+void
+SetupPosixSignals()
+{
+#ifdef __unix__
+ signal (SIGPIPE, SIG_IGN);
+ signal (SIGWINCH, sigwinch_handler);
+ signal (SIGINT, sigint_handler);
+#endif
+}
More information about the lldb-commits
mailing list