gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22682 - monkey/branches/MonkeyBacktracking/monkey/src/monkey
Date: Sun, 15 Jul 2012 12:42:57 +0200

Author: safey
Date: 2012-07-15 12:42:57 +0200 (Sun, 15 Jul 2012)
New Revision: 22682

Modified:
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/mail_sender.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
   monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h
Log:
Restoring mail reports

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c   
2012-07-15 10:42:57 UTC (rev 22682)
@@ -11,7 +11,7 @@
 #include <string.h>
 #include <stdio.h>
 
-extern void sendMail(const char *messageContents,
+extern void sendMail(const char *messageContents, const char *reportFileName,
                     const char *emailAddress);
 
 
@@ -211,6 +211,7 @@
                /* Change current GDB frame to the one containing source code */
                gmi_stack_select_frame(cntxt->gdb_handle,
                                           cntxt->gdb_frames->level);
+               //gmi_exec_display_expression_syntax(cntxt->gdb_handle, 
cntxt->gdb_frames->line);
 
                return GDB_STATE_STOPPED;
     }
@@ -232,27 +233,22 @@
 MONKEY_ACTION_report_file(struct MONKEY_ACTION_Context *cntxt,
                          const char *dumpFileName, int isXML)
 {
-    FILE *file = NULL;
-    if (!isXML) {
-       file = fopen(dumpFileName, "w");
-       MONKEY_assert(NULL != file);
-       fprintf(file, "%s", cntxt->debug_report);
-    } else {
-       file = MONKEY_XML_WRITER_create_document(dumpFileName);
-       MONKEY_XML_WRITER_write_document(file, cntxt->xml_report_node);
-    }
-
-    if (NULL != file)
-       fclose(file);
+       FILE *f;
+       f = MONKEY_XML_WRITER_create_document(dumpFileName);
+       MONKEY_XML_WRITER_write_document(f, cntxt->xml_report_node);
+       fclose(f);
     return MONKEY_OK;
 }
 
 
-int MONKEY_ACTION_report_email(struct MONKEY_ACTION_Context *cntxt)
+int MONKEY_ACTION_report_email(struct MONKEY_ACTION_Context *cntxt, const char 
* dumpFileName)
 {
-    if (cntxt->debug_mode == DEBUG_MODE_REPORT_READY)
-       sendMail(cntxt->debug_report, cntxt->email_address);
-
+       FILE *f;
+       MONKEY_ACTION_format_report_xml(cntxt);
+       f = MONKEY_XML_WRITER_create_document(dumpFileName);
+       MONKEY_XML_WRITER_write_document(f, cntxt->xml_report_node);
+       fclose(f);
+       sendMail(NULL, dumpFileName, cntxt->email_address);
     return MONKEY_OK;
 }
 
@@ -1211,72 +1207,13 @@
 }
 
 
