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 dump_raw_event(const char *context_file); |
46 | int create_timeline(const char *maps_file, |
47 | const char *context_file, void **pp_timeline); |
48 | int destroy_timeline(void *timeline); |
49 | int get_event(void *timeline, int index, EventEntry *entry); |
50 | const EventEntry *get_event_pointer(void *timeline); |
51 | int (void *timeline, int index, char *buf, int buf_size); |
52 | int generate_coredump(void *timeline, int index, const char *corefile, int verbose); |
53 | |
54 | // debug functions |
55 | const char *get_event_name(int type); |
56 | const char *syscall_name(long syscall_no); |
57 | const char *signal_name(int sig); |
58 | const char *errno_name(int err); |
59 | const char *sicode_name(int code, int sig); |
60 | const char *ptrace_event_name(int event); |
61 | #ifdef __cplusplus |
62 | } |
63 | #endif |
64 | |
65 | #endif // #ifndef _EVENT_H |
66 | |