blob: 32d1f51ab975b036816dc779ed820aeef52c79fe [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
35 std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override;
36
37 bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) override;
38
39 private:
40 std::unique_ptr<unwindstack::Memory> memory_;
41};
42
43class UnwindStackPtrace : public BacktracePtrace {
44 public:
45 UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map);
46 virtual ~UnwindStackPtrace() = default;
47
48 bool Unwind(size_t num_ignore_frames, ucontext_t* context) override;
49
50 std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset);
51
52 private:
53 std::unique_ptr<unwindstack::Memory> memory_;
54};
55
56#endif // _LIBBACKTRACE_UNWIND_STACK_H