gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r18486 - monkey/src/monkey


From: gnunet
Subject: [GNUnet-SVN] r18486 - monkey/src/monkey
Date: Wed, 7 Dec 2011 00:32:35 +0100

Author: safey
Date: 2011-12-07 00:32:35 +0100 (Wed, 07 Dec 2011)
New Revision: 18486

Added:
   monkey/src/monkey/bad_memory_access.db
   monkey/src/monkey/bug_bad_memory_access_rpt.ref
   monkey/src/monkey/bug_division_by_zero_loop.db
   monkey/src/monkey/test_monkey_bad_memory_access.sh
Removed:
   monkey/src/monkey/bug_null_assertion_failure.db
Modified:
   monkey/src/monkey/action_api.c
   monkey/src/monkey/bug_division_by_zero_loop.c
   monkey/src/monkey/gdbmi.h
   monkey/src/monkey/gdbmi_prg_control.c
   monkey/src/monkey/gnunet_monkey_action.h
   monkey/src/monkey/test_monkey_assertion_failure.sh
Log:
monkey.out
monkey.out


Modified: monkey/src/monkey/action_api.c
===================================================================
--- monkey/src/monkey/action_api.c      2011-12-06 23:30:49 UTC (rev 18485)
+++ monkey/src/monkey/action_api.c      2011-12-06 23:32:35 UTC (rev 18486)
@@ -140,6 +140,7 @@
        {
        case sr_exited_normally:
          return GDB_STATE_EXIT_NORMALLY;
+
        case sr_bkpt_hit:
          {
            /* We want to inspect an expression */
@@ -467,6 +468,15 @@
                                             NULL);
       ret = analyzeCustomFault (cntxt);
     }
+  else if (strcasecmp(signalMeaning, "Arithmetic exception") == 0) {
+         cntxt->bug_detected = BUG_CUSTOM;
+         GNUNET_MONKEY_EDB_get_sub_expressions (edbCntxt,
+                                                    cntxt->gdb_frames->file,
+                                                    cntxt->gdb_frames->line,
+                                                    endScope, 
&iterateExpressions,
+                                                    NULL);
+         ret = analyzeCustomFault (cntxt);
+  }
 
   GNUNET_MONKEY_EDB_disconnect (edbCntxt);
   mi_disconnect (cntxt->gdb_handle);
@@ -589,7 +599,7 @@
     }
   /* Here we should be stopped when the program crashes */
   ret = wait_for_stop (cntxt);
-  if (ret == GDB_STATE_ERROR)
+  if (ret == GDB_STATE_ERROR || ret == GDB_STATE_EXIT_NORMALLY)
     mi_disconnect (cntxt->gdb_handle);
 
   return ret;
