| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "public/platform/WebTraceLocation.h" | 5 #include "public/platform/WebTraceLocation.h" |
| 6 | 6 |
| 7 #include "wtf/Compiler.h" |
| 8 #include "wtf/build_config.h" |
| 9 |
| 10 #if OS(WIN) |
| 11 #include <intrin.h> |
| 12 #endif |
| 13 |
| 7 namespace blink { | 14 namespace blink { |
| 8 | 15 |
| 9 WebTraceLocation::WebTraceLocation() | 16 WebTraceLocation::WebTraceLocation() |
| 10 : m_functionName("unknown") | 17 : m_functionName("unknown") |
| 11 , m_fileName("unknown") | 18 , m_fileName("unknown") |
| 19 , m_lineNumber(-1) |
| 20 , m_programCounter(nullptr) |
| 12 { } | 21 { } |
| 13 | 22 |
| 14 WebTraceLocation::WebTraceLocation(const char* functionName, const char* fileNam
e) | 23 WebTraceLocation::WebTraceLocation(const char* functionName, const char* fileNam
e, int lineNumber, const void* programCounter) |
| 15 : m_functionName(functionName) | 24 : m_functionName(functionName) |
| 16 , m_fileName(fileName) | 25 , m_fileName(fileName) |
| 26 , m_lineNumber(lineNumber) |
| 27 , m_programCounter(programCounter) |
| 17 { } | 28 { } |
| 18 | 29 |
| 19 const char* WebTraceLocation::functionName() const | 30 const char* WebTraceLocation::functionName() const |
| 20 { | 31 { |
| 21 return m_functionName; | 32 return m_functionName; |
| 22 } | 33 } |
| 23 | 34 |
| 24 const char* WebTraceLocation::fileName() const | 35 const char* WebTraceLocation::fileName() const |
| 25 { | 36 { |
| 26 return m_fileName; | 37 return m_fileName; |
| 27 } | 38 } |
| 28 | 39 |
| 40 int WebTraceLocation::lineNumber() const |
| 41 { |
| 42 return m_lineNumber; |
| 43 } |
| 44 |
| 45 const void* WebTraceLocation::programCounter() const |
| 46 { |
| 47 return m_programCounter; |
| 48 } |
| 49 |
| 50 #if COMPILER(MSVC) |
| 51 __declspec(noinline) |
| 52 #endif |
| 53 const void* WebTraceLocation::getProgramCounter() |
| 54 { |
| 55 #if COMPILER(MSVC) |
| 56 return _ReturnAddress(); |
| 57 #elif COMPILER(GCC) && !OS(NACL) |
| 58 return __builtin_extract_return_addr(__builtin_return_address(0)); |
| 59 #else |
| 60 return nullptr; |
| 61 #endif |
| 62 } |
| 63 |
| 29 } // namespace blink | 64 } // namespace blink |
| OLD | NEW |