citrun

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

commit 15bafcc4c0566b13f2259f549d47684c38eccc22
parent 3deec9842bec7dd31b798d51b1ec6d750b0d046a
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Wed, 16 Mar 2016 18:03:04 -0600

lib: make runtime send first

Diffstat:
MSCV/Viewer.pm | 8++++----
Mlib/runtime.c | 16+++++++---------
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/SCV/Viewer.pm b/SCV/Viewer.pm @@ -31,8 +31,6 @@ sub get_metadata { my ($self) = @_; my $client = $self->{client_socket}; - $client->syswrite("\x00", 1); - # First thing sent is total number of translation units my $buf = read_all($client, 8); my $num_tus = unpack("Q", $buf); @@ -59,8 +57,6 @@ sub get_execution_data { my $client = $self->{client_socket}; my @tus = @{ $self->{tus} }; - $client->syswrite("\x01", 1); - my @data; for (@tus) { my $num_lines = $_->{lines}; @@ -70,6 +66,10 @@ sub get_execution_data { push @data, [@data_tmp]; } + + # Send an 'ok' response + $client->syswrite("\x01", 1); + return \@data; } diff --git a/lib/runtime.c b/lib/runtime.c @@ -19,6 +19,7 @@ control_thread(void *arg) { int fd; int i; + uint8_t response; fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) @@ -33,16 +34,13 @@ control_thread(void *arg) err(1, "connect"); } + /* Send metadata first */ + send_metadata(fd); + + /* Then synchronously send execution data */ while (1) { - uint8_t msg_type; - xread(fd, &msg_type, 1); - - if (msg_type == 0) - send_metadata(fd); - else if (msg_type == 1) - send_execution_data(fd); - else - errx(1, "unknown message type %i", msg_type); + send_execution_data(fd); + xread(fd, &response, 1); } }