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