1053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown/* 2053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * Copyright (C) 2012 The Android Open Source Project 3053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * 4053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License"); 5053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * you may not use this file except in compliance with the License. 6053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * You may obtain a copy of the License at 7053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * 8053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * http://www.apache.org/licenses/LICENSE-2.0 9053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * 10053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * Unless required by applicable law or agreed to in writing, software 11053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS, 12053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * See the License for the specific language governing permissions and 14053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown * limitations under the License. 15053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown */ 16053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown 17053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown#ifndef _DEBUGGERD_TOMBSTONE_H 18053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown#define _DEBUGGERD_TOMBSTONE_H 19053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown 20053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown#include <stdbool.h> 21e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao#include <stddef.h> 22053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown#include <sys/types.h> 2357f58f8e4a143f1208593c8b397b9a17d055dad0Josh Gao 2457f58f8e4a143f1208593c8b397b9a17d055dad0Josh Gao#include <map> 25e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao#include <string> 26e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao 27cbe70cb0a8cb0171f3802273050e851a47b090edJosh Gao#include "open_files_list.h" 28cbe70cb0a8cb0171f3802273050e851a47b090edJosh Gao 29e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gaoclass BacktraceMap; 30e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao 31e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao/* Create and open a tombstone file for writing. 32e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao * Returns a writable file descriptor, or -1 with errno set appropriately. 33e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao * If out_path is non-null, *out_path is set to the path of the tombstone file. 34e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gao */ 35e7a9e52740c952c623f7842ffa1d09b58b45e552Josh Gaoint open_tombstone(std::string* path); 36053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown 377c89f9e955ddd79312113f83cb4c210a68a940aaJosh Gao/* Creates a tombstone file and writes the crash dump to it. */ 3857f58f8e4a143f1208593c8b397b9a17d055dad0Josh Gaovoid engrave_tombstone(int tombstone_fd, BacktraceMap* map, const OpenFilesList* open_files, 3957f58f8e4a143f1208593c8b397b9a17d055dad0Josh Gao pid_t pid, pid_t tid, const std::string& process_name, 4057f58f8e4a143f1208593c8b397b9a17d055dad0Josh Gao const std::map<pid_t, std::string>& threads, uintptr_t abort_msg_address, 41a04c80255c29a57f63f123f10e15f3887a896cacJosh Gao std::string* amfd_data); 42053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown 43e1aa0ca58a2a356039047ffcc8a98d85d1bce8edJosh Gaovoid engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo, 44e1aa0ca58a2a356039047ffcc8a98d85d1bce8edJosh Gao ucontext_t* ucontext); 45e73c932373e59e4c0351cc7a8bd8cc5b8910d87eJosh Gao 469eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gao// Compatibility shim. 47c7fe0600cc14f0324e8f603309c92263aefb7193Josh Gao__attribute__((__unused__)) 489eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gaostatic void engrave_tombstone_ucontext(int tombstone_fd, pid_t, pid_t, uintptr_t abort_msg_address, 499eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gao siginfo_t* siginfo, ucontext_t* ucontext) { 509eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gao engrave_tombstone_ucontext(tombstone_fd, abort_msg_address, siginfo, ucontext); 519eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gao} 529eb4eb1811a8abb9f63d4d7a0ceb17e2a22c12e8Josh Gao 53053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown#endif // _DEBUGGERD_TOMBSTONE_H 54