Dangyi Liu | 8b39ccb | 2023-03-22 21:01:05 +0000 | [diff] [blame] | 1 | // Copyright 2023 The Fuchsia Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Dangyi Liu | 6ca0a60 | 2023-04-10 21:26:11 +0000 | [diff] [blame] | 5 | #ifndef SRC_LIB_UNWINDER_SCS_UNWINDER_H_ |
| 6 | #define SRC_LIB_UNWINDER_SCS_UNWINDER_H_ |
Dangyi Liu | 8b39ccb | 2023-03-22 21:01:05 +0000 | [diff] [blame] | 7 | |
Dangyi Liu | 6ca0a60 | 2023-04-10 21:26:11 +0000 | [diff] [blame] | 8 | #include "src/lib/unwinder/memory.h" |
| 9 | #include "src/lib/unwinder/registers.h" |
Dangyi Liu | 8b39ccb | 2023-03-22 21:01:05 +0000 | [diff] [blame] | 10 | |
| 11 | namespace unwinder { |
| 12 | |
| 13 | // Unwind from Shadow Call Stacks, only available on arm64. |
| 14 | // |
| 15 | // It's inherently unreliable to unwind from a shadow call stack, because |
Dangyi Liu | 1ab7744 | 2023-03-29 23:00:04 +0000 | [diff] [blame] | 16 | // 1) The shadow call stack provides nothing other than return addresses, so it's not possible to |
| 17 | // unwind the following frames with other unwinders. |
| 18 | // 2) A function can choose not to implement shadow call stack, e.g. a library compiled without |
| 19 | // SCS, and the unwinder has no way to detect; those frames will be dropped silently. |
Dangyi Liu | 8b39ccb | 2023-03-22 21:01:05 +0000 | [diff] [blame] | 20 | class ShadowCallStackUnwinder { |
| 21 | public: |
Dangyi Liu | 1ab7744 | 2023-03-29 23:00:04 +0000 | [diff] [blame] | 22 | Error Step(Memory* scs, const Registers& current, Registers& next); |
Dangyi Liu | 8b39ccb | 2023-03-22 21:01:05 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | } // namespace unwinder |
| 26 | |
Dangyi Liu | 6ca0a60 | 2023-04-10 21:26:11 +0000 | [diff] [blame] | 27 | #endif // SRC_LIB_UNWINDER_SCS_UNWINDER_H_ |