| OLD | NEW |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 // | 14 // |
| 15 // Declares a utility class for getting and storing quick and dirty stack | 15 // Declares a utility class for getting and storing quick and dirty stack |
| 16 // captures. | 16 // captures. |
| 17 | 17 |
| 18 #ifndef SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ | 18 #ifndef SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ |
| 19 #define SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ | 19 #define SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ |
| 20 | 20 |
| 21 #include <windows.h> | 21 #include <windows.h> |
| 22 | 22 |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "syzygy/agent/common/stack_walker_x86.h" | 24 #include "syzygy/agent/common/stack_walker.h" |
| 25 #include "syzygy/common/asan_parameters.h" | 25 #include "syzygy/common/asan_parameters.h" |
| 26 | 26 |
| 27 namespace agent { | 27 namespace agent { |
| 28 namespace common { | 28 namespace common { |
| 29 | 29 |
| 30 // A simple class for holding a stack trace capture. | 30 // A simple class for holding a stack trace capture. |
| 31 class StackCapture { | 31 class StackCapture { |
| 32 public: | 32 public: |
| 33 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, | 33 // From http://msdn.microsoft.com/en-us/library/bb204633.aspx, |
| 34 // The maximum number of frames which CaptureStackBackTrace can be asked | 34 // The maximum number of frames which CaptureStackBackTrace can be asked |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 // static | 216 // static |
| 217 __forceinline StackId StackCapture::StartStackId() { | 217 __forceinline StackId StackCapture::StartStackId() { |
| 218 return 0x4ADFA3E5; | 218 return 0x4ADFA3E5; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // static | 221 // static |
| 222 __forceinline StackId StackCapture::UpdateStackId(StackId stack_id, | 222 __forceinline StackId StackCapture::UpdateStackId(StackId stack_id, |
| 223 const void* frame) { | 223 const void* frame) { |
| 224 stack_id += reinterpret_cast<StackId>(frame); | 224 stack_id += static_cast<StackId>(reinterpret_cast<uintptr_t>(frame)); |
| 225 stack_id += stack_id << 10; | 225 stack_id += stack_id << 10; |
| 226 stack_id ^= stack_id >> 6; | 226 stack_id ^= stack_id >> 6; |
| 227 return stack_id; | 227 return stack_id; |
| 228 } | 228 } |
| 229 | 229 |
| 230 // static | 230 // static |
| 231 __forceinline StackId StackCapture::FinalizeStackId(StackId stack_id, | 231 __forceinline StackId StackCapture::FinalizeStackId(StackId stack_id, |
| 232 size_t num_frames) { | 232 size_t num_frames) { |
| 233 stack_id += stack_id << 3; | 233 stack_id += stack_id << 3; |
| 234 stack_id ^= stack_id >> 11; | 234 stack_id ^= stack_id >> 11; |
| 235 stack_id += stack_id << 15; | 235 stack_id += stack_id << 15; |
| 236 stack_id ^= num_frames; | 236 stack_id ^= num_frames; |
| 237 return stack_id; | 237 return stack_id; |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace common | 240 } // namespace common |
| 241 } // namespace agent | 241 } // namespace agent |
| 242 | 242 |
| 243 #endif // SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ | 243 #endif // SYZYGY_AGENT_COMMON_STACK_CAPTURE_H_ |
| OLD | NEW |