1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef _EVENT_H |
6 | #define _EVENT_H |
7 | #include <inttypes.h> |
8 | #include <time.h> |
9 | |
10 | #if !defined(__mips__) |
11 | #define __NR_Linux (0) |
12 | #else |
13 | #include <asm/unistd.h> |
14 | #endif |
15 | |
16 | #define DUMP_REASON_syscall_exit (-1000) |
17 | #define DUMP_REASON_signal (__NR_Linux + 1000) |
18 | #define DUMP_REASON_dbus (DUMP_REASON_signal + 1000) |
19 | #define DUMP_REASON_x11 (DUMP_REASON_dbus + 1000) |
20 | #define DUMP_REASON_ptrace (DUMP_REASON_x11 + 1000) |
21 | #define DUMP_REASON_INVALID (0xffff) |
22 | |
23 | #define MAP_FILE_NAME "map.dump" |
24 | #define CONTEXT_FILE_NAME "context.dump" |
25 | #define X11DBUS_FILE_NAME "other.dump" |
26 | #define EXEC_FILE_NAME "hardlink-" |
27 | #define LATEST_TRACE_NAME "latest-trace" |
28 | #define (512) |
29 | |
30 | #ifdef __cplusplus |
31 | extern "C" { |
32 | #endif |
33 | |
34 | typedef struct tagEventEntry { |
35 | double time; // unit is millisecond |
36 | double duration; // unit is millisecond |
37 | int16_t type; |
38 | uint16_t thread_num; |
39 | uint16_t tid; /* id of the thread event occurred */ |
40 | uint16_t ; |
41 | long offset; /* offset in trace file */ |
42 | long syscall_result; |
43 | }EventEntry; |
44 | |
45 | int create_timeline(const char *maps_file, |
46 | const char *context_file, void **pp_timeline); |
47 | int destroy_timeline(void *timeline); |
48 | int get_event(void *timeline, int index, EventEntry *entry); |
49 | const EventEntry *get_event_pointer(void *timeline); |
50 | int (void *timeline, int index, char *buf, int buf_size); |
51 | int generate_coredump(void *timeline, int index, const char *corefile, int verbose); |
52 | |
53 | // debug functions |
54 | const char *get_event_name(int type); |
55 | const char *syscall_name(long syscall_no); |
56 | const char *signal_name(int sig); |
57 | const char *errno_name(int err); |
58 | const char *sicode_name(int code, int sig); |
59 | const char *ptrace_event_name(int event); |
60 | #ifdef __cplusplus |
61 | } |
62 | #endif |
63 | |
64 | #endif // #ifndef _EVENT_H |
65 | |