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.
21 #include "instrumentation/dbi.h"
23 using namespace instrumentation
;
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
;
48 * @brief callback to initialize trace exploration.
50 * @param data unused parameters because all initialized data are global variables
53 VOID
start_exploring(VOID
* data
)
55 instruction_at_address
.clear();
56 instruction_at_execorder
.clear();
57 cbranch_at_execorder
.clear();
63 * @brief callback to finalize some operations (e.g. save logs, etc).
69 VOID
stop_exploring(INT32 code
, VOID
* data
)
75 int main(int argc
, char* 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