Index: base/tracked.h |
diff --git a/base/tracked.h b/base/tracked.h |
index 3c73519c6c650d051423918a59892763bcdf7fba..9b99b3e8485628e8f596db6ec545d2a558949a17 100644 |
--- a/base/tracked.h |
+++ b/base/tracked.h |
@@ -22,6 +22,8 @@ |
#include <string> |
#include "base/base_export.h" |
+#include "base/string_piece.h" |
+#include "base/stringize_macros.h" |
#include "base/time.h" |
#ifndef NDEBUG |
@@ -38,15 +40,15 @@ namespace tracked_objects { |
class BASE_EXPORT Location { |
public: |
- // 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, |
+ // Constructor should be called with a long-lived char*. It assumes the |
+ // provided value will persist as a global constant, and it will not make a |
+ // copy of it. |
+ // |file_line| is formatted as "FILE:LINE". |
+ Location(const char* file_line, |
+ const char* function_name, |
const void* program_counter); |
- // Provide a default constructor for easy of debugging. |
+ // Default constructor initializes to "Unknown:-1", "Unknown", NULL. |
Location(); |
// Comparison operator for insertion into a std::map<> hash tables. |
@@ -56,16 +58,16 @@ class BASE_EXPORT Location { |
// a difference), and then pointers as secondary keys (just to get some |
// distinctions). |
bool operator < (const Location& other) const { |
- if (line_number_ != other.line_number_) |
- return line_number_ < other.line_number_; |
- if (file_name_ != other.file_name_) |
- return file_name_ < other.file_name_; |
+ if (file_line_ != other.file_line_) |
+ return file_line_ < other.file_line_; |
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_; } |
+ // Get long-lived file_line string "FILE:LINE". |
+ const char* file_line() const { return file_line_; } |
+ const base::StringPiece file_name() const; |
+ int line_number() const; |
+ const base::StringPiece function_name() const; |
const void* program_counter() const { return program_counter_; } |
void Write(bool display_filename, bool display_function_name, |
@@ -75,10 +77,9 @@ class BASE_EXPORT Location { |
void WriteFunctionName(std::string* output) const; |
private: |
- const char* const function_name_; |
- const char* const file_name_; |
- const int line_number_; |
- const void* const program_counter_; |
+ const char* file_line_; |
+ const char* function_name_; |
+ const void* program_counter_; |
}; |
BASE_EXPORT const void* GetProgramCounter(); |
@@ -86,11 +87,9 @@ BASE_EXPORT const void* GetProgramCounter(); |
//------------------------------------------------------------------------------ |
// Define a macro to record the current source location. |
-#define FROM_HERE tracked_objects::Location( \ |
- __FUNCTION__, \ |
- __FILE__, \ |
- __LINE__, \ |
- tracked_objects::GetProgramCounter()) \ |
+#define FROM_HERE tracked_objects::Location( \ |
+ __FILE__ ":" STRINGIZE(__LINE__), __FUNCTION__, \ |
joth
2011/09/15 10:38:09
random musing:
if we passed in (sizeof(__FILE__) +
jar (doing other things)
2011/09/15 16:26:39
I think that sizeof(__FILE__) == sizeof(char*)
I
jbates
2011/09/15 16:48:33
I think it's best to just change to FileName style
|
+ tracked_objects::GetProgramCounter()) |
//------------------------------------------------------------------------------ |