2 * Copyright (c) 1996-2009 Barton P. Miller
4 * We provide the Paradyn Parallel Performance Tools (below
5 * described as "Paradyn") on an AS IS basis, and do not warrant its
6 * validity or performance. We reserve the right to update, modify,
7 * or discontinue this software at any time. We shall have no
8 * obligation to supply such updates or modifications or any other
9 * form of support to you.
11 * By your use of Paradyn, you understand and agree that we (or any
12 * other person or entity with proprietary rights in Paradyn) are
13 * under no obligation to provide either maintenance services,
14 * update services, notices of latent defects, or correction of
15 * defects for Paradyn.
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32 // $Id: test1_14.C,v 1.1 2008/10/30 19:17:43 legendre Exp $
35 * #Desc: Mutator Side - Replace Function Call
41 #include "BPatch_Vector.h"
42 #include "BPatch_thread.h"
43 #include "BPatch_snippet.h"
47 #include "dyninst_comp.h"
49 class test1_14_Mutator : public DyninstMutator {
50 const char *libNameAroot;
55 virtual test_results_t executeTest();
57 extern "C" DLLEXPORT TestMutator *test1_14_factory() {
58 return new test1_14_Mutator();
61 test1_14_Mutator::test1_14_Mutator() : libNameAroot("libtestA") {}
64 // Start Test Case #14 - mutator side (replace function call)
66 // static int mutatorTest(BPatch_thread *appAddrSpace, BPatch_image *appImage)
68 test_results_t test1_14_Mutator::executeTest() {
69 if ( replaceFunctionCalls(appAddrSpace, appImage, "test1_14_func1",
70 "test1_14_func2", "test1_14_call1",
71 14, "replace/remove function call", 1) < 0 ) {
74 if ( replaceFunctionCalls(appAddrSpace, appImage, "test1_14_func1",
75 "test1_14_func3", NULL,
76 14, "replace/remove function call", 1) < 0 ) {
81 #if defined(arch_x86_64_test) || defined(ppc64_linux_test)
82 pointer_size = pointerSize(appImage);
85 bool isStatic = false;
86 if( NULL != appBinEdit ) {
87 isStatic = appBinEdit->isStaticExecutable();
89 strncpy(libNameA, libNameAroot, 127);
90 addLibArchExt(libNameA,127, pointer_size, isStatic);
93 snprintf(libA, 128, "./%s", libNameA);
95 if (!appAddrSpace->loadLibrary(libA)) {
96 logerror("**Failed test1_14 (replace function call)\n");
97 logerror(" Mutator couldn't load %s into mutatee\n", libNameA);
101 if ( replaceFunctionCalls(appAddrSpace, appImage, "test1_14_func1",
102 "test1_14_func4", "test1_14_call2_libA",
103 14, "replace/remove function call", 1) < 0 ) {
108 } // test1_14_Mutator::executeTest()