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

Side by Side Diff: base/tracked_objects.cc

Issue 1784133002: [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use SetThreadName function. Created 4 years, 9 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
OLDNEW
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/tracked_objects.h" 5 #include "base/tracked_objects.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/base_switches.h" 11 #include "base/base_switches.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/debug/leak_annotations.h" 14 #include "base/debug/leak_annotations.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/third_party/valgrind/memcheck.h" 18 #include "base/third_party/valgrind/memcheck.h"
19 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
19 #include "base/tracking_info.h" 20 #include "base/tracking_info.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 22
22 using base::TimeDelta; 23 using base::TimeDelta;
23 24
24 namespace base { 25 namespace base {
25 class TimeDelta; 26 class TimeDelta;
26 } 27 }
27 28
28 namespace tracked_objects { 29 namespace tracked_objects {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 356
356 // static 357 // static
357 void ThreadData::InitializeThreadContext(const std::string& suggested_name) { 358 void ThreadData::InitializeThreadContext(const std::string& suggested_name) {
358 Initialize(); 359 Initialize();
359 ThreadData* current_thread_data = 360 ThreadData* current_thread_data =
360 reinterpret_cast<ThreadData*>(tls_index_.Get()); 361 reinterpret_cast<ThreadData*>(tls_index_.Get());
361 if (current_thread_data) 362 if (current_thread_data)
362 return; // Browser tests instigate this. 363 return; // Browser tests instigate this.
363 current_thread_data = new ThreadData(suggested_name); 364 current_thread_data = new ThreadData(suggested_name);
364 tls_index_.Set(current_thread_data); 365 tls_index_.Set(current_thread_data);
366
367 // Add thread name to pseudo stack frame of heap profiler. The name added here
368 // is valid for the lifetime of the process since ThreadData is not destroyed
369 // even if thread is dead.
Primiano Tucci (use gerrit) 2016/03/15 16:44:33 Bad news: I took a look to this and figured out th
ssid 2016/03/17 00:11:47 I think I should continue with good news and bad n
370 if (base::trace_event::AllocationContextTracker::capture_enabled()) {
371 base::trace_event::AllocationContextTracker::SetThreadName(
372 tracked_objects::ThreadData::Get()->thread_name().c_str());
373 }
365 } 374 }
366 375
367 // static 376 // static
368 ThreadData* ThreadData::Get() { 377 ThreadData* ThreadData::Get() {
369 if (!tls_index_.initialized()) 378 if (!tls_index_.initialized())
370 return NULL; // For unittests only. 379 return NULL; // For unittests only.
371 ThreadData* registered = reinterpret_cast<ThreadData*>(tls_index_.Get()); 380 ThreadData* registered = reinterpret_cast<ThreadData*>(tls_index_.Get());
372 if (registered) 381 if (registered)
373 return registered; 382 return registered;
374 383
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 #endif 977 #endif
969 } 978 }
970 979
971 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) = 980 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) =
972 default; 981 default;
973 982
974 ProcessDataSnapshot::~ProcessDataSnapshot() { 983 ProcessDataSnapshot::~ProcessDataSnapshot() {
975 } 984 }
976 985
977 } // namespace tracked_objects 986 } // namespace tracked_objects
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698