Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

can post and get result from server

  • Loading branch information...
commit 2a1c23ae9b922b8e3a990017a105bd4fcbcdb2fe 1 parent 64b9605
@zdwalter authored
View
1  .gitignore
@@ -3,3 +3,4 @@ lib-cov
test.log
src/*.js
deps/v8
+bin/d8
View
BIN  bin/d8
Binary file not shown
View
9 deps/Makefile
@@ -0,0 +1,9 @@
+.PHONY: all
+
+all: d8
+
+d8:
+ tar zxf v8.tgz
+ cd v8 && scons d8 && cp d8 ../../bin/
+
+
View
22 public/javascripts/debug.js
@@ -1,4 +1,7 @@
-
+function _f() {
+//INSERT_CODE
+ process.exit(0);
+}
Debug = debug.Debug
var steps = 0;
@@ -18,9 +21,16 @@ function listener(event, exec_state, event_data, data) {
}
steps++;
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
- _print(JSON.stringify(exec_state.frame().func()));
- _print(JSON.stringify(exec_state.frame().sourceLine()));
- _print(output);
+ var frame = exec_state.frame();
+ step = {
+ event: "step_line",
+ func_name: "",//frame.func(),
+ globals: {},
+ line: frame.sourceLine(),
+ stack_locals: [],
+ stdout: output,
+ }
+ _print(JSON.stringify(step));
}
};
@@ -28,9 +38,9 @@ function listener(event, exec_state, event_data, data) {
Debug.setListener(listener);
// Set a breakpoint on the for statement (line 1).
-Debug.setBreakPoint(f, 1);
+Debug.setBreakPoint(_f, 1);
-f();
+_f();
// Get rid of the debug event listener.
Debug.setListener(null);
View
24 src/app.coffee
@@ -1,6 +1,8 @@
fs = require 'fs'
express = require 'express'
zlib = require 'zlib'
+crypto = require 'crypto'
+exec = require('child_process').exec
formaline = require 'formaline'
winston = require 'winston'
@@ -89,16 +91,34 @@ routes.config = (req, res) ->
send: app.config.send
return app.apiResponse res, config
-debug_template = fs.readFileSync(__dirname+'/../public/javascripts/debug.js')
+debug_template = fs.readFileSync(__dirname+'/../public/javascripts/debug.js').toString()
+debug_cmd = "#{__dirname}/../bin/d8 --expose-debug-as debug "
routes.debugger = (req, res) ->
+ user_script = null
for field in req.json.fields
app.logger.debug(JSON.stringify(field))
if field.name isnt 'user_script'
continue
user_script = field.value[0]
+ if user_script
app.logger.debug(user_script)
- return res.end()
+ md5sum = crypto.createHash('md5')
+ md5sum.update(user_script)
+ md5 = md5sum.digest('hex')
+
+ debug_script = debug_template.replace('//INSERT_CODE',user_script)
+ debug_file = "/tmp/debug.#{md5}.js"
+ fs.writeFile debug_file, debug_script, (err) ->
+ app.logger.error(err) if err
+ return res.end() if err
+ cmd = debug_cmd+debug_file
+ exec cmd, (err, stdout, stderr) ->
+ app.logger.debug(stdout)
+ app.logger.error(err) if err
+ #return res.end() if err
+ output = '['+stdout.split('\n')+']'
+ return res.end(output)
# Routes
#cross_domain = (req, res, next) ->
Please sign in to comment.
Something went wrong with that request. Please try again.