Fixing the Windows build for the changes brought in from the iohandler merge.

llvm-svn: 200565
This commit is contained in:
Deepak Panickal 2014-01-31 18:48:46 +00:00
parent 322ce39e39
commit 914b8d989b
18 changed files with 240 additions and 292 deletions

View File

@ -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()
#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")

View File

@ -15,7 +15,7 @@
#include <stdio.h>
#ifdef _WIN32
#include "ELWrapper.h"
#include "lldb/Host/windows/editlinewin.h"
#else
#include <histedit.h>
#endif

View File

@ -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

View File

@ -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
);

View File

@ -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, ... );

View File

@ -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
}

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -6,4 +6,6 @@ add_lldb_library(lldbHostWindows
Mutex.cpp
Condition.cpp
Windows.cpp
EditLineWin.cpp
GetOptInc.cpp
)

View File

@ -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

View File

@ -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>
@ -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++) {
@ -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,7 +220,8 @@ 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);
}
@ -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;
@ -548,5 +467,3 @@ getopt_long_only(int nargc, char * const *nargv, const char *options,
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE | FLAG_LONGONLY));
}
#endif

View File

@ -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();
}

View File

@ -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)

View File

@ -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

View File

@ -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_

View File

@ -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
{

View File

@ -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>