-//int MONKEY_ACTION_format_report(struct MONKEY_ACTION_Context
-//                             *cntxt)
-//{
-//    switch (cntxt->debug_mode) {
-//    case DEBUG_MODE_GDB:
-//     if (cntxt->bug_detected == BUG_NULL_POINTER) {
-//         MONKEY_asprintf(&(cntxt->debug_report),
-//                         "Bug detected in 
file:%s\nfunction:%s\nline:%d\nreason:%s\nreceived signal:%s\n%s\n Details:\n 
Expression:%s is NULL\n",
-//                         cntxt->gdb_frames->file,
-//                         cntxt->gdb_frames->func,
-//                         cntxt->gdb_frames->line,
-//                         mi_reason_enum_to_str(cntxt->gdb_stop_reason->
-//                                               reason),
-//                         cntxt->gdb_stop_reason->signal_name,
-//                         cntxt->gdb_stop_reason->signal_meaning,
-//                         cntxt->gdb_null_variable);
-//     } else if (NULL == cntxt->inspect_expression) {
-//         const char *expToString =
-//             expressionListToString(expressionListHead);
-//
-//         if (cntxt->bug_detected == BUG_ARITHMETIC) {
-//             MONKEY_asprintf(&(cntxt->debug_report),
-//                             "Bug detected in 
file:%s\nfunction:%s\nline:%d\nreceived signal:%s\n%s\nDetails:\nArithmetic 
Exception: Division by Zero suspected\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);
-//         } else if (cntxt->bug_detected == BUG_ABORT) {
-//             /* Assertion Failure */
-//             MONKEY_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);
-//         }
-//     } else {
-//         /* Inspection of user-defined expression */
-//         /*
-//            MONKEY_asprintf(&(cntxt->debug_report),
-//            "Inspection of expression: %s in function: %s, file:%s\nHit 
Number: \t \tValue:\n%s",
-//            cntxt->inspect_expression, cntxt->inspect_function, 
cntxt->binary_name, watchInfoListToString(watchInfoListHead));
-//          */
-//     }
-//     break;
-//    case DEBUG_MODE_VALGRIND:
-//     MONKEY_asprintf(&(cntxt->debug_report),
-//                     "Bug detected in 
file:%s\nfunction:%s\nline:%d\nreceived signal:%s\n%s\n Details:\n Memory Check 
from Valgrind:\n%s",
-//                     cntxt->gdb_frames->file, cntxt->gdb_frames->func,
-//                     cntxt->gdb_frames->line,
-//                     cntxt->gdb_stop_reason->signal_name,
-//                     cntxt->gdb_stop_reason->signal_meaning,
-//                     getValgrindOutput(cntxt));
-//     break;
-//    default:
-//     break;
-//    }
-//
-//    cntxt->debug_mode = DEBUG_MODE_REPORT_READY;
-//    return MONKEY_OK;
-//}
+int MONKEY_ACTION_format_report(struct MONKEY_ACTION_Context
+                               *cntxt)
+{
 
+}
+
+
 int MONKEY_ACTION_delete_context(struct MONKEY_ACTION_Context
                                 *cntxt)
 {

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c      
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c      
2012-07-15 10:42:57 UTC (rev 22682)
@@ -205,7 +205,41 @@
 }
 
 
