Still cannot know why it does not work
[PathExplorer.git] / src / main.cpp
blob4be0559172ff8a23f2d3c6255baa6fb4b3875a86
1 /*
2 * Copyright (C) 2014 Ta Thanh Dinh <thanhdinh.ta@inria.fr>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "main.h"
21 #include "instrumentation/dbi.h"
23 using namespace instrumentation;
25 bool debug_enabled;
27 ADDRINT received_message_address;
28 INT32 received_message_length;
29 UINT32 current_execorder;
30 UINT32 exectrace_max_length;
31 UINT32 total_reexec_times;
32 UINT32 max_local_reexec_number;
33 UINT32 min_bridge_length;
35 boost::unordered_map<ADDRINT, ptr_instruction_t> instruction_at_address;
36 boost::unordered_map<UINT32, ptr_instruction_t> instruction_at_execorder;
37 boost::unordered_map<UINT32, ptr_cbranch_t> cbranch_at_execorder;
38 boost::unordered_map<UINT32, ptr_checkpoint_t> checkpoint_at_execorder;
39 boost::unordered_map<UINT32, exeorders_t> checkpoint_execorders_of_cbranch_at_execorder;
40 boost::unordered_map<UINT32, addresses_t> inputaddrs_affecting_cbranch_at_execorder;
41 boost::unordered_map<UINT32, ptr_insoperands_t> outerface_at_execorder;
42 boost::unordered_map<ADDRINT, UINT8> original_msgstate_at_address;
43 boost::unordered_map<ADDRINT, UINT8> original_memstate_at_address;
44 boost::unordered_map<ADDRINT, UINT8> current_memstate_at_address;
45 boost::unordered_map<UINT32, UINT32> target_execorder_of_bridge_at_execorder;
47 /**
48 * @brief callback to initialize trace exploration.
50 * @param data unused parameters because all initialized data are global variables
51 * @return VOID
53 VOID start_exploring(VOID* data)
55 instruction_at_address.clear();
56 instruction_at_execorder.clear();
57 cbranch_at_execorder.clear();
58 return;
62 /**
63 * @brief callback to finalize some operations (e.g. save logs, etc).
65 * @param code unused
66 * @param data ...
67 * @return VOID
69 VOID stop_exploring(INT32 code, VOID* data)
71 return;
75 int main(int argc, char* argv[])
77 // initialize PIN
78 PIN_InitSymbols();
79 PIN_Init(argc, argv);
81 // setup instrumentation functions
82 PIN_AddApplicationStartFunction(start_exploring, 0);
83 INS_AddInstrumentFunction(dbi::instrument_instruction_before, 0);
84 PIN_AddSyscallEntryFunction(dbi::instrument_syscall_enter, 0);
85 PIN_AddSyscallExitFunction(dbi::instrument_syscall_exit, 0);
86 PIN_AddFiniFunction(stop_exploring, 0);
88 // pass control to PIN
89 PIN_StartProgram();
90 return 0;