| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #ifdef __linux__ | 7 #ifdef __linux__ |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #endif | 10 #endif |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 static void SigProfSignalHandler(int signal, siginfo_t* info, void* context) { | 159 static void SigProfSignalHandler(int signal, siginfo_t* info, void* context) { |
| 160 if (signal != SIGPROF) return; | 160 if (signal != SIGPROF) return; |
| 161 was_sigprof_received = true; | 161 was_sigprof_received = true; |
| 162 old_sigprof_handler.sa_sigaction(signal, info, context); | 162 old_sigprof_handler.sa_sigaction(signal, info, context); |
| 163 } | 163 } |
| 164 | 164 |
| 165 #endif // __linux__ | 165 #endif // __linux__ |
| 166 | 166 |
| 167 | 167 |
| 168 static int CheckThatProfilerWorks(int log_pos) { | 168 static int CheckThatProfilerWorks(int log_pos) { |
| 169 Logger::ResumeProfiler(); | 169 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU); |
| 170 CHECK(LoggerTestHelper::IsSamplerActive()); | 170 CHECK(LoggerTestHelper::IsSamplerActive()); |
| 171 | 171 |
| 172 // Verify that the current map of compiled functions has been logged. | 172 // Verify that the current map of compiled functions has been logged. |
| 173 EmbeddedVector<char, 102400> buffer; | 173 EmbeddedVector<char, 102400> buffer; |
| 174 int map_log_size = GetLogLines(log_pos, &buffer); | 174 int map_log_size = GetLogLines(log_pos, &buffer); |
| 175 printf("map_log_size: %d\n", map_log_size); | 175 printf("map_log_size: %d\n", map_log_size); |
| 176 CHECK_GT(map_log_size, 0); | 176 CHECK_GT(map_log_size, 0); |
| 177 CHECK_GT(buffer.length(), map_log_size); | 177 CHECK_GT(buffer.length(), map_log_size); |
| 178 log_pos += map_log_size; | 178 log_pos += map_log_size; |
| 179 // Check buffer contents. | 179 // Check buffer contents. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 200 "(function(x) { return %d * x; })(i); }", | 200 "(function(x) { return %d * x; })(i); }", |
| 201 log_pos); | 201 log_pos); |
| 202 // Run code for 200 msecs to get some ticks. | 202 // Run code for 200 msecs to get some ticks. |
| 203 const double end_time = i::OS::TimeCurrentMillis() + 200; | 203 const double end_time = i::OS::TimeCurrentMillis() + 200; |
| 204 while (i::OS::TimeCurrentMillis() < end_time) { | 204 while (i::OS::TimeCurrentMillis() < end_time) { |
| 205 CompileAndRunScript(script_src.start()); | 205 CompileAndRunScript(script_src.start()); |
| 206 // Yield CPU to give Profiler thread a chance to process ticks. | 206 // Yield CPU to give Profiler thread a chance to process ticks. |
| 207 i::OS::Sleep(1); | 207 i::OS::Sleep(1); |
| 208 } | 208 } |
| 209 | 209 |
| 210 Logger::PauseProfiler(); | 210 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU); |
| 211 CHECK(!LoggerTestHelper::IsSamplerActive()); | 211 CHECK(!LoggerTestHelper::IsSamplerActive()); |
| 212 | 212 |
| 213 // Wait 50 msecs to allow Profiler thread to process the last | 213 // Wait 50 msecs to allow Profiler thread to process the last |
| 214 // tick sample it has got. | 214 // tick sample it has got. |
| 215 i::OS::Sleep(50); | 215 i::OS::Sleep(50); |
| 216 | 216 |
| 217 // Now we must have compiler and tick records. | 217 // Now we must have compiler and tick records. |
| 218 int log_size = GetLogLines(log_pos, &buffer); | 218 int log_size = GetLogLines(log_pos, &buffer); |
| 219 printf("log_size: %d\n", log_size); | 219 printf("log_size: %d\n", log_size); |
| 220 CHECK_GT(log_size, 0); | 220 CHECK_GT(log_size, 0); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // Make sure that all log data is written prior crash due to CHECK failure. | 739 // Make sure that all log data is written prior crash due to CHECK failure. |
| 740 fflush(stdout); | 740 fflush(stdout); |
| 741 CHECK(results_equal); | 741 CHECK(results_equal); |
| 742 | 742 |
| 743 env->Exit(); | 743 env->Exit(); |
| 744 Logger::TearDown(); | 744 Logger::TearDown(); |
| 745 i::FLAG_always_compact = saved_always_compact; | 745 i::FLAG_always_compact = saved_always_compact; |
| 746 } | 746 } |
| 747 | 747 |
| 748 #endif // ENABLE_LOGGING_AND_PROFILING | 748 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |