1df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris/* 2df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * Copyright (C) 2014 The Android Open Source Project 3df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * 4df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * Licensed under the Apache License, Version 2.0 (the "License"); 5df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * you may not use this file except in compliance with the License. 6df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * You may obtain a copy of the License at 7df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * 8df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * http://www.apache.org/licenses/LICENSE-2.0 9df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * 10df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * Unless required by applicable law or agreed to in writing, software 11df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * distributed under the License is distributed on an "AS IS" BASIS, 12df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * See the License for the specific language governing permissions and 14df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris * limitations under the License. 15df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris */ 16df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 17df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris#ifndef _LIBBACKTRACE_UNWIND_MAP_H 18df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris#define _LIBBACKTRACE_UNWIND_MAP_H 19df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 202c43cff01d1271be451671567955158629b23670Christopher Ferris#include <stdint.h> 212c43cff01d1271be451671567955158629b23670Christopher Ferris#include <sys/types.h> 222c43cff01d1271be451671567955158629b23670Christopher Ferris 23df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris#include <backtrace/BacktraceMap.h> 24df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 25df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris// The unw_map_cursor_t structure is different depending on whether it is 26df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris// the local or remote version. In order to get the correct version, include 27df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris// libunwind.h first then this header. 28df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 29df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferrisclass UnwindMap : public BacktraceMap { 30df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferrispublic: 31df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris UnwindMap(pid_t pid); 32df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 33df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris unw_map_cursor_t* GetMapCursor() { return &map_cursor_; } 34df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 35e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferrisprotected: 36df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris unw_map_cursor_t map_cursor_; 37df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris}; 38df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris 39d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferrisclass UnwindMapRemote : public UnwindMap { 40d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferrispublic: 41d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris UnwindMapRemote(pid_t pid); 42d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris virtual ~UnwindMapRemote(); 43d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris 44d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris bool Build() override; 45d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris 46d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferrisprivate: 47d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris bool GenerateMap(); 48d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris}; 49d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris 50e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferrisclass UnwindMapLocal : public UnwindMap { 51e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferrispublic: 52e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris UnwindMapLocal(); 53e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris virtual ~UnwindMapLocal(); 54e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris 55d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris bool Build() override; 56e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris 57d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris void FillIn(uintptr_t addr, backtrace_map_t* map) override; 58e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris 59d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferrisprivate: 60d4c884330c384bbb06f9a0d1fee2d2ae2086521cChristopher Ferris bool GenerateMap(); 61e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris 62e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris bool map_created_; 63e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris}; 64e29609106033a48a6128664668d22bf4fb42a7eeChristopher Ferris 65df2906186b6952c57b1f662bfef0b65c9f8c2e0dChristopher Ferris#endif // _LIBBACKTRACE_UNWIND_MAP_H 66