2009-03-04 11:32:55 +08:00
|
|
|
/* system/debuggerd/utility.h
|
|
|
|
**
|
|
|
|
** Copyright 2008, The Android Open Source Project
|
|
|
|
**
|
2014-07-15 07:10:15 +08:00
|
|
|
** 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
|
2009-03-04 11:32:55 +08:00
|
|
|
**
|
2014-07-15 07:10:15 +08:00
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
2009-03-04 11:32:55 +08:00
|
|
|
**
|
2014-07-15 07:10:15 +08:00
|
|
|
** 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
|
2009-03-04 11:32:55 +08:00
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-10-22 03:14:56 +08:00
|
|
|
#ifndef _DEBUGGERD_UTILITY_H
|
|
|
|
#define _DEBUGGERD_UTILITY_H
|
2009-03-04 11:32:55 +08:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
2013-11-22 03:17:20 +08:00
|
|
|
#include <sys/types.h>
|
2012-06-07 07:25:03 +08:00
|
|
|
|
2016-05-04 07:32:13 +08:00
|
|
|
#include <string>
|
|
|
|
|
2015-05-23 05:26:13 +08:00
|
|
|
#include <backtrace/Backtrace.h>
|
|
|
|
|
2014-06-21 07:19:58 +08:00
|
|
|
// Figure out the abi based on defined macros.
|
|
|
|
#if defined(__arm__)
|
|
|
|
#define ABI_STRING "arm"
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
#define ABI_STRING "arm64"
|
2015-03-10 09:41:32 +08:00
|
|
|
#elif defined(__mips__) && !defined(__LP64__)
|
2014-06-21 07:19:58 +08:00
|
|
|
#define ABI_STRING "mips"
|
2015-03-10 09:41:32 +08:00
|
|
|
#elif defined(__mips__) && defined(__LP64__)
|
|
|
|
#define ABI_STRING "mips64"
|
2014-06-21 07:19:58 +08:00
|
|
|
#elif defined(__i386__)
|
|
|
|
#define ABI_STRING "x86"
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define ABI_STRING "x86_64"
|
|
|
|
#else
|
|
|
|
#error "Unsupported ABI"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-07-18 05:52:33 +08:00
|
|
|
struct log_t{
|
2016-05-04 07:32:13 +08:00
|
|
|
// Tombstone file descriptor.
|
2012-06-07 07:25:03 +08:00
|
|
|
int tfd;
|
2016-05-04 07:32:13 +08:00
|
|
|
// Data to be sent to the Activity Manager.
|
|
|
|
std::string* amfd_data;
|
2014-06-11 02:53:08 +08:00
|
|
|
// 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;
|
2014-07-26 03:25:48 +08:00
|
|
|
// logd daemon crash, can block asking for logcat data, allow suppression.
|
|
|
|
bool should_retrieve_logcat;
|
2014-07-18 05:52:33 +08:00
|
|
|
|
|
|
|
log_t()
|
2016-05-04 07:32:13 +08:00
|
|
|
: tfd(-1), amfd_data(nullptr), crashed_tid(-1), current_tid(-1),
|
|
|
|
should_retrieve_logcat(true) {}
|
2014-07-18 05:52:33 +08:00
|
|
|
};
|
2009-03-04 11:32:55 +08:00
|
|
|
|
2014-06-11 02:53:08 +08:00
|
|
|
// List of types of logs to simplify the logging decision in _LOG
|
|
|
|
enum logtype {
|
|
|
|
HEADER,
|
|
|
|
THREAD,
|
|
|
|
REGISTERS,
|
2014-07-15 07:10:15 +08:00
|
|
|
FP_REGISTERS,
|
2014-06-11 02:53:08 +08:00
|
|
|
BACKTRACE,
|
|
|
|
MAPS,
|
|
|
|
MEMORY,
|
|
|
|
STACK,
|
|
|
|
LOGS
|
|
|
|
};
|
|
|
|
|
2014-11-01 12:34:38 +08:00
|
|
|
// Log information onto the tombstone.
|
2014-06-11 02:53:08 +08:00
|
|
|
void _LOG(log_t* log, logtype ltype, const char *fmt, ...)
|
2011-10-22 03:14:56 +08:00
|
|
|
__attribute__ ((format(printf, 3, 4)));
|
2011-09-23 07:37:06 +08:00
|
|
|
|
2016-08-11 08:57:01 +08:00
|
|
|
int wait_for_signal(pid_t tid);
|
2011-10-22 03:14:56 +08:00
|
|
|
|
2015-05-23 05:26:13 +08:00
|
|
|
void dump_memory(log_t* log, Backtrace* backtrace, uintptr_t addr, const char* fmt, ...);
|
2013-12-19 00:44:24 +08:00
|
|
|
|
2011-10-22 03:14:56 +08:00
|
|
|
#endif // _DEBUGGERD_UTILITY_H
|