diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/klee-replay/CMakeLists.txt | 16 | ||||
-rw-r--r-- | tools/klee-replay/file-creator.c | 26 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.c | 10 | ||||
-rw-r--r-- | tools/klee-replay/klee-replay.h | 1 |
4 files changed, 36 insertions, 17 deletions
diff --git a/tools/klee-replay/CMakeLists.txt b/tools/klee-replay/CMakeLists.txt index e0eb8d07..6388df50 100644 --- a/tools/klee-replay/CMakeLists.txt +++ b/tools/klee-replay/CMakeLists.txt @@ -6,7 +6,7 @@ # License. See LICENSE.TXT for details. # #===------------------------------------------------------------------------===# -if (HAVE_PTY_H) +if (HAVE_PTY_H OR HAVE_UTIL_H) add_executable(klee-replay fd_init.c file-creator.c @@ -15,16 +15,10 @@ if (HAVE_PTY_H) ) target_link_libraries(klee-replay PRIVATE kleeBasic ${LIBCAP_LIBRARIES}) - # FIXME: This isn't quite right. This is actually an implementation detail - # of glibc not Linux. Really we need to test if we can use `openpty()` - # with/without an additional library. - if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - if (NOT LIBUTIL_LIBRARIES) - message(FATAL_ERROR "klee-replay needs libutil under Linux") - endif() + if (openpty_in_libutil) target_link_libraries(klee-replay PRIVATE ${LIBUTIL_LIBRARIES}) - endif() -install(TARGETS klee-replay RUNTIME DESTINATION bin) + endif (openpty_in_libutil) + install(TARGETS klee-replay RUNTIME DESTINATION bin) else() - message(WARNING "Not building klee-replay due to missing \"pty.h\" header file") + message(WARNING "Not building klee-replay due to missing library for pty functions.") endif() diff --git a/tools/klee-replay/file-creator.c b/tools/klee-replay/file-creator.c index 505fb8d7..714a1112 100644 --- a/tools/klee-replay/file-creator.c +++ b/tools/klee-replay/file-creator.c @@ -17,13 +17,23 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include <termios.h> -#include <pty.h> #include <time.h> #include <sys/wait.h> #include <sys/time.h> #include <assert.h> +#ifdef HAVE_PTY_H +#include <pty.h> +#elif defined(HAVE_UTIL_H) +#include <util.h> +#endif + +#if defined(__APPLE__) +#include <sys/termios.h> +#else +#include <termios.h> +#endif + static void create_file(int target_fd, const char *target_name, exe_disk_file_t *dfile, @@ -105,7 +115,9 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile, ts->c_oflag = 5; ts->c_cflag = 1215; ts->c_lflag = 35287; +#ifndef __APPLE__ ts->c_line = 0; +#endif ts->c_cc[0] = '\x03'; ts->c_cc[1] = '\x1c'; ts->c_cc[2] = '\x7f'; @@ -152,16 +164,20 @@ static int create_char_dev(const char *fname, exe_disk_file_t *dfile, fprintf(stderr, "note: pty slave: setting raw mode\n"); { - struct termio mode; + struct termios mode; - int res = ioctl(aslave, TCGETA, &mode); + int res = tcgetattr(aslave, &mode); assert(!res); mode.c_iflag = IGNBRK; +#if defined(__APPLE__) + mode.c_oflag &= ~(ONLCR | OCRNL | ONLRET); +#else mode.c_oflag &= ~(OLCUC | ONLCR | OCRNL | ONLRET); +#endif mode.c_lflag = 0; mode.c_cc[VMIN] = 1; mode.c_cc[VTIME] = 0; - res = ioctl(aslave, TCSETA, &mode); + res = tcsetattr(aslave, TCSANOW, &mode); assert(res == 0); } diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c index 6b4fb8f4..150a82e8 100644 --- a/tools/klee-replay/klee-replay.c +++ b/tools/klee-replay/klee-replay.c @@ -22,9 +22,17 @@ #include <errno.h> #include <time.h> #include <unistd.h> -#include <sys/signal.h> + #include <sys/wait.h> +#if defined(__APPLE__) +#include <signal.h> +#define fgetc_unlocked(x) fgetc (x) +#define fputc_unlocked(x,y) fputc (x,y) +#else +#include <sys/signal.h> +#endif + #ifdef HAVE_SYS_CAPABILITY_H #include <sys/capability.h> #endif diff --git a/tools/klee-replay/klee-replay.h b/tools/klee-replay/klee-replay.h index 668b5e3e..09cb6603 100644 --- a/tools/klee-replay/klee-replay.h +++ b/tools/klee-replay/klee-replay.h @@ -13,6 +13,7 @@ #define _LARGEFILE64_SOURCE #define _FILE_OFFSET_BITS 64 +#include "klee/Config/config.h" // FIXME: This is a hack. #include "../../runtime/POSIX/fd.h" #include <sys/time.h> |