citrun

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

commit 27e660a7767dbd6adcbfbc24f975ddbf40a80397
parent 1bc2b2ca20329ad452afa15563cedf0af2e17e0b
Author: Kyle Milz <kyle@0x30.net>
Date:   Tue,  9 Aug 2016 18:08:34 -0600

use CITRUN_SHARE instead of CITRUN_{PATH,LIB}

Diffstat:
MJamrules | 23++++++++++-------------
Msrc/Jamfile | 7++-----
Msrc/inst_main.cc | 13+++++++------
Msrc/wrap.in | 2+-
Mt/inst_for.t | 1+
Mt/inst_if.t | 1+
Mt/inst_log.t | 2++
Mt/inst_return.t | 1+
Mt/inst_switch.t | 1+
Mt/inst_two_src_one_cmd.t | 1+
Mt/inst_while.t | 1+
11 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/Jamrules b/Jamrules @@ -1,14 +1,16 @@ +# +# Knowing the absolute path to citrun resources is necessary for +# instrumentation. If PREFIX is set, assume we're building a package. +# if $(PREFIX) { - # PREFIX was set, use absolute install paths. - CITRUN_LIB = $(PREFIX)/lib/libcitrun.a ; - CITRUN_PATH = $(PREFIX)/share/citrun ; + BUILD_MODE = "RELEASE" ; + CITRUN_SHARE = $(PREFIX)/share/citrun ; } else { - # No PREFIX means an in tree build. Use absolute paths to local copies. - ROOT = "`readlink -f $(TOP)`" ; - CITRUN_LIB = $(ROOT)/src/libcitrun.a ; - CITRUN_PATH = $(ROOT)/src ; + BUILD_MODE = "DEBUG" ; + CITRUN_SHARE = "`readlink -f $(TOP)/src`" ; } +echo ...build citrun ($(BUILD_MODE)) on $(OS)... ; # Try and respect this, {pkg,llvm}-config gives -O? too unfortunately OPTIM = $(CFLAGS) ; @@ -101,7 +103,7 @@ rule MkWrap actions MkWrap { - sed -e s,%CITRUN_PATH%,$(CITRUN_PATH), < $(2) > $(1) ; + sed -e s,%CITRUN_SHARE%,$(CITRUN_SHARE), < $(2) > $(1) ; chmod 755 $(1) ; } @@ -118,8 +120,3 @@ actions InstLink { $(RM) $(<) && $(LN) -s citrun-inst $(<) ; } - -echo ...build citrun ($(OS))... ; -echo " C++= $(C++)" ; -echo " CITRUN_LIB= $(CITRUN_LIB)" ; -echo " CITRUN_PATH= $(CITRUN_PATH)" ; diff --git a/src/Jamfile b/src/Jamfile @@ -5,7 +5,7 @@ SubDir TOP src ; # ObjectCcFlags runtime.c : -fPIC -pthread -ansi ; Library libcitrun : runtime.c ; -InstallLib $(PREFIX)/lib : libcitrun.a ; +InstallLib $(PREFIX)/share/citrun : libcitrun.a ; # # citrun-wrap, citrun-check @@ -15,9 +15,7 @@ MakeLocate citrun-check : $(LOCATE_SOURCE) ; Shell citrun-check : check.in ; InstallShell $(PREFIX)/bin : citrun-wrap citrun-check ; -# # utils.a -# Library utils : af_unix.cc runtime_proc.cc ; # @@ -67,8 +65,7 @@ INST_SRCS = Stringize runtime_h.h : runtime.h ; ObjectC++Flags $(INST_SRCS) : `llvm-config --cxxflags` ; -ObjectC++Flags $(INST_SRCS) : -DCITRUN_LIB=$(CITRUN_LIB) - -DCITRUN_PATH=$(CITRUN_PATH) +ObjectC++Flags $(INST_SRCS) : -DCITRUN_SHARE=$(CITRUN_SHARE) -DCITRUN_COVERAGE=$(CITRUN_COVERAGE) ; LINKFLAGS on citrun-inst = `llvm-config --ldflags` ; diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -74,6 +74,7 @@ CitrunInst::CitrunInst(int argc, char *argv[]) : << " (" << utsname.sysname << "-" << utsname.release << " " << utsname.machine << ") called as '" << m_args[0] << "'.\n"; + m_log << m_pfx << "Resource directory is '" << STR(CITRUN_SHARE) << "'\n"; char *base_name; if ((base_name = basename(m_args[0])) == NULL) @@ -106,7 +107,7 @@ CitrunInst::clean_PATH() m_log << m_pfx << "PATH='" << path << "'\n"; - // Filter CITRUN_PATH out of PATH + // Filter CITRUN_SHARE out of PATH std::stringstream path_ss(path); std::ostringstream new_path; std::string component; @@ -114,7 +115,7 @@ CitrunInst::clean_PATH() bool found_citrun_path = 0; while (std::getline(path_ss, component, ':')) { - if (component.compare(STR(CITRUN_PATH)) == 0) { + if (component.compare(STR(CITRUN_SHARE)) == 0) { found_citrun_path = 1; continue; } @@ -122,14 +123,14 @@ CitrunInst::clean_PATH() if (first_component == 0) new_path << ":"; - // It wasn't CITRUN_PATH, keep it + // It wasn't CITRUN_SHARE, keep it new_path << component; first_component = 0; } if (!found_citrun_path) { - m_log << m_pfx << "'" << STR(CITRUN_PATH) << "' not in PATH.\n"; - errx(1, "'%s' not in PATH", STR(CITRUN_PATH)); + m_log << m_pfx << "'" << STR(CITRUN_SHARE) << "' not in PATH.\n"; + errx(1, "'%s' not in PATH", STR(CITRUN_SHARE)); } // Set new $PATH @@ -249,7 +250,7 @@ CitrunInst::process_cmdline() // Needed because libcitrun.a will be instrumented with gcov. m_args.push_back(const_cast<char *>("-coverage")); #endif - m_args.push_back(const_cast<char *>(STR(CITRUN_LIB))); + m_args.push_back(const_cast<char *>(STR(CITRUN_SHARE) "/libcitrun.a")); m_log << m_args.back() << "' to command line.\n"; } diff --git a/src/wrap.in b/src/wrap.in @@ -5,5 +5,5 @@ if [[ ${1} = -* ]]; then exit 1 fi -export PATH="%CITRUN_PATH%:$PATH" +export PATH="%CITRUN_SHARE%:$PATH" exec $@ diff --git a/t/inst_for.t b/t/inst_for.t @@ -33,6 +33,7 @@ EOF cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' Command line is ''. Found source file ''. Object arg = 0, compile arg = 1 diff --git a/t/inst_if.t b/t/inst_if.t @@ -47,6 +47,7 @@ EOF cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' Command line is ''. Found source file ''. Object arg = 0, compile arg = 1 diff --git a/t/inst_log.t b/t/inst_log.t @@ -45,6 +45,7 @@ sed -e "s,^.*: ,," \ cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' PATH='' Command line is ''. Found source file ''. @@ -67,6 +68,7 @@ Forked ''. Restored ''. citrun-inst v0.0 () called as ''. +Resource directory is '' PATH='' Command line is ''. Object arg = 1, compile arg = 0 diff --git a/t/inst_return.t b/t/inst_return.t @@ -35,6 +35,7 @@ EOF cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' Command line is ''. Found source file ''. Object arg = 0, compile arg = 1 diff --git a/t/inst_switch.t b/t/inst_switch.t @@ -41,6 +41,7 @@ EOF cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' Command line is ''. Found source file ''. Object arg = 0, compile arg = 1 diff --git a/t/inst_two_src_one_cmd.t b/t/inst_two_src_one_cmd.t @@ -33,6 +33,7 @@ echo "ok 4 - processed citrun.log" cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' PATH='' Command line is ''. Found source file ''. diff --git a/t/inst_while.t b/t/inst_while.t @@ -31,6 +31,7 @@ EOF cat <<EOF > citrun.log.good citrun-inst v0.0 () called as ''. +Resource directory is '' Command line is ''. Found source file ''. Object arg = 0, compile arg = 1