Added parseThat feature to automatically binary search through instrumentation points...
[dyninst.git] / parseThat / src / ipc.h
1 #ifndef __IPC_H__
2 #define __IPC_H__
3
4 #include <cstdarg>
5 using namespace std;
6
7 #include "config.h"
8 #include "log.h"
9
10 enum statusID {
11     ID_INFO,
12     ID_TEST,
13     ID_WARN,
14     ID_FAIL,
15     ID_PASS
16 };
17
18 enum messageID {
19     ID_INVALID,
20
21     ID_INIT_CREATE_BPATCH,
22     ID_INIT_REGISTER_EXIT,
23     ID_INIT_REGISTER_FORK,
24     ID_INIT_CREATE_PROCESS,
25     ID_INIT_ATTACH_PROCESS,
26     ID_INIT_MERGE_TRAMP,
27     ID_INIT_SAVE_WORLD,
28     ID_INIT_GET_IMAGE,
29     ID_POST_FORK,
30
31     ID_PARSE_MODULE,
32     ID_PARSE_FUNC,
33     ID_PARSE_MODULE_CFG,
34     ID_PARSE_FUNC_CFG,
35
36     ID_INST_START_TRANS,
37     ID_INST_END_TRANS,
38
39     ID_INST_MODULE,
40     ID_INST_FUNC,
41     ID_INST_FUNC_ENTRY,
42     ID_INST_FUNC_EXIT,
43     ID_INST_BASIC_BLOCK,
44     ID_INST_MEM_READ,
45     ID_INST_MEM_WRITE,
46
47     ID_INST_GET_BB,
48     ID_NO_BB,
49     ID_INST_GET_BB_POINTS,
50     ID_GET_CFG,
51     ID_INST_BB_LIST,
52
53     ID_INST_FIND_INT,
54     ID_INST_MALLOC_INT,
55     ID_FAILED_INST_INIT_INT,
56     ID_INST_GET_FUNCS,
57     ID_INST_FIND_POINTS,
58     ID_NO_POINTS,
59     ID_INST_INSERT_CODE,
60
61     ID_TRACE_INIT,
62     ID_TRACE_INIT_MUTATEE,
63     ID_TRACE_FIND_OPEN,
64     ID_TRACE_FIND_WRITE,
65     ID_TRACE_OPEN_READER,
66     ID_TRACE_OPEN_WRITER,
67     ID_TRACE_INSERT,
68     ID_TRACE_INSERT_ONE,
69     ID_TRACE_READ,
70     ID_TRACE_POINT,
71
72     ID_ALLOC_COUNTER,
73
74     ID_RUN_CHILD,
75     ID_WAIT_TERMINATION, 
76     ID_WAIT_STATUS_CHANGE,
77     ID_POLL_STATUS_CHANGE,
78     ID_EXIT_CODE,
79     ID_EXIT_SIGNAL,
80     ID_SAVE_WORLD,
81     ID_DETACH_CHILD,
82     ID_STOP_CHILD,
83
84     ID_SUMMARY_INSERT,
85     ID_SUMMARY_START,
86     ID_SUMMARY_END,
87
88     ID_DATA_STRING,
89
90     ID_CRASH_HUNT_NUM_ACTIONS,
91
92     ID_MAX
93 };
94
95 #define encodeID(msgID, pri, statID)    ( ((msgID) << 8) | ((pri) << 4) | (statID) )
96 #define getMsgID(x)                     ((messageID)((x) >> 8))
97 #define getStatID(x)                    ((statusID)((x) & 0xF))
98 #define getPriID(x)                     ((logLevel)(((x) >> 4) & 0xF))
99
100 struct message {
101     unsigned id_data;
102     char *str_data;
103     int int_data;
104 };
105
106 void setSigHandlers();
107 void resetSigHandlers();
108 const char *msgStr(messageID);
109 message *readMsg(FILE *, message *);
110 void printMsg(FILE *, messageID, int = 0);
111 void sendMsg(FILE *, messageID, logLevel, statusID = ID_TEST, const char * = NULL);
112 void sendMsg(FILE *, messageID, logLevel, statusID, int);
113 void sendStr(FILE *, const char *fmt, ...);
114 void killProcess(pid_t);
115 void cleanupProcess();
116 void cleanupFinal();
117
118 int readStr(FILE *, char *, int);
119
120 #endif