Introductory parseThat commit. - - - - - - - - - - - - - - - - - - - - -
[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_GET_IMAGE,
26     ID_POST_FORK,
27
28     ID_PARSE_MODULE,
29     ID_PARSE_FUNC,
30     ID_PARSE_MODULE_CFG,
31     ID_PARSE_FUNC_CFG,
32
33     ID_INST_START_TRANS,
34     ID_INST_END_TRANS,
35
36     ID_INST_MODULE,
37     ID_INST_FUNC,
38     ID_INST_FUNC_ENTRY,
39     ID_INST_FUNC_EXIT,
40     ID_INST_BASIC_BLOCK,
41     ID_INST_MEM_READ,
42     ID_INST_MEM_WRITE,
43
44     ID_INST_GET_BB,
45     ID_NO_BB,
46     ID_INST_GET_BB_POINTS,
47     ID_GET_CFG,
48     ID_INST_BB_LIST,
49
50     ID_INST_FIND_INT,
51     ID_INST_MALLOC_INT,
52     ID_FAILED_INST_INIT_INT,
53     ID_INST_GET_FUNCS,
54     ID_INST_FIND_POINTS,
55     ID_NO_POINTS,
56     ID_INST_INSERT_CODE,
57
58     ID_ALLOC_COUNTER,
59
60     ID_RUN_CHILD,
61     ID_WAIT_TERMINATION,
62     ID_WAIT_STATUS_CHANGE,
63     ID_EXIT_CODE,
64     ID_EXIT_SIGNAL,
65
66     ID_SUMMARY_INSERT,
67     ID_SUMMARY_START,
68     ID_SUMMARY_END,
69
70     ID_DATA_STRING,
71
72     ID_MAX
73 };
74
75 #define encodeID(msgID, pri, statID)    ( ((msgID) << 8) | ((pri) << 4) | (statID) )
76 #define getMsgID(x)                     ((messageID)((x) >> 8))
77 #define getStatID(x)                    ((statusID)((x) & 0xF))
78 #define getPriID(x)                     ((logLevel)(((x) >> 4) & 0xF))
79
80 struct message {
81     unsigned id_data;
82     char *str_data;
83     int int_data;
84 };
85
86 void setSigHandlers();
87 void resetSigHandlers();
88 const char *msgStr(messageID);
89 message *readMsg(FILE *, message *);
90 void printMsg(FILE *, messageID, int = 0);
91 void sendMsg(FILE *, messageID, logLevel, statusID = ID_TEST, const char * = NULL);
92 void sendMsg(FILE *, messageID, logLevel, statusID, int);
93 void sendStr(FILE *, const char *fmt, ...);
94 void killProcess(pid_t);
95 void cleanupProcesses();
96
97 int readStr(FILE *, char *, int);
98
99 #endif