summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Panickal <deepak@codeplay.com>2014-01-31 18:48:46 +0000
committerDeepak Panickal <deepak@codeplay.com>2014-01-31 18:48:46 +0000
commit914b8d989b0ea9f0da066773c7ca703eaa013f6b (patch)
tree670cb2885c1a859d2f53f3539c52590675c25267
parent322ce39e39186aaea01c7b8ebfa14ff537721ea9 (diff)
downloadbcm5719-llvm-914b8d989b0ea9f0da066773c7ca703eaa013f6b.tar.gz
bcm5719-llvm-914b8d989b0ea9f0da066773c7ca703eaa013f6b.zip
Fixing the Windows build for the changes brought in from the iohandler merge.
llvm-svn: 200565
-rw-r--r--lldb/CMakeLists.txt29
-rw-r--r--lldb/include/lldb/Host/Editline.h2
-rw-r--r--lldb/include/lldb/Host/HostGetOpt.h20
-rw-r--r--lldb/include/lldb/Host/windows/GetOptInc.h46
-rw-r--r--lldb/include/lldb/Host/windows/editlinewin.h (renamed from lldb/tools/driver/ELWrapper.h)3
-rw-r--r--lldb/source/Commands/CommandObjectGUI.cpp5
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp7
-rw-r--r--lldb/source/Core/IOHandler.cpp17
-rw-r--r--lldb/source/Host/common/OptionParser.cpp8
-rw-r--r--lldb/source/Host/windows/CMakeLists.txt2
-rw-r--r--lldb/source/Host/windows/EditLineWin.cpp (renamed from lldb/tools/driver/ELWrapper.cpp)10
-rw-r--r--lldb/source/Host/windows/GetOptInc.cpp (renamed from lldb/source/Host/windows/msvc/getopt.inc)283
-rw-r--r--lldb/source/Target/Process.cpp8
-rw-r--r--lldb/tools/driver/CMakeLists.txt5
-rw-r--r--lldb/tools/driver/GetOptWrapper.cpp33
-rw-r--r--lldb/tools/driver/GetOptWrapper.h49
-rw-r--r--lldb/tools/driver/Platform.h3
-rw-r--r--lldb/tools/lldb-platform/lldb-platform.cpp2
18 files changed, 240 insertions, 292 deletions
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index a17d56575e5..a829cd1a36c 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -1,10 +1,14 @@
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
set(LLDB_DEFAULT_DISABLE_PYTHON 1)
+ set(LLDB_DEFAULT_DISABLE_CURSES 1)
else()
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
+ set(LLDB_DEFAULT_DISABLE_CURSES 0)
endif()
set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
"Disables the Python scripting integration.")
+set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
+ "Disables the Curses integration.")
# If we are not building as a part of LLVM, build LLDB as an
# standalone project, using LLVM as an external library:
@@ -77,6 +81,10 @@ if (LLDB_DISABLE_PYTHON)
add_definitions( -DLLDB_DISABLE_PYTHON )
endif()
+if (LLDB_DISABLE_CURSES)
+ add_definitions( -DLLDB_DISABLE_CURSES )
+endif()
+
macro(add_lldb_definitions)
# We don't want no semicolons on LLDB_DEFINITIONS:
foreach(arg ${ARGN})
@@ -182,7 +190,10 @@ macro(add_lldb_library name)
else()
set(libkind STATIC)
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+ #PIC not needed on Win
+ if (NOT MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+ endif()
add_library(${name} ${libkind} ${srcs})
#if (LLVM_COMMON_DEPENDS)
##add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
@@ -269,6 +280,22 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND system_libs ncurses panel)
endif()
+
+# Disable RTTI by default
+if(NOT LLDB_REQUIRES_RTTI)
+ if (NOT MSVC)
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR
+ "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ #gnu && clang compilers
+ set(LLDB_COMPILE_FLAGS "-fno-rtti")
+ endif() #GNU or CLANG
+ else()
+ #MSVC
+ set(LLDB_COMPILE_FLAGS "/GR-")
+ endif() #NOT MSVC
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLDB_COMPILE_FLAGS}")
+endif()
+
#add_subdirectory(include)
add_subdirectory(docs)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index dec68170994..b92de1052f2 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -15,7 +15,7 @@
#include <stdio.h>
#ifdef _WIN32
-#include "ELWrapper.h"
+#include "lldb/Host/windows/editlinewin.h"
#else
#include <histedit.h>
#endif
diff --git a/lldb/include/lldb/Host/HostGetOpt.h b/lldb/include/lldb/Host/HostGetOpt.h
new file mode 100644
index 00000000000..6fb7b51dddb
--- /dev/null
+++ b/lldb/include/lldb/Host/HostGetOpt.h
@@ -0,0 +1,20 @@
+//===-- GetOpt.h ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#pragma once
+
+#ifndef _MSC_VER
+
+#include <unistd.h>
+#include <getopt.h>
+
+#else
+
+#include <lldb/Host/windows/GetOptInc.h>
+
+#endif \ No newline at end of file
diff --git a/lldb/include/lldb/Host/windows/GetOptInc.h b/lldb/include/lldb/Host/windows/GetOptInc.h
new file mode 100644
index 00000000000..8f3b7bcb379
--- /dev/null
+++ b/lldb/include/lldb/Host/windows/GetOptInc.h
@@ -0,0 +1,46 @@
+#pragma once
+
+// from getopt.h
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+// option structure
+struct option
+{
+ const char *name;
+ // has_arg can't be an enum because some compilers complain about
+ // type mismatches in all the code that assumes it is an int.
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+int getopt( int argc, char * const argv[], const char *optstring );
+
+// from getopt.h
+extern char * optarg;
+extern int optind;
+extern int opterr;
+extern int optopt;
+
+// defined in unistd.h
+extern int optreset;
+
+int getopt_long
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
+
+int getopt_long_only
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
diff --git a/lldb/tools/driver/ELWrapper.h b/lldb/include/lldb/Host/windows/editlinewin.h
index a30182d948b..907ef373a37 100644
--- a/lldb/tools/driver/ELWrapper.h
+++ b/lldb/include/lldb/Host/windows/editlinewin.h
@@ -46,6 +46,7 @@
#define EL_GETFP 18 // , int, FILE **
#define EL_SETFP 19 // , int, FILE *
#define EL_REFRESH 20 // , void
+#define EL_PROMPT_ESC 21 // , prompt_func, Char); set/get
#define EL_BUILTIN_GETCFN (NULL)
@@ -105,7 +106,7 @@ extern "C"
void el_end ( EditLine * );
void el_reset ( EditLine * );
int el_getc ( EditLine *, char * );
- void el_push ( EditLine *, char * );
+ void el_push ( EditLine *, const char * );
void el_beep ( EditLine * );
int el_parse ( EditLine *, int, const char ** );
int el_get ( EditLine *, int, ... );
diff --git a/lldb/source/Commands/CommandObjectGUI.cpp b/lldb/source/Commands/CommandObjectGUI.cpp
index 0fe6cdcd8b0..3d05335e92e 100644
--- a/lldb/source/Commands/CommandObjectGUI.cpp
+++ b/lldb/source/Commands/CommandObjectGUI.cpp
@@ -38,6 +38,7 @@ CommandObjectGUI::~CommandObjectGUI ()
bool
CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
{
+#ifndef LLDB_DISABLE_CURSES
if (args.GetArgumentCount() == 0)
{
Debugger &debugger = m_interpreter.GetDebugger();
@@ -52,5 +53,9 @@ CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
result.SetStatus (eReturnStatusFailed);
}
return true;
+#else
+ result.AppendError("lldb was not build with gui support");
+ return false;
+#endif
}
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index caf5429084e..7ee93dea921 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -195,6 +195,7 @@ public:
{
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
+#ifndef LLDB_DISABLE_PYTHON
ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
if (interpreter)
{
@@ -309,7 +310,7 @@ public:
error_sp->Printf ("error: script interpreter missing, didn't add python command.\n");
error_sp->Flush();
}
-
+#endif // #ifndef LLDB_DISABLE_PYTHON
io_handler.SetIsDone(true);
}
@@ -482,6 +483,7 @@ protected:
{
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
+#ifndef LLDB_DISABLE_PYTHON
ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
if (interpreter)
{
@@ -577,9 +579,8 @@ protected:
error_sp->Flush();
}
+#endif // #ifndef LLDB_DISABLE_PYTHON
io_handler.SetIsDone(true);
-
-
}
public:
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 15754a44521..d89bad6acc2 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -11,8 +11,10 @@
#include "lldb/lldb-python.h"
#include <stdio.h> /* ioctl, TIOCGWINSZ */
-#include <sys/ioctl.h> /* ioctl, TIOCGWINSZ */
+#ifndef _MSC_VER
+#include <sys/ioctl.h> /* ioctl, TIOCGWINSZ */
+#endif
#include <string>
@@ -31,8 +33,10 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/ThreadPlan.h"
+#ifndef LLDB_DISABLE_CURSES
#include <ncurses.h>
#include <panel.h>
+#endif
using namespace lldb;
using namespace lldb_private;
@@ -328,9 +332,10 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
{
SetPrompt(prompt);
+ bool use_editline = false;
+#ifndef _MSC_VER
const int in_fd = GetInputFD();
struct winsize window_size;
- bool use_editline = false;
if (isatty (in_fd))
{
m_interactive = true;
@@ -340,6 +345,9 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
use_editline = true;
}
}
+#else
+ use_editline = true;
+#endif
if (use_editline)
{
@@ -588,6 +596,10 @@ IOHandlerEditline::GotEOF()
m_editline_ap->Interrupt();
}
+// we may want curses to be disabled for some builds
+// for instance, windows
+#ifndef LLDB_DISABLE_CURSES
+
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
@@ -5274,3 +5286,4 @@ IOHandlerCursesGUI::GotEOF()
{
}
+#endif // #ifndef LLDB_DISABLE_CURSES \ No newline at end of file
diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp
index ead044f53cf..cf133597cb8 100644
--- a/lldb/source/Host/common/OptionParser.cpp
+++ b/lldb/source/Host/common/OptionParser.cpp
@@ -9,14 +9,10 @@
#include "lldb/Host/OptionParser.h"
-#ifdef _MSC_VER
-#include "../windows/msvc/getopt.inc"
-#else
-#ifdef _WIN32
+#if (!defined( _MSC_VER ) && defined( _WIN32 ))
#define _BSD_SOURCE // Required so that getopt.h defines optreset
#endif
-#include <getopt.h>
-#endif
+#include "lldb/Host/HostGetOpt.h"
using namespace lldb_private;
diff --git a/lldb/source/Host/windows/CMakeLists.txt b/lldb/source/Host/windows/CMakeLists.txt
index 0ffe73439c8..604cfd6c0ca 100644
--- a/lldb/source/Host/windows/CMakeLists.txt
+++ b/lldb/source/Host/windows/CMakeLists.txt
@@ -6,4 +6,6 @@ add_lldb_library(lldbHostWindows
Mutex.cpp
Condition.cpp
Windows.cpp
+ EditLineWin.cpp
+ GetOptInc.cpp
)
diff --git a/lldb/tools/driver/ELWrapper.cpp b/lldb/source/Host/windows/EditLineWin.cpp
index 258f47e5169..da3a9eac857 100644
--- a/lldb/tools/driver/ELWrapper.cpp
+++ b/lldb/source/Host/windows/EditLineWin.cpp
@@ -12,7 +12,7 @@
#include "lldb/Host/windows/windows.h"
-#include "ELWrapper.h"
+#include "lldb/Host/windows/editlinewin.h"
#include <vector>
#include <assert.h>
@@ -303,8 +303,8 @@ el_set (EditLine *el, int code, ...)
clientData = GETARG( 0 );
}
break;
- default:
- assert( !"Not Implemented!" );
+// default:
+// assert( !"Not Implemented!" );
}
return 0;
}
@@ -329,9 +329,9 @@ el_getc (EditLine *, char *)
}
void
-el_push (EditLine *, char *)
+el_push (EditLine *, const char *)
{
- assert( !"Not implemented!" );
+// assert( !"Not implemented!" );
}
void
diff --git a/lldb/source/Host/windows/msvc/getopt.inc b/lldb/source/Host/windows/GetOptInc.cpp
index 9af237eb192..3be3700f9a4 100644
--- a/lldb/source/Host/windows/msvc/getopt.inc
+++ b/lldb/source/Host/windows/GetOptInc.cpp
@@ -1,91 +1,4 @@
-/* $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@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.
- */
-
-#ifdef _MSC_VER
-
-// getopt.h
-enum {
- no_argument = 0,
- required_argument,
- optional_argument
-};
-
-struct option {
- /* name of long option */
- const char *name;
- /*
- * one of no_argument, required_argument, and optional_argument:
- * whether option takes an argument
- */
- int has_arg;
- /* if not NULL, set *flag to val when option found */
- int *flag;
- /* if flag not NULL, value to set *flag to; else return value */
- int val;
-};
-
-int getopt(int argc, char * const argv[],
- const char *optstring);
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-int getopt_long(int argc, char * const *argv,
- const char *optstring,
- const struct option *longopts, int *longindex);
-
-int getopt_long_only(int argc, char * const *argv,
- const char *optstring,
- const struct option *longopts, int *longindex);
-extern int optreset;
+#include "lldb/Host/windows/GetOptInc.h"
// getopt.cpp
#include <errno.h>
@@ -112,9 +25,9 @@ char *optarg; /* argument associated with option */
#define EMSG ""
static int getopt_internal(int, char * const *, const char *,
- const struct option *, int *, int);
+ const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
- const struct option *, int *, int);
+ const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
@@ -133,8 +46,8 @@ static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
/*
- * Compute the greatest common divisor of a and b.
- */
+* Compute the greatest common divisor of a and b.
+*/
static int
gcd(int a, int b)
{
@@ -154,27 +67,27 @@ 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).
- */
+* 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)
+char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
- * compute lengths of blocks and number and size of cycles
- */
+ * 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;
+ cstart = panonopt_end + i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
@@ -183,7 +96,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
- ((char **) nargv)[pos] = nargv[cstart];
+ ((char **)nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
@@ -191,13 +104,13 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,
}
/*
- * 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.
- */
+* 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)
+const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
@@ -212,7 +125,8 @@ parse_long_options(char * const *nargv, const char *options,
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
- } else
+ }
+ else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
@@ -227,9 +141,9 @@ parse_long_options(char * const *nargv, const char *options,
break;
}
/*
- * If this is a known short option, don't allow
- * a partial match of a single character.
- */
+ * 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;
@@ -239,7 +153,7 @@ parse_long_options(char * const *nargv, const char *options,
/* ambiguous abbreviation */
if (PRINT_ERROR)
warnx(ambig, (int)current_argv_len,
- current_argv);
+ current_argv);
optopt = 0;
return (BADCH);
}
@@ -249,10 +163,10 @@ parse_long_options(char * const *nargv, const char *options,
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
- current_argv);
+ current_argv);
/*
- * XXX: GNU sets optopt to val regardless of flag
- */
+ * XXX: GNU sets optopt to val regardless of flag
+ */
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
@@ -266,23 +180,23 @@ parse_long_options(char * const *nargv, const char *options,
else if (long_options[match].has_arg ==
required_argument) {
/*
- * optional argument doesn't use next nargv
- */
+ * 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.
- */
+ * Missing argument; leading ':' indicates no error
+ * should be generated.
+ */
if (PRINT_ERROR)
warnx(recargstring,
- current_argv);
+ current_argv);
/*
- * XXX: GNU sets optopt to val regardless of flag
- */
+ * XXX: GNU sets optopt to val regardless of flag
+ */
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
@@ -290,7 +204,8 @@ parse_long_options(char * const *nargv, const char *options,
--optind;
return (BADARG);
}
- } else { /* unknown option */
+ }
+ else { /* unknown option */
if (short_too) {
--optind;
return (-1);
@@ -305,17 +220,18 @@ parse_long_options(char * const *nargv, const char *options,
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
- } else
+ }
+ else
return (long_options[match].val);
}
/*
- * getopt_internal --
- * Parse argc/argv argument vector. Called by user level routines.
- */
+* 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 struct option *long_options, int *idx, int flags)
{
const char *oli; /* option letter list index */
int optchar, short_too;
@@ -325,16 +241,16 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
return (-1);
/*
- * XXX Some GNU programs (like cvs) set optind to 0 instead of
- * XXX using optreset. Work around this braindamage.
- */
+ * 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 '+'.
- */
+ * 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 == '-')
@@ -360,9 +276,9 @@ start:
}
else if (nonopt_start != -1) {
/*
- * If we skipped non-options, set optind
- * to the first of them.
- */
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
@@ -373,17 +289,17 @@ start:
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
- * GNU extension:
- * return non-option as argument to option 1
- */
+ * 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.
- */
+ * If no permutation wanted, stop parsing
+ * at first non-option.
+ */
return (-1);
}
/* do permutation */
@@ -404,15 +320,15 @@ start:
nonopt_end = optind;
/*
- * If we have "-" do nothing, if "--" we are done.
- */
+ * 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.
- */
+ * 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);
@@ -424,11 +340,11 @@ start:
}
/*
- * 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()
- */
+ * 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;
@@ -449,10 +365,10 @@ start:
(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 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)
@@ -472,7 +388,8 @@ start:
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
- } else /* white space */
+ }
+ else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
@@ -482,7 +399,8 @@ start:
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
- } else { /* takes (optional) argument */
+ }
+ else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
@@ -493,7 +411,8 @@ start:
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
- } else
+ }
+ else
optarg = nargv[optind];
}
place = EMSG;
@@ -504,49 +423,47 @@ start:
}
/*
- * getopt --
- * Parse argc/argv argument vector.
- *
- * [eventually this will replace the BSD getopt]
- */
+* 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.
- */
+ * 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.
- */
+* 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)
+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.
- */
+* 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)
+const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
- FLAG_PERMUTE|FLAG_LONGONLY));
+ FLAG_PERMUTE | FLAG_LONGONLY));
}
-
-#endif
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 799f35a3dea..a18eab0f265 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4751,7 +4751,12 @@ public:
return true;
int fds[2];
+#ifdef _MSC_VER
+ // pipe is not supported on windows so default to a fail condition
+ int err = 1;
+#else
int err = pipe(fds);
+#endif
if (err == 0)
{
m_pipe_read.SetDescriptor(fds[0], true);
@@ -4786,6 +4791,8 @@ public:
Terminal terminal(read_fd);
terminal.SetCanonical(false);
terminal.SetEcho(false);
+// FD_ZERO, FD_SET are not supported on windows
+#ifndef _MSC_VER
while (!GetIsDone())
{
fd_set read_fdset;
@@ -4825,6 +4832,7 @@ public:
}
}
}
+#endif
terminal_state.Restore();
}
diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt
index f671b5bddaf..af3dbbe6fb7 100644
--- a/lldb/tools/driver/CMakeLists.txt
+++ b/lldb/tools/driver/CMakeLists.txt
@@ -1,12 +1,7 @@
set(LLVM_NO_RTTI 1)
add_lldb_executable(lldb
Driver.cpp
- #DriverEvents.cpp
- #DriverOptions.cpp
- #DriverPosix.cpp
- ELWrapper.cpp
Platform.cpp
- GetOptWrapper.cpp
)
target_link_libraries(lldb liblldb)
diff --git a/lldb/tools/driver/GetOptWrapper.cpp b/lldb/tools/driver/GetOptWrapper.cpp
deleted file mode 100644
index e7cdfd786c6..00000000000
--- a/lldb/tools/driver/GetOptWrapper.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//===-- GetOptWrapper.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 is only relevant for Visual C++
-#if defined( _MSC_VER )
-
-#include "GetOptWrapper.h"
-
-/*
-
-// already defined in lldbHostCommon.lib due to 'getopt.inc'
-
-extern int
-getopt_long_only
-(
- int ___argc,
- char *const *___argv,
- const char *__shortopts,
- const struct option *__longopts,
- int *__longind
-)
-{
- return -1;
-}
-*/
-
-#endif \ No newline at end of file
diff --git a/lldb/tools/driver/GetOptWrapper.h b/lldb/tools/driver/GetOptWrapper.h
deleted file mode 100644
index 9c9cf03d762..00000000000
--- a/lldb/tools/driver/GetOptWrapper.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//===-- GetOptWrapper.h -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_GetOptWrapper_h_
-#define lldb_GetOptWrapper_h_
-
-// from getopt.h
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-// defined int unistd.h
-extern int optreset;
-
-// from getopt.h
-extern char *optarg;
-extern int optind;
-extern int opterr;
-extern int optopt;
-
-// option structure
-struct option
-{
- const char *name;
- // has_arg can't be an enum because some compilers complain about
- // type mismatches in all the code that assumes it is an int.
- int has_arg;
- int *flag;
- int val;
-};
-
-//
-extern int
-getopt_long_only
-(
- int ___argc,
- char *const *___argv,
- const char *__shortopts,
- const struct option *__longopts,
- int *__longind
-);
-
-#endif // lldb_GetOptWrapper_h_ \ No newline at end of file
diff --git a/lldb/tools/driver/Platform.h b/lldb/tools/driver/Platform.h
index f1fe1e4aac1..faa2991bf6f 100644
--- a/lldb/tools/driver/Platform.h
+++ b/lldb/tools/driver/Platform.h
@@ -18,9 +18,8 @@
#include <io.h>
#include <eh.h>
#include <inttypes.h>
- #include "ELWrapper.h"
#include "lldb/Host/windows/Windows.h"
- #include "GetOptWrapper.h"
+ #include "lldb/Host/HostGetOpt.h"
struct timeval
{
diff --git a/lldb/tools/lldb-platform/lldb-platform.cpp b/lldb/tools/lldb-platform/lldb-platform.cpp
index d58e8042818..e18ebabc784 100644
--- a/lldb/tools/lldb-platform/lldb-platform.cpp
+++ b/lldb/tools/lldb-platform/lldb-platform.cpp
@@ -11,7 +11,7 @@
// C Includes
#include <errno.h>
-#include <getopt.h>
+#include "lldb/Host/HostGetOpt.h"
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
OpenPOWER on IntegriCloud