citrun

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

commit 8d25675b44b4f637608e1599c81877f339b50750
parent a79836d8e2dd2f76fd30eef2a3b03d6f1d926268
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri,  5 Aug 2016 17:08:39 -0600

lib: add citrun_{major,minor} runtime.h vars

Diffstat:
Mlib/runtime.c | 8+++-----
Mlib/runtime.h | 4+++-
Msrc/Jamfile | 3++-
Msrc/inst_action.cc | 2+-
Msrc/inst_main.cc | 13++++++++-----
5 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/runtime.c b/lib/runtime.c @@ -40,7 +40,7 @@ static void *relay_thread(void *); * Public interface: Insert a node into the sorted translation unit list. */ void -citrun_node_add(struct citrun_node *n) +citrun_node_add(uint8_t node_major, uint8_t node_minor, struct citrun_node *n) { struct citrun_node *walk = nodes_head; @@ -154,8 +154,6 @@ xwrite(int d, const void *buf, size_t bytes_total) static void send_static(int fd) { - uint8_t major = 0; - uint8_t minor = 0; struct citrun_node node; pid_t pids[3]; struct citrun_node *w; @@ -166,8 +164,8 @@ send_static(int fd) assert(sizeof(pid_t) == 4); - xwrite(fd, &major, sizeof(major)); - xwrite(fd, &minor, sizeof(minor)); + xwrite(fd, &citrun_major, sizeof(citrun_major)); + xwrite(fd, &citrun_minor, sizeof(citrun_minor)); xwrite(fd, &nodes_total, sizeof(nodes_total)); xwrite(fd, &lines_total, sizeof(lines_total)); diff --git a/lib/runtime.h b/lib/runtime.h @@ -1,4 +1,6 @@ #include <stdint.h> +static uint8_t citrun_major = 0; +static uint8_t citrun_minor = 0; struct citrun_node { uint64_t *lines_ptr; uint32_t size; @@ -8,5 +10,5 @@ struct citrun_node { uint64_t *old_lines; uint32_t *diffs; }; -void citrun_node_add(struct citrun_node *); +void citrun_node_add(uint8_t, uint8_t, struct citrun_node *); void citrun_start(); diff --git a/src/Jamfile b/src/Jamfile @@ -60,7 +60,8 @@ INST_SRCS = Stringize runtime_h.h : $(TOP)/lib/runtime.h ; ObjectC++Flags $(INST_SRCS) : `llvm-config --cxxflags` ; -ObjectC++Flags $(INST_SRCS) : -DCITRUN_LIB=$(CITRUN_LIB) +ObjectC++Flags $(INST_SRCS) : -I$(TOP) + -DCITRUN_LIB=$(CITRUN_LIB) -DCITRUN_PATH=$(CITRUN_PATH) -DCITRUN_COVERAGE=$(CITRUN_COVERAGE) ; diff --git a/src/inst_action.cc b/src/inst_action.cc @@ -63,7 +63,7 @@ InstrumentAction::EndSourceFileAction() ss << "};" << std::endl; ss << "__attribute__((constructor))" << std::endl << "static void citrun_constructor() {" << std::endl - << " citrun_node_add(&_citrun_node);" << std::endl + << " citrun_node_add(citrun_major, citrun_minor, &_citrun_node);" << std::endl << "}" << std::endl; ss << "#ifdef __cplusplus" << std::endl << "}" << std::endl diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -27,11 +27,13 @@ #include <err.h> #include <fstream> // ifstream, ofstream #include <libgen.h> // basename -#include <sstream> +#include <iostream> +#include <sstream> // stringstream #include <string> #include <unistd.h> // execvp, fork, getpid, unlink -#include "inst_action.h" +#include "lib/runtime.h" // citrun_major, citrun_minor +#include "inst_action.h" // InstrumentAction #define STR_EXPAND(tok) #tok #define STR(tok) STR_EXPAND(tok) @@ -77,9 +79,10 @@ CitrunInst::CitrunInst(int argc, char *argv[]) : if (uname(&utsname) == -1) err(1, "uname"); - m_log << "\n"; - m_log << m_pfx << "citrun-inst v0.0 (" << utsname.sysname - << "-" << utsname.release << " " << utsname.machine + m_log << "\n" << m_pfx << "citrun-inst v" + << unsigned(citrun_major) << "." << unsigned(citrun_minor) + << " (" << utsname.sysname << "-" << utsname.release + << " " << utsname.machine << ") called as '" << m_args[0] << "'.\n"; char *base_name;