diff options
author | Matt Morehouse <mascasa@google.com> | 2017-12-04 19:25:59 +0000 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2017-12-04 19:25:59 +0000 |
commit | 04304d129bbc6a63a7ff2051003e40ec9edbcb0f (patch) | |
tree | bee68f141877af7be7491074065b260c0292739d /compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp | |
parent | adf37517304a3a661a033c785cb6b502539db486 (diff) | |
download | bcm5719-llvm-04304d129bbc6a63a7ff2051003e40ec9edbcb0f.tar.gz bcm5719-llvm-04304d129bbc6a63a7ff2051003e40ec9edbcb0f.zip |
[libFuzzer] Encapsulate commands in a class.
Summary:
To be more portable (especially w.r.t. platforms without system()),
commands should be managed programmatically rather than via string
manipulation on the command line. This change introduces
Fuzzer::Command, with methods to manage arguments and flags, set output
options, and execute the command.
Patch By: aarongreen
Reviewers: kcc, morehouse
Reviewed By: kcc, morehouse
Subscribers: llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D40103
llvm-svn: 319680
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp')
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp index 2df4872a920..4bfbc11a50c 100644 --- a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// #include "FuzzerDefs.h" #if LIBFUZZER_APPLE - +#include "FuzzerCommand.h" #include "FuzzerIO.h" #include <mutex> #include <signal.h> @@ -38,7 +38,8 @@ static sigset_t OldBlockedSignalsSet; // signal handlers when the first thread enters and restores them when the last // thread finishes execution of the function and ensures this is not racey by // using a mutex. -int ExecuteCommand(const std::string &Command) { +int ExecuteCommand(const Command &Cmd) { + std::string CmdLine = Cmd.toString(); posix_spawnattr_t SpawnAttributes; if (posix_spawnattr_init(&SpawnAttributes)) return -1; @@ -98,7 +99,7 @@ int ExecuteCommand(const std::string &Command) { pid_t Pid; char **Environ = environ; // Read from global - const char *CommandCStr = Command.c_str(); + const char *CommandCStr = CmdLine.c_str(); char *const Argv[] = { strdup("sh"), strdup("-c"), |