commit 87391981e57467a2b0018c40f5d25cc80fa6f62f
parent 7f33d903e3a5f6fdfbd3d3eb496418ba14627941
Author: Kyle Milz <kyle@0x30.net>
Date: Sun, 31 Jul 2016 10:30:19 -0600
lib: send a protocol major and minor version
Diffstat:
5 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Test/Viewer.pm b/Test/Viewer.pm
@@ -34,9 +34,9 @@ sub accept {
# Protocol defined in lib/runtime.c function send_static().
#
- my $buf = read_all($client, 1 + 4 + 4 + 12);
- ($self->{ver}, $self->{num_tus}, $self->{lines_total}, $self->{pid},
- $self->{ppid}, $self->{pgrp}) = unpack("CL5", $buf);
+ my $buf = read_all($client, 1 + 1 + 4 + 4 + 12);
+ ($self->{major}, $self->{minor}, $self->{num_tus}, $self->{lines_total}, $self->{pid},
+ $self->{ppid}, $self->{pgrp}) = unpack("C2L5", $buf);
my $progname_sz = unpack("S", read_all($client, 2));
$self->{progname} = read_all($client, $progname_sz);
diff --git a/lib/runtime.c b/lib/runtime.c
@@ -142,7 +142,7 @@ xwrite(int d, const void *buf, size_t bytes_total)
/*
* Send static information contained in each instrumented node.
* Sent program wide values:
- * - version
+ * - version major and minor
* - total number of translation units
* - total number of lines in program
* - process id, parent process id, group process id
@@ -159,18 +159,20 @@ 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;
const char *progname;
char *cwd_buf;
- uint16_t sz;
- uint8_t ver = 0;
int i;
+ uint16_t sz;
assert(sizeof(pid_t) == 4);
- xwrite(fd, &ver, sizeof(ver));
+ xwrite(fd, &major, sizeof(major));
+ xwrite(fd, &minor, sizeof(minor));
xwrite(fd, &nodes_total, sizeof(nodes_total));
xwrite(fd, &lines_total, sizeof(lines_total));
diff --git a/src/runtime.cc b/src/runtime.cc
@@ -29,8 +29,9 @@ RuntimeProcess::RuntimeProcess(af_unix &sock) :
// Protocol defined in lib/runtime.c send_static().
// This is the receive side of things.
- m_socket.read_all(m_ver);
- assert(m_ver == 0);
+ m_socket.read_all(m_major);
+ assert(m_major == 0);
+ m_socket.read_all(m_minor);
m_socket.read_all(m_num_tus);
m_socket.read_all(m_lines_total);
m_socket.read_all(m_pid);
diff --git a/src/runtime.hh b/src/runtime.hh
@@ -20,7 +20,8 @@ public:
void read_executions();
// Protocol defined in lib/runtime.c send_static().
- uint8_t m_ver;
+ uint8_t m_major;
+ uint8_t m_minor;
std::string m_progname;
std::string m_cwd;
uint32_t m_num_tus;
diff --git a/t/rt_sanity.t b/t/rt_sanity.t
@@ -1,7 +1,7 @@
use strict;
use Cwd;
-use Test::More tests => 61;
+use Test::More tests => 62;
use Test::Differences;
use Test::Project;
@@ -61,7 +61,8 @@ $project->compile();
$project->run(45);
$viewer->accept();
-is( $viewer->{ver}, 0, "protocol version" );
+is( $viewer->{major}, 0, "protocol major" );
+is( $viewer->{minor}, 0, "protocol minor" );
is( $viewer->{num_tus}, 3, "translation unit count" );
is( $viewer->{progname}, "program", "program name" );
is( $viewer->{cwd}, getcwd, "current working dir" );