citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit f8560d575acc7691701daebf6331f823756551c8
parent e67f77a464a6d1df7402dd322aefb0dc55272f0c
Author: Kyle Milz <kyle@0x30.net>
Date:   Tue,  6 Dec 2016 18:04:54 -0700

src: flatten some codepaths

Diffstat:
Msrc/inst_frontend.cc | 27++++++++++++---------------
Mt/inst_log.sh | 4++--
Mt/inst_preprocess.sh | 4++--
3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/inst_frontend.cc b/src/inst_frontend.cc @@ -32,6 +32,7 @@ #include <sstream> // ostringstream #include <unistd.h> // execvp, fork, getpid, unlink + static llvm::cl::OptionCategory ToolingCategory("citrun-inst options"); InstrumentFrontend::InstrumentFrontend(int argc, char *argv[]) : @@ -53,29 +54,25 @@ InstrumentFrontend::InstrumentFrontend(int argc, char *argv[]) : m_log.set_citruninst(); } - m_log << "citrun-inst " << citrun_major << "." << citrun_minor << " "; + m_log << ">> citrun-inst v" << citrun_major << "." << citrun_minor; if (uname(&utsname) == -1) - m_log << "(Unknown OS)" << std::endl; - else { - m_log << "(" << utsname.sysname << "-" << utsname.release << " " - << utsname.machine << ")" << std::endl; - } - // This is important debugging information. - m_log << "CITRUN_SHARE = '" << CITRUN_SHARE << "'" << std::endl; + m_log << " Unknown OS" << std::endl; + else + m_log << " (" << utsname.sysname << "-" << utsname.release + << " " << utsname.machine << ")" << std::endl; - // If we're citrun-inst there's no more setup that's needed. - if (m_is_citruninst) { - m_log << ">> Welcome to C It Run! Have a nice day." << std::endl; - return; - } + m_log << "CITRUN_SHARE = '" << CITRUN_SHARE << "'" << std::endl; - // Sometimes this doesn't make a difference. + // Always re-search PATH for binary name (in non-citrun-inst case). m_log << "Switching argv[0] '" << m_args[0] << "' -> '" << base_name << "'" << std::endl; m_args[0] = base_name; + // Sometimes we're not called as citrun-inst so force that here. setprogname("citrun-inst"); - clean_PATH(); + + if (m_is_citruninst == false) + clean_PATH(); } // diff --git a/t/inst_log.sh b/t/inst_log.sh @@ -40,7 +40,7 @@ ok "is link ok" citrun-wrap cc -o main main.o strip_log citrun.log cat <<EOF > citrun.log.good -citrun-inst 0.0 () +>> citrun-inst v0.0 () CITRUN_SHARE = '' Switching argv[0] '' PATH='' @@ -60,7 +60,7 @@ Rewriting successful. Forked compiler '' Rewritten source compile successful Restored '' -citrun-inst 0.0 () +>> citrun-inst v0.0 () CITRUN_SHARE = '' Switching argv[0] '' PATH='' diff --git a/t/inst_preprocess.sh b/t/inst_preprocess.sh @@ -15,12 +15,12 @@ ok "wrapping compile w/ preprocessor arg -E" citrun-wrap cc -E prepro.c ok "wrapping compile w/ preprocessor arg -MM" citrun-wrap cc -E prepro.c cat <<EOF > citrun.log.good -citrun-inst 0.0 () +>> citrun-inst v0.0 () CITRUN_SHARE = '' Switching argv[0] '' PATH='' Preprocessor argument found -citrun-inst 0.0 () +>> citrun-inst v0.0 () CITRUN_SHARE = '' Switching argv[0] '' PATH=''