commit 6c9fea47615a529ae1587630a0d1acdc53e6f6de
parent b5238d50749bfcb6dd733dfbcbbee01ec3106a36
Author: Kyle Milz <kyle@0x30.net>
Date: Wed, 20 Jul 2016 21:18:04 -0600
src: get citrun-gl compiling again
Diffstat:
2 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/src/Jamfile b/src/Jamfile
@@ -42,7 +42,7 @@ ObjectC++Flags $(GL_SRCS) : -std=c++11 ;
ObjectC++Flags $(GL_SRCS) : `pkg-config $(PKG_CONFIG_LIBS) --cflags` ;
LINKLIBS on citrun-gl += `pkg-config $(PKG_CONFIG_LIBS) --libs` ;
-LinkLibraries citrun-gl : libglyphy ;
+LinkLibraries citrun-gl : libglyphy utils ;
Main citrun-gl : $(GL_SRCS) ;
InstallBin $(PREFIX)/bin : citrun-gl ;
diff --git a/src/gl_main.cc b/src/gl_main.cc
@@ -1,12 +1,14 @@
+#include <cmath>
#include <err.h>
#include <iostream>
+#include <sstream>
#include <vector>
#include "af_unix.h"
#include "demo-font.h"
#include "gl_buffer.h"
-#include "gl_runtime_conn.h"
#include "gl_view.h"
+#include "runtime_conn.h"
#if defined(__OpenBSD__)
#define FONT_PATH "/usr/X11R6/lib/X11/fonts/TTF/DejaVuSansMono.ttf"
@@ -33,7 +35,7 @@ public:
static View *static_vu;
static af_unix socket;
- static std::vector<drawable*> drawables;
+ static std::vector<RuntimeProcess*> drawables;
private:
static void display();
static void reshape_func(int, int);
@@ -45,7 +47,7 @@ private:
demo_glstate_t *st;
};
-std::vector<drawable*> window::drawables;
+std::vector<RuntimeProcess*> window::drawables;
af_unix window::socket;
View *window::static_vu;
@@ -151,16 +153,70 @@ current_time(void)
void
window::next_frame(View *vu)
{
+ // First update everything that's already known.
+ for (auto &rp : window::drawables) {
+
+ rp->read_executions();
+
+ glyphy_point_t tmp;
+ for (auto &t : rp->translation_units) {
+ size_t bytes_total = t.num_lines * sizeof(uint64_t);
+
+ for (int i = 0; i < t.num_lines; i++) {
+ if (t.execution_counts[i] == 0)
+ continue;
+
+ // demo_buffer_add_text(buffer, ">>", font, 1);
+ }
+ }
+ std::cout << "tick" << std::endl;
+ }
+
+ // Now check if there's any new connections pending.
af_unix *temp_socket = window::socket.accept();
if (temp_socket) {
temp_socket->set_block();
demo_buffer_clear(buffer);
- window::drawables.push_back(new RuntimeProcess(temp_socket, buffer, font));
+ RuntimeProcess *conn = new RuntimeProcess(*temp_socket);
+ window::drawables.push_back(conn);
+
+ std::stringstream ss;
+ ss << "program name:\t" << conn->program_name << std::endl;
+ ss << "code lines:\t" << conn->lines_total << std::endl;
+ ss << "trnsltn units:\t" << conn->num_tus << std::endl;
+ ss << "process id:\t" << conn->process_id << std::endl;
+ ss << "parent pid:\t" << conn->parent_process_id << std::endl;
+ ss << "process group:\t" << conn->process_group << std::endl;
+
+ glyphy_point_t cur_pos = { 0, 0 };
+ demo_buffer_move_to(buffer, &cur_pos);
+
+ demo_buffer_add_text(buffer, ss.str().c_str(), font, 2);
+
+ demo_buffer_current_point(buffer, &cur_pos);
+ double y_margin = cur_pos.y;
+
+ /*
+ * T: total lines, known
+ * W: number of 80 char columns
+ * H: number of rows
+ *
+ * (1 ) W * 80 * H = T
+ * (2 ) W * 80 = H
+ * (2a) W = H / 80
+ * (1a) (H / 80) * 80 * H = T
+ * (1b) H^2 = T
+ * (1c) H = sqrt(T)
+ */
+ // int rows_per_col = std::sqrt(lines_total) * 4;
+
+ cur_pos.x = 0;
+ glyphy_point_t tmp;
+ for (auto &t : conn->translation_units) {
+ demo_buffer_add_text(buffer, t.file_name.c_str(), font, 1);
+ }
}
- for (auto &i : window::drawables)
- i->idle();
-
glutPostRedisplay ();
}