[gtk+] [broadway] Add stacktrace debugging functions
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] [broadway] Add stacktrace debugging functions
- Date: Tue, 12 Apr 2011 09:14:03 +0000 (UTC)
commit 840df5c7c174150d243a1073aa00c5c5d1008c1a
Author: Alexander Larsson <alexl redhat com>
Date: Tue Apr 12 10:13:38 2011 +0200
[broadway] Add stacktrace debugging functions
gdk/broadway/broadway.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 1386cb0..150f46c 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -11,6 +11,62 @@ function log(str) {
logDiv.appendChild(document.createElement('br'));
}
+function getStackTrace()
+{
+ var callstack = [];
+ var isCallstackPopulated = false;
+ try {
+ i.dont.exist+=0;
+ } catch(e) {
+ if (e.stack) { // Firefox
+ var lines = e.stack.split("\n");
+ for (var i=0, len=lines.length; i<len; i++) {
+ if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
+ callstack.push(lines[i]);
+ }
+ }
+ // Remove call to getStackTrace()
+ callstack.shift();
+ isCallstackPopulated = true;
+ } else if (window.opera && e.message) { // Opera
+ var lines = e.message.split("\n");
+ for (var i=0, len=lines.length; i<len; i++) {
+ if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
+ var entry = lines[i];
+ // Append next line also since it has the file info
+ if (lines[i+1]) {
+ entry += " at " + lines[i+1];
+ i++;
+ }
+ callstack.push(entry);
+ }
+ }
+ // Remove call to getStackTrace()
+ callstack.shift();
+ isCallstackPopulated = true;
+ }
+ }
+ if (!isCallstackPopulated) { //IE and Safari
+ var currentFunction = arguments.callee.caller;
+ while (currentFunction) {
+ var fn = currentFunction.toString();
+ var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous";
+ callstack.push(fname);
+ currentFunction = currentFunction.caller;
+ }
+ }
+ return callstack;
+}
+
+function logStackTrace(len) {
+ var callstack = getStackTrace();
+ var end = callstack.length;
+ if (len > 0)
+ end = Math.min(len + 1, end);
+ for (var i = 1; i < end; i++)
+ log(callstack[i]);
+}
+
var base64Values = [
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]