Skip to content

Commit 4fb9c63

Browse files
authored
linux-specific code for printing the command line args from the opt pass when an unsound transformation is detected (#818)
1 parent 5c32879 commit 4fb9c63

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tv/tv.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ static void showStats() {
108108
IR::Memory::printAliasStats(*out);
109109
}
110110

111+
static void emitCommandLine(ostream *out) {
112+
#ifdef __linux__
113+
ifstream cmd_args;
114+
cmd_args.open("/proc/self/cmdline");
115+
if (!cmd_args.is_open()) {
116+
cerr << "Alive2: Couldn't open /proc/self/cmdline" << endl;
117+
exit(1);
118+
}
119+
*out << "Command line: ";
120+
std::string arg;
121+
while (std::getline(cmd_args, arg, '\0'))
122+
*out << "'" << arg << "' ";
123+
#else
124+
*out << "Command line: not available on this platform";
125+
#endif
126+
*out << "\n\n";
127+
}
111128

112129
struct TVLegacyPass final : public llvm::ModulePass {
113130
static char ID;
@@ -267,6 +284,8 @@ struct TVLegacyPass final : public llvm::ModulePass {
267284
has_failure |= errs.isUnsound();
268285
if (opt_error_fatal && has_failure)
269286
finalize();
287+
if (errs.isUnsound())
288+
emitCommandLine(out);
270289
} else {
271290
*out << "Transformation seems to be correct!\n\n";
272291
}

0 commit comments

Comments
 (0)