| OLD | NEW |
| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(COMPILER_MSVC) | 7 #if defined(COMPILER_MSVC) |
| 8 #include <intrin.h> | 8 #include <intrin.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 program_counter_(program_counter) { | 24 program_counter_(program_counter) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 Location::Location() | 27 Location::Location() |
| 28 : function_name_("Unknown"), | 28 : function_name_("Unknown"), |
| 29 file_name_("Unknown"), | 29 file_name_("Unknown"), |
| 30 line_number_(-1), | 30 line_number_(-1), |
| 31 program_counter_(NULL) { | 31 program_counter_(NULL) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 Location::Location(const Location& other) |
| 35 : function_name_(other.function_name_), |
| 36 file_name_(other.file_name_), |
| 37 line_number_(other.line_number_), |
| 38 program_counter_(other.program_counter_) { |
| 39 } |
| 40 |
| 34 std::string Location::ToString() const { | 41 std::string Location::ToString() const { |
| 35 return std::string(function_name_) + "@" + file_name_ + ":" + | 42 return std::string(function_name_) + "@" + file_name_ + ":" + |
| 36 base::IntToString(line_number_); | 43 base::IntToString(line_number_); |
| 37 } | 44 } |
| 38 | 45 |
| 39 void Location::Write(bool display_filename, bool display_function_name, | 46 void Location::Write(bool display_filename, bool display_function_name, |
| 40 std::string* output) const { | 47 std::string* output) const { |
| 41 base::StringAppendF(output, "%s[%d] ", | 48 base::StringAppendF(output, "%s[%d] ", |
| 42 display_filename ? file_name_ : "line", | 49 display_filename ? file_name_ : "line", |
| 43 line_number_); | 50 line_number_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 #if defined(COMPILER_MSVC) | 97 #if defined(COMPILER_MSVC) |
| 91 return _ReturnAddress(); | 98 return _ReturnAddress(); |
| 92 #elif defined(COMPILER_GCC) && !defined(OS_NACL) | 99 #elif defined(COMPILER_GCC) && !defined(OS_NACL) |
| 93 return __builtin_extract_return_addr(__builtin_return_address(0)); | 100 return __builtin_extract_return_addr(__builtin_return_address(0)); |
| 94 #else | 101 #else |
| 95 return NULL; | 102 return NULL; |
| 96 #endif | 103 #endif |
| 97 } | 104 } |
| 98 | 105 |
| 99 } // namespace tracked_objects | 106 } // namespace tracked_objects |
| OLD | NEW |