blob: 33c4282b20e67d65beaf6275f3150df1511558f1 [file] [log] [blame]
Christopher Ferris6f3981c2017-07-27 09:29:18 -07001/*
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
22#include <string>
23
24#include <backtrace/BacktraceMap.h>
25#include <unwindstack/Memory.h>
26
27#include "BacktraceCurrent.h"
28#include "BacktracePtrace.h"
29
30class UnwindStackCurrent : public BacktraceCurrent {
31 public:
32 UnwindStackCurrent(pid_t pid, pid_t tid, BacktraceMap* map);
33 virtual ~UnwindStackCurrent() = default;
34
Christopher Ferris7937a362018-01-18 11:15:49 -080035 std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override;
Christopher Ferris6f3981c2017-07-27 09:29:18 -070036
Christopher Ferrisc8bec5a2017-12-11 17:44:33 -080037 bool UnwindFromContext(size_t num_ignore_frames, void* ucontext) override;
Christopher Ferris6f3981c2017-07-27 09:29:18 -070038};
39
40class UnwindStackPtrace : public BacktracePtrace {
41 public:
42 UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map);
43 virtual ~UnwindStackPtrace() = default;
44
Christopher Ferrisc8bec5a2017-12-11 17:44:33 -080045 bool Unwind(size_t num_ignore_frames, void* context) override;
Christopher Ferris6f3981c2017-07-27 09:29:18 -070046
Christopher Ferrisc8bec5a2017-12-11 17:44:33 -080047 std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override;
Christopher Ferrise3286732017-12-07 17:41:18 -080048
Christopher Ferris7937a362018-01-18 11:15:49 -080049 size_t Read(uint64_t addr, uint8_t* buffer, size_t bytes) override;
Christopher Ferrise3286732017-12-07 17:41:18 -080050
51 private:
52 unwindstack::MemoryRemote memory_;
Christopher Ferris6f3981c2017-07-27 09:29:18 -070053};
54
Christopher Ferrisc8bec5a2017-12-11 17:44:33 -080055class UnwindStackOffline : public Backtrace {
56 public:
57 UnwindStackOffline(ArchEnum arch, pid_t pid, pid_t tid, BacktraceMap* map, bool map_shared);
58
59 bool Unwind(size_t num_ignore_frames, void* context) override;
60
61 std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset);
62
63 size_t Read(uint64_t addr, uint8_t* buffer, size_t bytes) override;
64
65 bool ReadWord(uint64_t ptr, word_t* out_value) override;
66
67 private:
68 ArchEnum arch_;
69};
70
Christopher Ferris6f3981c2017-07-27 09:29:18 -070071#endif // _LIBBACKTRACE_UNWIND_STACK_H