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

Unified Diff: base/tracked.cc

Issue 7039020: Tag all tracked objects, including Tasks, with the program counter at the site of FROM_HERE. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: base/tracked.cc
===================================================================
--- base/tracked.cc (revision 85540)
+++ base/tracked.cc (working copy)
@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
+#if defined(COMPILER_MSVC)
+#include <intrin.h>
+#endif
+
#include "base/tracked.h"
#include "base/stringprintf.h"
@@ -13,17 +19,21 @@
//------------------------------------------------------------------------------
-Location::Location(const char* function_name, const char* file_name,
- int line_number)
+Location::Location(const char* function_name,
+ const char* file_name,
+ int line_number,
+ void* program_counter)
: function_name_(function_name),
file_name_(file_name),
- line_number_(line_number) {
+ line_number_(line_number),
+ program_counter_(program_counter) {
}
Location::Location()
: function_name_("Unknown"),
file_name_("Unknown"),
- line_number_(-1) {
+ line_number_(-1),
+ program_counter_(NULL) {
}
void Location::Write(bool display_filename, bool display_function_name,
@@ -58,15 +68,29 @@
}
}
+BASE_API void* GetProgramCounterRegister() {
+#if defined(COMPILER_MSVC)
+ return _ReturnAddress();
+#elif defined(COMPILER_GCC)
+ return __builtin_return_address(0);
+#endif // COMPILER_GCC
+
+ return NULL;
+}
+
//------------------------------------------------------------------------------
#ifndef TRACK_ALL_TASK_OBJECTS
-Tracked::Tracked() {}
+Tracked::Tracked() : birth_program_counter_(NULL) {}
Tracked::~Tracked() {}
-void Tracked::SetBirthPlace(const Location& from_here) {}
+
+void Tracked::SetBirthPlace(const Location& from_here) {
+ birth_program_counter_ = from_here.program_counter();
+}
+
const Location Tracked::GetBirthPlace() const {
- static Location kNone("NoFunctionName", "NeedToSetBirthPlace", -1);
+ static Location kNone("NoFunctionName", "NeedToSetBirthPlace", -1, NULL);
return kNone;
}
bool Tracked::MissingBirthplace() const { return false; }
@@ -98,6 +122,8 @@
if (!current_thread_data)
return; // Shutdown started, and this thread wasn't registered.
tracked_births_ = current_thread_data->TallyABirth(from_here);
+
+ birth_program_counter_ = from_here.program_counter();
}
const Location Tracked::GetBirthPlace() const {

Powered by Google App Engine
This is Rietveld 408576698