Permalink
Browse files

Fiber, feat: not trace internal function in stack.

  • Loading branch information...
xicilion committed Oct 16, 2017
1 parent dd0c061 commit dc1089eefe5db9dc767988ac9d43830cd9703c25
Showing with 46 additions and 39 deletions.
  1. +39 −37 fibjs/src/base/v8_api.cpp
  2. +7 −2 fibjs/src/coroutine/Fiber.cpp
View
@@ -61,46 +61,48 @@ exlib::string traceInfo(v8::Isolate* isolate, int32_t deep, void* entry_fp, void
frame->Summarize(&frames);
const v8::internal::FrameSummary::JavaScriptFrameSummary& summ = frames[0].AsJavaScript();
v8::String::Utf8Value funcname(v8::Utils::ToLocal(summ.FunctionName()));
strBuffer.append(bFirst ? " at " : "\n at ");
bFirst = false;
if (**funcname) {
strBuffer.append(*funcname);
strBuffer.append(" (", 2);
}
v8::internal::Handle<v8::internal::Script> script = v8::internal::Handle<v8::internal::Script>::cast(summ.script());
int32_t line_number = 0;
int32_t column_number = 0;
v8::internal::Script::PositionInfo info;
bool valid_pos = v8::internal::Script::GetPositionInfo(script, summ.SourcePosition(),
&info, v8::internal::Script::WITH_OFFSET);
if (valid_pos) {
line_number = info.line + 1;
column_number = info.column + 1;
}
v8::internal::Handle<v8::internal::Object> name(script->name(), v8_isolate);
v8::String::Utf8Value filename(v8::Utils::ToLocal(name));
char numStr[32];
if (*filename) {
strBuffer.append(*filename);
if (script->type() == v8::internal::Script::TYPE_NORMAL) {
strBuffer.append(bFirst ? " at " : "\n at ");
bFirst = false;
v8::String::Utf8Value funcname(v8::Utils::ToLocal(summ.FunctionName()));
if (**funcname) {
strBuffer.append(*funcname);
strBuffer.append(" (", 2);
}
int32_t line_number = 0;
int32_t column_number = 0;
v8::internal::Script::PositionInfo info;
bool valid_pos = v8::internal::Script::GetPositionInfo(script, summ.SourcePosition(),
&info, v8::internal::Script::WITH_OFFSET);
if (valid_pos) {
line_number = info.line + 1;
column_number = info.column + 1;
}
v8::internal::Handle<v8::internal::Object> name(script->name(), v8_isolate);
v8::String::Utf8Value filename(v8::Utils::ToLocal(name));
char numStr[32];
if (*filename) {
strBuffer.append(*filename);
strBuffer.append(1, ':');
} else
strBuffer.append("[eval]:", 7);
sprintf(numStr, "%d", line_number);
strBuffer.append(numStr);
strBuffer.append(1, ':');
} else
strBuffer.append("[eval]:", 7);
sprintf(numStr, "%d", column_number);
strBuffer.append(numStr);
sprintf(numStr, "%d", line_number);
strBuffer.append(numStr);
strBuffer.append(1, ':');
sprintf(numStr, "%d", column_number);
strBuffer.append(numStr);
if (**funcname)
strBuffer.append(1, ')');
if (**funcname)
strBuffer.append(1, ')');
}
}
return strBuffer;
}
@@ -161,8 +161,13 @@ result_t JSFiber::get_stack(exlib::string& retVal)
else {
exlib::string str(" at ");
str += m_native_name;
str += " (native code)\n";
str += traceInfo(holder()->m_isolate, 300, m_c_entry_fp_, m_handler_);
str += " (native code)";
exlib::string str1 = traceInfo(holder()->m_isolate, 300, m_c_entry_fp_, m_handler_);
if (!str1.empty()) {
str += '\n';
str += str1;
}
retVal = str;
}

0 comments on commit dc1089e

Please sign in to comment.