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: test_mem_5.C,v 1.1 2008/10/30 19:21:59 legendre Exp $
35 * #Desc: Instrumentation w/effective address snippet
37 * #Arch: !(sparc_sun_solaris2_4_test,,rs6000_ibm_aix4_1_test,i386_unknown_linux2_0_test,x86_64_unknown_linux2_4_test,i386_unknown_nt4_0_test,ia64_unknown_linux2_4_test)
42 #include "BPatch_Vector.h"
43 #include "BPatch_thread.h"
44 #include "BPatch_snippet.h"
49 #include "dyninst_comp.h"
50 class test_mem_5_Mutator : public DyninstMutator {
52 virtual test_results_t executeTest();
54 extern "C" DLLEXPORT TestMutator *test_mem_5_factory() {
55 return new test_mem_5_Mutator();
58 // Instrument all accesses with an effective address snippet
59 // static int mutatorTest(BPatch_thread *bpthr, BPatch_image *bpimg)
60 test_results_t test_mem_5_Mutator::executeTest() {
62 const char* testdesc = "instrumentation w/effective address snippet";
63 #if !defined(sparc_sun_solaris2_4_test) \
64 &&(!defined(rs6000_ibm_aix4_1_test) || defined(AIX5)) \
65 && !defined(i386_unknown_linux2_0_test) \
66 && !defined(x86_64_unknown_linux2_4_test) /* Blind duplication - Ray */ \
67 && !defined(i386_unknown_nt4_0_test) \
68 && !defined(ia64_unknown_linux2_4_test)
69 //skiptest(testnum, testdesc);
72 BPatch_Set<BPatch_opCode> axs;
73 axs.insert(BPatch_opLoad);
74 axs.insert(BPatch_opStore);
75 axs.insert(BPatch_opPrefetch);
78 BPatch_Vector<BPatch_function *> found_funcs;
79 const char *inFunction = "loadsnstores";
80 if ((NULL == appImage->findFunction(inFunction, found_funcs, 1)) || !found_funcs.size()) {
81 logerror(" Unable to find function %s\n",
86 if (1 < found_funcs.size()) {
87 logerror("%s[%d]: WARNING : found %d functions named %s. Using the first.\n",
88 __FILE__, __LINE__, found_funcs.size(), inFunction);
91 BPatch_Vector<BPatch_point *> *res1 = found_funcs[0]->findPoint(axs);
94 failtest(testnum, testdesc, "Unable to find function \"loadsnstores\".\n");
96 //logerror("Doing test %d!!!!!!\n", testnum);
97 if (instEffAddr(appThread, "EffAddr", res1, false) < 0) {
101 //appThread->detach(false);
106 // External Interface
107 // extern "C" TEST_DLL_EXPORT int test6_5_mutatorMAIN(ParameterDict ¶m)
110 // bpatch = (BPatch *)(param["bpatch"]->getPtr());
111 // BPatch_thread *appThread = (BPatch_thread *)(param["appThread"]->getPtr());
113 // // Get log file pointers
114 // FILE *outlog = (FILE *)(param["outlog"]->getPtr());
115 // FILE *errlog = (FILE *)(param["errlog"]->getPtr());
116 // setOutputLog(outlog);
117 // setErrorLog(errlog);
119 // // Read the program's image and get an associated image object
120 // BPatch_image *appImage = appThread->getImage();
122 // // Run mutator code
123 // return mutatorTest(appThread, appImage);