commit 1c244c377d4f3aa18568777ee06d815fee4049f8
parent 7e06d7c506668af81f882ac7d965e59c8cdf1bde
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Sun, 27 Mar 2016 09:20:44 -0600
viewer: rename runtime client to process
Diffstat:
6 files changed, 142 insertions(+), 142 deletions(-)
diff --git a/viewer/Makefile b/viewer/Makefile
@@ -1,7 +1,7 @@
PROG = scv_viewer
SRCS = main.cc \
- runtime_client.cc \
+ runtime_process.cc \
af_unix.cc \
view.cc \
demo-atlas.cc \
diff --git a/viewer/main.cc b/viewer/main.cc
@@ -5,7 +5,7 @@
#include "default-text.h"
#include "af_unix.h"
-#include "runtime_client.h"
+#include "runtime_process.h"
#include "view.h"
#include "demo-buffer.h"
@@ -152,7 +152,7 @@ window::next_frame(View *vu)
{
af_unix *temp_socket = window::socket.accept();
if (temp_socket)
- window::drawables.push_back(new RuntimeClient(temp_socket, buffer, font));
+ window::drawables.push_back(new RuntimeProcess(temp_socket, buffer, font));
for (auto &i : window::drawables)
i->idle();
diff --git a/viewer/runtime_client.cc b/viewer/runtime_client.cc
@@ -1,99 +0,0 @@
-#include <err.h>
-
-#include <cassert>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <vector>
-
-#include "default-text.h"
-#include "runtime_client.h"
-
-RuntimeClient::RuntimeClient(af_unix *sock, demo_buffer_t *buf, demo_font_t *f) :
- socket(sock),
- buffer(buf),
- font(f)
-{
- uint64_t num_tus;
- socket->read_all(num_tus);
- translation_units.resize(num_tus);
-
- assert(sizeof(pid_t) == 4);
- socket->read_all((uint8_t *)&process_id, 4);
- socket->read_all((uint8_t *)&parent_process_id, 4);
- socket->read_all((uint8_t *)&process_group, 4);
-
- std::stringstream ss;
- ss << "Translation Units: " << num_tus << std::endl;
- ss << "Process ID: " << process_id << std::endl;
- ss << "Parent Process ID: " << parent_process_id << std::endl;
- ss << "Process Group: " << process_group << std::endl;
-
- glyphy_point_t top_left = { 0, 0 };
- demo_buffer_move_to(buffer, &top_left);
- demo_buffer_add_text(buffer, ss.str().c_str(), font, 1);
-
- for (auto ¤t_unit : translation_units) {
- top_left.y = 4;
-
- uint64_t file_name_sz;
- socket->read_all(file_name_sz);
-
- current_unit.file_name.resize(file_name_sz);
- socket->read_all((uint8_t *)¤t_unit.file_name[0], file_name_sz);
-
- read_file(current_unit.file_name, top_left);
- top_left.x += 50;
-
- socket->read_all((uint8_t *)¤t_unit.num_lines, 4);
- current_unit.execution_counts.resize(current_unit.num_lines);
-
- socket->read_all((uint8_t *)¤t_unit.inst_sites, 4);
- }
-
- demo_font_print_stats(font);
-}
-
-void
-RuntimeClient::read_file(std::string file_name, glyphy_point_t top_left)
-{
- std::string line;
- std::ifstream file_stream(file_name);
-
- if (file_stream.is_open() == 0)
- errx(1, "ifstream.open()");
-
- while (std::getline(file_stream, line)) {
- size_t tab_pos = 0;
- // Find and replace replace all tabs with spaces
- while ((tab_pos = line.find('\t')) != std::string::npos) {
- int rem = tab_pos % 8;
- line.erase(tab_pos, 1);
- line.insert(tab_pos, std::string(8 - rem, ' '));
- }
-
- demo_buffer_move_to(buffer, &top_left);
- demo_buffer_add_text(buffer, line.c_str(), font, 1);
- ++top_left.y;
- }
-
- file_stream.close();
-}
-
-void
-RuntimeClient::draw()
-{
-}
-
-void
-RuntimeClient::idle()
-{
- for (auto &trans_unit : translation_units) {
- size_t bytes_total = trans_unit.num_lines * sizeof(uint64_t);
- assert(socket->read_all((uint8_t *)&trans_unit.execution_counts[0], bytes_total) == bytes_total);
- }
-
- // Send response back
- uint8_t msg_type = 1;
- assert(socket->write_all(&msg_type, 1) == 1);
-}
diff --git a/viewer/runtime_client.h b/viewer/runtime_client.h
@@ -1,40 +0,0 @@
-#ifndef TEXT_H
-#define TEXT_H
-
-#include <string>
-#include <vector>
-
-#include "af_unix.h"
-#include "draw.h"
-
-#include "demo-buffer.h"
-#include "demo-font.h"
-
-struct TranslationUnit {
- std::string file_name;
- uint32_t num_lines;
- std::vector<uint64_t> execution_counts;
- uint32_t inst_sites;
-};
-
-class RuntimeClient : public drawable {
-public:
- RuntimeClient(af_unix *, demo_buffer_t *, demo_font_t *);
-
- void draw();
- void idle();
-private:
- void read_file(std::string, glyphy_point_t);
-
- pid_t process_id;
- pid_t parent_process_id;
- pid_t process_group;
-
- af_unix *socket;
- demo_buffer_t *buffer;
- demo_font_t *font;
-
- std::vector<TranslationUnit> translation_units;
-};
-
-#endif
diff --git a/viewer/runtime_process.cc b/viewer/runtime_process.cc
@@ -0,0 +1,99 @@
+#include <err.h>
+
+#include <cassert>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <vector>
+
+#include "default-text.h"
+#include "runtime_process.h"
+
+RuntimeProcess::RuntimeProcess(af_unix *sock, demo_buffer_t *buf, demo_font_t *f) :
+ socket(sock),
+ buffer(buf),
+ font(f)
+{
+ uint64_t num_tus;
+ socket->read_all(num_tus);
+ translation_units.resize(num_tus);
+
+ assert(sizeof(pid_t) == 4);
+ socket->read_all((uint8_t *)&process_id, 4);
+ socket->read_all((uint8_t *)&parent_process_id, 4);
+ socket->read_all((uint8_t *)&process_group, 4);
+
+ std::stringstream ss;
+ ss << "Translation Units: " << num_tus << std::endl;
+ ss << "Process ID: " << process_id << std::endl;
+ ss << "Parent Process ID: " << parent_process_id << std::endl;
+ ss << "Process Group: " << process_group << std::endl;
+
+ glyphy_point_t top_left = { 0, 0 };
+ demo_buffer_move_to(buffer, &top_left);
+ demo_buffer_add_text(buffer, ss.str().c_str(), font, 1);
+
+ for (auto ¤t_unit : translation_units) {
+ top_left.y = 4;
+
+ uint64_t file_name_sz;
+ socket->read_all(file_name_sz);
+
+ current_unit.file_name.resize(file_name_sz);
+ socket->read_all((uint8_t *)¤t_unit.file_name[0], file_name_sz);
+
+ read_file(current_unit.file_name, top_left);
+ top_left.x += 50;
+
+ socket->read_all((uint8_t *)¤t_unit.num_lines, 4);
+ current_unit.execution_counts.resize(current_unit.num_lines);
+
+ socket->read_all((uint8_t *)¤t_unit.inst_sites, 4);
+ }
+
+ demo_font_print_stats(font);
+}
+
+void
+RuntimeProcess::read_file(std::string file_name, glyphy_point_t top_left)
+{
+ std::string line;
+ std::ifstream file_stream(file_name);
+
+ if (file_stream.is_open() == 0)
+ errx(1, "ifstream.open()");
+
+ while (std::getline(file_stream, line)) {
+ size_t tab_pos = 0;
+ // Find and replace replace all tabs with spaces
+ while ((tab_pos = line.find('\t')) != std::string::npos) {
+ int rem = tab_pos % 8;
+ line.erase(tab_pos, 1);
+ line.insert(tab_pos, std::string(8 - rem, ' '));
+ }
+
+ demo_buffer_move_to(buffer, &top_left);
+ demo_buffer_add_text(buffer, line.c_str(), font, 1);
+ ++top_left.y;
+ }
+
+ file_stream.close();
+}
+
+void
+RuntimeProcess::draw()
+{
+}
+
+void
+RuntimeProcess::idle()
+{
+ for (auto &trans_unit : translation_units) {
+ size_t bytes_total = trans_unit.num_lines * sizeof(uint64_t);
+ assert(socket->read_all((uint8_t *)&trans_unit.execution_counts[0], bytes_total) == bytes_total);
+ }
+
+ // Send response back
+ uint8_t msg_type = 1;
+ assert(socket->write_all(&msg_type, 1) == 1);
+}
diff --git a/viewer/runtime_process.h b/viewer/runtime_process.h
@@ -0,0 +1,40 @@
+#ifndef TEXT_H
+#define TEXT_H
+
+#include <string>
+#include <vector>
+
+#include "af_unix.h"
+#include "draw.h"
+
+#include "demo-buffer.h"
+#include "demo-font.h"
+
+struct TranslationUnit {
+ std::string file_name;
+ uint32_t num_lines;
+ std::vector<uint64_t> execution_counts;
+ uint32_t inst_sites;
+};
+
+class RuntimeProcess : public drawable {
+public:
+ RuntimeProcess(af_unix *, demo_buffer_t *, demo_font_t *);
+
+ void draw();
+ void idle();
+private:
+ void read_file(std::string, glyphy_point_t);
+
+ pid_t process_id;
+ pid_t parent_process_id;
+ pid_t process_group;
+
+ af_unix *socket;
+ demo_buffer_t *buffer;
+ demo_font_t *font;
+
+ std::vector<TranslationUnit> translation_units;
+};
+
+#endif