* Copyright (c) 2024 Huawei Device Co., Ltd.
* 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.
*/
#ifndef DFX_SOCKET_REQUEST_H
#define DFX_SOCKET_REQUEST_H
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
static const char* const FAULTLOGGERD_SOCK_BASE_PATH = "/dev/unix/socket/";
#ifdef FAULTLOGGERD_TEST
static const char* const SERVER_SOCKET_NAME = "test.faultloggerd.server";
static const char* const SERVER_CRASH_SOCKET_NAME = "test.faultloggerd.crash.server";
static const char* const SERVER_SDKDUMP_SOCKET_NAME = "test.faultloggerd.sdkdump.server";
#else
static const char* const SERVER_SOCKET_NAME = "faultloggerd.server";
static const char* const SERVER_CRASH_SOCKET_NAME = "faultloggerd.crash.server";
static const char* const SERVER_SDKDUMP_SOCKET_NAME = "faultloggerd.sdkdump.server";
#endif
* @brief type of request
*
*/
typedef enum FaultLoggerType : int32_t {
CPP_CRASH = 2,
JS_CRASH,
APP_FREEZE,
CPP_STACKTRACE = 101,
JS_STACKTRACE,
JS_HEAP_SNAPSHOT,
JS_RAW_SNAPSHOT,
JS_HEAP_LEAK_LIST,
LEAK_STACKTRACE,
FFRT_CRASH_LOG,
JIT_CODE_LOG,
ADDR_SANITIZER,
CJ_HEAP_SNAPSHOT = 110,
COREDUMP_LITE = 111,
NATIVE_SNAPSHOT = 112,
MINIDUMP = 113,
KMP_HEAP_SNAPSHOT = 114,
JSVM_HEAP_SNAPSHOT = 115,
ARKWEB_JS_HEAP_SNAPSHOT = 117,
ARKWEB_JS_RAW_SNAPSHOT = 118,
HYBRID_JS_HEAP_SNAPSHOT = 119,
STATIC_JS_HEAP_SNAPSHOT = 120,
STATIC_JS_RAW_SNAPSHOT = 121,
JS_MAP = 122
} FaultLoggerType;
* @brief type of faultlogger client
*
*/
typedef enum FaultLoggerClientType : int8_t {
LOG_FILE_DES_CLIENT,
SDK_DUMP_CLIENT,
PIPE_FD_CLIENT,
REPORT_EXCEPTION_CLIENT,
DUMP_STATS_CLIENT,
COREDUMP_CLIENT,
COREDUMP_PROCESS_DUMP_CLIENT,
PIPE_FD_LITEPERF_CLIENT,
LIMITED_PROCESS_DUMP_CLIENT,
PIPE_FD_LIMITED_CLIENT,
MINIDUMP_CLIENT,
} FaultLoggerClientType;
typedef struct RequestDataHead {
int8_t clientType;
int32_t clientPid;
} __attribute__((packed)) RequestDataHead;
typedef struct CoreDumpRequestData {
RequestDataHead head;
int32_t pid;
uint64_t endTime;
int32_t coredumpAction;
} __attribute__((packed)) CoreDumpRequestData;
* @brief type of coredump Action
*
*/
typedef enum CoreDumpAction : int32_t {
DO_CORE_DUMP,
CANCEL_CORE_DUMP,
} CoreDumpAction;
* @brief type of coredump Status
*
*/
typedef enum CoreDumpStatus : int32_t {
CORE_DUMP_START = 1,
CORE_DUMP_END,
CORE_DUMP_ERROR,
} CoreDumpStatus;
typedef struct CoreDumpStatusData {
RequestDataHead head;
int32_t pid;
int32_t processDumpPid;
int32_t coredumpStatus;
char fileName[256];
int32_t retCode;
} __attribute__((packed)) CoreDumpStatusData;
typedef struct CoreDumpResult {
char fileName[256];
int32_t retCode;
} __attribute__((packed)) CoreDumpResult;
typedef struct SdkDumpRequestData {
RequestDataHead head;
int32_t pid;
int32_t sigCode;
int32_t tid;
int32_t callerTid;
uint64_t time;
uint64_t endTime;
} __attribute__((packed)) SdkDumpRequestData;
* @brief type of request about pipe
*/
typedef enum FaultLoggerPipeType : int8_t {
PIPE_FD_READ = 0,
PIPE_FD_WRITE,
PIPE_FD_DELETE,
} FaultLoggerPipeType;
typedef struct PipFdRequestData {
RequestDataHead head;
int32_t pid;
int8_t pipeType;
} __attribute__((packed)) PipFdRequestData;
typedef struct LitePerfFdRequestData {
RequestDataHead head;
int32_t pid;
uid_t uid;
int8_t pipeType;
int32_t timeout;
bool checkLimit;
} __attribute__((packed)) LitePerfFdRequestData;
typedef struct LiteDumpFdRequestData {
RequestDataHead head;
int32_t pid;
uid_t uid;
int8_t pipeType;
char processName[128];
} __attribute__((packed)) LiteDumpFdRequestData;
typedef struct MiniDumpRequestData {
RequestDataHead head;
int32_t pid;
uid_t uid;
int8_t enableMinidump;
int8_t enableMinidumpToCrashLog;
} __attribute__((packed)) MiniDumpRequestData;
* @brief request information
*/
typedef struct FaultLoggerdRequest {
RequestDataHead head;
int32_t pid;
int32_t type;
int32_t tid;
uint64_t time;
int32_t minidump;
} __attribute__((packed)) FaultLoggerdRequest;
* @brief type of faultloggerd stats request
*/
typedef enum FaultLoggerdStatType : int32_t {
DUMP_CATCHER = 0,
PROCESS_DUMP
} FaultLoggerdStatType;
* @brief struct of faultloggerd stats request
*/
typedef struct FaultLoggerdStatsRequest {
RequestDataHead head;
int32_t type;
int32_t pid;
uint64_t requestTime;
uint64_t signalTime;
uint64_t processdumpStartTime;
uint64_t processdumpFinishTime;
uint64_t dumpCatcherFinishTime;
uint64_t keyThreadUnwindTimestamp;
int32_t result;
uint32_t targetProcessThreadCount;
uint32_t writeDumpInfoCost;
uintptr_t offset;
uint64_t smoParseTime;
uint32_t pssMemory;
char summary[128];
char callerElf[128];
char callerProcess[128];
char targetProcess[128];
} __attribute__((packed)) FaultLoggerdStatsRequest;
typedef enum ResponseCode : int32_t {
RECEIVE_DATA_FAILED = -4,
SEND_DATA_FAILED = -3,
CONNECT_FAILED = -2,
DEFAULT_ERROR_CODE = -1,
REQUEST_SUCCESS = 0,
UNKNOWN_CLIENT_TYPE = 1,
INVALID_REQUEST_DATA = 2,
REQUEST_REJECT = 3,
ABNORMAL_SERVICE = 4,
SDK_DUMP_REPEAT,
SDK_DUMP_NOPROC,
SDK_PROCESS_CRASHED,
CORE_DUMP_REPEAT,
CORE_PROCESS_CRASHED,
CORE_DUMP_NOPROC,
CORE_DUMP_CANCEL,
CORE_DUMP_GENERATE_FAIL,
RESOURCE_LIMIT,
} ResponseCode;
#ifdef __cplusplus
}
#endif
#endif