{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/596","repository_url":"https://api.github.com/repos/svaarala/duktape","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/596/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/596/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/596/events","html_url":"https://github.com/svaarala/duktape/pull/596","id":134389784,"number":596,"title":"Implement out-of-band debugger commands","user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars.githubusercontent.com/u/4097841?v=3","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-02-17T20:22:38Z","updated_at":"2016-02-17T22:07:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/svaarala/duktape/pulls/596","html_url":"https://github.com/svaarala/duktape/pull/596","diff_url":"https://github.com/svaarala/duktape/pull/596.diff","patch_url":"https://github.com/svaarala/duktape/pull/596.patch"},"body":"This adds a new debug command marker, OOB. When Duktape receives a message beginning with an OOB dvalue (0x05), it pushes all the dvalues in the message to the valstack and calls `heap->dbg_oob_cb`.  The callback can push it own values to the stack, and these are sent back to the client as a REP.\r\n\r\nIt is also possible for the target to send out-of-band notifys to the client by calling duk_debugger_send_oob().\r\n\r\nThis currently represents a breaking API change because it adds an additional callback argument to duk_debugger_attach().  If possible, it would be better to implement this in a way that didn't break the existing API guarantees.\r\n\r\nThis branch is just a prototype right now for the purpose of having something concrete to discuss.  It needs documentation, and the new code is not yet documented in comments.  However, initial testing indicates the functionality itself is working as designed."},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/185429074","html_url":"https://github.com/svaarala/duktape/pull/596#issuecomment-185429074","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/596","id":185429074,"user":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T22:07:10Z","updated_at":"2016-02-17T22:07:10Z","body":"Regarding calling the user callback, I'd probably model it as a Duktape/C function and call it using `duk_safe_call()`. One hitch there might be that variable number of return values probably won't work at the moment.\r\n\r\nThe debugger command handling is not inside a safe call which is actually a bit dangerous: if an error happens it will propagate out of the debugger and skip updating debugger state flags (like `dbg_processing`). This is definitely something to fix in the future. But that's unrelated to this case though, since the OOB callback would not be trusted, it'd be necessary to locally catch any errors and handle them cleanly (communicating the error back to the debug client)."}}