gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25659 - monkey/trunk/pathologist/src/pathologist


From: gnunet
Subject: [GNUnet-SVN] r25659 - monkey/trunk/pathologist/src/pathologist
Date: Thu, 27 Dec 2012 20:04:29 +0100

Author: teichm
Date: 2012-12-27 20:04:29 +0100 (Thu, 27 Dec 2012)
New Revision: 25659

Modified:
   monkey/trunk/pathologist/src/pathologist/action_api.c
Log:
removed unimportant stuff (constants, trivial functionpointers, nullpointers) 
from the report and a little bit more code beauty

Modified: monkey/trunk/pathologist/src/pathologist/action_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/action_api.c       2012-12-27 
14:27:11 UTC (rev 25658)
+++ monkey/trunk/pathologist/src/pathologist/action_api.c       2012-12-27 
19:04:29 UTC (rev 25659)
@@ -24,7 +24,6 @@
 static int failureFunctionStartLine = 0;       // start line number of the 
function in which the failure occurs
 static struct WatchInfo *watchInfoListHead = NULL;
 static struct WatchInfo *watchInfoListTail = NULL;
-static struct Expression *faultyExpression = NULL;
 static struct FileName *fileNameListHead = NULL;
 static struct FileName *fileNameListTail = NULL;
 static struct ScopeEnd *scopeEndListHead = NULL;
@@ -376,6 +375,67 @@
 }
 
 
+static struct Expression*
+analyzeExpressionValue(        struct MONKEY_ACTION_Context *cntxt,
+                                       struct Expression *expr,
+                                       struct Expression **expressionListHead,
+                                       struct Expression **expressionListTail)
+{
+       MONKEY_assert(expr);
+       struct Expression *next = expr->next;
+       struct Expression *removedExpression = expr;
+
+       // We will not evaluate function calls (because GDB will evaluate by 
calling the function)
+       if( expr->isCall )
+               goto remove;
+
+       // We should NOT evaluate assignments, otherwise subsequent expression 
evaluations will be spoiled
+       else if( isAssignment(expr->expressionSyntax) )
+               goto remove;
+
+       // NULL Pointer are also ignored (cause theire NULL)
+       if (strcmp(expr->expressionSyntax, "NULL") == 0 ||
+               strcmp(expr->expressionSyntax, "0x0") == 0 ||
+               strcmp(expr->expressionSyntax, "((void*)0)") == 0)
+               goto remove;
+
+       expr->expressionValue =
+       gmi_data_evaluate_expression(   cntxt->gdb_handle,
+                                                                       
expr->expressionSyntax);
+
+       // ignore trivial report entries (constants for that matter)
+       if (expr->expressionValue && strcmp(expr->expressionSyntax, 
expr->expressionValue) == 0)
+               goto remove;
+
+       // ignore functionpointers with their default names
+       size_t value_len; //= strlen(expr->expressionValue);
+       size_t syntax_len; //= strlen(expr->expressionSyntax);
+       if (expr->expressionValue &&
+               (value_len = strlen(expr->expressionValue)) > (syntax_len = 
strlen(expr->expressionSyntax)) + 2 &&
+               !strncmp(expr->expressionValue + value_len - 1, ">", 1) &&
+               !strncmp(expr->expressionValue + value_len - syntax_len - 2, 
"<", 1) &&
+               !strncmp(expr->expressionValue + value_len - syntax_len - 1, 
expr->expressionSyntax, syntax_len))
+               goto remove;
+       
+       if (NULL != expr->expressionValue
+       && (strcmp(expr->expressionValue, "0x0") == 0
+               || strcmp(expr->expressionValue, "NULL") == 0))
+       {
+               expr->expressionValue = "NULL";
+               cntxt->gdb_null_variable = expr->expressionSyntax;
+               cntxt->has_null = MONKEY_YES;
+       }
+
+       return next;
+
+remove:
+       MONKEY_CONTAINER_DLL_remove(*expressionListHead,
+                                                               
*expressionListTail,
+                                                               
removedExpression);
+       return next;
+}
+
+
 static int
 analyzeExpressionValues(struct Function *function,
                         struct MONKEY_ACTION_Context *cntxt)
