Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
stacktrack committed Oct 16, 2016
1 parent 2277ba3 commit a7b532c
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 45 deletions.
74 changes: 54 additions & 20 deletions _site/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var vis = d3.select("#tree").append("svg:svg")

var gdict = [];
var root;
var trace;

// Copy all node info into the 'gdict' lookup table
// We use this table to expand "copied" and "duplicate" nodes
Expand Down Expand Up @@ -74,9 +75,9 @@ function node_to_dict(node) {
}


function init(x,y) {
node_depth = x;
node_height = y;
function init() {
node_height = getParameterByName('y') ? getParameterByName('y') : 20;
node_depth = getParameterByName('x') ? getParameterByName('x') : 100;
// Show the spinner while the tree is drawn
$("#loading").show();
// Tree depth
Expand All @@ -88,16 +89,7 @@ function init(x,y) {
$("input[name='depth']").val(depth + 1)
tree = d3.layout.tree();

if (getParameterByName('trace')){
//trace_f = '/json/' + getParameterByName('trace');
trace_f = getParameterByName('trace');
d3.json(trace_f, function(error, tree) {
if(tree){
trace = tree;
}
});
}


var json_f = getParameterByName('json') ? getParameterByName('json') : 'sys_chdir.json' ;
//json_f = '/json/' + json_f; // todo: error checking
d3.json(json_f, function(error, tree) {
Expand All @@ -124,15 +116,58 @@ function init(x,y) {
toggle_to(root,depth);
goto_node(root);
});

}

function follow_trace(){
function trace_child(child){

}
trace_f = getParameterByName('trace');
if (! trace_f ){
//trace_f = '/json/' + getParameterByName('trace');
return
}

d3.json(trace_f, function(error, tree) {
if(tree){
trace = tree;
console.log(tree);
console.log(root);
}
else {
alert('trace error ' + error);
}
});

console.log(trace);
console.log('tree');
//console.log(root);
var nodes = tree.nodes(root).reverse();
root.children.forEach(trace_child);
var links = vis.selectAll("path.link");
links_l = links.filter(function(l){
return l.target.name == "capable";
});
traced = trace.nodes(root);
traced_paths = [];
console.log(traced);
traced.forEach(function(node){
node.children.forEach(function(c){
//traced_paths =
console.log(c);
});
});
linke.style("stroke", "red");
update(tree);
}

function toggle_to(node,depth){
if (depth <= 0 ){
return;
}
children = node.children ? node.children : node._children;
if ( ! children ){
if ( ! children || children == 'undefined' ){
return;
}
children.forEach(function(c){
Expand Down Expand Up @@ -225,6 +260,7 @@ function node_color(node) {
// Check if a node is in the trace tree
// TODO: optimize
function is_traced(node){
return false;
path = get_path(node);
traced = trace;
if( ! traced || ! traced.children ){
Expand All @@ -251,7 +287,7 @@ function is_traced(node){
// CSS class of traced links
function get_link_class(link){
pclass = "link";
if(is_traced(link.target)){
if(!is_traced(link.target)){
pclass += " trace";
}
return pclass;
Expand Down Expand Up @@ -372,8 +408,8 @@ function update(source) {

// Enter any new links at the parent's previous position.
link.enter().insert("svg:path", "g")
.attr("class", get_link_class)
//.attr("class", "link")
//.attr("class", get_link_class)
.attr("class", "link")
.attr("d", function(d) {
var o = {
x: source.x0,
Expand Down Expand Up @@ -477,9 +513,7 @@ var spinner = new Spinner(opts).spin();
$("#loading").append(spinner.el);
///////// End Spinner

node_height = getParameterByName('y') ? getParameterByName('y') : 20;
node_depth = getParameterByName('x') ? getParameterByName('x') : 100;
init(node_depth,node_height); // Draw the tree
init(); // Draw the tree
//$("#control").draggable();

// Cause enter on the depth to expand
Expand Down
2 changes: 1 addition & 1 deletion _site/json/createjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ do
echo "['$syscall','$line'],"
done

echo '];') > /var/www/html/stacktrack.github.com/js/traces.js
echo '];') > /var/u/stacktrack.github.com/js/traces.js
19 changes: 19 additions & 0 deletions _site/json/sys_umask_callees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"sourcefile": "",
"name": "sys_umask",
"label": "sys_umask",
"children": [
{
"sourcefile": "",
"name": "__fentry__",
"label": "__fentry__",
"children": [],
"type": "original",
"index": 1,
"size": 1
}
],
"type": "original",
"index": 0,
"size": 1
}
3 changes: 2 additions & 1 deletion _site/tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@
</div>
</div>
<div id="inputs">
<input type="number" id="depth" name="depth" value="2" size="2" max="99">
<input type="number" id="depth" name="depth" value="2" size="2" max="99" />
<input type="button" id="expand" value="Expand" onclick="javascript:init()" />
<input type="button" id="trace_btn" value="Trace" onclick="javascript:follow_trace()" />
</div>
</div>

Expand Down
74 changes: 54 additions & 20 deletions js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var vis = d3.select("#tree").append("svg:svg")

var gdict = [];
var root;
var trace;

// Copy all node info into the 'gdict' lookup table
// We use this table to expand "copied" and "duplicate" nodes
Expand Down Expand Up @@ -74,9 +75,9 @@ function node_to_dict(node) {
}


function init(x,y) {
node_depth = x;
node_height = y;
function init() {
node_height = getParameterByName('y') ? getParameterByName('y') : 20;
node_depth = getParameterByName('x') ? getParameterByName('x') : 100;
// Show the spinner while the tree is drawn
$("#loading").show();
// Tree depth
Expand All @@ -88,16 +89,7 @@ function init(x,y) {
$("input[name='depth']").val(depth + 1)
tree = d3.layout.tree();

if (getParameterByName('trace')){
//trace_f = '/json/' + getParameterByName('trace');
trace_f = getParameterByName('trace');
d3.json(trace_f, function(error, tree) {
if(tree){
trace = tree;
}
});
}


var json_f = getParameterByName('json') ? getParameterByName('json') : 'sys_chdir.json' ;
//json_f = '/json/' + json_f; // todo: error checking
d3.json(json_f, function(error, tree) {
Expand All @@ -124,15 +116,58 @@ function init(x,y) {
toggle_to(root,depth);
goto_node(root);
});

}

function follow_trace(){
function trace_child(child){

}
trace_f = getParameterByName('trace');
if (! trace_f ){
//trace_f = '/json/' + getParameterByName('trace');
return
}

d3.json(trace_f, function(error, tree) {
if(tree){
trace = tree;
console.log(tree);
console.log(root);
}
else {
alert('trace error ' + error);
}
});

console.log(trace);
console.log('tree');
//console.log(root);
var nodes = tree.nodes(root).reverse();
root.children.forEach(trace_child);
var links = vis.selectAll("path.link");
links_l = links.filter(function(l){
return l.target.name == "capable";
});
traced = trace.nodes(root);
traced_paths = [];
console.log(traced);
traced.forEach(function(node){
node.children.forEach(function(c){
//traced_paths =
console.log(c);
});
});
linke.style("stroke", "red");
update(tree);
}

function toggle_to(node,depth){
if (depth <= 0 ){
return;
}
children = node.children ? node.children : node._children;
if ( ! children ){
if ( ! children || children == 'undefined' ){
return;
}
children.forEach(function(c){
Expand Down Expand Up @@ -225,6 +260,7 @@ function node_color(node) {
// Check if a node is in the trace tree
// TODO: optimize
function is_traced(node){
return false;
path = get_path(node);
traced = trace;
if( ! traced || ! traced.children ){
Expand All @@ -251,7 +287,7 @@ function is_traced(node){
// CSS class of traced links
function get_link_class(link){
pclass = "link";
if(is_traced(link.target)){
if(!is_traced(link.target)){
pclass += " trace";
}
return pclass;
Expand Down Expand Up @@ -372,8 +408,8 @@ function update(source) {

// Enter any new links at the parent's previous position.
link.enter().insert("svg:path", "g")
.attr("class", get_link_class)
//.attr("class", "link")
//.attr("class", get_link_class)
.attr("class", "link")
.attr("d", function(d) {
var o = {
x: source.x0,
Expand Down Expand Up @@ -477,9 +513,7 @@ var spinner = new Spinner(opts).spin();
$("#loading").append(spinner.el);
///////// End Spinner

node_height = getParameterByName('y') ? getParameterByName('y') : 20;
node_depth = getParameterByName('x') ? getParameterByName('x') : 100;
init(node_depth,node_height); // Draw the tree
init(); // Draw the tree
//$("#control").draggable();

// Cause enter on the depth to expand
Expand Down
4 changes: 2 additions & 2 deletions src/Graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#
DBHOST = 'localhost'
DBUSER = 'root'
DBPASS = 'fucksec'
DBPASS = 'kcofpass'
DB = 'stacktrack'


Expand All @@ -63,7 +63,7 @@ def add_node(self,node):
- (json) dict
There can only be one node with the same name. If the name
already exists in _instances, the corresponding node value
already exists in Graph.nodes , the corresponding node value
is returned
'''
callees = set()
Expand Down
3 changes: 2 additions & 1 deletion tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@
</div>
</div>
<div id="inputs">
<input type="number" id="depth" name="depth" value="2" size="2" max="99">
<input type="number" id="depth" name="depth" value="2" size="2" max="99" />
<input type="button" id="expand" value="Expand" onclick="javascript:init()" />
<input type="button" id="trace_btn" value="Trace" onclick="javascript:follow_trace()" />
</div>
</div>

Expand Down

0 comments on commit a7b532c

Please sign in to comment.