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

Side by Side Diff: base/debug/activity_tracker.cc

Issue 2544853003: Store log messages in global activity tracker. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « base/debug/activity_tracker.h ('k') | base/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/activity_tracker.h" 5 #include "base/debug/activity_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 851 }
852 852
853 void GlobalActivityTracker::ReleaseUserDataMemory( 853 void GlobalActivityTracker::ReleaseUserDataMemory(
854 PersistentMemoryAllocator::Reference* reference) { 854 PersistentMemoryAllocator::Reference* reference) {
855 DCHECK(*reference); 855 DCHECK(*reference);
856 base::AutoLock autolock(user_data_allocator_lock_); 856 base::AutoLock autolock(user_data_allocator_lock_);
857 user_data_allocator_.ReleaseObjectReference(*reference); 857 user_data_allocator_.ReleaseObjectReference(*reference);
858 *reference = PersistentMemoryAllocator::kReferenceNull; 858 *reference = PersistentMemoryAllocator::kReferenceNull;
859 } 859 }
860 860
861 void GlobalActivityTracker::RecordLogMessage(StringPiece message) {
862 PersistentMemoryAllocator::Reference ref =
manzagop (departed) 2016/12/02 19:10:41 Wdyt of setting a max size that we'll truncate to?
bcwhite 2016/12/02 19:28:07 If it's somehow too big, the allocation will fail
manzagop (departed) 2016/12/02 20:08:09 Yeah, the worry is if it's too big then you get no
bcwhite 2016/12/02 20:16:30 Somewhat related: You should report the IsFull()
manzagop (departed) 2016/12/02 20:50:09 Thanks for the heads up! Added to the list.
863 allocator_->Allocate(message.size() + 1, kTypeIdGlobalLogMessage);
manzagop (departed) 2016/12/02 19:10:41 The extra character is to ensure null termination,
bcwhite 2016/12/02 19:28:07 Done.
864 char* memory = allocator_->GetAsArray<char>(ref, kTypeIdGlobalLogMessage,
865 message.size() + 1);
866 if (memory) {
867 memcpy(memory, message.data(), message.size());
868 allocator_->MakeIterable(ref);
869 }
870 }
871
861 GlobalActivityTracker::GlobalActivityTracker( 872 GlobalActivityTracker::GlobalActivityTracker(
862 std::unique_ptr<PersistentMemoryAllocator> allocator, 873 std::unique_ptr<PersistentMemoryAllocator> allocator,
863 int stack_depth) 874 int stack_depth)
864 : allocator_(std::move(allocator)), 875 : allocator_(std::move(allocator)),
865 stack_memory_size_(ThreadActivityTracker::SizeForStackDepth(stack_depth)), 876 stack_memory_size_(ThreadActivityTracker::SizeForStackDepth(stack_depth)),
866 this_thread_tracker_(&OnTLSDestroy), 877 this_thread_tracker_(&OnTLSDestroy),
867 thread_tracker_count_(0), 878 thread_tracker_count_(0),
868 thread_tracker_allocator_(allocator_.get(), 879 thread_tracker_allocator_(allocator_.get(),
869 kTypeIdActivityTracker, 880 kTypeIdActivityTracker,
870 kTypeIdActivityTrackerFree, 881 kTypeIdActivityTrackerFree,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 : GlobalActivityTracker::ScopedThreadActivity( 1008 : GlobalActivityTracker::ScopedThreadActivity(
998 program_counter, 1009 program_counter,
999 nullptr, 1010 nullptr,
1000 Activity::ACT_PROCESS_WAIT, 1011 Activity::ACT_PROCESS_WAIT,
1001 ActivityData::ForProcess(process->Pid()), 1012 ActivityData::ForProcess(process->Pid()),
1002 /*lock_allowed=*/true) {} 1013 /*lock_allowed=*/true) {}
1003 #endif 1014 #endif
1004 1015
1005 } // namespace debug 1016 } // namespace debug
1006 } // namespace base 1017 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_tracker.h ('k') | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698