@@ -725,16 +735,17 @@
          if (NULL == cntxt->inspect_expression)
            {
              /* Assertion Failure */
-             const char *expToString =
-               expressionListToString (expressionListHead);
-             GNUNET_asprintf (&(cntxt->debug_report),
+             //const char *expToString =
+               //expressionListToString (expressionListHead);
+
+           GNUNET_asprintf (&(cntxt->debug_report),
                               "Bug detected in 
file:%s\nfunction:%s\nline:%d\nreceived signal:%s\n%s\nDetails:\nAssertion 
Failure\nExpression evaluation:\n%s\n",
                               cntxt->gdb_frames->file,
                               cntxt->gdb_frames->func,
                               cntxt->gdb_frames->line,
                               cntxt->gdb_stop_reason->signal_name,
                               cntxt->gdb_stop_reason->signal_meaning,
-                              expToString);
+                              "hello/world\n");
            }
          else
            {

Added: monkey/src/monkey/bad_memory_access.db
===================================================================
(Binary files differ)


Property changes on: monkey/src/monkey/bad_memory_access.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: monkey/src/monkey/bug_bad_memory_access_rpt.ref
===================================================================
--- monkey/src/monkey/bug_bad_memory_access_rpt.ref                             
(rev 0)
+++ monkey/src/monkey/bug_bad_memory_access_rpt.ref     2011-12-06 23:32:35 UTC 
(rev 18486)
@@ -0,0 +1,37 @@
+Bug detected in file:bug_bad_memory_access.c
+function:badMemoryAccess
+line:9
+received signal:SIGSEGV
+Segmentation fault
+ Details:
+ Memory Check from Valgrind:
+==7459== Memcheck, a memory error detector
+==7459== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
+==7459== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
+==7459== Command: src/monkey/bug_bad_memory_access
+==7459== Parent PID: 7458
+==7459== 
+==7459== Invalid write of size 4
+==7459==    at 0x400512: badMemoryAccess (bug_bad_memory_access.c:9)
+==7459==    by 0x400532: main (bug_bad_memory_access.c:14)
+==7459==  Address 0x4252352 is not stack'd, malloc'd or (recently) free'd
+==7459== 
+==7459== 
+==7459== Process terminating with default action of signal 11 (SIGSEGV)
+==7459==  Access not within mapped region at address 0x4252352
+==7459==    at 0x400512: badMemoryAccess (bug_bad_memory_access.c:9)
+==7459==    by 0x400532: main (bug_bad_memory_access.c:14)
+==7459==  If you believe this happened as a result of a stack
+==7459==  overflow in your program's main thread (unlikely but
+==7459==  possible), you can try to increase the size of the
+==7459==  main thread stack using the --main-stacksize= flag.
+==7459==  The main thread stack size used in this run was 8388608.
+==7459== 
+==7459== HEAP SUMMARY:
+==7459==     in use at exit: 0 bytes in 0 blocks
+==7459==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+==7459== 
+==7459== All heap blocks were freed -- no leaks are possible
+==7459== 
+==7459== For counts of detected and suppressed errors, rerun with: -v
+==7459== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

Modified: monkey/src/monkey/bug_division_by_zero_loop.c
===================================================================
--- monkey/src/monkey/bug_division_by_zero_loop.c       2011-12-06 23:30:49 UTC 
(rev 18485)
+++ monkey/src/monkey/bug_division_by_zero_loop.c       2011-12-06 23:32:35 UTC 
(rev 18486)
@@ -1,15 +1,19 @@
+#include <stdio.h>
+
 int
-main (const char *args[])
+main (int argc, char *argv[])
 {
   int i;
   int k = -1;
-  double result = 0.0;
+  int result = 10;
   int tmp;
 
+  printf("I am alive!\n");
   for (i = 0; i < 5; i++)
     {
       k += i;
       result = result / k;     /* Division by zero in second iteration */
+      printf("result = %d\n", result);
     }
   return 0;
 }

Added: monkey/src/monkey/bug_division_by_zero_loop.db
===================================================================
(Binary files differ)


Property changes on: monkey/src/monkey/bug_division_by_zero_loop.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Deleted: monkey/src/monkey/bug_null_assertion_failure.db
===================================================================
Modified: monkey/src/monkey/gdbmi.h
===================================================================
--- monkey/src/monkey/gdbmi.h   2011-12-06 23:30:49 UTC (rev 18485)
+++ monkey/src/monkey/gdbmi.h   2011-12-06 23:32:35 UTC (rev 18486)
@@ -571,6 +571,8 @@
 int gmi_exec_next_instruction(mi_h *h);
 /* Next line of code. Get inside functions. */
 int gmi_exec_step(mi_h *h);
+/* Previous line of code. Get inside functions. */
+int gmi_exec_step_back(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/src/monkey/gdbmi_prg_control.c
===================================================================
--- monkey/src/monkey/gdbmi_prg_control.c       2011-12-06 23:30:49 UTC (rev 
18485)
+++ monkey/src/monkey/gdbmi_prg_control.c       2011-12-06 23:32:35 UTC (rev 
18486)
@@ -131,6 +131,15 @@
     mi_send(h,"-exec-step\n");
 }
 
+
+void mi_exec_step_back(mi_h *h, int count)
+{
+       if (count>1)
+               mi_send(h, "-exec-step %d --reverse\n", count);
+       else
+               mi_send(h, "-exec-step --reverse\n");
+}
+
 void mi_exec_step_instruction(mi_h *h)
 {
  mi_send(h,"-exec-step-instruction\n");
@@ -352,9 +361,27 @@
  return mi_res_simple_running(h);
 }
 
