diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp index a323089b966..d3a27f1215a 100644 --- a/shell/mongo_vstudio.cpp +++ b/shell/mongo_vstudio.cpp @@ -21,11 +21,20 @@ const StringData _jscode_raw_utils = "return false;\n" "}\n" "\n" +"printStackTrace = function(){\n" +"try{\n" +"throw new Error(\"Printing Stack Trace (lines are 0-based in spidermonkey)\");\n" +"} catch (e) {\n" +"print(e.stack);\n" +"}\n" +"}\n" +"\n" "doassert = function (msg) {\n" "if (msg.indexOf(\"assert\") == 0)\n" "print(msg);\n" "else\n" "print(\"assert: \" + msg);\n" +"printStackTrace();\n" "throw msg;\n" "}\n" "\n" diff --git a/shell/utils.js b/shell/utils.js index 7eab1069f1d..6e19befff10 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -16,11 +16,20 @@ friendlyEqual = function( a , b ){ return false; } +printStackTrace = function(){ + try{ + throw new Error("Printing Stack Trace (lines are 0-based in spidermonkey)"); + } catch (e) { + print(e.stack); + } +} + doassert = function (msg) { if (msg.indexOf("assert") == 0) print(msg); else print("assert: " + msg); + printStackTrace(); throw msg; }