| Index: test/cctest/test-log-stack-tracer.cc
|
| ===================================================================
|
| --- test/cctest/test-log-stack-tracer.cc (revision 7006)
|
| +++ test/cctest/test-log-stack-tracer.cc (working copy)
|
| @@ -33,6 +33,7 @@
|
|
|
| #include "v8.h"
|
|
|
| +#include "api.h"
|
| #include "codegen.h"
|
| #include "log.h"
|
| #include "isolate.h"
|
| @@ -201,19 +202,19 @@
|
| }
|
|
|
|
|
| -static void CheckJSFunctionAtAddress(const char* func_name, Address addr) {
|
| - CHECK(HEAP->Contains(addr));
|
| - i::Object* obj = i::HeapObject::FromAddress(addr);
|
| - CHECK(obj->IsJSFunction());
|
| - CHECK(JSFunction::cast(obj)->shared()->name()->IsString());
|
| - i::SmartPointer<char> found_name =
|
| - i::String::cast(
|
| - JSFunction::cast(
|
| - obj)->shared()->name())->ToCString();
|
| - CHECK_EQ(func_name, *found_name);
|
| +static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
|
| + i::Code* code = function->code();
|
| + return code->contains(addr);
|
| }
|
|
|
| +static bool IsAddressWithinFuncCode(const char* func_name, Address addr) {
|
| + v8::Local<v8::Value> func = env->Global()->Get(v8_str(func_name));
|
| + CHECK(func->IsFunction());
|
| + JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func));
|
| + return IsAddressWithinFuncCode(js_func, addr);
|
| +}
|
|
|
| +
|
| // This C++ function is called as a constructor, to grab the frame pointer
|
| // from the calling function. When this function runs, the stack contains
|
| // a C_Entry frame and a Construct frame above the calling function's frame.
|
| @@ -310,8 +311,8 @@
|
|
|
| // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace"
|
| CHECK_GT(sample.frames_count, base + 1);
|
| - CheckJSFunctionAtAddress("JSFuncDoTrace", sample.stack[base + 0]);
|
| - CheckJSFunctionAtAddress("JSTrace", sample.stack[base + 1]);
|
| + CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0]));
|
| + CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1]));
|
| }
|
|
|
|
|
| @@ -352,9 +353,6 @@
|
| // DoTraceHideCEntryFPAddress(EBP) [native]
|
| // StackTracer::Trace
|
| //
|
| - // The last JS function called. It is only visible through
|
| - // sample.function, as its return address is above captured EBP value.
|
| - CheckJSFunctionAtAddress("JSFuncDoTrace", sample.function);
|
|
|
| // The VM state tracking keeps track of external callbacks and puts
|
| // them at the top of the sample stack.
|
| @@ -364,8 +362,8 @@
|
|
|
| // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
|
| CHECK_GT(sample.frames_count, base + 1);
|
| - CheckJSFunctionAtAddress("JSTrace", sample.stack[base + 0]);
|
| - CheckJSFunctionAtAddress("OuterJSTrace", sample.stack[base + 1]);
|
| + CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0]));
|
| + CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1]));
|
| }
|
|
|
|
|
|
|