diff options
Diffstat (limited to 'debuggerd/libdebuggerd/include')
-rw-r--r-- | debuggerd/libdebuggerd/include/backtrace.h | 38 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/elf_utils.h | 27 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/machine.h | 29 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/open_files_list.h | 36 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/tombstone.h | 42 | ||||
-rw-r--r-- | debuggerd/libdebuggerd/include/utility.h | 86 |
6 files changed, 258 insertions, 0 deletions
diff --git a/debuggerd/libdebuggerd/include/backtrace.h b/debuggerd/libdebuggerd/include/backtrace.h new file mode 100644 index 000000000..acd5eaac6 --- /dev/null +++ b/debuggerd/libdebuggerd/include/backtrace.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DEBUGGERD_BACKTRACE_H +#define _DEBUGGERD_BACKTRACE_H + +#include <sys/types.h> + +#include <set> +#include <string> + +#include "utility.h" + +class Backtrace; +class BacktraceMap; + +// Dumps a backtrace using a format similar to what Dalvik uses so that the result +// can be intermixed in a bug report. +void dump_backtrace(int fd, BacktraceMap* map, pid_t pid, pid_t tid, + const std::set<pid_t>& siblings, std::string* amfd_data); + +/* Dumps the backtrace in the backtrace data structure to the log. */ +void dump_backtrace_to_log(Backtrace* backtrace, log_t* log, const char* prefix); + +#endif // _DEBUGGERD_BACKTRACE_H diff --git a/debuggerd/libdebuggerd/include/elf_utils.h b/debuggerd/libdebuggerd/include/elf_utils.h new file mode 100644 index 000000000..11d0a4348 --- /dev/null +++ b/debuggerd/libdebuggerd/include/elf_utils.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DEBUGGERD_ELF_UTILS_H +#define _DEBUGGERD_ELF_UTILS_H + +#include <stdint.h> +#include <string> + +class Backtrace; + +bool elf_get_build_id(Backtrace*, uintptr_t, std::string*); + +#endif // _DEBUGGERD_ELF_UTILS_H diff --git a/debuggerd/libdebuggerd/include/machine.h b/debuggerd/libdebuggerd/include/machine.h new file mode 100644 index 000000000..e65b147f6 --- /dev/null +++ b/debuggerd/libdebuggerd/include/machine.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DEBUGGERD_MACHINE_H +#define _DEBUGGERD_MACHINE_H + +#include <sys/types.h> + +#include <backtrace/Backtrace.h> + +#include "utility.h" + +void dump_memory_and_code(log_t* log, Backtrace* backtrace); +void dump_registers(log_t* log, pid_t tid); + +#endif // _DEBUGGERD_MACHINE_H diff --git a/debuggerd/libdebuggerd/include/open_files_list.h b/debuggerd/libdebuggerd/include/open_files_list.h new file mode 100644 index 000000000..b37228d03 --- /dev/null +++ b/debuggerd/libdebuggerd/include/open_files_list.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DEBUGGERD_OPEN_FILES_LIST_H +#define _DEBUGGERD_OPEN_FILES_LIST_H + +#include <sys/types.h> + +#include <string> +#include <utility> +#include <vector> + +#include "utility.h" + +typedef std::vector<std::pair<int, std::string>> OpenFilesList; + +/* Populates the given list with open files for the given process. */ +void populate_open_files_list(pid_t pid, OpenFilesList* list); + +/* Dumps the open files list to the log. */ +void dump_open_files_list_to_log(const OpenFilesList& files, log_t* log, const char* prefix); + +#endif // _DEBUGGERD_OPEN_FILES_LIST_H diff --git a/debuggerd/libdebuggerd/include/tombstone.h b/debuggerd/libdebuggerd/include/tombstone.h new file mode 100644 index 000000000..4ff24af26 --- /dev/null +++ b/debuggerd/libdebuggerd/include/tombstone.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DEBUGGERD_TOMBSTONE_H +#define _DEBUGGERD_TOMBSTONE_H + +#include <stdbool.h> +#include <stddef.h> +#include <sys/types.h> +#include <set> +#include <string> + +#include "open_files_list.h" + +class BacktraceMap; + +/* Create and open a tombstone file for writing. + * Returns a writable file descriptor, or -1 with errno set appropriately. + * If out_path is non-null, *out_path is set to the path of the tombstone file. + */ +int open_tombstone(std::string* path); + +/* Creates a tombstone file and writes the crash dump to it. */ +void engrave_tombstone(int tombstone_fd, BacktraceMap* map, + const OpenFilesList& open_files, pid_t pid, pid_t tid, + const std::set<pid_t>& siblings, uintptr_t abort_msg_address, + std::string* amfd_data); + +#endif // _DEBUGGERD_TOMBSTONE_H diff --git a/debuggerd/libdebuggerd/include/utility.h b/debuggerd/libdebuggerd/include/utility.h new file mode 100644 index 000000000..bbc45468b --- /dev/null +++ b/debuggerd/libdebuggerd/include/utility.h @@ -0,0 +1,86 @@ +/* system/debuggerd/utility.h +** +** Copyright 2008, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef _DEBUGGERD_UTILITY_H +#define _DEBUGGERD_UTILITY_H + +#include <signal.h> +#include <stdbool.h> +#include <sys/types.h> + +#include <string> + +#include <backtrace/Backtrace.h> + +// Figure out the abi based on defined macros. +#if defined(__arm__) +#define ABI_STRING "arm" +#elif defined(__aarch64__) +#define ABI_STRING "arm64" +#elif defined(__mips__) && !defined(__LP64__) +#define ABI_STRING "mips" +#elif defined(__mips__) && defined(__LP64__) +#define ABI_STRING "mips64" +#elif defined(__i386__) +#define ABI_STRING "x86" +#elif defined(__x86_64__) +#define ABI_STRING "x86_64" +#else +#error "Unsupported ABI" +#endif + + +struct log_t{ + // Tombstone file descriptor. + int tfd; + // Data to be sent to the Activity Manager. + std::string* amfd_data; + // The tid of the thread that crashed. + pid_t crashed_tid; + // The tid of the thread we are currently working with. + pid_t current_tid; + // logd daemon crash, can block asking for logcat data, allow suppression. + bool should_retrieve_logcat; + + log_t() + : tfd(-1), amfd_data(nullptr), crashed_tid(-1), current_tid(-1), + should_retrieve_logcat(true) {} +}; + +// List of types of logs to simplify the logging decision in _LOG +enum logtype { + HEADER, + THREAD, + REGISTERS, + FP_REGISTERS, + BACKTRACE, + MAPS, + MEMORY, + STACK, + LOGS, + OPEN_FILES +}; + +// Log information onto the tombstone. +void _LOG(log_t* log, logtype ltype, const char *fmt, ...) + __attribute__ ((format(printf, 3, 4))); + +bool wait_for_signal(pid_t tid, siginfo_t* siginfo); + +void dump_memory(log_t* log, Backtrace* backtrace, uintptr_t addr, const char* fmt, ...); + +#endif // _DEBUGGERD_UTILITY_H |