Reland "[tracing] Cleanup up trace_log"
This is a reland of commit 235af46635
Reason for revert:
LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5650878292819968
Fix: initialize TraceEventHandle to 0 to avoid
MemorySanitizer: use-of-uninitialized-value error
Original change's description:
> [tracing] Cleanup up trace_log
>
> This CL cleans up some of the unused functionalities in trace_log
> - legacy metadata
> - member AddTraceEvent* function: replaced by static ones
> - SetTrackDescriptor: covered by TrackNameRecorder
> We no longer update SetTrackDescriptor on UpdateProcessLabel;
> this is unnecessary because TrackNameRecorder calls
> SetTrackDescriptor when the session ends.
>
> Bug: 343404899
> Change-Id: Ia3c4524cd3b3dd4d4ad12a0348e60480b5d03f67
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6120057
> Reviewed-by: Derek Schuff <dschuff@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Alexander Timin <altimin@chromium.org>
> Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
> Reviewed-by: Mikhail Khokhlov <khokhlov@google.com>
> Cr-Commit-Position: refs/heads/main@{#1403710}
Bug: 343404899
Change-Id: Icb14722297b39f3b8fc7be0985452182a7b5846f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6163823
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1404225}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c9bfcab17e
commit
4898bbcd46
base
content
app
android
browser
common
gpu
ppapi_plugin
renderer
shell
headless/lib
ppapi/shared_impl
services/tracing/public/cpp/perfetto
@ -190,9 +190,6 @@ void CurrentProcess::SetProcessNameAndType(const std::string& process_name,
|
||||
process_type_.store(static_cast<CurrentProcessType>(process_type),
|
||||
std::memory_order_relaxed);
|
||||
}
|
||||
#if BUILDFLAG(ENABLE_BASE_TRACING)
|
||||
trace_event::TraceLog::GetInstance()->OnSetProcessName(process_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
@ -42,12 +42,7 @@ typedef base::RepeatingCallback<bool(const std::string& metadata_name)>
|
||||
MetadataFilterPredicate;
|
||||
|
||||
struct TraceEventHandle {
|
||||
uint32_t chunk_seq;
|
||||
// These numbers of bits must be kept consistent with
|
||||
// TraceBufferChunk::kMaxTrunkIndex and
|
||||
// TraceBufferChunk::kTraceBufferChunkSize (in trace_buffer.h).
|
||||
unsigned chunk_index : 26;
|
||||
unsigned event_index : 6;
|
||||
uint64_t dummy;
|
||||
};
|
||||
|
||||
class BASE_EXPORT TraceEvent {
|
||||
|
@ -72,28 +72,6 @@ ThreadTicks ThreadNow() {
|
||||
: ThreadTicks();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void InitializeMetadataEvent(TraceEvent* trace_event,
|
||||
PlatformThreadId thread_id,
|
||||
const char* metadata_name,
|
||||
const char* arg_name,
|
||||
const T& value) {
|
||||
if (!trace_event) {
|
||||
return;
|
||||
}
|
||||
|
||||
TraceArguments args(arg_name, value);
|
||||
base::TimeTicks now = TRACE_TIME_TICKS_NOW();
|
||||
ThreadTicks thread_now;
|
||||
trace_event->Reset(
|
||||
thread_id, now, thread_now, TRACE_EVENT_PHASE_METADATA,
|
||||
TraceLog::GetInstance()->GetCategoryGroupEnabled("__metadata"),
|
||||
metadata_name,
|
||||
trace_event_internal::kGlobalScope, // scope
|
||||
trace_event_internal::kNoId, // id
|
||||
&args, TRACE_EVENT_FLAG_NONE);
|
||||
}
|
||||
|
||||
void AddConvertableToTraceFormat(
|
||||
base::trace_event::ConvertableToTraceFormat* value,
|
||||
perfetto::protos::pbzero::DebugAnnotation* annotation) {
|
||||
@ -257,6 +235,31 @@ void OnUpdateLegacyTraceEventDuration(
|
||||
perfetto::internal::TrackEventInternal::kDefaultTrack, timestamp);
|
||||
}
|
||||
|
||||
base::trace_event::TraceEventHandle AddTraceEventWithThreadIdAndTimestamps(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
base::PlatformThreadId thread_id,
|
||||
const base::TimeTicks& timestamp,
|
||||
const base::ThreadTicks& thread_timestamp,
|
||||
base::trace_event::TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
base::trace_event::TraceEventHandle handle = {};
|
||||
if (!*category_group_enabled) {
|
||||
return handle;
|
||||
}
|
||||
DCHECK(!timestamp.is_null());
|
||||
|
||||
base::trace_event::TraceEvent new_trace_event(
|
||||
thread_id, timestamp, thread_timestamp, phase, category_group_enabled,
|
||||
name, scope, id, args, flags);
|
||||
|
||||
base::trace_event::OnAddLegacyTraceEvent(&new_trace_event);
|
||||
return handle;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#if BUILDFLAG(USE_PERFETTO_TRACE_PROCESSOR)
|
||||
@ -358,8 +361,7 @@ void TraceLog::ResetForTesting() {
|
||||
self->InitializePerfettoIfNeeded();
|
||||
}
|
||||
|
||||
TraceLog::TraceLog(int generation)
|
||||
: process_sort_index_(0), process_id_(base::kNullProcessId) {
|
||||
TraceLog::TraceLog(int generation) : process_id_(base::kNullProcessId) {
|
||||
#if BUILDFLAG(IS_NACL) // NaCl shouldn't expose the process id.
|
||||
SetProcessID(0);
|
||||
#else
|
||||
@ -590,8 +592,6 @@ void TraceLog::SetDisabledWhileLocked() {
|
||||
return;
|
||||
}
|
||||
|
||||
AddMetadataEventsWhileLocked();
|
||||
|
||||
TrackEvent::Flush();
|
||||
// If the current thread has an active task runner, allow nested tasks to run
|
||||
// while stopping the session. This is needed by some tests, e.g., to allow
|
||||
@ -758,178 +758,10 @@ void TraceLog::OnTraceData(const char* data, size_t size, bool has_more) {
|
||||
}
|
||||
#endif // BUILDFLAG(USE_PERFETTO_TRACE_PROCESSOR)
|
||||
|
||||
TraceEventHandle TraceLog::AddTraceEvent(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
auto thread_id = base::PlatformThread::CurrentId();
|
||||
base::TimeTicks now = TRACE_TIME_TICKS_NOW();
|
||||
return AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, category_group_enabled, name, scope, id,
|
||||
trace_event_internal::kNoId, // bind_id
|
||||
thread_id, now, args, flags);
|
||||
}
|
||||
|
||||
TraceEventHandle TraceLog::AddTraceEventWithProcessId(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
ProcessId process_id,
|
||||
TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
base::TimeTicks now = TRACE_TIME_TICKS_NOW();
|
||||
return AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, category_group_enabled, name, scope, id,
|
||||
trace_event_internal::kNoId, // bind_id
|
||||
static_cast<PlatformThreadId>(process_id), now, args,
|
||||
flags | TRACE_EVENT_FLAG_HAS_PROCESS_ID);
|
||||
}
|
||||
|
||||
TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
uint64_t bind_id,
|
||||
PlatformThreadId thread_id,
|
||||
const TimeTicks& timestamp,
|
||||
TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
ThreadTicks thread_now;
|
||||
// If timestamp is provided explicitly, don't record thread time as it would
|
||||
// be for the wrong timestamp. Similarly, if we record an event for another
|
||||
// process or thread, we shouldn't report the current thread's thread time.
|
||||
if (!(flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ||
|
||||
flags & TRACE_EVENT_FLAG_HAS_PROCESS_ID ||
|
||||
thread_id != PlatformThread::CurrentId())) {
|
||||
thread_now = ThreadNow();
|
||||
}
|
||||
return AddTraceEventWithThreadIdAndTimestamps(
|
||||
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
|
||||
timestamp, thread_now, args, flags);
|
||||
}
|
||||
|
||||
TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamps(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
uint64_t bind_id,
|
||||
PlatformThreadId thread_id,
|
||||
const TimeTicks& timestamp,
|
||||
const ThreadTicks& thread_timestamp,
|
||||
TraceArguments* args,
|
||||
unsigned int flags) NO_THREAD_SAFETY_ANALYSIS {
|
||||
TraceEventHandle handle = {0, 0, 0};
|
||||
if (!*category_group_enabled) {
|
||||
return handle;
|
||||
}
|
||||
DCHECK(!timestamp.is_null());
|
||||
|
||||
TraceEvent new_trace_event(thread_id, timestamp, thread_timestamp, phase,
|
||||
category_group_enabled, name, scope, id, args,
|
||||
flags);
|
||||
|
||||
OnAddLegacyTraceEvent(&new_trace_event);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void TraceLog::UpdateTraceEventDuration(
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
TraceEventHandle handle) {
|
||||
if (!*category_group_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
OnUpdateLegacyTraceEventDuration(
|
||||
category_group_enabled, name, base::PlatformThread::CurrentId(),
|
||||
/*explicit_timestamps=*/false,
|
||||
base::subtle::TimeTicksNowIgnoringOverride(), ThreadNow());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TraceLog::AddMetadataEventWhileLocked(PlatformThreadId thread_id,
|
||||
const char* metadata_name,
|
||||
const char* arg_name,
|
||||
const T& value) {
|
||||
TraceEvent trace_event;
|
||||
InitializeMetadataEvent(&trace_event, thread_id, metadata_name, arg_name,
|
||||
value);
|
||||
OnAddLegacyTraceEvent(&trace_event);
|
||||
}
|
||||
|
||||
void TraceLog::AddMetadataEventsWhileLocked() {
|
||||
#if !BUILDFLAG(IS_NACL) // NaCl shouldn't expose the process id.
|
||||
AddMetadataEventWhileLocked(0, "num_cpus", "number",
|
||||
base::SysInfo::NumberOfProcessors());
|
||||
#endif
|
||||
|
||||
auto current_thread_id = base::PlatformThread::CurrentId();
|
||||
if (process_sort_index_ != 0) {
|
||||
AddMetadataEventWhileLocked(current_thread_id, "process_sort_index",
|
||||
"sort_index", process_sort_index_);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
AddMetadataEventWhileLocked(current_thread_id, "chrome_library_address",
|
||||
"start_address",
|
||||
base::StringPrintf("%p", &__executable_start));
|
||||
base::debug::ElfBuildIdBuffer build_id;
|
||||
size_t build_id_length =
|
||||
base::debug::ReadElfBuildId(&__executable_start, true, build_id);
|
||||
if (build_id_length > 0) {
|
||||
AddMetadataEventWhileLocked(current_thread_id, "chrome_library_module",
|
||||
"id", std::string(build_id));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!process_labels_.empty()) {
|
||||
std::vector<std::string_view> labels;
|
||||
for (const auto& it : process_labels_) {
|
||||
labels.push_back(it.second);
|
||||
}
|
||||
AddMetadataEventWhileLocked(current_thread_id, "process_labels", "labels",
|
||||
base::JoinString(labels, ","));
|
||||
}
|
||||
|
||||
// Thread sort indices.
|
||||
for (const auto& it : thread_sort_indices_) {
|
||||
if (it.second == 0) {
|
||||
continue;
|
||||
}
|
||||
AddMetadataEventWhileLocked(it.first, "thread_sort_index", "sort_index",
|
||||
it.second);
|
||||
}
|
||||
}
|
||||
|
||||
void TraceLog::SetProcessID(ProcessId process_id) {
|
||||
process_id_ = process_id;
|
||||
}
|
||||
|
||||
void TraceLog::SetProcessSortIndex(int sort_index) {
|
||||
AutoLock lock(lock_);
|
||||
process_sort_index_ = sort_index;
|
||||
}
|
||||
|
||||
void TraceLog::OnSetProcessName(const std::string& process_name) {
|
||||
if (perfetto::Tracing::IsInitialized()) {
|
||||
auto track = perfetto::ProcessTrack::Current();
|
||||
auto desc = track.Serialize();
|
||||
desc.mutable_process()->set_process_name(process_name);
|
||||
desc.mutable_process()->set_pid(static_cast<int>(process_id_));
|
||||
TrackEvent::SetTrackDescriptor(track, std::move(desc));
|
||||
}
|
||||
}
|
||||
|
||||
int TraceLog::GetNewProcessLabelId() {
|
||||
AutoLock lock(lock_);
|
||||
return next_process_label_id_++;
|
||||
@ -941,13 +773,6 @@ void TraceLog::UpdateProcessLabel(int label_id,
|
||||
return RemoveProcessLabel(label_id);
|
||||
}
|
||||
|
||||
if (perfetto::Tracing::IsInitialized()) {
|
||||
auto track = perfetto::ProcessTrack::Current();
|
||||
auto desc = track.Serialize();
|
||||
desc.mutable_process()->add_process_labels(current_label);
|
||||
TrackEvent::SetTrackDescriptor(track, std::move(desc));
|
||||
}
|
||||
|
||||
AutoLock lock(lock_);
|
||||
process_labels_[label_id] = current_label;
|
||||
}
|
||||
@ -957,11 +782,6 @@ void TraceLog::RemoveProcessLabel(int label_id) {
|
||||
process_labels_.erase(label_id);
|
||||
}
|
||||
|
||||
void TraceLog::SetThreadSortIndex(PlatformThreadId thread_id, int sort_index) {
|
||||
AutoLock lock(lock_);
|
||||
thread_sort_indices_[thread_id] = sort_index;
|
||||
}
|
||||
|
||||
size_t TraceLog::GetObserverCountForTest() const {
|
||||
AutoLock lock(observers_lock_);
|
||||
return enabled_state_observers_.size();
|
||||
@ -1042,8 +862,12 @@ base::trace_event::TraceEventHandle AddTraceEvent(
|
||||
uint64_t id,
|
||||
base::trace_event::TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
return base::trace_event::TraceLog::GetInstance()->AddTraceEvent(
|
||||
phase, category_group_enabled, name, scope, id, args, flags);
|
||||
auto thread_id = base::PlatformThread::CurrentId();
|
||||
base::TimeTicks now = TRACE_TIME_TICKS_NOW();
|
||||
return AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, category_group_enabled, name, scope, id,
|
||||
trace_event_internal::kNoId, // bind_id
|
||||
thread_id, now, args, flags);
|
||||
}
|
||||
|
||||
base::trace_event::TraceEventHandle AddTraceEventWithProcessId(
|
||||
@ -1055,8 +879,12 @@ base::trace_event::TraceEventHandle AddTraceEventWithProcessId(
|
||||
base::ProcessId process_id,
|
||||
base::trace_event::TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
return base::trace_event::TraceLog::GetInstance()->AddTraceEventWithProcessId(
|
||||
phase, category_group_enabled, name, scope, id, process_id, args, flags);
|
||||
base::TimeTicks now = TRACE_TIME_TICKS_NOW();
|
||||
return AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, category_group_enabled, name, scope, id,
|
||||
trace_event_internal::kNoId, // bind_id
|
||||
static_cast<base::PlatformThreadId>(process_id), now, args,
|
||||
flags | TRACE_EVENT_FLAG_HAS_PROCESS_ID);
|
||||
}
|
||||
|
||||
base::trace_event::TraceEventHandle AddTraceEventWithThreadIdAndTimestamp(
|
||||
@ -1070,10 +898,18 @@ base::trace_event::TraceEventHandle AddTraceEventWithThreadIdAndTimestamp(
|
||||
const base::TimeTicks& timestamp,
|
||||
base::trace_event::TraceArguments* args,
|
||||
unsigned int flags) {
|
||||
return base::trace_event::TraceLog::GetInstance()
|
||||
->AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
|
||||
timestamp, args, flags);
|
||||
base::ThreadTicks thread_now;
|
||||
// If timestamp is provided explicitly, don't record thread time as it would
|
||||
// be for the wrong timestamp. Similarly, if we record an event for another
|
||||
// process or thread, we shouldn't report the current thread's thread time.
|
||||
if (!(flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP ||
|
||||
flags & TRACE_EVENT_FLAG_HAS_PROCESS_ID ||
|
||||
thread_id != base::PlatformThread::CurrentId())) {
|
||||
thread_now = base::trace_event::ThreadNow();
|
||||
}
|
||||
return base::trace_event::AddTraceEventWithThreadIdAndTimestamps(
|
||||
phase, category_group_enabled, name, scope, id, thread_id, timestamp,
|
||||
thread_now, args, flags);
|
||||
}
|
||||
|
||||
base::trace_event::TraceEventHandle AddTraceEventWithThreadIdAndTimestamps(
|
||||
@ -1086,18 +922,23 @@ base::trace_event::TraceEventHandle AddTraceEventWithThreadIdAndTimestamps(
|
||||
const base::TimeTicks& timestamp,
|
||||
const base::ThreadTicks& thread_timestamp,
|
||||
unsigned int flags) {
|
||||
return base::trace_event::TraceLog::GetInstance()
|
||||
->AddTraceEventWithThreadIdAndTimestamps(
|
||||
phase, category_group_enabled, name, scope, id,
|
||||
trace_event_internal::kNoId, // bind_id,
|
||||
thread_id, timestamp, thread_timestamp, nullptr, flags);
|
||||
return base::trace_event::AddTraceEventWithThreadIdAndTimestamps(
|
||||
phase, category_group_enabled, name, scope, id, thread_id, timestamp,
|
||||
thread_timestamp, nullptr, flags);
|
||||
}
|
||||
|
||||
void UpdateTraceEventDuration(const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
base::trace_event::TraceEventHandle handle) {
|
||||
return base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration(
|
||||
category_group_enabled, name, handle);
|
||||
if (!*category_group_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
base::trace_event::OnUpdateLegacyTraceEventDuration(
|
||||
category_group_enabled, name, base::PlatformThread::CurrentId(),
|
||||
/*explicit_timestamps=*/false,
|
||||
base::subtle::TimeTicksNowIgnoringOverride(),
|
||||
base::trace_event::ThreadNow());
|
||||
}
|
||||
|
||||
} // namespace trace_event_internal
|
||||
|
@ -172,53 +172,6 @@ class BASE_EXPORT TraceLog : public perfetto::TrackEventSessionObserver {
|
||||
static const char* GetCategoryGroupName(
|
||||
const unsigned char* category_group_enabled);
|
||||
|
||||
// Called by TRACE_EVENT* macros, don't call this directly.
|
||||
// If |copy| is set, |name|, |arg_name1| and |arg_name2| will be deep copied
|
||||
// into the event; see "Memory scoping note" and TRACE_EVENT_COPY_XXX above.
|
||||
TraceEventHandle AddTraceEvent(char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
TraceArguments* args,
|
||||
unsigned int flags);
|
||||
TraceEventHandle AddTraceEventWithProcessId(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
ProcessId process_id,
|
||||
TraceArguments* args,
|
||||
unsigned int flags);
|
||||
TraceEventHandle AddTraceEventWithThreadIdAndTimestamp(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
uint64_t bind_id,
|
||||
PlatformThreadId thread_id,
|
||||
const TimeTicks& timestamp,
|
||||
TraceArguments* args,
|
||||
unsigned int flags);
|
||||
TraceEventHandle AddTraceEventWithThreadIdAndTimestamps(
|
||||
char phase,
|
||||
const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
const char* scope,
|
||||
uint64_t id,
|
||||
uint64_t bind_id,
|
||||
PlatformThreadId thread_id,
|
||||
const TimeTicks& timestamp,
|
||||
const ThreadTicks& thread_timestamp,
|
||||
TraceArguments* args,
|
||||
unsigned int flags);
|
||||
|
||||
void UpdateTraceEventDuration(const unsigned char* category_group_enabled,
|
||||
const char* name,
|
||||
TraceEventHandle handle);
|
||||
|
||||
ProcessId process_id() const { return process_id_; }
|
||||
|
||||
std::unordered_map<int, std::string> process_labels() const {
|
||||
@ -232,25 +185,12 @@ class BASE_EXPORT TraceLog : public perfetto::TrackEventSessionObserver {
|
||||
|
||||
void SetProcessID(ProcessId process_id);
|
||||
|
||||
// Process sort indices, if set, override the order of a process will appear
|
||||
// relative to other processes in the trace viewer. Processes are sorted first
|
||||
// on their sort index, ascending, then by their name, and then tid.
|
||||
void SetProcessSortIndex(int sort_index);
|
||||
|
||||
// Helper function to set process_name in base::CurrentProcess.
|
||||
void OnSetProcessName(const std::string& process_name);
|
||||
|
||||
// Processes can have labels in addition to their names. Use labels, for
|
||||
// instance, to list out the web page titles that a process is handling.
|
||||
int GetNewProcessLabelId();
|
||||
void UpdateProcessLabel(int label_id, const std::string& current_label);
|
||||
void RemoveProcessLabel(int label_id);
|
||||
|
||||
// Thread sort indices, if set, override the order of a thread will appear
|
||||
// within its process in the trace viewer. Threads are sorted first on their
|
||||
// sort index, ascending, then by their name, and then tid.
|
||||
void SetThreadSortIndex(PlatformThreadId thread_id, int sort_index);
|
||||
|
||||
size_t GetObserverCountForTest() const;
|
||||
|
||||
struct TrackEventSession {
|
||||
@ -283,13 +223,6 @@ class BASE_EXPORT TraceLog : public perfetto::TrackEventSessionObserver {
|
||||
|
||||
explicit TraceLog(int generation);
|
||||
~TraceLog() override;
|
||||
void AddMetadataEventsWhileLocked() EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
template <typename T>
|
||||
void AddMetadataEventWhileLocked(PlatformThreadId thread_id,
|
||||
const char* metadata_name,
|
||||
const char* arg_name,
|
||||
const T& value)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
|
||||
void SetDisabledWhileLocked() EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
|
||||
@ -317,8 +250,6 @@ class BASE_EXPORT TraceLog : public perfetto::TrackEventSessionObserver {
|
||||
|
||||
int next_process_label_id_ GUARDED_BY(lock_) = 0;
|
||||
std::unordered_map<int, std::string> process_labels_;
|
||||
int process_sort_index_;
|
||||
std::unordered_map<PlatformThreadId, int> thread_sort_indices_;
|
||||
|
||||
ProcessId process_id_;
|
||||
|
||||
|
@ -27,8 +27,6 @@ bool LibraryLoaded(JNIEnv* env,
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_BROWSER);
|
||||
}
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventBrowserProcessSortIndex);
|
||||
|
||||
// Tracing itself can only be enabled after mojo is initialized, we do so in
|
||||
// ContentMainRunnerImpl::Initialize.
|
||||
|
@ -21,8 +21,6 @@ int BrowserMain(MainFunctionParams parameters) {
|
||||
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_BROWSER);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventBrowserProcessSortIndex);
|
||||
|
||||
std::unique_ptr<BrowserMainRunnerImpl> main_runner(
|
||||
BrowserMainRunnerImpl::Create());
|
||||
|
@ -11,14 +11,6 @@ namespace content {
|
||||
// 20MiB
|
||||
const size_t kMaxLengthOfDataURLString = 1024 * 1024 * 20;
|
||||
|
||||
const int kTraceEventBrowserProcessSortIndex = -6;
|
||||
const int kTraceEventRendererProcessSortIndex = -5;
|
||||
const int kTraceEventPpapiProcessSortIndex = -3;
|
||||
const int kTraceEventPpapiBrokerProcessSortIndex = -2;
|
||||
const int kTraceEventGpuProcessSortIndex = -1;
|
||||
|
||||
const int kTraceEventRendererMainThreadSortIndex = -1;
|
||||
|
||||
#if BUILDFLAG(ENABLE_AV1_DECODER)
|
||||
const char kFrameAcceptHeaderValue[] =
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,"
|
||||
|
@ -28,16 +28,6 @@ constexpr base::TimeDelta kHungRendererDelay = base::Seconds(15);
|
||||
// The maximum length of string as data url.
|
||||
extern const size_t kMaxLengthOfDataURLString;
|
||||
|
||||
// Constants used to organize content processes in about:tracing.
|
||||
CONTENT_EXPORT extern const int kTraceEventBrowserProcessSortIndex;
|
||||
CONTENT_EXPORT extern const int kTraceEventRendererProcessSortIndex;
|
||||
CONTENT_EXPORT extern const int kTraceEventPpapiProcessSortIndex;
|
||||
CONTENT_EXPORT extern const int kTraceEventPpapiBrokerProcessSortIndex;
|
||||
CONTENT_EXPORT extern const int kTraceEventGpuProcessSortIndex;
|
||||
|
||||
// Constants used to organize content threads in about:tracing.
|
||||
CONTENT_EXPORT extern const int kTraceEventRendererMainThreadSortIndex;
|
||||
|
||||
// Accept header used for frame requests.
|
||||
CONTENT_EXPORT extern const char kFrameAcceptHeaderValue[];
|
||||
|
||||
|
@ -213,8 +213,6 @@ int GpuMain(MainFunctionParams parameters) {
|
||||
TRACE_EVENT0("gpu", "GpuMain");
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_GPU);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventGpuProcessSortIndex);
|
||||
|
||||
const base::CommandLine& command_line = *parameters.command_line;
|
||||
|
||||
|
@ -134,8 +134,6 @@ int PpapiPluginMain(MainFunctionParams parameters) {
|
||||
base::PlatformThread::SetName("CrPPAPIMain");
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_PPAPI_PLUGIN);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventPpapiProcessSortIndex);
|
||||
|
||||
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
|
||||
gin::V8Initializer::LoadV8Snapshot();
|
||||
|
@ -544,10 +544,6 @@ void RenderThreadImpl::Init() {
|
||||
|
||||
GetContentClient()->renderer()->PostIOThreadCreated(GetIOTaskRunner().get());
|
||||
|
||||
base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex(
|
||||
base::PlatformThread::CurrentId(),
|
||||
kTraceEventRendererMainThreadSortIndex);
|
||||
|
||||
#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
|
||||
// On Mac and Android Java UI, the select popups are rendered by the browser.
|
||||
blink::WebView::SetUseExternalPopupMenus(true);
|
||||
|
@ -152,8 +152,6 @@ int RendererMain(MainFunctionParams parameters) {
|
||||
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_RENDERER);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventRendererProcessSortIndex);
|
||||
|
||||
const base::CommandLine& command_line = *parameters.command_line;
|
||||
|
||||
|
@ -291,8 +291,6 @@ absl::variant<int, MainFunctionParams> ShellMainDelegate::RunProcess(
|
||||
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_BROWSER);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventBrowserProcessSortIndex);
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
if (switches::IsRunWebTestsSwitchPresent()) {
|
||||
|
@ -91,10 +91,6 @@ const base::FilePath::CharType kDefaultProfileName[] =
|
||||
|
||||
namespace {
|
||||
|
||||
// Keep in sync with content/common/content_constants_internal.h.
|
||||
// TODO(skyostil): Add a tracing test for this.
|
||||
const int kTraceEventBrowserProcessSortIndex = -6;
|
||||
|
||||
HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
|
||||
|
||||
#if !BUILDFLAG(IS_FUCHSIA)
|
||||
@ -450,8 +446,6 @@ HeadlessContentMainDelegate::RunProcess(
|
||||
|
||||
base::CurrentProcess::GetInstance().SetProcessType(
|
||||
base::CurrentProcessType::PROCESS_BROWSER);
|
||||
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
|
||||
kTraceEventBrowserProcessSortIndex);
|
||||
|
||||
std::unique_ptr<content::BrowserMainRunner> browser_runner =
|
||||
content::BrowserMainRunner::Create();
|
||||
|
@ -46,7 +46,7 @@ void TraceEventImpl::AddTraceEvent(int8_t phase,
|
||||
base::trace_event::TraceArguments args(
|
||||
num_args, arg_names, arg_types,
|
||||
reinterpret_cast<const unsigned long long*>(arg_values));
|
||||
base::trace_event::TraceLog::GetInstance()->AddTraceEvent(
|
||||
trace_event_internal::AddTraceEvent(
|
||||
phase, static_cast<const unsigned char*>(category_enabled), name,
|
||||
trace_event_internal::kGlobalScope, id, &args, flags);
|
||||
}
|
||||
@ -68,12 +68,10 @@ void TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp(
|
||||
base::trace_event::TraceArguments args(
|
||||
num_args, arg_names, arg_types,
|
||||
reinterpret_cast<const unsigned long long*>(arg_values));
|
||||
base::trace_event::TraceLog::GetInstance()
|
||||
->AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, static_cast<const unsigned char*>(category_enabled), name,
|
||||
trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId,
|
||||
thread_id, base::TimeTicks::FromInternalValue(timestamp), &args,
|
||||
flags);
|
||||
trace_event_internal::AddTraceEventWithThreadIdAndTimestamp(
|
||||
phase, static_cast<const unsigned char*>(category_enabled), name,
|
||||
trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId,
|
||||
thread_id, base::TimeTicks::FromInternalValue(timestamp), &args, flags);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -157,8 +157,6 @@ void TrackNameRecorder::OnStop(const perfetto::DataSourceBase::StopArgs&) {
|
||||
void TrackNameRecorder::OnThreadNameChanged(const char* name) {
|
||||
// If tracing is not initialized, the thread name is lost, but this should
|
||||
// never happen outside of tests.
|
||||
if (perfetto::Tracing::IsInitialized()) {
|
||||
FillThreadTrack(perfetto::ThreadTrack::Current(), name);
|
||||
}
|
||||
FillThreadTrack(perfetto::ThreadTrack::Current(), name);
|
||||
}
|
||||
} // namespace tracing
|
||||
|
Reference in New Issue
Block a user