Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _LIBBACKTRACE_UNWIND_STACK_H |
| 18 | #define _LIBBACKTRACE_UNWIND_STACK_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
Casey Dahlin | 6b95a0e | 2019-03-12 17:50:52 -0700 | [diff] [blame] | 22 | #include <memory> |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 23 | #include <string> |
| 24 | |
| 25 | #include <backtrace/BacktraceMap.h> |
| 26 | #include <unwindstack/Memory.h> |
| 27 | |
| 28 | #include "BacktraceCurrent.h" |
| 29 | #include "BacktracePtrace.h" |
| 30 | |
| 31 | class UnwindStackCurrent : public BacktraceCurrent { |
| 32 | public: |
| 33 | UnwindStackCurrent(pid_t pid, pid_t tid, BacktraceMap* map); |
| 34 | virtual ~UnwindStackCurrent() = default; |
| 35 | |
Christopher Ferris | 7937a36 | 2018-01-18 11:15:49 -0800 | [diff] [blame] | 36 | std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override; |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 37 | |
Christopher Ferris | c8bec5a | 2017-12-11 17:44:33 -0800 | [diff] [blame] | 38 | bool UnwindFromContext(size_t num_ignore_frames, void* ucontext) override; |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | class UnwindStackPtrace : public BacktracePtrace { |
| 42 | public: |
| 43 | UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map); |
| 44 | virtual ~UnwindStackPtrace() = default; |
| 45 | |
Christopher Ferris | c8bec5a | 2017-12-11 17:44:33 -0800 | [diff] [blame] | 46 | bool Unwind(size_t num_ignore_frames, void* context) override; |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 47 | |
Christopher Ferris | c8bec5a | 2017-12-11 17:44:33 -0800 | [diff] [blame] | 48 | std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override; |
Christopher Ferris | e328673 | 2017-12-07 17:41:18 -0800 | [diff] [blame] | 49 | |
Christopher Ferris | 7937a36 | 2018-01-18 11:15:49 -0800 | [diff] [blame] | 50 | size_t Read(uint64_t addr, uint8_t* buffer, size_t bytes) override; |
Christopher Ferris | e328673 | 2017-12-07 17:41:18 -0800 | [diff] [blame] | 51 | |
| 52 | private: |
Casey Dahlin | 6b95a0e | 2019-03-12 17:50:52 -0700 | [diff] [blame] | 53 | std::shared_ptr<unwindstack::Memory> memory_; |
Christopher Ferris | c8bec5a | 2017-12-11 17:44:33 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
Christopher Ferris | 6f3981c | 2017-07-27 09:29:18 -0700 | [diff] [blame] | 56 | #endif // _LIBBACKTRACE_UNWIND_STACK_H |