citrun

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

commit 72d5d5178bcfac00747ac547d22d677af3806928
parent cdd35f3b6e82ef40e711b11153ac4655bd3f7177
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 29 Jul 2016 20:10:32 -0600

src: update protocol

Diffstat:
Msrc/runtime_conn.cc | 24++++++++++++++++++++----
Msrc/runtime_conn.h | 7+++++--
2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/runtime_conn.cc b/src/runtime_conn.cc @@ -23,18 +23,26 @@ RuntimeProcess::RuntimeProcess(af_unix &sock) : socket(sock) { - uint64_t sz; + uint16_t sz; assert(sizeof(pid_t) == 4); - socket.read_all(sz); - program_name.resize(sz); - socket.read_all((uint8_t *)&program_name[0], sz); + // Protocol defined in lib/runtime.c send_static(). + // This is the receive side of things. + socket.read_all(m_ver); socket.read_all(num_tus); socket.read_all(lines_total); socket.read_all(process_id); socket.read_all(parent_process_id); socket.read_all(process_group); + socket.read_all(sz); + program_name.resize(sz); + socket.read_all((uint8_t *)&program_name[0], sz); + + socket.read_all(sz); + m_cwd.resize(sz); + socket.read_all((uint8_t *)&m_cwd[0], sz); + translation_units.resize(num_tus); for (auto &t : translation_units) { socket.read_all(sz); @@ -66,6 +74,14 @@ void RuntimeProcess::read_executions() { for (auto &t : translation_units) { + uint8_t flag = 0; + socket.read_all(flag); + + if (flag == 0) { + std::fill(t.execution_counts.begin(), t.execution_counts.end(), 0); + continue; + } + size_t bytes_total = t.num_lines * sizeof(uint32_t); socket.read_all((uint8_t *)&t.execution_counts[0], bytes_total); } diff --git a/src/runtime_conn.h b/src/runtime_conn.h @@ -18,9 +18,12 @@ public: RuntimeProcess(af_unix &); void read_executions(); + // Protocol defined in lib/runtime.c send_static(). + uint8_t m_ver; std::string program_name; - uint64_t num_tus; - uint64_t lines_total; + std::string m_cwd; + uint32_t num_tus; + uint32_t lines_total; pid_t process_id; pid_t parent_process_id; pid_t process_group;