JavaScriptでコールスタックを取得

arguments.callee.callerが使える環境でのみ動作

コード

function getCallStack()
{
	var caller = arguments.callee, 
		ret = [];
	while( (caller = caller.caller) )
		ret.unshift(caller);
	return ret;
}

テストBookmarklet

javascript:function f(a,b){a=[],b=arguments.callee;while(b=b.caller)a.unshift(b);return a}function a(){alert(f())}function b(){a()}b()