Josh Gao | cbe70cb | 2016-10-18 18:17:52 -0700 | [diff] [blame] | 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 | // Sockets in the ANDROID_SOCKET_NAMESPACE_RESERVED namespace. |
| 22 | // Both sockets are SOCK_SEQPACKET sockets, so no explicit length field is needed. |
| 23 | constexpr char kTombstonedCrashSocketName[] = "tombstoned_crash"; |
Narayan Kamath | 922f6b2 | 2017-05-15 15:59:30 +0100 | [diff] [blame] | 24 | constexpr char kTombstonedJavaTraceSocketName[] = "tombstoned_java_trace"; |
Josh Gao | cbe70cb | 2016-10-18 18:17:52 -0700 | [diff] [blame] | 25 | constexpr char kTombstonedInterceptSocketName[] = "tombstoned_intercept"; |
| 26 | |
| 27 | enum 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 | |
| 42 | struct DumpRequest { |
| 43 | int32_t pid; |
| 44 | }; |
| 45 | |
| 46 | // The full packet must always be written, regardless of whether the union is used. |
| 47 | struct 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. |
| 56 | struct InterceptRequest { |
| 57 | int32_t pid; |
| 58 | }; |
| 59 | |
Josh Gao | 460b336 | 2017-03-30 16:40:47 -0700 | [diff] [blame] | 60 | enum class InterceptStatus : uint8_t { |
| 61 | kFailed, |
| 62 | kStarted, |
| 63 | kRegistered, |
| 64 | }; |
| 65 | |
Josh Gao | cbe70cb | 2016-10-18 18:17:52 -0700 | [diff] [blame] | 66 | // Sent either immediately upon failure, or when the intercept has been used. |
| 67 | struct InterceptResponse { |
Josh Gao | 460b336 | 2017-03-30 16:40:47 -0700 | [diff] [blame] | 68 | InterceptStatus status; |
Josh Gao | cbe70cb | 2016-10-18 18:17:52 -0700 | [diff] [blame] | 69 | char error_message[127]; // always null-terminated |
| 70 | }; |