citrun

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

commit cdd35f3b6e82ef40e711b11153ac4655bd3f7177
parent 40de032983a728090c7612a3cf68b5b04a999420
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 29 Jul 2016 19:43:54 -0600

lib: add flag indicating no executions took place

Diffstat:
MTest/Viewer.pm | 16++++++++++++++--
Mlib/runtime.c | 15++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/Test/Viewer.pm b/Test/Viewer.pm @@ -85,9 +85,21 @@ sub get_dynamic_data { my %data; for my $tu (@{ $self->{tus} }) { + # Check if there's any update. + my $buf = read_all($client, 1); + my $has_data = unpack("C", $buf); + my $num_lines = $tu->[1]; - my $buf = read_all($client, 4 * $num_lines); - my @data_tmp = unpack("L$num_lines", $buf); + + my @data_tmp; + if ($has_data == 0) { + # print STDERR "no data for tu $_\n"; + @data_tmp = (0) x $num_lines; + } + else { + $buf = read_all($client, 4 * $num_lines); + @data_tmp = unpack("L$num_lines", $buf); + } $data{$tu->[0]} = \@data_tmp; } diff --git a/lib/runtime.c b/lib/runtime.c @@ -180,6 +180,7 @@ send_static(int fd) sz = strnlen(cwd_buf, PATH_MAX); xwrite(fd, &sz, sizeof(sz)); xwrite(fd, cwd_buf, sz); + free(cwd_buf); for (w = nodes_head, i = 0; w != NULL; w = w->next, i++) { node = *w; @@ -204,14 +205,18 @@ send_dynamic(int fd) uint64_t *lines_ptr; uint64_t *old_lines_ptr; uint64_t diff64; + uint32_t *tmp_space; uint32_t diff; int i; int line; + uint8_t flag; /* Write execution buffers. */ for (w = nodes_head, i = 0; w != NULL; w = w->next, i++) { lines_ptr = w->lines_ptr; old_lines_ptr = w->old_lines; + tmp_space = malloc(w->size * sizeof(diff)); + flag = 0; for (line = 0; line < w->size; line++) { assert(lines_ptr[line] >= old_lines_ptr[line]); @@ -221,11 +226,19 @@ send_dynamic(int fd) diff = UINT32_MAX; else diff = diff64; - xwrite(fd, &diff, sizeof(uint32_t)); + + tmp_space[line] = diff; + if (diff > 0) + flag = 1; /* Let's try incremental updating of old_lines. */ old_lines_ptr[line] += diff64; } + + xwrite(fd, &flag, sizeof(flag)); + if (flag == 1) + xwrite(fd, tmp_space, w->size * sizeof(diff)); + free(tmp_space); } assert(i == nodes_total); assert(w == NULL);