Skip to content

Instantly share code, notes, and snippets.

@mindon
Created March 13, 2014 08:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindon/9524222 to your computer and use it in GitHub Desktop.
Save mindon/9524222 to your computer and use it in GitHub Desktop.
A Simple JavaScript trace function for QML (BlackBerry 10)
// trace callstack
// by Mindon from http://mindon.github.io
function trace() {
var callstacks = [];
var fn = arguments.callee.caller;
while (fn) {
var fnstr = fn.toString();
fnstr = fnstr.substring(fnstr.indexOf("function") + 8, fnstr.indexOf('{')).replace(/^\s+|\s+$/g, '');
var fname = fnstr == '()' ? '(anonymous function)': fnstr;
callstacks.push(fname);
fn = fn.caller;
}
console.debug("[CALLSTACK]: " + callstacks.reverse().join(' -> '));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment