blob: 144efc8f7c42f04779af530178e6b98aa66f9421 [file] [log] [blame]
Josh Gaocbe70cb2016-10-18 18:17:52 -07001/*
2 * Copyright 2016, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stdint.h>
20
21// Sockets in the ANDROID_SOCKET_NAMESPACE_RESERVED namespace.
22// Both sockets are SOCK_SEQPACKET sockets, so no explicit length field is needed.
23constexpr char kTombstonedCrashSocketName[] = "tombstoned_crash";
Narayan Kamath922f6b22017-05-15 15:59:30 +010024constexpr char kTombstonedJavaTraceSocketName[] = "tombstoned_java_trace";
Josh Gaocbe70cb2016-10-18 18:17:52 -070025constexpr char kTombstonedInterceptSocketName[] = "tombstoned_intercept";
26
27enum class CrashPacketType : uint8_t {
28 // Initial request from crash_dump.
29 kDumpRequest = 0,
30
31 // Notification of a completed crash dump.
32 // Sent after a dump is completed and the process has been untraced, but
33 // before it has been resumed with SIGCONT.
34 kCompletedDump,
35
36 // Responses to kRequest.
37 // kPerformDump sends along an output fd via cmsg(3).
38 kPerformDump = 128,
39 kAbortDump,
40};
41
42struct DumpRequest {
43 int32_t pid;
44};
45
46// The full packet must always be written, regardless of whether the union is used.
47struct TombstonedCrashPacket {
48 CrashPacketType packet_type;
49 union {
50 DumpRequest dump_request;
51 } packet;
52};
53
54// Comes with a file descriptor via SCM_RIGHTS.
55// This packet should be sent before an actual dump happens.
56struct InterceptRequest {
57 int32_t pid;
58};
59
Josh Gao460b3362017-03-30 16:40:47 -070060enum class InterceptStatus : uint8_t {
61 kFailed,
62 kStarted,
63 kRegistered,
64};
65
Josh Gaocbe70cb2016-10-18 18:17:52 -070066// Sent either immediately upon failure, or when the intercept has been used.
67struct InterceptResponse {
Josh Gao460b3362017-03-30 16:40:47 -070068 InterceptStatus status;
Josh Gaocbe70cb2016-10-18 18:17:52 -070069 char error_message[127]; // always null-terminated
70};