gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20355 - monkey/branches/MonkeyBacktracking/monkey/src/monk


From: gnunet
Subject: [GNUnet-SVN] r20355 - monkey/branches/MonkeyBacktracking/monkey/src/monkey
Date: Wed, 7 Mar 2012 21:02:48 +0100

Author: safey
Date: 2012-03-07 21:02:48 +0100 (Wed, 07 Mar 2012)
New Revision: 20355

Modified:
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
Log:
Scope Depth flag removed. Scope depth is passed to monkey as a command argument.

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-03-07 19:15:01 UTC (rev 20354)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-03-07 20:02:48 UTC (rev 20355)
@@ -250,7 +250,7 @@
          fprintf (file, "%s", cntxt->debug_report);
        } else {
                file = MONKEY_XML_WRITER_create_document(dumpFileName);
-               MONKEY_XML_WRITER_write_document(file, 
cntxt->xmlReportRootNode);
+               MONKEY_XML_WRITER_write_document(file, cntxt->xml_report_node);
        }
 
        if (NULL != file)
@@ -356,7 +356,7 @@
   expression->lineNo = atoi (colValues[1]);
   expression->expressionValue = NULL; expression->next = NULL; 
expression->prev = NULL;
 
-  MONKEY_CONTAINER_DLL_insert_tail (function->expressionListHead, 
function->expressionListTail,
+  MONKEY_CONTAINER_DLL_insert (function->expressionListHead, 
function->expressionListTail,
                               expression);
 
   return 0;                    /* OK */
@@ -557,51 +557,51 @@
   if (endScope <= 0)
     return MONKEY_NO;
 
-#if EXPRESSION_EVALUATION_DEPTH
-  struct ScopeEnd *scopeEndPtr;
-  int index = 1;
+if (cntxt->scope_depth > 0) {
+       /* Means we need to look is scopes outer than the one where the problem 
occurred */
+         struct ScopeEnd *scopeEndPtr;
+         int index = 1;
 
-  cntxt->scope_depth = EXPRESSION_EVALUATION_DEPTH;
-  ret = MONKEY_EDB_function_start_line_for_scope(edbCntxt, 
cntxt->gdb_frames->file,
-               endScope,
-               &functionStartCallback, cntxt);
-  if (ret == MONKEY_NO || cntxt->function_start_line <= 0)
-         return MONKEY_NO;
+         ret = MONKEY_EDB_function_start_line_for_scope(edbCntxt, 
cntxt->gdb_frames->file,
+                       endScope,
+                       &functionStartCallback, cntxt);
+         if (ret == MONKEY_NO || cntxt->function_start_line <= 0)
+                 return MONKEY_NO;
 
-  ret = MONKEY_EDB_get_all_outer_scopes(edbCntxt, cntxt->gdb_frames->file,
-               cntxt->function_start_line,
-               cntxt->gdb_frames->line,
-               endScope,
-               &outerScopesCallback, NULL);
-  if (ret == MONKEY_NO)
-         return MONKEY_NO;
-  /**
-   * 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)
-                 scopeEndPtr = scopeEndPtr->next;
-         endScope = scopeEndPtr->lineNo;
-  }
-#endif
+         ret = MONKEY_EDB_get_all_outer_scopes(edbCntxt, 
cntxt->gdb_frames->file,
+                       cntxt->function_start_line,
+                       cntxt->gdb_frames->line,
+                       endScope,
+                       &outerScopesCallback, NULL);
+         if (ret == MONKEY_NO)
+                 return MONKEY_NO;
+         /**
+          * 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)
+                         scopeEndPtr = scopeEndPtr->next;
+                 endScope = scopeEndPtr->lineNo;
+         }
+}
 
   /* Now we know the end scope of the faulty expression. We can build the 
function struct */
   function = MONKEY_malloc(sizeof(struct Function));
@@ -959,24 +959,24 @@
 
                switch (cntxt->bug_detected) {
                case BUG_NULL_POINTER:
-                       cntxt->xmlReportRootNode = createXmlCrashNode("npe", 
functionPtr->name, functionPtr->line, functionPtr->file);
+                       cntxt->xml_report_node = createXmlCrashNode("npe", 
functionPtr->name, functionPtr->line, functionPtr->file);
                        break;
                case BUG_BAD_MEM_ACCESS:
-                       cntxt->xmlReportRootNode = createXmlCrashNode("Bad 
memory access", functionPtr->name, functionPtr->line, functionPtr->file);
-                       node = 
MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode, 
createXmlSimpleNode("valgrind", getValgrindOutput(cntxt)));
+                       cntxt->xml_report_node = createXmlCrashNode("Bad memory 
access", functionPtr->name, functionPtr->line, functionPtr->file);
+                       node = 
MONKEY_XML_WRITER_add_child(cntxt->xml_report_node, 
createXmlSimpleNode("valgrind", getValgrindOutput(cntxt)));
                        break;
                case BUG_ABORT:
-                       cntxt->xmlReportRootNode = 
createXmlCrashNode("Assertion Failure", functionPtr->name, functionPtr->line, 
functionPtr->file);
+                       cntxt->xml_report_node = createXmlCrashNode("Assertion 
Failure", functionPtr->name, functionPtr->line, functionPtr->file);
                        break;
                case BUG_ARITHMETIC:
-                       cntxt->xmlReportRootNode = createXmlCrashNode("Division 
By Zero", functionPtr->name, functionPtr->line, functionPtr->file);
+                       cntxt->xml_report_node = createXmlCrashNode("Division 
By Zero", functionPtr->name, functionPtr->line, functionPtr->file);
                        break;
                default:
                        return MONKEY_NO; //problem!
                }
 
        /* Adding Stack Trace Nodes to XML Report */
-       node = MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode, 
createXmlSimpleNode("history", NULL));
+       node = MONKEY_XML_WRITER_add_child(cntxt->xml_report_node, 
createXmlSimpleNode("history", NULL));
        node = MONKEY_XML_WRITER_add_child(node, createXmlEpochStep(0));
        traceNode = MONKEY_XML_WRITER_add_child(node, 
createXmlSimpleNode("trace", NULL));
        while (NULL != functionPtr) {
@@ -1081,8 +1081,8 @@
       remove (cntxt->valgrind_output_tmp_file_name);
       MONKEY_free (cntxt->valgrind_output_tmp_file_name);
     }
-  if (NULL != cntxt->xmlReportRootNode)
-         MONKEY_XML_WRITER_delete_tree(cntxt->xmlReportRootNode);
+  if (NULL != cntxt->xml_report_node)
+         MONKEY_XML_WRITER_delete_tree(cntxt->xml_report_node);
 
   MONKEY_free (cntxt);
   return MONKEY_OK;

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-03-07 19:15:01 UTC (rev 20354)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-03-07 20:02:48 UTC (rev 20355)
@@ -31,15 +31,16 @@
 
 #define MIN_ARG_REQUIRED 2
 
-static const char *mode = NULL;
-static const char *dumpFileName = NULL;
-static const char *binaryName = NULL;
-static const char *emailAddress = NULL;
-static const char *edbFilePath = NULL;
-static const char *gdbBinaryPath = NULL;
-static const char *valgrindBinaryPath = NULL;
-static const char *inspectExpression = NULL;
-static const char *inspectFunction = NULL;
+static char *mode = NULL;
+static char *dumpFileName = NULL;
+static char *binaryName = NULL;
+static char *emailAddress = NULL;
+static char *edbFilePath = NULL;
+static char *gdbBinaryPath = NULL;
+static char *valgrindBinaryPath = NULL;
+static char *inspectExpression = NULL;
+static char *inspectFunction = NULL;
+static char *scopeDepth = NULL;
 static int ret = 0;
 
 /**
@@ -92,9 +93,9 @@
   cntxt->valgrind_binary_path = valgrindBinaryPath;
   cntxt->inspect_expression = inspectExpression;
   cntxt->inspect_function = inspectFunction;
+  cntxt->scope_depth = (NULL == scopeDepth) ? 0 : atoi(scopeDepth);
   cntxt->function_start_line = 0;
-  cntxt->scope_depth = 0;
-  cntxt->xmlReportRootNode = NULL;
+  cntxt->xml_report_node = NULL;
 
   result = MONKEY_ACTION_rerun_with_gdb (cntxt);
   switch (result)
@@ -170,9 +171,10 @@
    printf ("\t-f: function: function name at which monkey will set a 
breakpoint [optional]\n");
    printf ("\t-g: gdb: path to gdb binary to use. If not passed, monkey will 
set it to /usr/bin/gdb [optional]\n");
    printf ("\t-l: valgrind: path to valgrind binary. If not passed, monkey 
will set it to /usr/bin/valgrind [optional]\n");
+   printf ("\t-p: depth: scope depth. How many scopes should monkey lookup 
expression values outer than the scope in which the problem occurs.\n\t Default 
is 0 which means, monkey is restricted to the scope of the expression in which 
the debugged program stopped [optional]\n");
    printf ("\t-h: help: print this help [optional]\n");
    printf ("\t-i: inspect: expression to inspect in the function specified 
after argument f [optional]\n");
-   printf ("\t-o: output: path to the debug report generated by monkey.\n If 
not provided monkey will save the report in a file named monkey_output in the 
current working directory [optional]\n");
+   printf ("\t-o: output: path to the debug report generated by monkey.\n\t If 
not provided monkey will save the report in a file named monkey_output in the 
current working directory [optional]\n");
    printf ("\t-v: version: monkey's version [optional]\n");
    printf ("Report bugs to address@hidden");
    printf ("GNUnet home page:  http://www.gnu.org/software/gnunet/\n";);
@@ -199,6 +201,8 @@
                MONKEY_free(inspectExpression);
        if (NULL != inspectFunction)
                MONKEY_free(inspectFunction);
+       if (NULL != scopeDepth)
+               MONKEY_free(scopeDepth);
 
        return MONKEY_OK;
 }
@@ -253,6 +257,9 @@
                 else if (strcmp("-i", argv[i]) == 0) {
                         inspectExpression = MONKEY_strdup(argv[++i]);
                 }
+                else if (strcmp("-p", argv[i]) == 0) {
+                        scopeDepth = MONKEY_strdup(argv[++i]);
+                }
         }
         if (MONKEY_NO == binaryCheck)
                 printf("Error: missing argument: path to the binary file.\n");

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-03-07 19:15:01 UTC (rev 20354)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-03-07 20:02:48 UTC (rev 20355)
@@ -29,9 +29,7 @@
 #define BUG_ABORT 7
 #define BUG_ARITHMETIC 8
 #define BUG_BAD_MEM_ACCESS 9
-#define EXPRESSION_EVALUATION_DEPTH 0
 
-
 /**
  * Context for the Action API
  */
@@ -47,7 +45,7 @@
   int debug_mode;
   int bug_detected;
   char *debug_report;
-  struct MONKEY_XML_Node *xmlReportRootNode;
+  struct MONKEY_XML_Node *xml_report_node;
 
   /* gdb debugging attributes */
   int run_reverse;




reply via email to

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