citrun

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

commit 8dc1cc2a5c83fbe6c7e997bf720341375cf53f33
parent 1c568e4ea891001d0fded0e945e6f0bc31f755aa
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 19 Aug 2016 15:59:20 -0600

src: dont put version in runtime header

Diffstat:
Msrc/inst_action.cc | 6++++--
Msrc/inst_main.cc | 2+-
Msrc/runtime.c | 3+--
Msrc/runtime.h | 2--
Msrc/runtime_proc.cc | 2+-
Mt/inst_preamble.t | 5+----
Mtest/utils.sh | 2+-
7 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/inst_action.cc b/src/inst_action.cc @@ -15,6 +15,7 @@ // #include "inst_action.h" #include "runtime_h.h" +#include "version.h" // citrun_major, citrun_minor #include <clang/Frontend/CompilerInstance.h> #include <err.h> @@ -78,7 +79,7 @@ InstrumentAction::EndSourceFileAction() preamble << "#ifdef __cplusplus\n" << "extern \"C\" {\n" << "#endif\n"; - preamble << runtime_h << "\n"; + preamble << runtime_h; preamble << "static struct citrun_node _citrun = {\n" << " " << num_lines << ",\n" << " \"" << m_compiler_file_name << "\",\n" @@ -86,7 +87,8 @@ InstrumentAction::EndSourceFileAction() preamble << "};\n"; preamble << "__attribute__((constructor))\n" << "static void citrun_constructor() {\n" - << " citrun_node_add(citrun_major, citrun_minor, &_citrun);\n" + << " citrun_node_add(" << unsigned(citrun_major) << ", " + << unsigned(citrun_minor) << ", &_citrun);\n" << "}\n"; preamble << "#ifdef __cplusplus\n" << "}\n" diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -13,8 +13,8 @@ // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#include "runtime.h" // citrun_major, citrun_minor #include "inst_frontend.h" // InstrumentFrontend +#include "version.h" // citrun_major, citrun_minor #include <sys/utsname.h> // uname diff --git a/src/runtime.c b/src/runtime.c @@ -20,12 +20,11 @@ #include <err.h> #include <fcntl.h> /* O_CREAT */ #include <limits.h> /* PATH_MAX */ -#include <stdlib.h> /* getenv */ -#include <stdio.h> #include <string.h> /* strnlen */ #include <unistd.h> /* get{cwd,pid,ppid,pgrp} */ #include "runtime.h" +#include "version.h" #define SHM_PATH "/tmp/citrun.shared" diff --git a/src/runtime.h b/src/runtime.h @@ -1,6 +1,4 @@ #include <stdint.h> -static const uint8_t citrun_major = 0; -static const uint8_t citrun_minor = 0; struct citrun_node { uint32_t size; const char *comp_file_path; diff --git a/src/runtime_proc.cc b/src/runtime_proc.cc @@ -17,7 +17,7 @@ #include <err.h> #include <fstream> -#include "runtime.h" // citrun_major +#include "version.h" // citrun_major #include "runtime_proc.h" RuntimeProcess::RuntimeProcess(shm &s) : diff --git a/t/inst_preamble.t b/t/inst_preamble.t @@ -14,8 +14,6 @@ cat <<EOF > preamble.c.good extern "" { #endif #include <stdint.h> -static const uint8_t citrun_major = 0; -static const uint8_t citrun_minor = 0; struct citrun_node { uint32_t size; const char *comp_file_path; @@ -23,7 +21,6 @@ struct citrun_node { uint64_t *data; }; void citrun_node_add(uint8_t, uint8_t, struct citrun_node *); - static struct citrun_node _citrun = { 1, "", @@ -31,7 +28,7 @@ static struct citrun_node _citrun = { }; __attribute__((constructor)) static void citrun_constructor() { - citrun_node_add(citrun_major, citrun_minor, &_citrun); + citrun_node_add(0, 0, &_citrun); } #ifdef __cplusplus } diff --git a/test/utils.sh b/test/utils.sh @@ -22,7 +22,7 @@ function inst_diff test_num="${2}" test_desc="instrumented source diff" - tail -n +27 $file.citrun > $file.inst_proc + tail -n +24 $file.citrun > $file.inst_proc test_diff $test_num "$test_desc" $file.inst_good $file.inst_proc }