• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include "dump_type.h"
22 
23 // Sockets in the ANDROID_SOCKET_NAMESPACE_RESERVED namespace.
24 // Both sockets are SOCK_SEQPACKET sockets, so no explicit length field is needed.
25 constexpr char kTombstonedCrashSocketName[] = "tombstoned_crash";
26 constexpr char kTombstonedJavaTraceSocketName[] = "tombstoned_java_trace";
27 constexpr char kTombstonedInterceptSocketName[] = "tombstoned_intercept";
28 
29 enum class CrashPacketType : uint8_t {
30   // Initial request from crash_dump.
31   kDumpRequest = 0,
32 
33   // Notification of a completed crash dump.
34   // Sent after a dump is completed and the process has been untraced, but
35   // before it has been resumed with SIGCONT.
36   kCompletedDump,
37 
38   // Responses to kRequest.
39   // kPerformDump sends along an output fd via cmsg(3).
40   kPerformDump = 128,
41   kAbortDump,
42 };
43 
44 struct DumpRequest {
45   DebuggerdDumpType dump_type;
46   int32_t pid;
47 };
48 
49 // The full packet must always be written, regardless of whether the union is used.
50 struct TombstonedCrashPacket {
51   CrashPacketType packet_type;
52   union {
53     DumpRequest dump_request;
54   } packet;
55 };
56 
57 // Comes with a file descriptor via SCM_RIGHTS.
58 // This packet should be sent before an actual dump happens.
59 struct InterceptRequest {
60   DebuggerdDumpType dump_type;
61   int32_t pid;
62 };
63 
64 enum class InterceptStatus : uint8_t {
65   // Returned when an intercept of a different type has already been
66   // registered (and is active) for a given PID.
67   kFailedAlreadyRegistered,
68   // Returned in all other failure cases.
69   kFailed,
70   kStarted,
71   kRegistered,
72 };
73 
74 // Sent either immediately upon failure, or when the intercept has been used.
75 struct InterceptResponse {
76   InterceptStatus status;
77   char error_message[127];  // always null-terminated
78 };
79