blob: 229bb0115ab328ae1b07ced7fda0a8127a281b3a [file] [log] [blame]
Christopher Ferris17e91d42013-10-21 13:30:52 -07001/*
2 * Copyright (C) 2013 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_CORKSCREW_H
18#define _LIBBACKTRACE_CORKSCREW_H
19
20#include <inttypes.h>
21
22#include <string>
23
Christopher Ferris17e91d42013-10-21 13:30:52 -070024#include <backtrace/Backtrace.h>
Christopher Ferris46756822014-01-14 20:16:30 -080025#include <backtrace/BacktraceMap.h>
Christopher Ferris17e91d42013-10-21 13:30:52 -070026
27#include <corkscrew/backtrace.h>
28
29#include "Backtrace.h"
30#include "BacktraceThread.h"
31
32class CorkscrewCommon : public BacktraceImpl {
33public:
34 bool GenerateFrameData(backtrace_frame_t* cork_frames, ssize_t num_frames);
Christopher Ferris46756822014-01-14 20:16:30 -080035
36 virtual BacktraceMap* CreateBacktraceMap(pid_t pid) { return new BacktraceMap(pid); }
Christopher Ferris17e91d42013-10-21 13:30:52 -070037};
38
39class CorkscrewCurrent : public CorkscrewCommon {
40public:
41 CorkscrewCurrent();
42 virtual ~CorkscrewCurrent();
43
44 virtual bool Unwind(size_t num_ignore_threads);
45
46 virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset);
47};
48
Christopher Ferris46756822014-01-14 20:16:30 -080049class CorkscrewMap : public BacktraceMap {
50public:
51 CorkscrewMap(pid_t pid);
52 virtual ~CorkscrewMap();
53
54 virtual bool Build();
55
56 map_info_t* GetMapInfo() { return map_info_; }
57
58private:
59 map_info_t* map_info_;
60};
61
Christopher Ferris17e91d42013-10-21 13:30:52 -070062class CorkscrewThread : public CorkscrewCurrent, public BacktraceThreadInterface {
63public:
64 CorkscrewThread();
65 virtual ~CorkscrewThread();
66
67 virtual bool Init();
68
69 virtual void ThreadUnwind(
70 siginfo_t* siginfo, void* sigcontext, size_t num_ignore_frames);
71
Christopher Ferris46756822014-01-14 20:16:30 -080072 virtual BacktraceMap* CreateBacktraceMap(pid_t pid) { return new CorkscrewMap(pid); }
Christopher Ferris17e91d42013-10-21 13:30:52 -070073};
74
75class CorkscrewPtrace : public CorkscrewCommon {
76public:
77 CorkscrewPtrace();
78 virtual ~CorkscrewPtrace();
79
80 virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset);
81
82 virtual bool Unwind(size_t num_ignore_threads);
83
84private:
85 ptrace_context_t* ptrace_context_;
86};
87
88#endif // _LIBBACKTRACE_CORKSCREW_H