2016-10-19 03:17:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-21 23:31:17 +02:00
|
|
|
#include <signal.h>
|
2016-10-19 03:17:52 +02:00
|
|
|
#include <stdint.h>
|
2017-08-21 23:31:17 +02:00
|
|
|
#include <sys/ucontext.h>
|
|
|
|
#include <unistd.h>
|
2016-10-19 03:17:52 +02:00
|
|
|
|
2017-05-24 16:07:25 +02:00
|
|
|
#include "dump_type.h"
|
|
|
|
|
2016-10-19 03:17:52 +02:00
|
|
|
// Sockets in the ANDROID_SOCKET_NAMESPACE_RESERVED namespace.
|
|
|
|
// Both sockets are SOCK_SEQPACKET sockets, so no explicit length field is needed.
|
|
|
|
constexpr char kTombstonedCrashSocketName[] = "tombstoned_crash";
|
2017-05-15 16:59:30 +02:00
|
|
|
constexpr char kTombstonedJavaTraceSocketName[] = "tombstoned_java_trace";
|
2016-10-19 03:17:52 +02:00
|
|
|
constexpr char kTombstonedInterceptSocketName[] = "tombstoned_intercept";
|
|
|
|
|
|
|
|
enum class CrashPacketType : uint8_t {
|
|
|
|
// Initial request from crash_dump.
|
|
|
|
kDumpRequest = 0,
|
|
|
|
|
|
|
|
// Notification of a completed crash dump.
|
|
|
|
// Sent after a dump is completed and the process has been untraced, but
|
|
|
|
// before it has been resumed with SIGCONT.
|
|
|
|
kCompletedDump,
|
|
|
|
|
|
|
|
// Responses to kRequest.
|
|
|
|
// kPerformDump sends along an output fd via cmsg(3).
|
|
|
|
kPerformDump = 128,
|
|
|
|
kAbortDump,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DumpRequest {
|
2017-05-24 16:07:25 +02:00
|
|
|
DebuggerdDumpType dump_type;
|
2016-10-19 03:17:52 +02:00
|
|
|
int32_t pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The full packet must always be written, regardless of whether the union is used.
|
|
|
|
struct TombstonedCrashPacket {
|
|
|
|
CrashPacketType packet_type;
|
|
|
|
union {
|
|
|
|
DumpRequest dump_request;
|
|
|
|
} packet;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Comes with a file descriptor via SCM_RIGHTS.
|
|
|
|
// This packet should be sent before an actual dump happens.
|
|
|
|
struct InterceptRequest {
|
2017-05-24 16:07:25 +02:00
|
|
|
DebuggerdDumpType dump_type;
|
2016-10-19 03:17:52 +02:00
|
|
|
int32_t pid;
|
|
|
|
};
|
|
|
|
|
2017-03-31 01:40:47 +02:00
|
|
|
enum class InterceptStatus : uint8_t {
|
2017-05-24 16:07:25 +02:00
|
|
|
// Returned when an intercept of a different type has already been
|
|
|
|
// registered (and is active) for a given PID.
|
|
|
|
kFailedAlreadyRegistered,
|
|
|
|
// Returned in all other failure cases.
|
2017-03-31 01:40:47 +02:00
|
|
|
kFailed,
|
|
|
|
kStarted,
|
|
|
|
kRegistered,
|
|
|
|
};
|
|
|
|
|
2016-10-19 03:17:52 +02:00
|
|
|
// Sent either immediately upon failure, or when the intercept has been used.
|
|
|
|
struct InterceptResponse {
|
2017-03-31 01:40:47 +02:00
|
|
|
InterceptStatus status;
|
2016-10-19 03:17:52 +02:00
|
|
|
char error_message[127]; // always null-terminated
|
|
|
|
};
|
2017-08-21 23:31:17 +02:00
|
|
|
|
|
|
|
// Sent from handler to crash_dump via pipe.
|
2018-08-07 00:38:29 +02:00
|
|
|
struct __attribute__((__packed__)) CrashInfoHeader {
|
|
|
|
uint32_t version;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct __attribute__((__packed__)) CrashInfoDataV1 {
|
2017-08-21 23:31:17 +02:00
|
|
|
siginfo_t siginfo;
|
|
|
|
ucontext_t ucontext;
|
|
|
|
uintptr_t abort_msg_address;
|
|
|
|
};
|
2018-08-07 00:38:29 +02:00
|
|
|
|
|
|
|
struct __attribute__((__packed__)) CrashInfoDataV2 : public CrashInfoDataV1 {
|
|
|
|
uintptr_t fdsan_table_address;
|
|
|
|
};
|
|
|
|
|
2020-02-14 23:54:31 +01:00
|
|
|
struct __attribute__((__packed__)) CrashInfoDataV3 : public CrashInfoDataV2 {
|
|
|
|
uintptr_t gwp_asan_state;
|
|
|
|
uintptr_t gwp_asan_metadata;
|
|
|
|
};
|
|
|
|
|
2018-08-07 00:38:29 +02:00
|
|
|
struct __attribute__((__packed__)) CrashInfo {
|
|
|
|
CrashInfoHeader header;
|
|
|
|
union {
|
|
|
|
CrashInfoDataV1 v1;
|
|
|
|
CrashInfoDataV2 v2;
|
2020-02-14 23:54:31 +01:00
|
|
|
CrashInfoDataV3 v3;
|
2018-08-07 00:38:29 +02:00
|
|
|
} data;
|
|
|
|
};
|