+
+
 /**[txh]********************************************************************
 
   Description:
+  Previous line of code. Get inside functions.
+
+  Command: -exec-step --reverse
+  Return: !=0 OK
+
+***************************************************************************/
+int gmi_exec_step_back(mi_h *h)
+{
+       mi_exec_step_back(h,1);
+       return mi_res_simple_running(h);
+}
+
+
+/**[txh]********************************************************************
+
+  Description:
   Next count lines of code. Get inside functions.
 
   Command: -exec-step count

Modified: monkey/src/monkey/gnunet_monkey_action.h
===================================================================
--- monkey/src/monkey/gnunet_monkey_action.h    2011-12-06 23:30:49 UTC (rev 
18485)
+++ monkey/src/monkey/gnunet_monkey_action.h    2011-12-06 23:32:35 UTC (rev 
18486)
@@ -64,6 +64,7 @@
   char *debug_report;
 
   /* gdb debugging attributes */
+  int run_reverse;
   mi_h *gdb_handle;
   const char *gdb_in_use;
   mi_stop *gdb_stop_reason;

Modified: monkey/src/monkey/test_monkey_assertion_failure.sh
===================================================================
--- monkey/src/monkey/test_monkey_assertion_failure.sh  2011-12-06 23:30:49 UTC 
(rev 18485)
+++ monkey/src/monkey/test_monkey_assertion_failure.sh  2011-12-06 23:32:35 UTC 
(rev 18486)
@@ -1,13 +1,16 @@
 #!/bin/sh
-echo -n "Test Monkey with Bug - Null Pointer Exception -"
-gnunet-monkey -m text -d bug_assertion_failure.db -b bug_assertion_failure -o 
npe.out || (echo "Monkey Failed!" && exit 1)
-grep "Bug detected in file:bug_null_pointer_exception.c" npe.out > /dev/null 
|| (echo "FAIL" && exit 1)
-grep "function:crashFunction" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep "line:14" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep "reason:(null)" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep "received signal:SIGSEGV" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep "Segmentation fault" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep " Details:" npe.out > /dev/null || (echo "FAIL" && exit 1)
-grep " Expression:crashStruct is NULL" npe.out > /dev/null || (echo "FAIL" && 
exit 1)
-rm -f npe.out
+echo -n "Test Monkey with Bug - Assertion Failure -"
+gnunet-monkey -m text -d bug_assertion_failure.db -b bug_assertion_failure -o 
monkey.out || (echo "Monkey Failed!" && exit 1)
+grep "Bug detected in file:bug_assertion_failure.c" monkey.out > /dev/null || 
(echo "FAIL" && exit 1)
+grep "function:assertionFailure" monkey.out > /dev/null || (echo "FAIL" && 
exit 1)
+grep "line:8" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "received signal:SIGABRT" monkey.out > /dev/null || (echo "FAIL" && exit 
1)
+grep "Aborted" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "Details:" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "Assertion Failure" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "Expression evaluation:" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "assert(x<4) = Not evaluated" monkey.out > /dev/null || (echo "FAIL" && 
exit 1)
+grep "x<4 = 0" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+grep "x = 5" monkey.out > /dev/null || (echo "FAIL" && exit 1)
+rm -f monkey.out
 echo "PASS"

Added: monkey/src/monkey/test_monkey_bad_memory_access.sh
===================================================================
--- monkey/src/monkey/test_monkey_bad_memory_access.sh                          
(rev 0)
+++ monkey/src/monkey/test_monkey_bad_memory_access.sh  2011-12-06 23:32:35 UTC 
(rev 18486)
@@ -0,0 +1,15 @@
+echo -n "Test Monkey with Bug - Bad Memory Access -"
+gnunet-monkey -m text -d bug_bad_memory_access.db -b bug_bad_memory_access -o 
monkey.out || (echo "Monkey Failed!" && exit 1)
+for i in `cat bug_bad_memory_access_rpt.ref`
+do
+       grep $i monkey.out
+       if [ $? -ne 0 ]
+       then
+               {
+               echo $i
+               echo "FAIL"
+               exit 1
+               }
+       fi
+done 
+echo "PASS"




reply via email to

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