blob: b89bc89394f91cae353b285554883fe4c3c0419d [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_BACKTRACE_H
18#define _LIBBACKTRACE_BACKTRACE_H
19
20#include <backtrace/Backtrace.h>
21
22#include <sys/types.h>
23
24class BacktraceImpl {
25public:
26 virtual ~BacktraceImpl() { }
27
28 virtual bool Unwind(size_t num_ignore_frames) = 0;
29
30 // The name returned is not demangled, Backtrace::GetFunctionName()
31 // takes care of demangling the name.
32 virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) = 0;
33
34 void SetParent(Backtrace* backtrace) { backtrace_obj_ = backtrace; }
35
36protected:
37 backtrace_t* GetBacktraceData();
38
39 Backtrace* backtrace_obj_;
40};
41
42class BacktraceCurrent : public Backtrace {
43public:
44 BacktraceCurrent(BacktraceImpl* impl);
45 virtual ~BacktraceCurrent();
46
47 bool ReadWord(uintptr_t ptr, uint32_t* out_value);
48};
49
50class BacktracePtrace : public Backtrace {
51public:
52 BacktracePtrace(BacktraceImpl* impl, pid_t pid, pid_t tid);
53 virtual ~BacktracePtrace();
54
55 bool ReadWord(uintptr_t ptr, uint32_t* out_value);
56};
57
58Backtrace* CreateCurrentObj();
59Backtrace* CreatePtraceObj(pid_t pid, pid_t tid);
60Backtrace* CreateThreadObj(pid_t tid);
61
62#endif // _LIBBACKTRACE_BACKTRACE_H