+int
+MONKEY_EDB_get_expression_scope_end_for_expression (struct MONKEY_EDB_Context
+                                           *cntxt, const char *file_name,
+                                           const char * expr_syntax,
+                                           MONKEY_ExpressionIterator
+                                           iter, void *iter_cls)
+{
+  int err;
+  char *errMsg;
+  char *query;
 
+  if (MONKEY_asprintf
+      (&query,
+       "select end_lineno from Expression where file_name LIKE \'%%/%s\' and 
expr_syntax = %s",
+       file_name, expr_syntax) == -1)
+    {
+      fprintf(stderr,
+                 "Memory allocation problem occurred during creating database 
query!\n");
+      return MONKEY_NO;
+    }
+
+  err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
+  MONKEY_free (query);
+
+  if (err)
+    {
+      fprintf(stderr,
+                 "Error occurred while executing Database query. `%s'",
+                 errMsg);
+      return MONKEY_NO;
+    }
+  return MONKEY_OK;
+}
+
+
 int
 MONKEY_EDB_get_expressions_outer_scopes (struct MONKEY_EDB_Context *cntxt,
                                   const char *file_name, int start_line_no,

Modified: 
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c    
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gdbmi_prg_control.c    
2012-07-15 10:42:57 UTC (rev 22682)
@@ -124,11 +124,16 @@
  mi_send(h,"-exec-interrupt\n");
 }
 
-void mi_exec_record_process(h)
+void mi_exec_record_process(mi_h *h)
 {
 mi_send(h, "-interpreter-exec mi record\n");
 }
 
+void mi_exec_display_expression_syntax(mi_h *h, int lineNo)
+{
+mi_send(h, "-interpreter-exec console list\n");
+}
+
 void mi_exec_next(mi_h *h, int count)
 {
  if (count>1)
@@ -394,6 +399,12 @@
        return 1;
 }
 
+int gmi_exec_display_expression_syntax(mi_h *h, int lineNo)
+{
+       mi_exec_display_expression_syntax(h, lineNo);
+       return 1;
+}
+
 /**[txh]********************************************************************
 
   Description:

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/mail_sender.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/mail_sender.c  
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/mail_sender.c  
2012-07-15 10:42:57 UTC (rev 22682)
@@ -144,7 +144,7 @@
 }
 
 
-void sendMail(const char *messageContents, const char *emailAddress)
+void sendMail(const char *messageContents, const char* reportFileName, const 
char *emailAddress)
 {
        smtp_session_t session;
        smtp_message_t message;
@@ -152,8 +152,8 @@
        const smtp_status_t *status;
        struct sigaction sa;
        char *host = "localhost:25";
-       char *from = "gnunet-monkey";
-       char *subject = "e-mail from Libesmtp!";
+       char *from = "address@hidden";
+       char *subject = "Monkey bug report";
        const char *recipient_address = emailAddress;
        char tempFileName[1000];
        int tempFd;
@@ -187,14 +187,19 @@
 
        
        /* Prepare message */
-       memset(tempFileName, 0, sizeof(tempFileName));
-       sprintf(tempFileName, "/tmp/messageXXXXXX");
-       tempFd = mkstemp(tempFileName);
-       fp = fdopen(tempFd, "w");
-       fprintf(fp, "%s", messageContents);
-       fclose(fp);     
-       fp = fopen(tempFileName, "r");
-       smtp_set_message_fp(message, fp);
+       if (NULL == reportFileName) {
+               memset(tempFileName, 0, sizeof(tempFileName));
+               sprintf(tempFileName, "/tmp/messageXXXXXX");
+               tempFd = mkstemp(tempFileName);
+               fp = fdopen(tempFd, "w");
+               fprintf(fp, "%s", messageContents);
+               fclose(fp);
+               fp = fopen(tempFileName, "r");
+               smtp_set_message_fp(message, fp);
+       } else {
+               fp = fopen(reportFileName, "r");
+               smtp_set_message_fp(message, fp);
+       }
 
        
        recipient = smtp_add_recipient(message, recipient_address);

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c       
2012-07-15 10:42:57 UTC (rev 22682)
@@ -89,6 +89,7 @@
 
   /* Initialize context for the Action API */
   cntxt = MONKEY_malloc (sizeof (struct MONKEY_ACTION_Context));
+  cntxt->email_address = emailAddress;
   cntxt->binary_name = binaryName;
   cntxt->binaryArgs = binaryArgs;
   cntxt->expression_database_path = edbFilePath;
@@ -154,7 +155,7 @@
        }
       if (strcasecmp (mode, "email") == 0)
        {
-         if (MONKEY_OK != MONKEY_ACTION_report_email (cntxt))
+         if (MONKEY_OK != MONKEY_ACTION_report_email (cntxt, dumpFileName))
            {
              fprintf( stderr, "Error sending email!\n");
              ret = 1;

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h        
2012-07-15 10:42:57 UTC (rev 22682)
@@ -68,7 +68,7 @@
 int MONKEY_ACTION_report_file (struct MONKEY_ACTION_Context
                                      *cntxt, const char *dumpFileName, int 
isXML);
 int MONKEY_ACTION_report_email (struct MONKEY_ACTION_Context
-                                      *cntxt);
+                                      *cntxt, const char *dumpFileName);
 int MONKEY_ACTION_inspect_expression_database (struct
                                                      MONKEY_ACTION_Context
                                                      *cntxt);

Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h   
2012-07-15 10:41:42 UTC (rev 22681)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h   
2012-07-15 10:42:57 UTC (rev 22682)
@@ -76,6 +76,12 @@
                                            iter, void *iter_cls);
 
 
+int
+MONKEY_EDB_get_expression_scope_end_for_expression (struct MONKEY_EDB_Context
+                                           *cntxt, const char *file_name,
+                                           const char * expr_syntax,
+                                           MONKEY_ExpressionIterator
+                                           iter, void *iter_cls);
 
 /**
  * Return all the source code file names available in the Expression Database




reply via email to

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