blob: 16333980d2db540a3fe47432d99a4e1ba979fbd9 [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
Christopher Ferrisdf290612014-01-22 19:21:07 -080029#include "BacktraceImpl.h"
Christopher Ferris17e91d42013-10-21 13:30:52 -070030#include "BacktraceThread.h"
31
Christopher Ferris46756822014-01-14 20:16:30 -080032class CorkscrewMap : public BacktraceMap {
33public:
34 CorkscrewMap(pid_t pid);
35 virtual ~CorkscrewMap();
36
37 virtual bool Build();
38
39 map_info_t* GetMapInfo() { return map_info_; }
40
41private:
42 map_info_t* map_info_;
43};
44
Christopher Ferrisdf290612014-01-22 19:21:07 -080045class CorkscrewCommon : public BacktraceImpl {
46public:
47 bool GenerateFrameData(backtrace_frame_t* cork_frames, ssize_t num_frames);
48};
49
50class CorkscrewCurrent : public CorkscrewCommon {
51public:
52 CorkscrewCurrent();
53 virtual ~CorkscrewCurrent();
54
55 virtual bool Unwind(size_t num_ignore_threads);
56
57 virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset);
58};
59
Christopher Ferris17e91d42013-10-21 13:30:52 -070060class CorkscrewThread : public CorkscrewCurrent, public BacktraceThreadInterface {
61public:
62 CorkscrewThread();
63 virtual ~CorkscrewThread();
64
Christopher Ferris17e91d42013-10-21 13:30:52 -070065 virtual void ThreadUnwind(
66 siginfo_t* siginfo, void* sigcontext, size_t num_ignore_frames);
Christopher Ferris17e91d42013-10-21 13:30:52 -070067};
68
69class CorkscrewPtrace : public CorkscrewCommon {
70public:
71 CorkscrewPtrace();
72 virtual ~CorkscrewPtrace();
73
74 virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset);
75
76 virtual bool Unwind(size_t num_ignore_threads);
77
78private:
79 ptrace_context_t* ptrace_context_;
80};
81
82#endif // _LIBBACKTRACE_CORKSCREW_H