gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25637 - monkey/trunk/pathologist/src/pathologist
Date: Fri, 21 Dec 2012 21:45:17 +0100

Author: teichm
Date: 2012-12-21 21:45:17 +0100 (Fri, 21 Dec 2012)
New Revision: 25637

Modified:
   monkey/trunk/pathologist/src/pathologist/action_api.c
   monkey/trunk/pathologist/src/pathologist/edb_api.c
   monkey/trunk/pathologist/src/pathologist/pathologist_edb.h
Log:
fixed crappy scopes; no more stacktrace traversal for the moment

Modified: monkey/trunk/pathologist/src/pathologist/action_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/action_api.c       2012-12-21 
18:28:46 UTC (rev 25636)
+++ monkey/trunk/pathologist/src/pathologist/action_api.c       2012-12-21 
20:45:17 UTC (rev 25637)
@@ -270,13 +270,11 @@
 {
     struct FileName *fileName;
     char *token;
-    char *ext;
-    int tokenLength;
 
     if (NULL == colValues[0])
        return 1;               /* Error */
 
-    /* This is done to extract the only the file name from the full path 
coming from the Database */
+    // This is done to extract the only the file name from the full path 
coming from the Database
     token = strrchr(colValues[0], '/');
     if (NULL == token) {
        token = colValues[0];
@@ -356,33 +354,10 @@
     return 0;
 }
 
-#if 0
-static struct Expression *getFaultyExpression(struct Function *function)
-{
-    struct Expression *faultyExpression = NULL;
-    struct Expression *tmp = NULL;
-    int expressionLength = 0;
 
-    tmp = function->expressionListHead;
-    while (NULL != tmp) {
-       if ((tmp->lineNo == function->line)
-           && (strlen(tmp->expressionSyntax) > expressionLength)) {
-           expressionLength = strlen(tmp->expressionSyntax);
-           faultyExpression = tmp;
-       }
-       tmp = tmp->next;
-    }
-
-    return faultyExpression;
-}
-#endif
-
-
 static int isAssignment(const char *expressionSyntax)
 {
-    if (NULL != strstr(expressionSyntax, "="))
-       return MONKEY_YES;
-    return MONKEY_NO;
+    return (NULL != strstr(expressionSyntax, "=")) ? MONKEY_YES : MONKEY_NO;
 }
 
 
@@ -394,40 +369,36 @@
 
        tmp = function->expressionListHead;
        while (NULL != tmp) {
-               if (MONKEY_YES == tmp->isCall) {
+               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; // We will not evaluate function calls 
(because GDB will evaluate by calling the function)
+                       continue;
                }
-           if (tmp != faultyExpression) {
-                       if (MONKEY_NO == isAssignment(tmp->expressionSyntax)) { 
// We should NOT evaluate assignments, otherwise subsequent expression 
evaluations will be spoiled
-                               if (strcmp(tmp->expressionSyntax, "NULL") == 0) 
{
-                                       tmp->expressionValue = "0x0";
-                                       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)) {
-                                       cntxt->gdb_null_variable = 
tmp->expressionSyntax;
-                                       cntxt->has_null = MONKEY_YES;
-                               }
-                       } else {
-                               /* 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;       // don't progress the pointer 
twice
-                       }
-           }
+               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 = "0x0";
+                       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))
+               {
+                       cntxt->gdb_null_variable = tmp->expressionSyntax;
+                       cntxt->has_null = MONKEY_YES;
+               }
                tmp = tmp->next;
        }
 
@@ -505,12 +476,9 @@
        scopeEndListTail = NULL;
 }
 
-int MONKEY_ACTION_inspect_expression_database(struct
-                                             MONKEY_ACTION_Context
-                                             *cntxt)
+int MONKEY_ACTION_inspect_expression_database(struct MONKEY_ACTION_Context 
*cntxt)
 {
     int ret = MONKEY_OK;
-    int endScope;
     struct Function *function = NULL;
 
     /* Variables used across recursive calls */
@@ -531,98 +499,21 @@
     }
 
     if (0 == stackDepth) {
-               /* Initialize the trace structure for this particular epoch 
step */
+               // Initialize the trace structure for this particular epoch step
                trace = MONKEY_malloc(sizeof(struct Trace));
                MONKEY_CONTAINER_DLL_insert_tail(epoch->traceListHead,
                                                 epoch->traceListTail, trace);
 
-               /* Create a connection to the Expression Database */
+               // Create a connection to the Expression Database
                edbCntxt = MONKEY_EDB_connect(cntxt->expression_database_path);
                if (NULL == edbCntxt) {
-                       fprintf(stderr,
-                               "Unable to connect to Expression Database 
file!\n");
+                       fprintf(stderr, "Unable to connect to Expression 
Database file!\n");
                        ret = MONKEY_NO;
                        goto cleanup;
                }
     }
 
-    ret = MONKEY_EDB_get_expression_scope_end(edbCntxt,
-                                             cntxt->gdb_frames->file,
-                                             cntxt->gdb_frames->line,
-                                             &scopeEndCallback,
-                                             &endScope);
-    if (endScope <= 0) {
-       /* crash expression not found in the EDB, get the end scope of the 
crash function */
-       crashExpressionFoundInEDB = MONKEY_NO;
-       ret = MONKEY_EDB_expression_function_end_scope(edbCntxt, 
cntxt->gdb_frames->file,
-                       cntxt->gdb_frames->line,
-                       &scopeEndCallback, &endScope);
-       if (endScope <= 0) {
-               ret = MONKEY_NO;
-               goto cleanup;
-       }
-    }
-
-    if (cntxt->scope_depth > 0 && MONKEY_YES == crashExpressionFoundInEDB) {
-               /* Means we need to look is scopes outer than the one where the 
problem occurred */
-               struct ScopeEnd *scopeEndPtr;
-               int index = 1;
-
-               ret =
-                       MONKEY_EDB_function_start_line_for_scope(edbCntxt,
-                                                                
cntxt->gdb_frames->
-                                                                file, endScope,
-                                                                
&functionStartCallback,
-                                                                NULL);
-               if (ret == MONKEY_NO || failureFunctionStartLine <= 0) {
-                       goto cleanup;
-               }
-
-               /* Scope end list should be flushed before being used for the 
new function */
-               if (NULL != scopeEndListHead)
-                       flushScopeEndList();
-
-               ret =
-                       MONKEY_EDB_get_all_outer_scopes(edbCntxt,
-                                                       cntxt->gdb_frames->file,
-                                                       
failureFunctionStartLine,
-                                                       cntxt->gdb_frames->line,
-                                                       endScope, 
&outerScopesCallback,
-                                                       NULL);
-               if (ret == MONKEY_NO) {
-                       goto cleanup;
-               }
-                 /**
-                  * 1 void fun()
-                  * 2 {
-                  * 3  int i;
-                  * 4  int j;
-                  * 5  for (i = 0; i < 5; i++)
-                  * 6  {
-                  * 7          //Stuff
-                  * 8          .
-                  * 9          .
-                  * 10         for (j = 0; j < 7; j++)
-                  * 11         {
-                  * 12                 //Other Stuff
-                  * 13                 .
-                  * 14                 .
-                  * 15                 stop->because = crash->happens->here; 
<----------Crash happens here (Depth 0)
-                  * 16         }
-                  * 17  }<------- Scope End List: first element 
<---------------Outer scope depth 1
-                  * 18}<--------- Scope End List: second 
element<---------------Outer scope depth 2
-                  */
-               if (NULL != scopeEndListHead) {
-                       scopeEndPtr = scopeEndListHead;
-                       while (index < cntxt->scope_depth && NULL != 
scopeEndPtr->next) {
-                               scopeEndPtr = scopeEndPtr->next;
-                               index++;
-                       }
-                       endScope = scopeEndPtr->lineNo;
-               }
-    }
-
-    /* Now we know the end scope of the faulty expression. We can build the 
function struct */
+    // Now we know the end scope of the faulty expression. We can build the 
function struct
     function = MONKEY_malloc(sizeof(struct Function));
     function->depth = stackDepth++;
     function->line = cntxt->gdb_frames->line;
@@ -635,24 +526,15 @@
     MONKEY_CONTAINER_DLL_insert_tail(trace->functionListHead,
                                     trace->functionListTail, function);
 
-    /* Retrieve scope expressions from the database */
-    if (cntxt->scope_depth > 0) {
-               MONKEY_EDB_get_expressions_outer_scopes(edbCntxt,
-                                                       cntxt->gdb_frames->
-                                                       file,
-                                                       
failureFunctionStartLine, endScope,
-                                                       &iterateExpressions,
-                                                       function);
-    }
-    else {
-               MONKEY_EDB_get_expressions(edbCntxt,
-                                          cntxt->gdb_frames->file,
-                                          cntxt->gdb_frames->line, endScope,
-                                          &iterateExpressions, function);
-    }
+    // Retrieve scope expressions from the database
+       MONKEY_EDB_get_expressions(edbCntxt,
+                                                          
cntxt->gdb_frames->file,
+                                                          
cntxt->gdb_frames->line,
+                                                          &iterateExpressions, 
function);
 
-    /* Do value analysis for relevant expressions */
+    // Do value analysis for relevant expressions
     analyzeExpressionValues(function, cntxt);
+
     if (MONKEY_NO == isBugClassified) {
                isBugClassified = MONKEY_YES;
                if ((strcasecmp(signalMeaning, "Segmentation fault") == 0)
@@ -687,9 +569,10 @@
                MONKEY_EDB_disconnect(edbCntxt);
     } else {
                /* Recursively inspect the database for deeper frames */
-       gmi_stack_select_frame(cntxt->gdb_handle, cntxt->gdb_frames->level);
+/*     gmi_stack_select_frame(cntxt->gdb_handle, cntxt->gdb_frames->level);
        gmi_stack_info_frame(cntxt->gdb_handle);
-               ret = MONKEY_ACTION_inspect_expression_database(cntxt);
+               ret = MONKEY_ACTION_inspect_expression_database(cntxt); */
+               return MONKEY_OK;
     }
     return ret;
 }
@@ -1152,13 +1035,8 @@
 }
 
 
-int MONKEY_ACTION_format_report(struct MONKEY_ACTION_Context
-                               *cntxt)
-{
 
-}
 
-
 int MONKEY_ACTION_delete_context(struct MONKEY_ACTION_Context
                                 *cntxt)
 {

Modified: monkey/trunk/pathologist/src/pathologist/edb_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/edb_api.c  2012-12-21 18:28:46 UTC 
(rev 25636)
+++ monkey/trunk/pathologist/src/pathologist/edb_api.c  2012-12-21 20:45:17 UTC 
(rev 25637)
@@ -303,12 +303,11 @@
 
 /**
  * Run an SQLite query to retrieve those expressions that are previous to
- * given expression and are in the same scope of the given expression
+ * given expression and are in the same function of the given expression
  * 
  * @param cntxt context containing the Expression Database handle
  * @param file_name path to the file in which the expression in question exists
  * @param start_line_no expression beginning line
- * @param end_line_no line number for the expression's scope end
  * @param iter callback function, iterator for expressions returned from the 
Database
  * @param iter_cls closure for the expression iterator
  * @return MONKEY_OK success, MONKEY_NO failure
@@ -316,7 +315,6 @@
 int
 MONKEY_EDB_get_expressions (struct MONKEY_EDB_Context *cntxt,
                                   const char *file_name, int start_line_no,
-                                  int end_line_no,
                                   MONKEY_ExpressionIterator iter,
                                   void *iter_cls)
 {
@@ -325,20 +323,17 @@
   char *query;
   if (MONKEY_asprintf
       (&query,
-       "select expr_syntax, start_lineno, is_call from Expression where 
file_name LIKE \'%%%s\' and start_lineno <= %d and end_lineno = %d",
-       file_name, start_line_no, end_line_no) == -1)
+       "select expr_syntax, start_lineno, is_call from Expression where 
file_name LIKE \'%%%s\' and ((start_lineno <= %d and end_lineno >= %d and 
end_lineno != 32767) or (start_lineno = 0 and end_lineno = 32767))",
+       file_name, start_line_no, start_line_no) == -1)
     {
-      fprintf(stderr,
-                 "Memory allocation problem occurred!\n");
+      fprintf(stderr, "Memory allocation problem occurred!\n");
       return MONKEY_NO;
     }
 
   err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
   if (err)
     {
-      fprintf(stderr,
-                 "Error occurred while executing Database query. `%s'",
-                 errMsg);
+      fprintf(stderr, "Error occurred while executing Database query. `%s'\n", 
errMsg);
       return MONKEY_NO;
     }
   return MONKEY_OK;

Modified: monkey/trunk/pathologist/src/pathologist/pathologist_edb.h
===================================================================
--- monkey/trunk/pathologist/src/pathologist/pathologist_edb.h  2012-12-21 
18:28:46 UTC (rev 25636)
+++ monkey/trunk/pathologist/src/pathologist/pathologist_edb.h  2012-12-21 
20:45:17 UTC (rev 25637)
@@ -129,7 +129,6 @@
  * @param cntxt context containing the Expression Database handle.
  * @param file_name path to the file in which the expression in question exists
  * @param start_line_no expression beginning line
- * @param end_line_no line number for the expression's scope end
  * @param iter callback function, iterator for expressions returned from the 
Database
  * @param iter_cls closure for the expression iterator
  * @return MONKEY_OK success, MONKEY_NO failure
@@ -137,7 +136,6 @@
 int
 MONKEY_EDB_get_expressions (struct MONKEY_EDB_Context *cntxt,
                                   const char *file_name, int start_line_no,
-                                  int end_line_no,
                                   MONKEY_ExpressionIterator iter,
                                   void *iter_cls);
 




reply via email to

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