OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/debug/trace_event_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 const char* name, | 578 const char* name, |
579 unsigned long long id, | 579 unsigned long long id, |
580 int num_args, | 580 int num_args, |
581 const char** arg_names, | 581 const char** arg_names, |
582 const unsigned char* arg_types, | 582 const unsigned char* arg_types, |
583 const unsigned long long* arg_values, | 583 const unsigned long long* arg_values, |
584 int threshold_begin_id, | 584 int threshold_begin_id, |
585 long long threshold, | 585 long long threshold, |
586 unsigned char flags) { | 586 unsigned char flags) { |
587 DCHECK(name); | 587 DCHECK(name); |
588 TimeTicks now = TimeTicks::HighResNow(); | 588 TimeTicks now = TimeTicks::NowFromSystemTraceTime(); |
589 BufferFullCallback buffer_full_callback_copy; | 589 BufferFullCallback buffer_full_callback_copy; |
590 int ret_begin_id = -1; | 590 int ret_begin_id = -1; |
591 { | 591 { |
592 AutoLock lock(lock_); | 592 AutoLock lock(lock_); |
593 if (!*category_enabled) | 593 if (!*category_enabled) |
594 return -1; | 594 return -1; |
595 if (logged_events_.size() >= kTraceEventBufferSize) | 595 if (logged_events_.size() >= kTraceEventBufferSize) |
596 return -1; | 596 return -1; |
597 | 597 |
598 int thread_id = static_cast<int>(PlatformThread::CurrentId()); | 598 int thread_id = static_cast<int>(PlatformThread::CurrentId()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 "The kernel's tracing clock must be set to global in order for " << | 703 "The kernel's tracing clock must be set to global in order for " << |
704 "trace_event to be synchronized with . Do this by\n" << | 704 "trace_event to be synchronized with . Do this by\n" << |
705 " echo global > /sys/kerel/debug/tracing/trace_clock"; | 705 " echo global > /sys/kerel/debug/tracing/trace_clock"; |
706 return; | 706 return; |
707 } | 707 } |
708 | 708 |
709 // Android's kernel trace system has a trace_marker feature: this is a file on | 709 // Android's kernel trace system has a trace_marker feature: this is a file on |
710 // debugfs that takes the written data and pushes it onto the trace | 710 // debugfs that takes the written data and pushes it onto the trace |
711 // buffer. So, to establish clock sync, we write our monotonic clock into that | 711 // buffer. So, to establish clock sync, we write our monotonic clock into that |
712 // trace buffer. | 712 // trace buffer. |
713 TimeTicks now = TimeTicks::HighResNow(); | 713 TimeTicks now = TimeTicks::NowFromSystemTraceTime(); |
714 | 714 |
715 double now_in_seconds = now.ToInternalValue() / 1000000.0; | 715 double now_in_seconds = now.ToInternalValue() / 1000000.0; |
716 std::string marker = | 716 std::string marker = |
717 StringPrintf("trace_event_clock_sync: parent_ts=%f\n", | 717 StringPrintf("trace_event_clock_sync: parent_ts=%f\n", |
718 now_in_seconds); | 718 now_in_seconds); |
719 if (file_util::WriteFile( | 719 if (file_util::WriteFile( |
720 FilePath("/sys/kernel/debug/tracing/trace_marker"), | 720 FilePath("/sys/kernel/debug/tracing/trace_marker"), |
721 marker.c_str(), marker.size()) == -1) { | 721 marker.c_str(), marker.size()) == -1) { |
722 DLOG(WARNING) << "Couldn't write to /sys/kernel/debug/tracing/trace_marker"; | 722 DLOG(WARNING) << "Couldn't write to /sys/kernel/debug/tracing/trace_marker"; |
723 return; | 723 return; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // Create a FNV hash from the process ID for XORing. | 760 // Create a FNV hash from the process ID for XORing. |
761 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. | 761 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. |
762 unsigned long long offset_basis = 14695981039346656037ull; | 762 unsigned long long offset_basis = 14695981039346656037ull; |
763 unsigned long long fnv_prime = 1099511628211ull; | 763 unsigned long long fnv_prime = 1099511628211ull; |
764 unsigned long long pid = static_cast<unsigned long long>(process_id_); | 764 unsigned long long pid = static_cast<unsigned long long>(process_id_); |
765 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; | 765 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; |
766 } | 766 } |
767 | 767 |
768 } // namespace debug | 768 } // namespace debug |
769 } // namespace base | 769 } // namespace base |
OLD | NEW |