@@ -384,38 +444,7 @@
 
        tmp = function->expressionListHead;
        while (NULL != tmp) {
-               if( tmp->isCall || tmp == faultyExpression ) {
-                        // We will not evaluate function calls (because GDB 
will evaluate by calling the function) or faultyExpressions
-                       tmp = tmp->next;
-                       continue;
-               }
-               else if( isAssignment(tmp->expressionSyntax) ) {
-                       // We should NOT evaluate assignments, otherwise 
subsequent expression evaluations will be spoiled
-                       // Expressions with assignments should be removed from 
the list of expressions
-                       struct Expression *removedExpression = tmp;
-                       tmp = tmp->next;
-                       
MONKEY_CONTAINER_DLL_remove(function->expressionListHead,
-                                                                               
function->expressionListTail,
-                                                                               
removedExpression);
-                       continue;
-               }
-               if (strcmp(tmp->expressionSyntax, "NULL") == 0) {
-                       tmp->expressionValue = "NULL";
-                       tmp = tmp->next;
-                       continue;
-               }
-               tmp->expressionValue =
-               gmi_data_evaluate_expression(   cntxt->gdb_handle,
-                                                                               
tmp->expressionSyntax);
-               if (NULL != tmp->expressionValue
-               && (strcmp(tmp->expressionValue, "0x0") == 0
-                       || strcmp(tmp->expressionValue, "NULL") == 0))
-               {
-                       tmp->expressionValue = "NULL";
-                       cntxt->gdb_null_variable = tmp->expressionSyntax;
-                       cntxt->has_null = MONKEY_YES;
-               }
-               tmp = tmp->next;
+               tmp = analyzeExpressionValue(cntxt, tmp, 
&(function->expressionListHead), &(function->expressionListTail));
        }
 
     return MONKEY_OK;
@@ -430,38 +459,7 @@
 
        tmp = trace->globalsListHead;
        while (NULL != tmp) {
-               if( tmp->isCall || tmp == faultyExpression ) {
-                        // We will not evaluate function calls (because GDB 
will evaluate by calling the function) or faultyExpressions
-                       tmp = tmp->next;
-                       continue;
-               }
-               else if( isAssignment(tmp->expressionSyntax) ) {
-                       // We should NOT evaluate assignments, otherwise 
subsequent expression evaluations will be spoiled
-                       // Expressions with assignments should be removed from 
the list of expressions
-                       struct Expression *removedExpression = tmp;
-                       tmp = tmp->next;
-                       MONKEY_CONTAINER_DLL_remove(trace->globalsListHead,
-                                                                               
trace->globalsListTail,
-                                                                               
removedExpression);
-                       continue;
-               }
-               if (strcmp(tmp->expressionSyntax, "NULL") == 0) {
-                       tmp->expressionValue = "NULL";
-                       tmp = tmp->next;
-                       continue;
-               }
-               tmp->expressionValue =
-               gmi_data_evaluate_expression(   cntxt->gdb_handle,
-                                                                               
tmp->expressionSyntax);
-               if (NULL != tmp->expressionValue
-               && (strcmp(tmp->expressionValue, "0x0") == 0
-                       || strcmp(tmp->expressionValue, "NULL") == 0))
-               {
-                       tmp->expressionValue = "NULL";
-                       cntxt->gdb_null_variable = tmp->expressionSyntax;
-                       cntxt->has_null = MONKEY_YES;
-               }
-               tmp = tmp->next;
+               tmp = analyzeExpressionValue(cntxt, tmp, 
&(trace->globalsListHead), &(trace->globalsListTail));
        }
 
     return MONKEY_OK;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]