Comment #2 on issue 307 by [email protected]: Print stack trace to a string
instead of on a FILE.
http://code.google.com/p/v8/issues/detail?id=307
(Although I work for Google, I am not a v8 or chrome developer and do not
speak for
them)
A workaround for this is to use v8::Debug::Call() and look through the
exe_state
object. There is an array of frames and each frame has a reference to a
function
object through the func() property you can look at. Here's a C++ string
constant
with a script used to grab a stacktrace as a formatted string:
"function frameBackTrace_(exec_state, fromFrame, toFrame) {"
" var result = undefined;"
" try {"
" var total_frames = exec_state.frameCount();"
" if (total_frames === 0) return result;"
" var from_index = fromFrame ? fromFrame : 0;"
" var to_index = toFrame ? toFrame : 10;"
" to_index = Math.min(total_frames, to_index);"
" var frames = [];"
" for (var i = from_index; i < to_index; i++) {"
" var frame = exec_state.frame(i);"
" var sourceLineNumber = frame.sourceLine();"
" var sourceColumnNumber = frame.sourceColumn();"
" var func = frame.func();"
" var name = func ? func.name() : '';"
" var inferredName = func ? func.inferredName() : '';"
" var script = func.resolved() ? func.script() : undefined;"
" var sourceName = script ? script.name() : '(unresolved)';"
" var comma = ',';"
" frames.push(String(i) + comma + sourceName + comma +
String(sourceLineNumber)"
" + comma + String(sourceColumnNumber) + comma + name + comma +
inferredName);"
" }"
" if (frames.length > 0)"
" result = frames.join(';');"
" } catch (ex) {"
" result = String(ex);"
" }"
" return result;"
"}"
"function frameBackTrace(exec_state) {"
" return frameBackTrace_(exec_state, 0, 10);"
"}"));
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev