gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r20513 - monkey/branches/MonkeyBacktracking/monkey/src/monkey
Date: Thu, 15 Mar 2012 11:53:36 +0100

Author: safey
Date: 2012-03-15 11:53:36 +0100 (Thu, 15 Mar 2012)
New Revision: 20513

Modified:
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi.h
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
Log:
Backtracking supported. Tested on Bug Null Pointer Exception. Produces XML 
report.

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-03-15 10:17:44 UTC (rev 20512)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-03-15 10:53:36 UTC (rev 20513)
@@ -15,6 +15,9 @@
 
 
 static int async_c = 0;
+static int stepBackCount = 0;
+static char *signalMeaning = NULL;
+static int failureFunctionStartLine = 0; // start line number of the function 
in which the failure occurs
 static struct Expression *expressionListHead = NULL;
 static struct Expression *expressionListTail = NULL;
 static struct WatchInfo *watchInfoListHead = NULL;
@@ -68,11 +71,19 @@
 
 struct Trace
 {
+       struct Trace *next;
+       struct Trace *prev;
        struct Function *functionListHead;
        struct Function *functionListTail;
-} *trace;
+};
 
 
+struct Epoch
+{
+       struct Trace *traceListHead;
+       struct Trace *traceListTail;
+} *epoch;
+
 struct WatchInfo
 {
   struct WatchInfo *next;
@@ -143,116 +154,115 @@
 wait_for_stop (struct MONKEY_ACTION_Context *cntxt)
 {
        static int safetyCount = 0;
+
   while (!mi_get_response (cntxt->gdb_handle))
     usleep (1000);
-  /* The end of the async. */
-  cntxt->gdb_stop_reason = mi_res_stop (cntxt->gdb_handle);
-  if (cntxt->gdb_stop_reason)
-    {
-      switch (cntxt->gdb_stop_reason->reason)
-       {
-       case sr_exited_normally:
-         return GDB_STATE_EXIT_NORMALLY;
+  if (MONKEY_NO == cntxt->gdb_ignore_analysis) {
+         /* The end of the async. */
+         cntxt->gdb_stop_reason = mi_res_stop (cntxt->gdb_handle);
+         if (cntxt->gdb_stop_reason)
+               {
+                 safetyCount = 0; // reset the Safety Count whenever you stop 
for a meaningful reason
 
-       case sr_bkpt_hit:
-         {
-           /* We want to inspect an expression */
-           /* Set hardware watch at the expression to inspect */
-//         mi_wp *wp =
-//           gmi_break_watch (cntxt->gdb_handle, wm_write,
-//                            cntxt->inspect_expression);
-//         if (NULL == wp)
-//           {
-//             printf ("Error in setting a watchpoint at expression:%s\n",
-//                     cntxt->inspect_expression);
-//             return GDB_STATE_ERROR;
-//           }
-//         mi_free_wp (wp);
-           /* continue execution */
-           gmi_exec_continue (cntxt->gdb_handle);
-           return wait_for_stop (cntxt);
-         }
-       case sr_wp_trigger:
-         {
-                 /* Execution stopped because of hitting a watch point */
-           static int watchPointHitNumber = 0;
-           struct WatchInfo *watchInfo =
-             MONKEY_malloc (sizeof (struct WatchInfo));
-           watchInfo->hitNumber = ++watchPointHitNumber;
-           watchInfo->value = cntxt->gdb_stop_reason->wp_val;
-           MONKEY_CONTAINER_DLL_insert (watchInfoListHead, watchInfoListTail,
-                                        watchInfo);
-           if (watchPointHitNumber == 1023)
-             printf ("HEY! 1023! WE ARE GETTING OUT OF THE LOOP!\n");
-           gmi_exec_continue (cntxt->gdb_handle);
-           return wait_for_stop (cntxt);
-         }
-       case sr_wp_scope:
-         gmi_exec_continue (cntxt->gdb_handle);
-         return wait_for_stop (cntxt);
+                 switch (cntxt->gdb_stop_reason->reason)
+               {
+               case sr_exited_normally:
+                 return GDB_STATE_EXIT_NORMALLY;
 
-       default:
-         break;
-       }
+               case sr_bkpt_hit:
+                 {
+                       /* We want to inspect an expression */
+                       /* Set hardware watch at the expression to inspect */
+       //          mi_wp *wp =
+       //            gmi_break_watch (cntxt->gdb_handle, wm_write,
+       //                             cntxt->inspect_expression);
+       //          if (NULL == wp)
+       //            {
+       //              printf ("Error in setting a watchpoint at 
expression:%s\n",
+       //                      cntxt->inspect_expression);
+       //              return GDB_STATE_ERROR;
+       //            }
+       //          mi_free_wp (wp);
+                       /* continue execution */
+                       gmi_exec_continue (cntxt->gdb_handle);
+                       return wait_for_stop (cntxt);
+                 }
+               case sr_wp_trigger:
+                 {
+                         /* Execution stopped because of hitting a watch point 
*/
+                       static int watchPointHitNumber = 0;
+                       struct WatchInfo *watchInfo =
+                         MONKEY_malloc (sizeof (struct WatchInfo));
+                       watchInfo->hitNumber = ++watchPointHitNumber;
+                       watchInfo->value = cntxt->gdb_stop_reason->wp_val;
+                       MONKEY_CONTAINER_DLL_insert (watchInfoListHead, 
watchInfoListTail,
+                                                watchInfo);
+                       if (watchPointHitNumber == 1023)
+                         printf ("HEY! 1023! WE ARE GETTING OUT OF THE 
LOOP!\n");
+                       gmi_exec_continue (cntxt->gdb_handle);
+                       return wait_for_stop (cntxt);
+                 }
+               case sr_wp_scope:
+                 gmi_exec_continue (cntxt->gdb_handle);
+                 return wait_for_stop (cntxt);
+               default:
+                 break;
+               }
 
-      /* Reaching this line means that the program has stopped abnormally */
-      if (MONKEY_NO != gmi_exec_step_back(cntxt->gdb_handle)) {
-         printf("Hurray Reverse Execution!\n");
-      }
-      else {
-         printf("Bad Luck Reverse Execution!\n");
-      }
+                 /* Reaching this line means that the program has stopped 
abnormally OR we are in backtracking mode, and it's a step backward */
+                 cntxt->gdb_frames = gmi_stack_info_frame (cntxt->gdb_handle);
+                 if (NULL == cntxt->gdb_frames)
+               {
+                 cntxt->gdb_frames = gmi_stack_list_frames (cntxt->gdb_handle);
+                 /*
+                  * When working with GDB > 6.1, this is normal.
+                  * libmigdb fails to load current frame from the handle.
+                  * Instead, it's available in the reason struct
+                  */
+                 //cntxt->gdb_frames = cntxt->gdb_stop_reason->frame;
 
-      cntxt->gdb_frames = gmi_stack_info_frame (cntxt->gdb_handle);
-      if (NULL == cntxt->gdb_frames)
-       {
-         cntxt->gdb_frames = gmi_stack_list_frames (cntxt->gdb_handle);
-         /*
-          * When working with GDB > 6.1, this is normal.
-          * libmigdb fails to load current frame from the handle.
-          * Instead, it's available in the reason struct
-          */
-         //cntxt->gdb_frames = cntxt->gdb_stop_reason->frame;
+                 //EXPERIMENTAL CODE:
+                 while (MONKEY_YES != isInCodeBase (cntxt->gdb_frames->file))
+                       {
+                         cntxt->gdb_frames = cntxt->gdb_frames->next;
+                       }
 
-         //EXPERIMENTAL CODE:
-         while (MONKEY_YES != isInCodeBase (cntxt->gdb_frames->file))
-           {
-             cntxt->gdb_frames = cntxt->gdb_frames->next;
-           }
+                 if (NULL == cntxt->gdb_frames)
+                       MONKEY_break (0);
+               }
 
-         if (NULL == cntxt->gdb_frames)
-           MONKEY_break (0);
-       }
+                 if (0 == cntxt->gdb_frames->line)
+               {
+                 /*
+                  * This happens if the program stops in a shared library 
(inner frames)
+                  * We will move to outer frames until reaching the faulty 
line in the source code
+                  */
+                 cntxt->gdb_frames = gmi_stack_list_frames (cntxt->gdb_handle);
+                 do
+                       {
+                         cntxt->gdb_frames = cntxt->gdb_frames->next;
+                       }
+                 while (0 == cntxt->gdb_frames->line);
+               }
+                 /* Change current GDB frame to the one containing source code 
*/
+                 gmi_stack_select_frame (cntxt->gdb_handle, 
cntxt->gdb_frames->level);
 
-      if (0 == cntxt->gdb_frames->line)
-       {
-         /*
-          * This happens if the program stops in a shared library (inner 
frames)
-          * We will move to outer frames until reaching the faulty line in the 
source code
-          */
-         cntxt->gdb_frames = gmi_stack_list_frames (cntxt->gdb_handle);
-         do
-           {
-             cntxt->gdb_frames = cntxt->gdb_frames->next;
-           }
-         while (0 == cntxt->gdb_frames->line);
-       }
-      /* Change current GDB frame to the one containing source code */
-      gmi_stack_select_frame (cntxt->gdb_handle, cntxt->gdb_frames->level);
+                 return GDB_STATE_STOPPED;
+               }
+         else if ((MONKEY_YES == cntxt->run_reverse) && (safetyCount < 
GDB_SAFETY_COUNT)) { // GDB_SAFETY_COUNT prevents infinite analysis
+                 /* If the stop reason is NULL, don't bail out immediately, 
wait for stop again.
+                  * It happens when a breakpoint is placed (for backtracking) 
that the program stops for an unknown reason,
+                  * resulting in a NULL stop reason which causes Monkey to 
bail out before finishing its analysis. This else if
+                  * clause prevents premature bail out
+                  */
+                 safetyCount++;
+                 wait_for_stop(cntxt);
+                 return GDB_STATE_STOPPED;
+         }
 
-      return GDB_STATE_STOPPED;
-    }
-  else if ((MONKEY_YES == cntxt->run_reverse) && (safetyCount < 
GDB_SAFETY_COUNT)) { // GDB_SAFETY_COUNT prevents infinite analysis
-         /* If the stop reason is NULL, don't bail out immediately, wait for 
stop again.
-          * It happens when a breakpoint is placed (for backtracking) that the 
program stops for an unknown reason,
-          * resulting in a NULL stop reason which causes Monkey to bail out 
before finishing its analysis. This else if
-          * clause prevents premature bail out
-          */
-         safetyCount++;
-         wait_for_stop(cntxt);
+         return GDB_STATE_ERROR;
   }
-
-  return GDB_STATE_ERROR;
+  return GDB_STATE_EXIT_NORMALLY; // gdb analysis ignored
 }
 
 
@@ -347,13 +357,10 @@
 functionStartCallback (void *cls, int numColumns, char **colValues,
                char **colNames)
 {
-       struct MONKEY_ACTION_Context *cntxt =
-                       (struct MONKEY_ACTION_Context *) cls;
-
        if (NULL == colValues[0])
                return 1; /* Error */
 
-       cntxt->function_start_line = atoi(colValues[0]);
+       failureFunctionStartLine = atoi(colValues[0]);
        return 0; /* OK */
 }
 
@@ -543,23 +550,29 @@
 }
 
 static void printTrace() {
-       struct Function *functionPtr = trace->functionListHead;
+       int i = 0;
+       struct Function *functionPtr;
        struct Expression *expressionPtr;
-       printf("Program Stack Trace:\n");
-       while (NULL != functionPtr) {
-               printf("Function: %s, file: %s, line: %d\n", functionPtr->name, 
functionPtr->file, functionPtr->line);
-               
printf("--------------------------------------------------------------------------------------------------\n");
-               printf("Expressions:\n");
+       struct Trace *tracePtr = epoch->traceListHead;
+       while (NULL != tracePtr) {
+               printf("Program Stack Trace: Epoch Step %d\n", i++);
+               functionPtr = tracePtr->functionListHead;
+               while (NULL != functionPtr) {
+                       printf("Function: %s, file: %s, line: %d\n", 
functionPtr->name, functionPtr->file, functionPtr->line);
+                       
printf("--------------------------------------------------------------------------------------------------\n");
+                       printf("Expressions:\n");
 
-               expressionPtr = functionPtr->expressionListHead;
-               while (NULL != expressionPtr) {
-                       printf("%s = %s, line: %d\n", 
expressionPtr->expressionSyntax, (NULL == expressionPtr->expressionValue) ? "No 
Value" : expressionPtr->expressionValue , expressionPtr->lineNo);
-                       expressionPtr = expressionPtr->next;
+                       expressionPtr = functionPtr->expressionListHead;
+                       while (NULL != expressionPtr) {
+                               printf("%s = %s, line: %d\n", 
expressionPtr->expressionSyntax, (NULL == expressionPtr->expressionValue) ? "No 
Value" : expressionPtr->expressionValue , expressionPtr->lineNo);
+                               expressionPtr = expressionPtr->next;
+                       }
+
+                       functionPtr = functionPtr->next;
                }
-
-               functionPtr = functionPtr->next;
+               printf("############################## End Stack Trace 
######################################################\n\n");
+               tracePtr = tracePtr->next;
        }
-       printf("############################## End Stack Trace 
######################################################\n\n");
 }
 
 int
@@ -569,20 +582,28 @@
 {
   int ret = MONKEY_OK;
   int endScope;
-  const char *signalMeaning = cntxt->gdb_stop_reason->signal_meaning;
   struct Function *function = NULL;
 
   /* Variables used across recursive calls */
+  static struct Trace *trace = NULL;
   static int stackDepth = 0;
   static struct MONKEY_EDB_Context *edbCntxt;
 
-  if (NULL == trace) {
-         trace = MONKEY_malloc(sizeof(struct Trace));
-         trace->functionListHead = NULL;
-         trace->functionListTail = NULL;
+  if (NULL == signalMeaning)
+         signalMeaning = cntxt->gdb_stop_reason->signal_meaning;
+
+  if (NULL == epoch) {
+         epoch = MONKEY_malloc(sizeof(struct Epoch));
+         epoch->traceListHead = NULL;
+         epoch->traceListTail = NULL;
   }
 
   if (0 == stackDepth) {
+         /* 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 */
          edbCntxt = MONKEY_EDB_connect (cntxt->expression_database_path);
          if (NULL == edbCntxt)
                {
@@ -607,12 +628,12 @@
 
          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)
+                       &functionStartCallback, NULL);
+         if (ret == MONKEY_NO || failureFunctionStartLine <= 0)
                  return MONKEY_NO;
 
          ret = MONKEY_EDB_get_all_outer_scopes(edbCntxt, 
cntxt->gdb_frames->file,
-                       cntxt->function_start_line,
+                       failureFunctionStartLine,
                        cntxt->gdb_frames->line,
                        endScope,
                        &outerScopesCallback, NULL);
@@ -707,8 +728,12 @@
   /* Now, dive deeper into the stack trace */
   cntxt->gdb_frames = cntxt->gdb_frames->next;
   if (NULL == cntxt->gdb_frames) {
+         /* Cleanup function static variables that are used across recursive 
calls */
          stackDepth = 0;
-         mi_disconnect(cntxt->gdb_handle);
+         trace = NULL;
+
+         if (MONKEY_NO == cntxt->run_reverse)
+                 mi_disconnect(cntxt->gdb_handle); // otherwise, we will need 
to use gdb mi for reverse execution
          MONKEY_EDB_disconnect (edbCntxt);
   } else {
          /* Recursively inspect the database for deeper frames */
@@ -718,6 +743,49 @@
 }
 
 
+int MONKEY_ACTION_start_reverse_execution(struct MONKEY_ACTION_Context * 
cntxt) {
+       const char *failureFile = epoch->traceListHead->functionListHead->file;
+       const char *failureFunction = 
epoch->traceListHead->functionListHead->name;
+       struct Trace *tracePtr = epoch->traceListHead;
+
+       /*
+        * We ignore gdb analysis only after the first step back operation.
+        * The reason is that after crash, step back gets us to the expression 
where the crash happened.
+        * We already have this expression in our stack structure from the 
previous epoch step (the initial epoch)
+        */
+       cntxt->gdb_ignore_analysis = MONKEY_YES;
+       if (MONKEY_NO != gmi_exec_next_reverse(cntxt->gdb_handle)) {
+                 wait_for_stop(cntxt);
+                 cntxt->gdb_ignore_analysis = MONKEY_NO;
+        }
+        else {
+                 fprintf(stderr, "Error: Reverse Execution has failed!\n");
+                 mi_disconnect(cntxt->gdb_handle); // No need for gdb mi at 
this point!
+                 return MONKEY_NO;
+        }
+
+       /* Do reverse execution for all expressions in the function in which 
the failure occurred */
+       do {
+               if (MONKEY_NO != gmi_exec_next_reverse(cntxt->gdb_handle)) {
+                         if(GDB_STATE_ERROR == wait_for_stop(cntxt)) {
+                                 fprintf(stderr, "Error: Analysis during 
Reverse Execution has failed!\n");
+                                 return MONKEY_NO;
+                         }
+                         MONKEY_ACTION_inspect_expression_database(cntxt);
+                 }
+                 else {
+                         fprintf(stderr, "Error: Reverse Execution has 
failed!\n");
+                         return MONKEY_NO;
+                 }
+
+                 tracePtr = tracePtr->next;
+       } while ((NULL != tracePtr) && (strcmp(failureFile, 
tracePtr->functionListHead->file) == 0) &&
+                       (strcmp(failureFunction, 
tracePtr->functionListHead->name) == 0));
+
+       mi_disconnect(cntxt->gdb_handle); // No need for gdb mi at this point!
+       return MONKEY_OK;
+}
+
 int
 MONKEY_ACTION_rerun_with_valgrind (struct MONKEY_ACTION_Context
                                          *cntxt)
@@ -760,7 +828,7 @@
                                     *cntxt)
 {
   struct MONKEY_EDB_Context *edbCntxt;
-  trace = NULL; /* Initializing Stack Trace Data Structure */
+  epoch = NULL; /* Initializing epoch Data Structure */
 
   cntxt->debug_mode = DEBUG_MODE_GDB;
   /* This is like a file-handle for fopen.
@@ -1021,9 +1089,12 @@
 int
 MONKEY_ACTION_format_report_xml (struct MONKEY_ACTION_Context
                                        *cntxt) {
+       int i = 0;
        struct MONKEY_XML_Node *node;
+       struct MONKEY_XML_Node *historyNode;
        struct MONKEY_XML_Node *traceNode;
-       struct Function *functionPtr = trace->functionListHead;
+       struct Trace *tracePtr = epoch->traceListHead;
+       struct Function *functionPtr = tracePtr->functionListHead;
        struct Expression *expressionPtr;
 
 
@@ -1045,22 +1116,31 @@
                        return MONKEY_NO; //problem!
                }
 
+       historyNode = MONKEY_XML_WRITER_add_child(cntxt->xml_report_node, 
createXmlSimpleNode("history", NULL));
+
        /* Adding Stack Trace Nodes to XML Report */
-       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) {
-               node = MONKEY_XML_WRITER_add_child(traceNode, 
createXmlFunctionNode(functionPtr->name, functionPtr->line, functionPtr->file, 
functionPtr->depth));
-               node = MONKEY_XML_WRITER_add_child(node, 
createXmlSimpleNode("expressions", NULL));
+       while (NULL != tracePtr) {
+               node = MONKEY_XML_WRITER_add_child(historyNode, 
createXmlEpochStep(i));
+               traceNode = MONKEY_XML_WRITER_add_child(node, 
createXmlSimpleNode("trace", NULL));
 
-               expressionPtr = functionPtr->expressionListHead;
-               while (NULL != expressionPtr) {
-                       MONKEY_XML_WRITER_add_child(node, 
createXmlExpressionNode(expressionPtr->expressionSyntax,
-                                       (NULL == 
expressionPtr->expressionValue) ? "Not Evaluated" : 
expressionPtr->expressionValue)); // node = "expressions" node
-                       expressionPtr = expressionPtr->next;
+               functionPtr = tracePtr->functionListHead;
+               while (NULL != functionPtr) {
+                       node = MONKEY_XML_WRITER_add_child(traceNode, 
createXmlFunctionNode(functionPtr->name, functionPtr->line, functionPtr->file, 
functionPtr->depth));
+                       node = MONKEY_XML_WRITER_add_child(node, 
createXmlSimpleNode("expressions", NULL));
+
+                       expressionPtr = functionPtr->expressionListHead;
+                       while (NULL != expressionPtr) {
+                               MONKEY_XML_WRITER_add_child(node, 
createXmlExpressionNode(expressionPtr->expressionSyntax,
+                                               (NULL == 
expressionPtr->expressionValue) ? "Not Evaluated" : 
expressionPtr->expressionValue)); // node = "expressions" node
+
+                               expressionPtr = expressionPtr->next;
+                       }
+
+                       functionPtr = functionPtr->next;
                }
 
-               functionPtr = functionPtr->next;
+               tracePtr = tracePtr->next;
+               i++;
        }
        return MONKEY_OK;
 }

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi.h        
2012-03-15 10:17:44 UTC (rev 20512)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi.h        
2012-03-15 10:53:36 UTC (rev 20513)
@@ -575,6 +575,8 @@
 int gmi_exec_step(mi_h *h);
 /* Previous line of code. Get inside functions. */
 int gmi_exec_step_back(mi_h *h);
+/*  Previous line of code (do not step into).*/
+int gmi_exec_next_reverse(mi_h *h);
 /* Next count lines of code. Get inside functions. */
 int gmi_exec_step_cnt(mi_h *h, int count);
 /* Next line of assembler code. Get inside calls. */

Modified: 
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c    
2012-03-15 10:17:44 UTC (rev 20512)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c    
2012-03-15 10:53:36 UTC (rev 20513)
@@ -112,7 +112,7 @@
 
 void mi_exec_record_process(h)
 {
-mi_send(h, "-interpreter-exec console record\n");
+mi_send(h, "-interpreter-exec mi record\n");
 }
 
 void mi_exec_next(mi_h *h, int count)
@@ -145,6 +145,16 @@
                mi_send(h, "-exec-step --reverse\n");
 }
 
+
+void mi_exec_next_reverse(mi_h *h, int count)
+{
+       if (count>1)
+               mi_send(h, "-exec-next %d --reverse\n", count);
+       else
+               mi_send(h, "-exec-next --reverse\n");
+}
+
+
 void mi_exec_step_instruction(mi_h *h)
 {
  mi_send(h,"-exec-step-instruction\n");
@@ -330,7 +340,6 @@
 int gmi_exec_record_process(mi_h *h)
 {
        mi_exec_record_process(h);
-       //return mi_res_simple_running(h);
        return 1;
 }
 
@@ -403,6 +412,22 @@
 /**[txh]********************************************************************
 
   Description:
+  Previous line of code (do not step into).
+
+  Command: -exec-next --reverse
+  Return: !=0 OK
+
+***************************************************************************/
+int gmi_exec_next_reverse(mi_h *h)
+{
+       mi_exec_next_reverse(h,1);
+       return mi_res_simple_running(h);
+}
+
+
+/**[txh]********************************************************************
+
+  Description:
   Next count lines of code. Get inside functions.
 
   Command: -exec-step count

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-03-15 10:17:44 UTC (rev 20512)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-03-15 10:53:36 UTC (rev 20513)
@@ -95,9 +95,9 @@
   cntxt->inspect_expression = inspectExpression;
   cntxt->inspect_function = inspectFunction;
   cntxt->scope_depth = (NULL == scopeDepth) ? 0 : atoi(scopeDepth);
-  cntxt->function_start_line = 0;
   cntxt->xml_report_node = NULL;
   cntxt->run_reverse = reverseExecutionAllowed;
+  cntxt->gdb_ignore_analysis = MONKEY_NO;
 
   result = MONKEY_ACTION_rerun_with_gdb (cntxt);
   switch (result)
@@ -130,6 +130,19 @@
              break;
            }
        }
+       else {
+                 /* Monkey was able to detect problem using GDB, start 
backtracking if requested by user */
+               if (cntxt->run_reverse) {
+                 retVal = MONKEY_ACTION_start_reverse_execution(cntxt);
+                 if (MONKEY_NO == retVal) {
+                         fprintf(stderr, "Error during Backtracking!\n");
+                         ret = 1;
+                         break;
+                 }
+               }
+       }
+
+ /*                            REPORTING                                       
                */
       if (MONKEY_OK != MONKEY_ACTION_format_report_xml (cntxt))
        {
          fprintf( stderr,

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-03-15 10:17:44 UTC (rev 20512)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-03-15 10:53:36 UTC (rev 20513)
@@ -50,8 +50,8 @@
 
   /* gdb debugging attributes */
   int run_reverse;
-  int function_start_line;
   int scope_depth;
+  int gdb_ignore_analysis;
   mi_h *gdb_handle;
   const char *gdb_in_use;
   mi_stop *gdb_stop_reason;
@@ -72,6 +72,7 @@
                                                      *cntxt);
 int MONKEY_ACTION_rerun_with_gdb (struct MONKEY_ACTION_Context
                                         *cntxt);
+int MONKEY_ACTION_start_reverse_execution(struct MONKEY_ACTION_Context * 
cntxt);
 int MONKEY_ACTION_rerun_with_valgrind (struct
                                              MONKEY_ACTION_Context
                                              *cntxt);




reply via email to

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