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
|
|
|
|
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"
|
|
|
|
#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-18 05:52:33 +08:00
|
|
|
struct log_t{
|
2012-06-07 07:25:03 +08:00
|
|
|
/* tombstone file descriptor */
|
|
|
|
int tfd;
|
2013-03-20 04:12:23 +08:00
|
|
|
/* Activity Manager socket file descriptor */
|
|
|
|
int amfd;
|
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()
|
2014-07-26 03:25:48 +08:00
|
|
|
: tfd(-1), amfd(-1), 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 {
|
|
|
|
ERROR,
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Log information onto the tombstone. */
|
|
|
|
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
|
|
|
|
2012-06-07 07:25:03 +08:00
|
|
|
int wait_for_signal(pid_t tid, int* total_sleep_time_usec);
|
|
|
|
void wait_for_stop(pid_t tid, int* total_sleep_time_usec);
|
2011-10-22 03:14:56 +08:00
|
|
|
|
2014-06-11 02:53:08 +08:00
|
|
|
void dump_memory(log_t* log, pid_t tid, uintptr_t addr);
|
2013-12-19 00:44:24 +08:00
|
|
|
|
2011-10-22 03:14:56 +08:00
|
|
|
#endif // _DEBUGGERD_UTILITY_H
|