Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: test/cctest/test-log-stack-tracer.cc

Issue 422593003: Initial GetSample implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed Address from public API. Removed the function to copy TickSample to Sample. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 using v8::Value; 49 using v8::Value;
50 50
51 using v8::internal::byte; 51 using v8::internal::byte;
52 using v8::internal::Address; 52 using v8::internal::Address;
53 using v8::internal::Handle; 53 using v8::internal::Handle;
54 using v8::internal::Isolate; 54 using v8::internal::Isolate;
55 using v8::internal::JSFunction; 55 using v8::internal::JSFunction;
56 using v8::internal::TickSample; 56 using v8::internal::TickSample;
57 57
58 58
59 static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) { 59 static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
Sven Panne 2014/09/02 08:15:02 Use a void* for the 2nd arg and do the static_cast
gholap 2014/09/02 08:56:08 Done.
60 i::Code* code = function->code(); 60 i::Code* code = function->code();
61 return code->contains(addr); 61 return code->contains(addr);
62 } 62 }
63 63
64 64
65 static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context, 65 static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context,
66 const char* func_name, 66 const char* func_name,
67 Address addr) { 67 Address addr) {
68 v8::Local<v8::Value> func = context->Global()->Get(v8_str(func_name)); 68 v8::Local<v8::Value> func = context->Global()->Get(v8_str(func_name));
69 CHECK(func->IsFunction()); 69 CHECK(func->IsFunction());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // TickSample::Trace 169 // TickSample::Trace
170 170
171 CHECK(sample.has_external_callback); 171 CHECK(sample.has_external_callback);
172 CHECK_EQ(FUNCTION_ADDR(i::TraceExtension::Trace), sample.external_callback); 172 CHECK_EQ(FUNCTION_ADDR(i::TraceExtension::Trace), sample.external_callback);
173 173
174 // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace" 174 // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace"
175 unsigned base = 0; 175 unsigned base = 0;
176 CHECK_GT(sample.frames_count, base + 1); 176 CHECK_GT(sample.frames_count, base + 1);
177 177
178 CHECK(IsAddressWithinFuncCode( 178 CHECK(IsAddressWithinFuncCode(
179 context, "JSFuncDoTrace", sample.stack[base + 0])); 179 context, "JSFuncDoTrace",
180 CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 1])); 180 reinterpret_cast<Address>(sample.stack[base + 0])));
181 CHECK(IsAddressWithinFuncCode(
182 context, "JSTrace",
183 reinterpret_cast<Address>(sample.stack[base + 1])));
181 } 184 }
182 185
183 186
184 // This test verifies that stack tracing works when called during 187 // This test verifies that stack tracing works when called during
185 // execution of JS code. However, as calling TickSample::Trace requires 188 // execution of JS code. However, as calling TickSample::Trace requires
186 // entering native code, we can only emulate pure JS by erasing 189 // entering native code, we can only emulate pure JS by erasing
187 // Isolate::c_entry_fp value. In this case, TickSample::Trace uses passed frame 190 // Isolate::c_entry_fp value. In this case, TickSample::Trace uses passed frame
188 // pointer value as a starting point for stack walking. 191 // pointer value as a starting point for stack walking.
189 TEST(PureJSStackTrace) { 192 TEST(PureJSStackTrace) {
190 // This test does not pass with inlining enabled since inlined functions 193 // This test does not pass with inlining enabled since inlined functions
(...skipping 29 matching lines...) Expand all
220 // DoTraceHideCEntryFPAddress(EBP) [native] 223 // DoTraceHideCEntryFPAddress(EBP) [native]
221 // TickSample::Trace 224 // TickSample::Trace
222 // 225 //
223 226
224 CHECK(sample.has_external_callback); 227 CHECK(sample.has_external_callback);
225 CHECK_EQ(FUNCTION_ADDR(i::TraceExtension::JSTrace), sample.external_callback); 228 CHECK_EQ(FUNCTION_ADDR(i::TraceExtension::JSTrace), sample.external_callback);
226 229
227 // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" 230 // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
228 unsigned base = 0; 231 unsigned base = 0;
229 CHECK_GT(sample.frames_count, base + 1); 232 CHECK_GT(sample.frames_count, base + 1);
230 CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 0]));
231 CHECK(IsAddressWithinFuncCode( 233 CHECK(IsAddressWithinFuncCode(
232 context, "OuterJSTrace", sample.stack[base + 1])); 234 context, "JSTrace",
235 reinterpret_cast<Address>(sample.stack[base + 0])));
236 CHECK(IsAddressWithinFuncCode(
237 context, "OuterJSTrace",
238 reinterpret_cast<Address>(sample.stack[base + 1])));
233 } 239 }
234 240
235 241
236 static void CFuncDoTrace(byte dummy_parameter) { 242 static void CFuncDoTrace(byte dummy_parameter) {
237 Address fp; 243 Address fp;
238 #ifdef __GNUC__ 244 #ifdef __GNUC__
239 fp = reinterpret_cast<Address>(__builtin_frame_address(0)); 245 fp = reinterpret_cast<Address>(__builtin_frame_address(0));
240 #elif defined _MSC_VER 246 #elif defined _MSC_VER
241 // Approximate a frame pointer address. We compile without base pointers, 247 // Approximate a frame pointer address. We compile without base pointers,
242 // so we can't trust ebp/rbp. 248 // so we can't trust ebp/rbp.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); 283 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
278 v8::Context::Scope context_scope(context); 284 v8::Context::Scope context_scope(context);
279 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp()); 285 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp());
280 CompileRun("a = 1; b = a + 1;"); 286 CompileRun("a = 1; b = a + 1;");
281 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp()); 287 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp());
282 CompileRun("js_entry_sp();"); 288 CompileRun("js_entry_sp();");
283 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp()); 289 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp());
284 CompileRun("js_entry_sp_level2();"); 290 CompileRun("js_entry_sp_level2();");
285 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp()); 291 CHECK_EQ(0, i::TraceExtension::GetJsEntrySp());
286 } 292 }
OLDNEW
« src/sampler.cc ('K') | « test/cctest/cctest.gyp ('k') | test/cctest/test-sampler-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698