citrun

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

commit 1dfc35ab04da3e4ea584697dfaf8fa43e49b0e7b
parent d9031e5d8194fda970b2c7f58ef92b40577480b4
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sun, 13 Mar 2016 19:06:49 -0600

runtime: send back total message size first

Diffstat:
MSCV/Viewer.pm | 7+++++--
Mlib/runtime.c | 22+++++++++++++++++++---
2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/SCV/Viewer.pm b/SCV/Viewer.pm @@ -33,8 +33,11 @@ sub request_data { $client->syswrite("\x00", 1); - # First thing sent back is total number of translation units in the - # instrumentation chain + # First thing sent back is total message size and then the total number + # of translation units. + my $buf = read_all($client, 8); + my $msg_size = unpack("Q", $buf); + my $buf = read_all($client, 8); my $num_tus = unpack("Q", $buf); diff --git a/lib/runtime.c b/lib/runtime.c @@ -54,13 +54,29 @@ void walk_nodes(int fd) { size_t file_name_sz; - uint64_t num_tus; + uint64_t num_tus = 0; + uint64_t msg_size = 0; struct scv_node walk = node0; - /* Find how many translation units there are in this application */ - for (num_tus = 0; walk.size != 0; num_tus++) + /* Find out the total size of data we're going to send */ + while (walk.size != 0) { + /* File name size, 8 bytes */ + msg_size += sizeof(file_name_sz); + /* The file name */ + msg_size += strnlen(walk.file_name, PATH_MAX); + + /* Number of coverage lines */ + msg_size += sizeof(uint64_t); + /* Coverage lines, one 8 byte integer each */ + msg_size += walk.size * sizeof(uint64_t); + + num_tus++; walk = *walk.next; + } + + /* Send total size and total number of translation units */ + xwrite(fd, &msg_size, sizeof(msg_size)); xwrite(fd, &num_tus, sizeof(num_tus)); /* Reset walk back to the start */