test_pt_ls: update to execute rewritten binary (both automatically via parseThat...
[dyninst.git] / testsuite / src / dyninst / ParseThat.h
1 #ifndef __PARSE_THAT_H__
2 #define __PARSE_THAT_H__
3
4 #include <string>
5 #include <vector>
6 #include "test_lib.h"
7 //#include "dyninst_comp.h"
8 #include "util.h"
9 //  A (hopefully simple) c++ class interface for issuing parseThat commands
10 //  inside the testsuite
11
12 class ParseThat {
13         public:
14
15         typedef enum {
16                 T_None,
17                 T_Func,
18                 T_Mod,
19                 T_Proc
20         } InstTransaction;
21
22         typedef enum {
23                 PL_Module = 0,
24                 PL_Func = 1,
25                 PL_CFG = 2
26         } ParseLevel;
27
28         typedef enum {
29                 IL_None = 0,
30                 IL_FuncEntry = 1,
31                 IL_FuncExit = 2,
32                 IL_BasicBlock = 3,
33                 IL_MemRead = 4,
34                 IL_MemWrite = 5 
35         } InstLevel;
36
37         TESTLIB_DLL_EXPORT ParseThat();
38         TESTLIB_DLL_EXPORT ~ParseThat();
39
40         TESTLIB_DLL_EXPORT void pt_output_redirect(std::string fname) {pt_out_name = fname;}
41         TESTLIB_DLL_EXPORT void cmd_stdout_redirect(std::string fname) {cmd_stdout_name = fname;}
42         TESTLIB_DLL_EXPORT void cmd_stderr_redirect(std::string fname) {cmd_stderr_name = fname;}
43         TESTLIB_DLL_EXPORT void func_only(std::string fname) {limit_func = fname;}
44         TESTLIB_DLL_EXPORT void module_only(std::string mname) {limit_mod = mname;}
45         TESTLIB_DLL_EXPORT void set_transactions(InstTransaction t) {trans = t;}
46         TESTLIB_DLL_EXPORT void skip_functions_matching(std::string regex) {skip_funcs = regex;}
47         TESTLIB_DLL_EXPORT void skip_modules_matching(std::string regex) {skip_mods = regex;}
48         TESTLIB_DLL_EXPORT void suppress_ipc_messages() {suppress_ipc  = true;}
49         TESTLIB_DLL_EXPORT void set_verbosity(int v) {verbosity = v;}
50         TESTLIB_DLL_EXPORT void dont_fork() {nofork = true;}
51         TESTLIB_DLL_EXPORT void set_timeout(unsigned secs) {timeout_secs  = secs;}
52         TESTLIB_DLL_EXPORT void set_tracing() {do_trace = true;}
53         TESTLIB_DLL_EXPORT void set_tracesize(unsigned ntraces) {tracelength  = ntraces;}
54         TESTLIB_DLL_EXPORT void print_summary() {print_summary_ = true;}
55         TESTLIB_DLL_EXPORT void recursive() {do_recursive = true;}
56         TESTLIB_DLL_EXPORT void setParseLevel(ParseLevel pl) {parse_level = pl;}
57         TESTLIB_DLL_EXPORT void use_rewriter(std::string dest) {rewrite_filename = dest;}
58         TESTLIB_DLL_EXPORT void use_merge() {merge_tramps = true;}
59         TESTLIB_DLL_EXPORT void inst_level(InstLevel il) {inst_level_ = il;}
60         TESTLIB_DLL_EXPORT void include_libs() {include_libs_ = true;}
61
62         TESTLIB_DLL_EXPORT test_results_t operator()(std::string exec_path, 
63                         std::vector<std::string> &args);
64         TESTLIB_DLL_EXPORT test_results_t operator()(int pid);
65
66         TESTLIB_DLL_EXPORT static test_results_t sys_execute(std::string cmd, 
67                         std::vector<std::string> &args, 
68                         std::string stdout_redirect = emptyString, 
69                         std::string stderr_redirect = emptyString);
70
71         static std::string emptyString;
72         private:
73         std::string pt_path;
74         std::string cmd_stdout_name;
75         std::string cmd_stderr_name;
76         std::string pt_out_name;
77         std::string rewrite_filename;
78         InstTransaction trans;
79         std::string skip_mods; // regex string
80         std::string skip_funcs; // regex string
81         std::string limit_mod;  // only use this module
82         std::string limit_func; // only use this func
83
84         bool suppress_ipc; //
85         bool nofork;
86         unsigned verbosity; // presently can be 0-7
87         unsigned int timeout_secs;
88         bool do_trace;
89         unsigned tracelength;
90         bool print_summary_;
91         ParseLevel parse_level;
92         bool do_recursive;
93         bool merge_tramps;
94         InstLevel inst_level_;
95         bool include_libs_;
96
97         bool setup_args(std::vector<std::string> &);
98         test_results_t pt_execute(std::vector<std::string> &);
99
100 };
101 #endif