summaryrefslogtreecommitdiffstats
path: root/base/tracked.h
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 22:28:25 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-19 22:28:25 +0000
commitfcb30f7bc726a11540d942deec17baf62511c2e0 (patch)
treea6f695de8a0f6689cd7a7565ae199277f151141b /base/tracked.h
parent216813957f67962e1c50fcbbad0d3e8fcd17760e (diff)
downloadchromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.zip
chromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.tar.gz
chromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.tar.bz2
Tag all tracked objects, including Tasks, with the program counter at the site of FROM_HERE.
This is to make it easier to determine the site Tasks are posted from in release builds, especially when only a minidump is available. It should help diagnose http://crbug.com/81499. I added a debug function to alias variables so that the optimizer will not strip them out if they are not live. The semantics of the MessageLoop::PostTask functions is changed and it is wrong but I am not sure what semantics are intended. It seems location information was no longer being tracked for Tasks wrapped as Closures and I don't know if this was intended. PTAL. Update: this has since been fixed. TEST=Set breakpoint in TaskClosureAdapter::Run and very that the post site can be located in an optimized build. BUG=81499 Review URL: http://codereview.chromium.org/7039020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tracked.h')
-rw-r--r--base/tracked.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/base/tracked.h b/base/tracked.h
index 45776d1..777e604 100644
--- a/base/tracked.h
+++ b/base/tracked.h
@@ -41,7 +41,10 @@ class BASE_API Location {
// Constructor should be called with a long-lived char*, such as __FILE__.
// It assumes the provided value will persist as a global constant, and it
// will not make a copy of it.
- Location(const char* function_name, const char* file_name, int line_number);
+ Location(const char* function_name,
+ const char* file_name,
+ int line_number,
+ const void* program_counter);
// Provide a default constructor for easy of debugging.
Location();
@@ -60,9 +63,10 @@ class BASE_API Location {
return function_name_ < other.function_name_;
}
- const char* function_name() const { return function_name_; }
- const char* file_name() const { return file_name_; }
- int line_number() const { return line_number_; }
+ const char* function_name() const { return function_name_; }
+ const char* file_name() const { return file_name_; }
+ int line_number() const { return line_number_; }
+ const void* program_counter() const { return program_counter_; }
void Write(bool display_filename, bool display_function_name,
std::string* output) const;
@@ -74,13 +78,19 @@ class BASE_API Location {
const char* const function_name_;
const char* const file_name_;
const int line_number_;
+ const void* const program_counter_;
};
+BASE_API const void* GetProgramCounter();
//------------------------------------------------------------------------------
// Define a macro to record the current source location.
-#define FROM_HERE tracked_objects::Location(__FUNCTION__, __FILE__, __LINE__)
+#define FROM_HERE tracked_objects::Location( \
+ __FUNCTION__, \
+ __FILE__, \
+ __LINE__, \
+ tracked_objects::GetProgramCounter()) \
//------------------------------------------------------------------------------
@@ -110,6 +120,11 @@ class BASE_API Tracked {
base::TimeTicks tracked_birth_time() const { return base::TimeTicks::Now(); }
#endif // defined(TRACK_ALL_TASK_OBJECTS)
+ // Returns null if SetBirthPlace has not been called.
+ const void* get_birth_program_counter() const {
+ return birth_program_counter_;
+ }
+
private:
#if defined(TRACK_ALL_TASK_OBJECTS)
@@ -123,6 +138,8 @@ class BASE_API Tracked {
#endif // defined(TRACK_ALL_TASK_OBJECTS)
+ const void* birth_program_counter_;
+
DISALLOW_COPY_AND_ASSIGN(Tracked);
};