@@ -48,8 +48,8 @@ public class DecompilerSwitchAnalysisCmd extends BackgroundCommand<Program> {
48
48
protected DecompInterface decompiler ;
49
49
private boolean useArraysForSwitchTables = false ;
50
50
51
- public DecompilerSwitchAnalysisCmd (DecompileResults decopmileResults ) {
52
- this .decompilerResults = decopmileResults ;
51
+ public DecompilerSwitchAnalysisCmd (DecompileResults decompileResults ) {
52
+ this .decompilerResults = decompileResults ;
53
53
}
54
54
55
55
@ Override
@@ -71,20 +71,18 @@ private void analyzeFunction(TaskMonitor monitor) {
71
71
}
72
72
73
73
try {
74
-
75
74
monitor .checkCancelled ();
76
75
77
76
Function f = decompilerResults .getFunction ();
78
77
HighFunction hfunction = decompilerResults .getHighFunction ();
79
- processBranchIND (f , hfunction , monitor );
80
-
81
- monitor .checkCancelled ();
82
-
78
+
83
79
String errMsg = getStatusMsg ();
84
- if (decompilerResults . getHighFunction () == null ) {
80
+ if (hfunction == null ) {
85
81
String msg = (errMsg != null && errMsg .length () != 0 ) ? (": " + errMsg ) : "" ;
86
82
Msg .debug (this , " Failed to decompile function: " + f .getName () + msg );
87
83
}
84
+
85
+ processBranchIND (f , hfunction , monitor );
88
86
}
89
87
catch (Exception e ) {
90
88
if (!monitor .isCancelled ()) {
@@ -248,35 +246,37 @@ public boolean hasAllReferences(TaskMonitor monitor, JumpTable table, Instructio
248
246
Address [] tableDest = table .getCases ();
249
247
Integer [] caseValues = table .getLabelValues ();
250
248
251
- boolean allRefsFound = true ;
252
- int caseIndex ;
253
- for (caseIndex = 0 ; caseIndex < tableDest .length ; caseIndex ++) {
249
+ // check that all cases are already a reference on the instruction, except default
250
+ for (int caseIndex = 0 ; caseIndex < tableDest .length ; caseIndex ++) {
254
251
monitor .checkCancelled ();
255
252
256
253
// a case is default if it is first case to not have a value, or has a magic case value
257
254
boolean isDefaultCase = isDefaultCase (caseValues , caseIndex );
258
255
259
- boolean foundit = false ;
260
256
if (containingBody != null && !containingBody .contains (tableDest [caseIndex ])) {
261
257
// switch case missing from owner function's body
262
- allRefsFound = false ;
263
- break ;
258
+ return false ;
264
259
}
260
+
261
+ boolean foundit = false ;
265
262
for (Reference element : referencesFrom ) {
266
263
if (element .getToAddress ().equals (tableDest [caseIndex ])) {
267
- // good only if this isn't default case
268
- // default case should not be on switching instruction
269
- foundit = !isDefaultCase ;
264
+ foundit = true ;
270
265
break ;
271
- } else if (isDefaultCase ) {
272
- foundit = true ; // not finding default case is good
273
266
}
274
267
}
275
- if (!foundit ) {
276
- allRefsFound = false ;
268
+ if (isDefaultCase ) {
269
+ // default case should not be on switching instruction
270
+ if (foundit ) {
271
+ return false ;
272
+ }
273
+ }
274
+ else if (!foundit ) {
275
+ return false ;
277
276
}
278
277
}
279
- return allRefsFound ;
278
+
279
+ return true ;
280
280
}
281
281
282
282
/*
0 commit comments