Skip to content

Commit f74cc5c

Browse files
committed
some changes in the greenlist of deadCode methods
1 parent 3be6621 commit f74cc5c

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

src/main/java/edu/uniandes/tsdl/mutapk/MutAPK.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class MutAPK {
6969
static int confidenceLevel = -1;
7070
static int marginError = -1;
7171

72-
static OperatorBundle operatorBundle;
72+
static OperatorBundle operatorBundle;
7373

7474
static HashMap<String, SmaliAST> smaliASTs = new HashMap<String, SmaliAST>();
7575

@@ -115,11 +115,6 @@ public static void runMutAPK(String[] args) throws NumberFormatException, FileNo
115115
String apkAbsolutePath = APKToolWrapper.openAPK(apkPath, extraPath);
116116
System.out.println("--------------------------------------");
117117

118-
// Text-Based operators selected
119-
List<MutationLocationDetector> textBasedDetectors = operatorBundle.getTextBasedDetectors();
120-
121-
// Run detection phase for Text-based detectors
122-
HashMap<MutationType, List<MutationLocation>> locations = TextBasedDetectionsProcessor.process("temp", textBasedDetectors);
123118

124119
//--------------------------------------------
125120
// Run detection phase for AST-based detectors
@@ -130,7 +125,7 @@ public static void runMutAPK(String[] args) throws NumberFormatException, FileNo
130125
if(ignoreDeadCode) {
131126

132127
Long initTime = System.currentTimeMillis();
133-
128+
134129
// Generate the Call Graph
135130
System.out.println("## Call Graph Results");
136131
System.out.println("");
@@ -165,26 +160,33 @@ public static void runMutAPK(String[] args) throws NumberFormatException, FileNo
165160

166161
// Check Dead Code Methods
167162

168-
// for(Entry<String, HashMap<String, CallGraphNode>> entry : deadCode.entrySet()) {
169-
// System.out.println(entry.getKey());
170-
// for(Entry<String, CallGraphNode> entryy : entry.getValue().entrySet()) {
171-
// System.out.println(" "+entryy.getKey());
172-
// }
173-
// }
163+
// for(Entry<String, HashMap<String, CallGraphNode>> entry : deadCode.entrySet()) {
164+
// System.out.println(entry.getKey());
165+
// for(Entry<String, CallGraphNode> entryy : entry.getValue().entrySet()) {
166+
// System.out.println(" "+entryy.getKey());
167+
// }
168+
// }
174169

175170
// Prune ASTs
176171
for(Entry<String, SmaliAST> entry: smaliASTs.entrySet()) {
177172
if(deadCode.get(entry.getKey())!=null) {
178173
smaliASTs.put(entry.getKey(), ASTHelper.pruneAST(entry.getValue(),deadCode.get(entry.getKey())));
179174
}
180175
}
181-
176+
182177
Long duration = (System.currentTimeMillis()-initTime);
183178
System.out.println("");
184179
System.out.println("> It took "+duration+" miliseconds to remove dead code from APK analysis.");
185180

186181

187182
}
183+
184+
// Text-Based operators selected
185+
List<MutationLocationDetector> textBasedDetectors = operatorBundle.getTextBasedDetectors();
186+
187+
// Run detection phase for Text-based detectors
188+
HashMap<MutationType, List<MutationLocation>> locations = TextBasedDetectionsProcessor.process("temp", textBasedDetectors);
189+
188190
// Generate PFP over pruned ASTs
189191
for(Entry<String, SmaliAST> entry : smaliASTs.entrySet()) {
190192
SmaliAST temp = entry.getValue();
@@ -267,20 +269,12 @@ public static void runMutAPK(String[] args) throws NumberFormatException, FileNo
267269
private static boolean methodIsDeadCode(CallGraphNode cGN) {
268270

269271
String[] exceptions = new String[] {
270-
"<init>",
271-
"<clinit>",
272-
"init",
273-
"onClick",
274-
"onCreate",
275-
"onOptionsItemSelected",
276-
"onCreateOptionsMenu",
277-
"onResume",
278-
"update",
279-
"query",
280-
"getType",
281-
"insert",
282-
"doInBackground",
283-
"onPostExecute"
272+
"<init>","<clinit>","init","onClick","onCreate","onOptionsItemSelected","onCreateOptionsMenu","onResume","update",
273+
"query","getType","insert","doInBackground","onPostExecute","delete","clone","onCreateDialog","onCancel","onRestoreInstanceState",
274+
"onSaveInstanceState","onRetainNonConfigurationInstance","run","getParent","onNothingSelected","onItemSelected","onProgressUpdate",
275+
"onPreExecute", "onReceive","toString","onItemClick","getUri","onPreferenceClick","onTabChanged","getDropDownView","getCount",
276+
"getViewTypeCount","getView","registerDataSetObserver","saved","isEnabled","onActivityResult","unregisterDataSetObserver","attach",
277+
"onChange","isIntentAvailable","onDateChanged","onContextItemSelected", "onCreateContextMenu"
284278
};
285279

286280
if(cGN.getCallers().size()>0) {

src/main/java/edu/uniandes/tsdl/mutapk/helper/CallGraphHelper.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ public static HashMap<String, HashMap<String, CallGraphNode>> getCallGraph(HashM
4646
&& !methodCallSegments[1].startsWith("findViewById")
4747
&& !methodCallSegments[1].startsWith("getActivity")
4848
&& !methodCallSegments[1].startsWith("getContentResolver")
49-
// && !methodCallSegments[1].startsWith("getParent")
49+
&& !methodCallSegments[1].startsWith("setContentView")
50+
&& !methodCallSegments[1].startsWith("getStatus")
51+
&& !methodCallSegments[1].startsWith("removeDialog")
52+
&& !methodCallSegments[1].startsWith("execute")
53+
&& !methodCallSegments[1].startsWith("getString")
54+
&& !methodCallSegments[1].startsWith("getParent")
55+
&& !methodCallSegments[1].startsWith("getId")
56+
&& !methodCallSegments[1].startsWith("getText")
57+
&& !methodCallSegments[1].startsWith("onSaveInstanceState")
5058
) {
5159
// System.out.println(" ###"+methodCall);
5260
contador++;

test/MutAPK-2.0.0.jar

770 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)