[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19856 - in monkey/branches/MonkeyBacktracking/monkey/src:
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19856 - in monkey/branches/MonkeyBacktracking/monkey/src: include monkey |
Date: |
Mon, 20 Feb 2012 00:22:39 +0100 |
Author: safey
Date: 2012-02-20 00:22:39 +0100 (Mon, 20 Feb 2012)
New Revision: 19856
Added:
monkey/branches/MonkeyBacktracking/monkey/src/include/monkey_common.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_xml_writer.h
Removed:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_action.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_edb.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_xml_writer.h
Modified:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet-monkey.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
Log:
Disconnecting Monkey from GNUnet.
Monkey front-end still using GNUnet for command parsing.
Added: monkey/branches/MonkeyBacktracking/monkey/src/include/monkey_common.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/include/monkey_common.h
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/src/include/monkey_common.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -0,0 +1,165 @@
+/**
+ * @file monkey_common.h
+ * @brief commonly used definitions
+ * @author Safey A.Halim
+ */
+
+#ifndef MONKEY_COMMON_H
+#define MONKEY_COMMON_H
+
+#include <stdio.h>
+/**
+ * Named constants for return values.
+ */
+#define MONKEY_OK 1
+#define MONKEY_SYSERR -1
+#define MONKEY_YES 1
+#define MONKEY_NO 0
+
+/**
+ * Use this for fatal errors that cannot be handled
+ */
+#define MONKEY_assert(cond) do { if (! (cond)) { fprintf(stderr, "Assertion
failed at %s:%d.\n", __FILE__, __LINE__); abort(); } } while(0)
+
+/**
+ * Use this for fatal errors that cannot be handled
+ */
+#define MONKEY_assert_at(cond, f, l) do { if (! (cond)) { fprintf(stderr,
"Assertion failed at %s:%d.\n", f, l); abort(); } } while(0)
+
+/**
+ * Use this for internal assertion violations that are
+ * not fatal (can be handled) but should not occur.
+ */
+#define MONKEY_break(cond) do { if (! (cond)) { fprintf(stderr, "Assertion
failed at %s:%d.\n", __FILE__, __LINE__); } } while(0)
+
+
+/* ******************** doubly-linked list *************** */
+/* To avoid mistakes: head->prev == tail->next == NULL */
+
+/**
+ * Insert an element at the head of a DLL. Assumes that head, tail and
+ * element are structs with prev and next fields.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param element element to insert
+ */
+#define MONKEY_CONTAINER_DLL_insert(head,tail,element) do { \
+ MONKEY_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ MONKEY_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->next = (head); \
+ (element)->prev = NULL; \
+ if ((tail) == NULL) \
+ (tail) = element; \
+ else \
+ (head)->prev = element; \
+ (head) = (element); } while (0)
+
+
+/**
+ * Insert an element at the tail of a DLL. Assumes that head, tail and
+ * element are structs with prev and next fields.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param element element to insert
+ */
+#define MONKEY_CONTAINER_DLL_insert_tail(head,tail,element) do { \
+ MONKEY_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ MONKEY_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->prev = (tail); \
+ (element)->next = NULL; \
+ if ((head) == NULL) \
+ (head) = element; \
+ else \
+ (tail)->next = element; \
+ (tail) = (element); } while (0)
+
+
+/**
+ * Insert an element into a DLL after the given other element. Insert
+ * at the head if the other element is NULL.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param other prior element, NULL for insertion at head of DLL
+ * @param element element to insert
+ */
+#define MONKEY_CONTAINER_DLL_insert_after(head,tail,other,element) do { \
+ MONKEY_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ MONKEY_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->prev = (other); \
+ if (NULL == other) \
+ { \
+ (element)->next = (head); \
+ (head) = (element); \
+ } \
+ else \
+ { \
+ (element)->next = (other)->next; \
+ (other)->next = (element); \
+ } \
+ if (NULL == (element)->next) \
+ (tail) = (element); \
+ else \
+ (element)->next->prev = (element); } while (0)
+
+
+/**
+ * Insert an element into a DLL before the given other element. Insert
+ * at the tail if the other element is NULL.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param other prior element, NULL for insertion at head of DLL
+ * @param element element to insert
+ */
+#define MONKEY_CONTAINER_DLL_insert_before(head,tail,other,element) do { \
+ MONKEY_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
+ MONKEY_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
+ (element)->next = (other); \
+ if (NULL == other) \
+ { \
+ (element)->prev = (tail); \
+ (tail) = (element); \
+ } \
+ else \
+ { \
+ (element)->prev = (other)->prev; \
+ (other)->prev = (element); \
+ } \
+ if (NULL == (element)->prev) \
+ (head) = (element); \
+ else \
+ (element)->prev->next = (element); } while (0)
+
+
+/**
+ * Remove an element from a DLL. Assumes
+ * that head, tail and element are structs
+ * with prev and next fields.
+ *
+ * @param head pointer to the head of the DLL
+ * @param tail pointer to the tail of the DLL
+ * @param element element to remove
+ */
+#define MONKEY_CONTAINER_DLL_remove(head,tail,element) do { \
+ MONKEY_assert ( ( (element)->prev != NULL) || ((head) == (element))); \
+ MONKEY_assert ( ( (element)->next != NULL) || ((tail) == (element))); \
+ if ((element)->prev == NULL) \
+ (head) = (element)->next; \
+ else \
+ (element)->prev->next = (element)->next; \
+ if ((element)->next == NULL) \
+ (tail) = (element)->prev; \
+ else \
+ (element)->next->prev = (element)->prev; \
+ (element)->next = NULL; \
+ (element)->prev = NULL; } while (0)
+
+
+#define MONKEY_MIN(a,b) (((a) < (b)) ? (a) : (b))
+
+#define MONKEY_MAX(a,b) (((a) > (b)) ? (a) : (b))
+
+#endif /* MONKEY_COMMON_H */
Property changes on:
monkey/branches/MonkeyBacktracking/monkey/src/include/monkey_common.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
2012-02-19 23:22:39 UTC (rev 19856)
@@ -21,28 +21,25 @@
libmonkeyedb_la_SOURCES = \
edb_api.c \
- gnunet_monkey_edb.h
+ monkey_edb.h
libmonkeyedb_la_LIBADD = \
- -lgnunetutil \
-lsqlite3 \
$(GN_LIBINTL) $(XLIB)
libmonkeyaction_la_SOURCES = \
action_api.c \
- gnunet_monkey_action.h
+ monkey_action.h
libmonkeyaction_la_LIBADD = \
- -lgnunetutil \
$(GN_LIBINTL) $(XLIB)
libmonkeyxml_la_LIBADD = \
- -lgnunetutil \
$(GN_LIBINTL) $(XLIB)
libmonkeyxml_la_SOURCES = \
xml_writer.c \
- gnunet_monkey_xml_writer.h
+ monkey_xml_writer.h
bin_PROGRAMS = \
gnunet-monkey \
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,35 +1,15 @@
-/*
- This file is part of GNUnet.
- (C) 2010, 2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
/**
* @file monkey/action_api.c
* @brief Monkey API for actions taken by Monkey while debugging
*/
-#include "platform.h"
-#include <gnunet/gnunet_common.h>
-#include "gnunet_monkey_action.h"
-#include "gnunet_monkey_edb.h"
-#include "gnunet_monkey_xml_writer.h"
-#include <gnunet/gnunet_container_lib.h>
+#include "monkey_action.h"
+#include "monkey_edb.h"
+#include "monkey_xml_writer.h"
+#include "monkey_common.h"
#include <libesmtp.h>
+#include <string.h>
+#include <stdio.h>
extern void sendMail (const char *messageContents, const char *emailAddress);
@@ -57,8 +37,8 @@
struct FileName
{
- struct FileNames *next;
- struct FileNames *prev;
+ struct FileName *next;
+ struct FileName *prev;
const char *name;
};
@@ -73,6 +53,26 @@
int lineNo;
};
+
+struct Function
+{
+ struct Function *next;
+ struct Function *prev;
+ const char *name;
+ const char *file;
+ int line;
+ int depth;
+ struct Expression *expressionListHead;
+ struct Expression *expressionListTail;
+};
+
+struct Trace
+{
+ struct Function *functionListHead;
+ struct Function *functionListTail;
+} *trace;
+
+
struct WatchInfo
{
struct WatchInfo *next;
@@ -132,15 +132,15 @@
while (NULL != fileName)
{
if (strcmp (fileName->name, name) == 0)
- return GNUNET_YES;
+ return MONKEY_YES;
fileName = fileName->next;
}
- return GNUNET_NO;
+ return MONKEY_NO;
}
static int
-wait_for_stop (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+wait_for_stop (struct MONKEY_ACTION_Context *cntxt)
{
while (!mi_get_response (cntxt->gdb_handle))
usleep (1000);
@@ -176,10 +176,10 @@
/* Execution stopped because of hitting a watch point */
static int watchPointHitNumber = 0;
struct WatchInfo *watchInfo =
- GNUNET_malloc (sizeof (struct WatchInfo));
+ malloc (sizeof (struct WatchInfo));
watchInfo->hitNumber = ++watchPointHitNumber;
watchInfo->value = cntxt->gdb_stop_reason->wp_val;
- GNUNET_CONTAINER_DLL_insert (watchInfoListHead, watchInfoListTail,
+ MONKEY_CONTAINER_DLL_insert (watchInfoListHead, watchInfoListTail,
watchInfo);
if (watchPointHitNumber == 1023)
printf ("HEY! 1023! WE ARE GETTING OUT OF THE LOOP!\n");
@@ -208,13 +208,13 @@
//cntxt->gdb_frames = cntxt->gdb_stop_reason->frame;
//EXPERIMENTAL CODE:
- while (GNUNET_YES != isInCodeBase (cntxt->gdb_frames->file))
+ while (MONKEY_YES != isInCodeBase (cntxt->gdb_frames->file))
{
cntxt->gdb_frames = cntxt->gdb_frames->next;
}
if (NULL == cntxt->gdb_frames)
- GNUNET_break (0);
+ MONKEY_break (0);
}
if (0 == cntxt->gdb_frames->line)
@@ -240,32 +240,32 @@
int
-GNUNET_MONKEY_ACTION_report_file (struct GNUNET_MONKEY_ACTION_Context *cntxt,
+MONKEY_ACTION_report_file (struct MONKEY_ACTION_Context *cntxt,
const char *dumpFileName, int isXML)
{
FILE *file = NULL;
if (!isXML) {
file = fopen (dumpFileName, "w");
- GNUNET_assert (NULL != file);
+ MONKEY_assert (NULL != file);
fprintf (file, "%s", cntxt->debug_report);
} else {
- file = GNUNET_MONKEY_XML_WRITER_create_document(dumpFileName);
- GNUNET_MONKEY_XML_WRITER_write_document(file,
cntxt->xmlReportRootNode);
+ file = MONKEY_XML_WRITER_create_document(dumpFileName);
+ MONKEY_XML_WRITER_write_document(file,
cntxt->xmlReportRootNode);
}
if (NULL != file)
fclose(file);
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_ACTION_report_email (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+MONKEY_ACTION_report_email (struct MONKEY_ACTION_Context *cntxt)
{
if (cntxt->debug_mode == DEBUG_MODE_REPORT_READY)
sendMail (cntxt->debug_report, cntxt->email_address);
- return GNUNET_OK;
+ return MONKEY_OK;
}
@@ -292,9 +292,9 @@
printf ("%s\n", ext);
if (strcmp (ext, ".c") == 0)
{
- fileName = GNUNET_malloc (sizeof (struct FileName));
+ fileName = malloc (sizeof (struct FileName));
fileName->name = strdup (token);
- GNUNET_CONTAINER_DLL_insert (fileNameListHead, fileNameListTail,
+ MONKEY_CONTAINER_DLL_insert (fileNameListHead, fileNameListTail,
fileName);
return 0; /* OK */
}
@@ -316,9 +316,9 @@
if (NULL == colValues[0])
return 1; /* Error */
- struct ScopeEnd *scopeEnd = GNUNET_malloc(sizeof(struct ScopeEnd));
+ struct ScopeEnd *scopeEnd = malloc(sizeof(struct ScopeEnd));
scopeEnd->lineNo = atoi(colValues[0]);
- GNUNET_CONTAINER_DLL_insert (scopeEndListHead, scopeEndListTail,
+ MONKEY_CONTAINER_DLL_insert (scopeEndListHead, scopeEndListTail,
scopeEnd);
return 0; /* OK */
}
@@ -328,8 +328,8 @@
functionStartCallback (void *cls, int numColumns, char **colValues,
char **colNames)
{
- struct GNUNET_MONKEY_ACTION_Context *cntxt =
- (struct GNUNET_MONKEY_ACTION_Context *) cls;
+ struct MONKEY_ACTION_Context *cntxt =
+ (struct MONKEY_ACTION_Context *) cls;
if (NULL == colValues[0])
return 1; /* Error */
@@ -344,15 +344,16 @@
char **colNames)
{
struct Expression *expression;
+ struct Function *function = (struct Function *) cls;
if (NULL == colValues[0] || NULL == colValues[1])
return 1; /* Error */
- expression = GNUNET_malloc (sizeof (struct Expression));
+ expression = malloc (sizeof (struct Expression));
expression->expressionSyntax = strdup (colValues[0]);
expression->lineNo = atoi (colValues[1]);
- GNUNET_CONTAINER_DLL_insert (expressionListHead, expressionListTail,
+ MONKEY_CONTAINER_DLL_insert (function->expressionListHead,
function->expressionListTail,
expression);
return 0; /* OK */
@@ -373,7 +374,7 @@
static struct Expression *
-getFaultyExpression (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+getFaultyExpression (struct Function *function)
{
struct Expression *faultyExpression = NULL;
struct Expression *tmp = NULL;
@@ -382,7 +383,7 @@
tmp = expressionListHead;
while (NULL != tmp)
{
- if ((tmp->lineNo == cntxt->gdb_frames->line)
+ if ((tmp->lineNo == function->line)
&& (strlen (tmp->expressionSyntax) > expressionLength))
{
expressionLength = strlen (tmp->expressionSyntax);
@@ -395,30 +396,29 @@
}
static int
-analyzeSegmentationFault (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+analyzeSegmentationFault (struct Function *function, struct
MONKEY_ACTION_Context *cntxt)
{
struct Expression *tmp;
- faultyExpression = getFaultyExpression (cntxt);
+ faultyExpression = getFaultyExpression (function);
if (NULL != faultyExpression)
{
- tmp = expressionListHead;
+ tmp = function->expressionListHead;
while (NULL != tmp)
{
- const char *eval;
if (tmp != faultyExpression)
{
- eval =
+ tmp->expressionValue =
gmi_data_evaluate_expression (cntxt->gdb_handle,
tmp->expressionSyntax);
- if (NULL != eval
- && (strcmp (eval, "0x0") == 0
- || strcmp (eval, "NULL") == 0))
+ if (NULL != tmp->expressionValue
+ && (strcmp (tmp->expressionValue, "0x0") == 0
+ || strcmp (tmp->expressionValue, "NULL") == 0))
{
cntxt->gdb_null_variable = tmp->expressionSyntax;
- return GNUNET_OK;
+ return MONKEY_OK;
}
}
tmp = tmp->next;
@@ -441,7 +441,7 @@
// }
// tmp = tmp->next;
// }
-// return GNUNET_OK;
+// return MONKEY_OK;
// }
return GDB_STATE_ERROR;
}
@@ -449,7 +449,7 @@
static int
-analyzeCustomFault (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+analyzeCustomFault (struct MONKEY_ACTION_Context *cntxt)
{
struct Expression *tmp;
faultyExpression = getFaultyExpression (cntxt);
@@ -471,54 +471,85 @@
tmp = tmp->next;
}
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
+static int flushTrace(struct Trace *trace) {
+ struct Function *functionPtr = NULL;
+ struct Expression *expressionPtr = NULL;
+
+ while (NULL != trace->functionListHead) {
+ functionPtr = trace->functionListHead;
+ trace->functionListHead = trace->functionListHead->next;
+
+ while (NULL != functionPtr->expressionListHead) {
+ expressionPtr = functionPtr->expressionListHead;
+ functionPtr->expressionListHead =
functionPtr->expressionListHead->next;
+
+ free(expressionPtr->expressionSyntax);
+ free(expressionPtr);
+ }
+ free(functionPtr);
+ }
+ return MONKEY_OK;
+}
+
+
int
-GNUNET_MONKEY_ACTION_inspect_expression_database (struct
- GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_inspect_expression_database (struct
+ MONKEY_ACTION_Context
*cntxt)
{
- struct GNUNET_MONKEY_EDB_Context *edbCntxt;
- int ret = GNUNET_OK;
+ struct MONKEY_EDB_Context *edbCntxt;
+ int ret = MONKEY_OK;
int endScope;
const char *signalMeaning = cntxt->gdb_stop_reason->signal_meaning;
+ struct Function *function = NULL;
+ static int stackDepth = 0;
- edbCntxt = GNUNET_MONKEY_EDB_connect (cntxt->expression_database_path);
- if (NULL == edbCntxt)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to connect to Expression Database file!\n");
- return GNUNET_NO;
- }
+ if (NULL != trace) {
+ trace = malloc(sizeof(struct Trace));
+ trace->functionListHead = NULL;
+ trace->functionListTail = NULL;
+ }
- ret = GNUNET_MONKEY_EDB_get_expression_scope_end (edbCntxt,
+ if (0 == stackDepth) {
+ edbCntxt = MONKEY_EDB_connect (cntxt->expression_database_path);
+ if (NULL == edbCntxt)
+ {
+ fprintf(stderr,
+ "Unable to connect to Expression Database file!\n");
+ return MONKEY_NO;
+ }
+ }
+
+ ret = MONKEY_EDB_get_expression_scope_end (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line,
&scopeEndCallback,
&endScope);
if (endScope <= 0)
- return GNUNET_NO;
+ return MONKEY_NO;
#if EXPRESSION_EVALUATION_DEPTH
struct ScopeEnd *scopeEndPtr;
int index = 1;
cntxt->scope_depth = EXPRESSION_EVALUATION_DEPTH;
- ret = GNUNET_MONKEY_EDB_function_start_line_for_scope(edbCntxt,
cntxt->gdb_frames->file,
+ ret = MONKEY_EDB_function_start_line_for_scope(edbCntxt,
cntxt->gdb_frames->file,
endScope,
&functionStartCallback, cntxt);
- if (ret == GNUNET_NO || cntxt->function_start_line <= 0)
- return GNUNET_NO;
+ if (ret == MONKEY_NO || cntxt->function_start_line <= 0)
+ return MONKEY_NO;
- ret = GNUNET_MONKEY_EDB_get_all_outer_scopes(edbCntxt,
cntxt->gdb_frames->file,
+ 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 == GNUNET_NO)
- return GNUNET_NO;
+ if (ret == MONKEY_NO)
+ return MONKEY_NO;
if (NULL != scopeEndListHead) {
scopeEndPtr = scopeEndListHead;
while (index < cntxt->scope_depth && NULL != scopeEndPtr)
@@ -527,26 +558,35 @@
}
#endif
+ /* Now we know the end scope of the faulty expression. We can build the
function struct */
+ function = malloc(sizeof(struct Function));
+ function->depth = stackDepth++;
+ function->line = cntxt->gdb_frames->line;
+ function->name = cntxt->gdb_frames->func;
+ function->file = cntxt->gdb_frames->file;
+ MONKEY_CONTAINER_DLL_insert (trace->functionListHead,
trace->functionListTail,
+ function);
+
if (strcasecmp (signalMeaning, "Segmentation fault") == 0)
{
cntxt->bug_detected = BUG_NULL_POINTER;
- GNUNET_MONKEY_EDB_get_expressions (edbCntxt,
+ MONKEY_EDB_get_expressions (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line, endScope,
- &iterateExpressions, NULL);
- ret = analyzeSegmentationFault (cntxt);
+ &iterateExpressions, function);
+ ret = analyzeSegmentationFault (function, cntxt);
}
else if (strcasecmp (signalMeaning, "Aborted") == 0)
{
cntxt->bug_detected = BUG_CUSTOM;
/*
- GNUNET_MONKEY_EDB_get_sub_expressions (edbCntxt,
+ MONKEY_EDB_get_sub_expressions (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line,
endScope, &iterateExpressions,
NULL);
*/
- GNUNET_MONKEY_EDB_get_expressions (edbCntxt,
+ MONKEY_EDB_get_expressions (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line, endScope,
&iterateExpressions, NULL);
@@ -555,62 +595,73 @@
else if (strcasecmp(signalMeaning, "Arithmetic exception") == 0) {
cntxt->bug_detected = BUG_CUSTOM;
/*
- GNUNET_MONKEY_EDB_get_sub_expressions (edbCntxt,
+ MONKEY_EDB_get_sub_expressions (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line,
endScope,
&iterateExpressions,
NULL);
*/
if (cntxt->scope_depth > 0)
- GNUNET_MONKEY_EDB_get_expressions_outer_scopes (edbCntxt,
+ MONKEY_EDB_get_expressions_outer_scopes (edbCntxt,
cntxt->gdb_frames->file,
cntxt->gdb_frames->line, endScope,
&iterateExpressions, NULL);
else
- GNUNET_MONKEY_EDB_get_expressions (edbCntxt,
+ MONKEY_EDB_get_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);
+ /* Now, dive deeper into the stack trace */
+ cntxt->gdb_frames = cntxt->gdb_frames->next;
+ if (NULL == cntxt->gdb_frames) {
+ stackDepth = 0;
+ flushTrace(trace);
+ MONKEY_EDB_disconnect (edbCntxt);
+ mi_disconnect (cntxt->gdb_handle);
+ } else {
+ /* Recursively inspect the database for deeper frames */
+ MONKEY_ACTION_inspect_expression_database(cntxt);
+ }
return ret;
}
int
-GNUNET_MONKEY_ACTION_rerun_with_valgrind (struct GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_rerun_with_valgrind (struct MONKEY_ACTION_Context
*cntxt)
{
char *valgrindCommand;
FILE *valgrindPipe;
- GNUNET_asprintf (&cntxt->valgrind_output_tmp_file_name, "%d", rand ());
+ asprintf (&cntxt->valgrind_output_tmp_file_name, "%d", rand ());
cntxt->debug_mode = DEBUG_MODE_VALGRIND;
- GNUNET_asprintf (&valgrindCommand,
+ asprintf (&valgrindCommand,
"valgrind --leak-check=yes --log-file=%s %s",
cntxt->valgrind_output_tmp_file_name, cntxt->binary_name);
valgrindPipe = popen (valgrindCommand, "r");
if (NULL == valgrindPipe)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error in running Valgrind!\n");
- GNUNET_free (valgrindCommand);
- return GNUNET_NO;
+ fprintf(stderr, "Error in running Valgrind!\n");
+ free (valgrindCommand);
+ return MONKEY_NO;
}
pclose (valgrindPipe);
- GNUNET_free (valgrindCommand);
- return GNUNET_OK;
+ free (valgrindCommand);
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_ACTION_rerun_with_gdb (struct GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_rerun_with_gdb (struct MONKEY_ACTION_Context
*cntxt)
{
- struct GNUNET_MONKEY_EDB_Context *edbCntxt;
+ struct MONKEY_EDB_Context *edbCntxt;
+ trace = NULL; /* Initializing Stack Trace Data Structure */
+
cntxt->debug_mode = DEBUG_MODE_GDB;
/* This is like a file-handle for fopen.
Here we have all the state of gdb "connection". */
@@ -623,7 +674,7 @@
if (!cntxt->gdb_handle)
{
printf ("Connect failed\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
printf ("Connected to gdb!\n");
@@ -640,7 +691,7 @@
{
printf ("Error setting exec y args\n");
mi_disconnect (cntxt->gdb_handle);
- return GNUNET_NO;
+ return MONKEY_NO;
}
/* Tell gdb to attach the child to a terminal. */
@@ -648,7 +699,7 @@
{
printf ("Error selecting target terminal\n");
mi_disconnect (cntxt->gdb_handle);
- return GNUNET_NO;
+ return MONKEY_NO;
}
if ((NULL != cntxt->inspect_expression)
@@ -663,27 +714,27 @@
printf ("Error setting breakpoint at function:%s\n",
cntxt->inspect_function);
mi_disconnect (cntxt->gdb_handle);
- return GNUNET_NO;
+ return MONKEY_NO;
}
mi_free_bkpt (bp);
}
/* Prepare a list of the file names for the source files we are analyzing */
- edbCntxt = GNUNET_MONKEY_EDB_connect (cntxt->expression_database_path);
+ edbCntxt = MONKEY_EDB_connect (cntxt->expression_database_path);
if (NULL == edbCntxt)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Unable to connect to Expression Database file!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
- if (GNUNET_OK != GNUNET_MONKEY_EDB_get_file_names (edbCntxt,
+ if (MONKEY_OK != MONKEY_EDB_get_file_names (edbCntxt,
&iterateFileNames, NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error in executing Database query!\n");
}
- GNUNET_MONKEY_EDB_disconnect (edbCntxt);
+ MONKEY_EDB_disconnect (edbCntxt);
/* Run the program. */
@@ -691,7 +742,7 @@
{
printf ("Error in run!\n");
mi_disconnect (cntxt->gdb_handle);
- return GNUNET_NO;
+ return MONKEY_NO;
}
/* Here we should be stopped when the program crashes */
ret = wait_for_stop (cntxt);
@@ -705,20 +756,20 @@
static const char *
expressionListToString (struct Expression *head)
{
- char *string = GNUNET_strdup ("");
+ char *string = strdup ("");
char *strTmp;
struct Expression *tmp;
for (tmp = head; NULL != tmp; tmp = tmp->next)
{
- GNUNET_asprintf (&strTmp,
+ asprintf (&strTmp,
"%s%s => %s\n",
string,
tmp->expressionSyntax,
NULL ==
tmp->expressionValue ? "Not evaluated" : tmp->
expressionValue);
- GNUNET_free (string);
+ free (string);
string = strTmp;
}
return string;
@@ -746,20 +797,20 @@
static const char *
watchInfoListToString (struct WatchInfo *head)
{
- char *string = GNUNET_malloc (getWatchInfoListSize (head));
+ char *string = malloc (getWatchInfoListSize (head));
char *strTmp;
struct WatchInfo *tmp = head;
- GNUNET_asprintf (&strTmp, "%s\t \t%s\n", tmp->hitNumber, tmp->value);
+ asprintf (&strTmp, "%s\t \t%s\n", tmp->hitNumber, tmp->value);
strcpy (string, strTmp);
- GNUNET_free (strTmp);
+ free (strTmp);
tmp = tmp->next;
while (NULL != tmp)
{
- GNUNET_asprintf (&strTmp, "%s\t \t%s\n", tmp->hitNumber, tmp->value);
+ asprintf (&strTmp, "%s\t \t%s\n", tmp->hitNumber, tmp->value);
strcat (string, strTmp);
- GNUNET_free (strTmp);
+ free (strTmp);
tmp = tmp->next;
}
@@ -768,7 +819,7 @@
#endif
static const char *
-getValgrindOutput (struct GNUNET_MONKEY_ACTION_Context *cntxt)
+getValgrindOutput (struct MONKEY_ACTION_Context *cntxt)
{
char *valgrindOutput;
int size;
@@ -777,104 +828,103 @@
size = ftell (valgrindFile);
fseek (valgrindFile, 0L, SEEK_SET);
- valgrindOutput = GNUNET_malloc (size);
+ valgrindOutput = malloc (size);
fread (valgrindOutput, size - 1, 1, valgrindFile);
fclose (valgrindFile);
return valgrindOutput;
}
-static struct GNUNET_MONKEY_XML_Node * createXmlSimpleNode(const char
*nodeName) {
- struct GNUNET_MONKEY_XML_Node *node =
- GNUNET_MONKEY_XML_WRITER_new_node(nodeName, NULL);
+static struct MONKEY_XML_Node * createXmlSimpleNode(const char *nodeName) {
+ struct MONKEY_XML_Node *node =
+ MONKEY_XML_WRITER_new_node(nodeName, NULL);
return node;
}
-static struct GNUNET_MONKEY_XML_Node * createXmlCrashNode(const char
*category, const char *function, int line, const char *file) {
- struct GNUNET_MONKEY_XML_Node * node;
+static struct MONKEY_XML_Node * createXmlCrashNode(const char *category, const
char *function, int line, const char *file) {
+ struct MONKEY_XML_Node * node;
const char *lineStr;
- GNUNET_asprintf(&lineStr, "%d", line);
- node = GNUNET_MONKEY_XML_WRITER_new_node("crash", NULL);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "category", category);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "function", function);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "line", lineStr);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "file", file);
+ asprintf(&lineStr, "%d", line);
+ node = MONKEY_XML_WRITER_new_node("crash", NULL);
+ MONKEY_XML_WRITER_add_attribute(node, "category", category);
+ MONKEY_XML_WRITER_add_attribute(node, "function", function);
+ MONKEY_XML_WRITER_add_attribute(node, "line", lineStr);
+ MONKEY_XML_WRITER_add_attribute(node, "file", file);
return node;
}
-static struct GNUNET_MONKEY_XML_Node * createXmlEpochStep(int step) {
- struct GNUNET_MONKEY_XML_Node * node;
+static struct MONKEY_XML_Node * createXmlEpochStep(int step) {
+ struct MONKEY_XML_Node * node;
const char *stepStr;
- GNUNET_asprintf(&stepStr, "%d", step);
- node = GNUNET_MONKEY_XML_WRITER_new_node("epoch", NULL);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "step", stepStr);
+ asprintf(&stepStr, "%d", step);
+ node = MONKEY_XML_WRITER_new_node("epoch", NULL);
+ MONKEY_XML_WRITER_add_attribute(node, "step", stepStr);
return node;
}
-static struct GNUNET_MONKEY_XML_Node * createXmlFunctionNode(const char *name,
int line, const char *file, int depth) {
- struct GNUNET_MONKEY_XML_Node * node;
+static struct MONKEY_XML_Node * createXmlFunctionNode(const char *name, int
line, const char *file, int depth) {
+ struct MONKEY_XML_Node * node;
const char *lineStr;
const char *depthStr;
- GNUNET_asprintf(&lineStr, "%d", line);
- GNUNET_asprintf(&depthStr, "%d", depth);
- node = GNUNET_MONKEY_XML_WRITER_new_node("function", NULL);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "name", name);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "line", lineStr);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "file", file);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "depth", depthStr);
+ asprintf(&lineStr, "%d", line);
+ asprintf(&depthStr, "%d", depth);
+ node = MONKEY_XML_WRITER_new_node("function", NULL);
+ MONKEY_XML_WRITER_add_attribute(node, "name", name);
+ MONKEY_XML_WRITER_add_attribute(node, "line", lineStr);
+ MONKEY_XML_WRITER_add_attribute(node, "file", file);
+ MONKEY_XML_WRITER_add_attribute(node, "depth", depthStr);
return node;
}
-static struct GNUNET_MONKEY_XML_Node * createXmlExpressionNode(const char
*name, const char *value) {
- struct GNUNET_MONKEY_XML_Node * node;
+static struct MONKEY_XML_Node * createXmlExpressionNode(const char *name,
const char *value) {
+ struct MONKEY_XML_Node * node;
- node = GNUNET_MONKEY_XML_WRITER_new_node("expression", value);
- GNUNET_MONKEY_XML_WRITER_add_attribute(node, "name", name);
+ node = MONKEY_XML_WRITER_new_node("expression", value);
+ MONKEY_XML_WRITER_add_attribute(node, "name", name);
return node;
}
int
-GNUNET_MONKEY_ACTION_format_report_xml (struct GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_format_report_xml (struct MONKEY_ACTION_Context
*cntxt) {
- struct GNUNET_MONKEY_XML_Node *node;
- char *str;
+ struct MONKEY_XML_Node *node;
switch (cntxt->debug_mode) {
case DEBUG_MODE_GDB:
switch (cntxt->bug_detected) {
case BUG_NULL_POINTER:
cntxt->xmlReportRootNode = createXmlCrashNode("npe",
cntxt->gdb_frames->func, cntxt->gdb_frames->line, cntxt->gdb_frames->file);
- node =
GNUNET_MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode,
createXmlSimpleNode("history"));
- node = GNUNET_MONKEY_XML_WRITER_add_child(node,
createXmlEpochStep(0));
- node = GNUNET_MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("trace"));
- node = GNUNET_MONKEY_XML_WRITER_add_child(node,
createXmlFunctionNode(cntxt->gdb_frames->func, cntxt->gdb_frames->line,
cntxt->gdb_frames->file, 0));
- node = GNUNET_MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("expressions"));
- node = GNUNET_MONKEY_XML_WRITER_add_child(node,
createXmlExpressionNode(cntxt->gdb_null_variable, "NULL"));
+ node =
MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode,
createXmlSimpleNode("history"));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlEpochStep(0));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("trace"));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlFunctionNode(cntxt->gdb_frames->func, cntxt->gdb_frames->line,
cntxt->gdb_frames->file, 0));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("expressions"));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlExpressionNode(cntxt->gdb_null_variable, "NULL"));
break;
case BUG_CUSTOM:
default:
- return GNUNET_NO; //problem!
+ return MONKEY_NO; //problem!
}
break;
case DEBUG_MODE_VALGRIND:
break;
default:
- return GNUNET_NO; //problem!
+ return MONKEY_NO; //problem!
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_ACTION_format_report (struct GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_format_report (struct MONKEY_ACTION_Context
*cntxt)
{
switch (cntxt->debug_mode)
@@ -882,7 +932,7 @@
case DEBUG_MODE_GDB:
if (cntxt->bug_detected == BUG_NULL_POINTER)
{
- GNUNET_asprintf (&(cntxt->debug_report),
+ 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,
@@ -901,7 +951,7 @@
expressionListToString (expressionListHead);
if (strcasecmp(cntxt->gdb_stop_reason->signal_meaning, "Arithmetic
exception") == 0) {
- GNUNET_asprintf (&(cntxt->debug_report),
+ 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,
@@ -912,7 +962,7 @@
}
else {
/* Assertion Failure */
- GNUNET_asprintf (&(cntxt->debug_report),
+ 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,
@@ -926,7 +976,7 @@
{
/* Inspection of user-defined expression */
/*
- GNUNET_asprintf(&(cntxt->debug_report),
+ 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));
*/
@@ -934,7 +984,7 @@
}
break;
case DEBUG_MODE_VALGRIND:
- GNUNET_asprintf (&(cntxt->debug_report),
+ 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,
@@ -947,31 +997,31 @@
}
cntxt->debug_mode = DEBUG_MODE_REPORT_READY;
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_ACTION_delete_context (struct GNUNET_MONKEY_ACTION_Context
+MONKEY_ACTION_delete_context (struct MONKEY_ACTION_Context
*cntxt)
{
if (NULL != cntxt->debug_report)
- GNUNET_free (cntxt->debug_report);
+ free (cntxt->debug_report);
if (NULL != cntxt->valgrind_output_tmp_file_name)
{
remove (cntxt->valgrind_output_tmp_file_name);
- GNUNET_free (cntxt->valgrind_output_tmp_file_name);
+ free (cntxt->valgrind_output_tmp_file_name);
}
if (NULL != cntxt->xmlReportRootNode)
- GNUNET_MONKEY_XML_WRITER_delete_tree(cntxt->xmlReportRootNode);
+ MONKEY_XML_WRITER_delete_tree(cntxt->xmlReportRootNode);
- GNUNET_free (cntxt);
- return GNUNET_OK;
+ free (cntxt);
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_ACTION_check_bug_redundancy ()
+MONKEY_ACTION_check_bug_redundancy ()
{
- return GNUNET_OK;
+ return MONKEY_OK;
}
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/edb_api.c
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,38 +1,19 @@
-/*
- This file is part of GNUnet.
- (C) 2009, 2010 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
/**
* @file monkey/edb_api.c
* @brief Monkey API for accessing the Expression Database (edb)
*/
-#include "platform.h"
-#include <gnunet/gnunet_common.h>
-#include "gnunet_monkey_edb.h"
+#include "monkey_common.h"
+#include <stdlib.h>
+#include <stdio.h>
#include <sqlite3.h>
+#include <monkey_edb.h>
/**
* Context for Database connection and Expressions
*/
-struct GNUNET_MONKEY_EDB_Context
+struct MONKEY_EDB_Context
{
/**
* Database connection
@@ -47,17 +28,17 @@
* @param db_file_name path the Expression Database file
* @return context to use for Accessing the Expression Database, NULL on error
*/
-struct GNUNET_MONKEY_EDB_Context *
-GNUNET_MONKEY_EDB_connect (const char *db_file_name)
+struct MONKEY_EDB_Context *
+MONKEY_EDB_connect (const char *db_file_name)
{
int err;
- struct GNUNET_MONKEY_EDB_Context *ctxt =
- GNUNET_malloc (sizeof (struct GNUNET_MONKEY_EDB_Context));
+ struct MONKEY_EDB_Context *ctxt =
+ malloc (sizeof (struct MONKEY_EDB_Context));
err = sqlite3_open (db_file_name, &ctxt->db_handle);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Cannot open Expression Database. `%s'\n",
sqlite3_errmsg (ctxt->db_handle));
return NULL;
@@ -70,21 +51,21 @@
* Disconnect from Database, and cleanup resources
*
* @param context context containing the Expression Database handle
- * @return GNUNET_OK on success, GNUNET_NO on failure
+ * @return MONKEY_OK on success, MONKEY_NO on failure
*/
int
-GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *cntxt)
+MONKEY_EDB_disconnect (struct MONKEY_EDB_Context *cntxt)
{
sqlite3_close (cntxt->db_handle);
- GNUNET_free (cntxt);
- return GNUNET_OK;
+ free (cntxt);
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_EDB_get_file_names (struct GNUNET_MONKEY_EDB_Context *cntxt,
- GNUNET_MONKEY_FileIterator iter,
+MONKEY_EDB_get_file_names (struct MONKEY_EDB_Context *cntxt,
+ MONKEY_FileIterator iter,
void *iter_cls)
{
int err;
@@ -93,31 +74,31 @@
if (asprintf (&query, "select distinct file_name from Expression") == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred during creating database
query!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_EDB_get_all_outer_scopes(struct GNUNET_MONKEY_EDB_Context
+MONKEY_EDB_get_all_outer_scopes(struct MONKEY_EDB_Context
*cntxt, const char *file_name,
int function_beginning,
int scope_in_question_start,
int scope_in_question_end,
- GNUNET_MONKEY_ExpressionIterator
+ MONKEY_ExpressionIterator
iter, void *iter_cls)
{
int err;
@@ -129,28 +110,28 @@
"select distinct end_lineno from Expression where file_name
LIKE \'%%/%s\' and start_lineno >= %d and start_lineno < %d and end_lineno > %d
order by end_lineno",
file_name, function_beginning, scope_in_question_start,
scope_in_question_end) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred during creating
database query!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_EDB_function_start_line_for_scope(struct
GNUNET_MONKEY_EDB_Context
+MONKEY_EDB_function_start_line_for_scope(struct MONKEY_EDB_Context
*cntxt, const char *file_name,
int scope_end,
- GNUNET_MONKEY_ExpressionIterator
+ MONKEY_ExpressionIterator
iter, void *iter_cls)
{
int err;
@@ -162,20 +143,20 @@
"select MIN(start_lineno) from Expression where file_name LIKE
\'%%/%s\' and end_lineno >= %d",
file_name, scope_end) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred during creating
database query!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
@@ -187,13 +168,13 @@
* @param start_line_no expression's line
* @param iter callback function, iterator for values returned from the
Database
* @param iter_cls closure for the expression iterator, will contain the
scope-end line number
- * @return GNUNET_OK on success, GNUNET_NO on failure
+ * @return MONKEY_OK on success, MONKEY_NO on failure
*/
int
-GNUNET_MONKEY_EDB_get_expression_scope_end (struct GNUNET_MONKEY_EDB_Context
+MONKEY_EDB_get_expression_scope_end (struct MONKEY_EDB_Context
*cntxt, const char *file_name,
int start_line_no,
- GNUNET_MONKEY_ExpressionIterator
+ MONKEY_ExpressionIterator
iter, void *iter_cls)
{
int err;
@@ -205,29 +186,29 @@
"select end_lineno from Expression where file_name LIKE \'%%/%s\' and
start_lineno = %d",
file_name, start_line_no) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred during creating database
query!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_EDB_get_expressions_outer_scopes (struct
GNUNET_MONKEY_EDB_Context *cntxt,
+MONKEY_EDB_get_expressions_outer_scopes (struct MONKEY_EDB_Context *cntxt,
const char *file_name, int start_line_no,
int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
+ MONKEY_ExpressionIterator iter,
void *iter_cls) {
int err;
char *errMsg;
@@ -237,20 +218,20 @@
"select expr_syntax, start_lineno from Expression where file_name
LIKE \'%%/%s\' and start_lineno <= %d and end_lineno <= %d",
file_name, start_line_no, end_line_no) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
/**
@@ -263,13 +244,13 @@
* @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 GNUNET_OK success, GNUNET_NO failure
+ * @return MONKEY_OK success, MONKEY_NO failure
*/
int
-GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *cntxt,
+MONKEY_EDB_get_expressions (struct MONKEY_EDB_Context *cntxt,
const char *file_name, int start_line_no,
int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
+ MONKEY_ExpressionIterator iter,
void *iter_cls)
{
int err;
@@ -280,28 +261,28 @@
"select expr_syntax, start_lineno from Expression where file_name LIKE
\'%%/%s\' and start_lineno <= %d and end_lineno = %d",
file_name, start_line_no, end_line_no) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
int
-GNUNET_MONKEY_EDB_get_sub_expressions (struct GNUNET_MONKEY_EDB_Context
+MONKEY_EDB_get_sub_expressions (struct MONKEY_EDB_Context
*cntxt, const char *file_name,
int start_line_no, int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
+ MONKEY_ExpressionIterator iter,
void *iter_cls)
{
int err;
@@ -312,18 +293,18 @@
"select expr_syntax, start_lineno from Expression where file_name LIKE
\'%%/%s\' and start_lineno = %d and end_lineno = %d",
file_name, start_line_no, end_line_no) == -1)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Memory allocation problem occurred!\n");
- return GNUNET_NO;
+ return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ fprintf(stderr,
"Error occurred while executing Database query. `%s'",
errMsg);
- return GNUNET_NO;
+ return MONKEY_NO;
}
- return GNUNET_OK;
+ return MONKEY_OK;
}
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet-monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet-monkey.c
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet-monkey.c
2012-02-19 23:22:39 UTC (rev 19856)
@@ -27,7 +27,7 @@
#include <sys/stat.h>
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
-#include "gnunet_monkey_action.h"
+#include "monkey_action.h"
static const char *mode;
static const char *dumpFileName;
@@ -53,7 +53,7 @@
const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
{
int result;
- struct GNUNET_MONKEY_ACTION_Context *cntxt;
+ struct MONKEY_ACTION_Context *cntxt;
if (NULL == edbFilePath)
{
@@ -90,7 +90,7 @@
}
/* Initialize context for the Action API */
- cntxt = GNUNET_malloc (sizeof (struct GNUNET_MONKEY_ACTION_Context));
+ cntxt = GNUNET_malloc (sizeof (struct MONKEY_ACTION_Context));
cntxt->binary_name = binaryName;
cntxt->expression_database_path = edbFilePath;
cntxt->gdb_binary_path = gdbBinaryPath;
@@ -100,7 +100,7 @@
cntxt->scope_depth = 0;
cntxt->xmlReportRootNode = NULL;
- result = GNUNET_MONKEY_ACTION_rerun_with_gdb (cntxt);
+ result = MONKEY_ACTION_rerun_with_gdb (cntxt);
switch (result)
{
int retVal;
@@ -113,7 +113,7 @@
break;
case GDB_STATE_STOPPED:
/*FIXME: Expression Database should be inspected here (before writing
the report) */
- retVal = GNUNET_MONKEY_ACTION_inspect_expression_database (cntxt);
+ retVal = MONKEY_ACTION_inspect_expression_database (cntxt);
if (GNUNET_NO == retVal)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -124,7 +124,7 @@
else if (GDB_STATE_ERROR == retVal)
{
/* GDB could not locate a NULL value expression, launch Valgrind */
- retVal = GNUNET_MONKEY_ACTION_rerun_with_valgrind (cntxt);
+ retVal = MONKEY_ACTION_rerun_with_valgrind (cntxt);
if (GNUNET_NO == retVal)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error using Valgrind!\n");
@@ -132,7 +132,7 @@
break;
}
}
- if (GNUNET_OK != GNUNET_MONKEY_ACTION_format_report_xml (cntxt))
+ if (GNUNET_OK != MONKEY_ACTION_format_report_xml (cntxt))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error in generating debug report!\n");
@@ -140,7 +140,7 @@
}
if (strcasecmp (mode, "email") == 0)
{
- if (GNUNET_OK != GNUNET_MONKEY_ACTION_report_email (cntxt))
+ if (GNUNET_OK != MONKEY_ACTION_report_email (cntxt))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error sending email!\n");
ret = 1;
@@ -150,7 +150,7 @@
{
/* text mode */
if (GNUNET_OK !=
- GNUNET_MONKEY_ACTION_report_file (cntxt, dumpFileName,
GNUNET_YES))
+ MONKEY_ACTION_report_file (cntxt, dumpFileName, GNUNET_YES))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error in saving debug file!\n");
@@ -161,7 +161,7 @@
default:
break;
}
- GNUNET_MONKEY_ACTION_delete_context (cntxt);
+ MONKEY_ACTION_delete_context (cntxt);
}
Deleted:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_action.h
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_action.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,111 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2010, 2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-/**
- * @file monkey/gnunet_monkey_action.h
- * @brief Monkey API for actions taken by Monkey while debugging
- */
-
-#ifndef GNUNET_MONKEY_ACTION_H
-#define GNUNET_MONKEY_ACTION_H
-
-#include "gdbmi.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-/* Debug constants */
-#define DEBUG_MODE_GDB 0
-#define GDB_STATE_STOPPED 1
-#define GDB_STATE_EXIT_NORMALLY 2
-#define GDB_STATE_ERROR 3
-#define DEBUG_MODE_VALGRIND 4
-#define DEBUG_MODE_REPORT_READY 5
-#define BUG_NULL_POINTER 6
-#define BUG_CUSTOM 7
-#define EXPRESSION_EVALUATION_DEPTH 0
-
-
-/**
- * Context for the Action API
- */
-struct GNUNET_MONKEY_ACTION_Context
-{
- const char *binary_name;
- const char *email_address;
- const char *expression_database_path;
- const char *gdb_binary_path;
- const char *inspect_expression;
- const char *inspect_function;
- int debug_mode;
- int bug_detected;
- char *debug_report;
- struct GNUNET_MONKEY_XML_WRITER_node *xmlReportRootNode;
-
- /* gdb debugging attributes */
- int run_reverse;
- int function_start_line;
- int scope_depth;
- mi_h *gdb_handle;
- const char *gdb_in_use;
- mi_stop *gdb_stop_reason;
- mi_frames *gdb_frames;
- const char *gdb_null_variable;
-
- /* Valgrind memcheck attributes */
- char* valgrind_output_tmp_file_name;
-};
-
-
-int GNUNET_MONKEY_ACTION_report_file (struct GNUNET_MONKEY_ACTION_Context
- *cntxt, const char *dumpFileName, int
isXML);
-int GNUNET_MONKEY_ACTION_report_email (struct GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int GNUNET_MONKEY_ACTION_inspect_expression_database (struct
-
GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int GNUNET_MONKEY_ACTION_rerun_with_gdb (struct GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int GNUNET_MONKEY_ACTION_rerun_with_valgrind (struct
- GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int GNUNET_MONKEY_ACTION_format_report (struct GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int
-GNUNET_MONKEY_ACTION_format_report_xml (struct GNUNET_MONKEY_ACTION_Context
- *cntxt);
-int GNUNET_MONKEY_ACTION_delete_context(struct GNUNET_MONKEY_ACTION_Context
*cntxt);
-
-int GNUNET_MONKEY_ACTION_check_bug_redundancy (void);
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
Deleted:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_edb.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_edb.h
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_edb.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,169 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2009, 2010 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-/**
- * @file monkey/gnunet_monkey_edb.h
- * @brief Monkey API for accessing the Expression Database (edb)
- */
-
-#ifndef GNUNET_MONKEY_EDB_H
-#define GNUNET_MONKEY_EDB_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-struct GNUNET_MONKEY_EDB_Context;
-
-/**
- * Establish a connection to the Expression Database
- *
- * @param db_file_name path the Expression Database file
- * @return context to use for Accessing the Expression Database, NULL on error
- */
-struct GNUNET_MONKEY_EDB_Context *GNUNET_MONKEY_EDB_connect (const char
- *db_file_name);
-
-
-/**
- * Disconnect from Database, and cleanup resources
- *
- * @param context context
- * @return GNUNET_OK on success, GNUNET_NO on failure
- */
-int GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *cntxt);
-
-
-typedef int (*GNUNET_MONKEY_ExpressionIterator) (void *, int, char **,
- char **);
-
-typedef int (*GNUNET_MONKEY_FileIterator) (void *, int, char **, char **);
-
-
-
-int
-GNUNET_MONKEY_EDB_get_all_outer_scopes(struct GNUNET_MONKEY_EDB_Context
- *cntxt, const char *file_name,
- int function_beginning,
- int scope_in_question_start,
- int scope_in_question_end,
- GNUNET_MONKEY_ExpressionIterator
- iter, void *iter_cls);
-
-int
-GNUNET_MONKEY_EDB_function_start_line_for_scope(struct
GNUNET_MONKEY_EDB_Context
- *cntxt, const char *file_name,
- int scope_end,
- GNUNET_MONKEY_ExpressionIterator
- iter, void *iter_cls);
-/**
- * Return the line number of the end-of-scope for the expression indicated by
start_line_no
- *
- * @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's line
- * @param iter callback function, iterator for values returned from the
Database
- * @param iter_cls closure for the expression iterator, will contain the
scope-end line number
- * @return GNUNET_OK on success, GNUNET_NO on failure
- */
-int
-GNUNET_MONKEY_EDB_get_expression_scope_end (struct GNUNET_MONKEY_EDB_Context
- *cntxt, const char *file_name,
- int start_line_no,
- GNUNET_MONKEY_ExpressionIterator
- iter, void *iter_cls);
-
-
-
-/**
- * Return all the source code file names available in the Expression Database
- *
- * @param cntxt context containing the Expression Database handle
- * @param iter callback function, iterator for values returned from the
Database
- * @param iter_cls closure for the file names iterator, will contain the file
names
- * @return GNUNET_OK on success, GNUNET_NO on failure
- */
-int
-GNUNET_MONKEY_EDB_get_file_names (struct GNUNET_MONKEY_EDB_Context *cntxt,
- GNUNET_MONKEY_FileIterator iter,
- void *iter_cls);
-
-
-int
-GNUNET_MONKEY_EDB_get_expressions_outer_scopes (struct
GNUNET_MONKEY_EDB_Context *cntxt,
- const char *file_name, int start_line_no,
- int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
- void *iter_cls);
-
-/**
- * Run an SQLite query to retrieve those expressions that are previous to
- * given expression and are in the same scope of the given expression
- * For example, consider the following code snippet:
- *
- * {
- * struct Something whole; // line no.1
- * struct SomethingElse part; // line no.2
- * whole.part = ∂ // line no.3
- * whole.part->member = 1; // line no.4
- * }
- *
- * If the expression supplied to the function is that of line no.4
"whole.part->member = 1;"
- * The returned list of expressions will be: whole.part (line no.4),
whole.part->member (line no.4),
- * whole (line no.3), whole.part (line no.3), &part (line no.3), whole.part =
&part (line no.3)
- *
- * @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 GNUNET_OK success, GNUNET_NO failure
- */
-int
-GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *cntxt,
- const char *file_name, int start_line_no,
- int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
- void *iter_cls);
-
-
-int
-GNUNET_MONKEY_EDB_get_sub_expressions (struct GNUNET_MONKEY_EDB_Context
- *cntxt, const char *file_name,
- int start_line_no, int end_line_no,
- GNUNET_MONKEY_ExpressionIterator iter,
- void *iter_cls);
-
-
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Deleted:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_xml_writer.h
===================================================================
---
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_xml_writer.h
2012-02-18 22:28:04 UTC (rev 19855)
+++
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_xml_writer.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,74 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010, 2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file monkey/gnunet_monkey_xml_writer.h
- * @brief Monkey API for generating XML debug report
- */
-
-
-#ifndef GNUNET_MONKEY_XML_WRITER_H
-#define GNUNET_MONKEY_XML_WRITER_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-
-struct XmlAttribute {
- struct XmlAttribute *next;
- struct XmlAttribute *prev;
- const char *name;
- const char *value;
-};
-
-
-struct GNUNET_MONKEY_XML_Node {
- struct GNUNET_MONKEY_XML_Node *next;
- struct GNUNET_MONKEY_XML_Node *prev;
- const char *name;
- const char *value;
- const char *innerText;
- struct XmlAttribute* attributeListHead;
- struct XmlAttribute* attributeListTail;
- struct GNUNET_MONKEY_XML_Node *childrenListHead;
- struct GNUNET_MONKEY_XML_Node *childrenListTail;
-};
-
-struct GNUNET_MONKEY_XML_Node* GNUNET_MONKEY_XML_WRITER_new_node(const char
*name, const char *innerText);
-int GNUNET_MONKEY_XML_WRITER_delete_tree(struct GNUNET_MONKEY_XML_Node *root);
-struct GNUNET_MONKEY_XML_Node* GNUNET_MONKEY_XML_WRITER_add_child(struct
GNUNET_MONKEY_XML_Node *parent, struct GNUNET_MONKEY_XML_Node *child);
-int GNUNET_MONKEY_XML_WRITER_write_document(FILE* file, struct
GNUNET_MONKEY_XML_Node *root);
-FILE* GNUNET_MONKEY_XML_WRITER_create_document(const char *filePath);
-int GNUNET_MONKEY_XML_WRITER_add_attribute(struct GNUNET_MONKEY_XML_Node*
node, const char *attrName, const char *attrValue);
-int GNUNET_MONKEY_XML_WRITER_add_inner_text(struct GNUNET_MONKEY_XML_Node
*node, const char *innerText);
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Copied: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
(from rev 19189,
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_action.h)
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -0,0 +1,91 @@
+/**
+ * @file monkey/MONKEY_action.h
+ * @brief Monkey API for actions taken by Monkey while debugging
+ */
+
+#ifndef MONKEY_ACTION_H
+#define MONKEY_ACTION_H
+
+#include "gdbmi.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+/* Debug constants */
+#define DEBUG_MODE_GDB 0
+#define GDB_STATE_STOPPED 1
+#define GDB_STATE_EXIT_NORMALLY 2
+#define GDB_STATE_ERROR 3
+#define DEBUG_MODE_VALGRIND 4
+#define DEBUG_MODE_REPORT_READY 5
+#define BUG_NULL_POINTER 6
+#define BUG_CUSTOM 7
+#define EXPRESSION_EVALUATION_DEPTH 0
+
+
+/**
+ * Context for the Action API
+ */
+struct MONKEY_ACTION_Context
+{
+ const char *binary_name;
+ const char *email_address;
+ const char *expression_database_path;
+ const char *gdb_binary_path;
+ const char *inspect_expression;
+ const char *inspect_function;
+ int debug_mode;
+ int bug_detected;
+ char *debug_report;
+ struct MONKEY_XML_node *xmlReportRootNode;
+
+ /* gdb debugging attributes */
+ int run_reverse;
+ int function_start_line;
+ int scope_depth;
+ mi_h *gdb_handle;
+ const char *gdb_in_use;
+ mi_stop *gdb_stop_reason;
+ mi_frames *gdb_frames;
+ const char *gdb_null_variable;
+
+ /* Valgrind memcheck attributes */
+ char* valgrind_output_tmp_file_name;
+};
+
+
+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);
+int MONKEY_ACTION_inspect_expression_database (struct
+ MONKEY_ACTION_Context
+ *cntxt);
+int MONKEY_ACTION_rerun_with_gdb (struct MONKEY_ACTION_Context
+ *cntxt);
+int MONKEY_ACTION_rerun_with_valgrind (struct
+ MONKEY_ACTION_Context
+ *cntxt);
+int MONKEY_ACTION_format_report (struct MONKEY_ACTION_Context
+ *cntxt);
+int
+MONKEY_ACTION_format_report_xml (struct MONKEY_ACTION_Context
+ *cntxt);
+int MONKEY_ACTION_delete_context(struct MONKEY_ACTION_Context *cntxt);
+
+int MONKEY_ACTION_check_bug_redundancy (void);
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
Copied: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h (from
rev 19189,
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_edb.h)
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_edb.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -0,0 +1,149 @@
+/**
+ * @file monkey/MONKEY_edb.h
+ * @brief Monkey API for accessing the Expression Database (edb)
+ */
+
+#ifndef MONKEY_EDB_H
+#define MONKEY_EDB_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+struct MONKEY_EDB_Context;
+
+/**
+ * Establish a connection to the Expression Database
+ *
+ * @param db_file_name path the Expression Database file
+ * @return context to use for Accessing the Expression Database, NULL on error
+ */
+struct MONKEY_EDB_Context *MONKEY_EDB_connect (const char
+ *db_file_name);
+
+
+/**
+ * Disconnect from Database, and cleanup resources
+ *
+ * @param context context
+ * @return MONKEY_OK on success, MONKEY_NO on failure
+ */
+int MONKEY_EDB_disconnect (struct MONKEY_EDB_Context *cntxt);
+
+
+typedef int (*MONKEY_ExpressionIterator) (void *, int, char **,
+ char **);
+
+typedef int (*MONKEY_FileIterator) (void *, int, char **, char **);
+
+
+
+int
+MONKEY_EDB_get_all_outer_scopes(struct MONKEY_EDB_Context
+ *cntxt, const char *file_name,
+ int function_beginning,
+ int scope_in_question_start,
+ int scope_in_question_end,
+ MONKEY_ExpressionIterator
+ iter, void *iter_cls);
+
+int
+MONKEY_EDB_function_start_line_for_scope(struct MONKEY_EDB_Context
+ *cntxt, const char *file_name,
+ int scope_end,
+ MONKEY_ExpressionIterator
+ iter, void *iter_cls);
+/**
+ * Return the line number of the end-of-scope for the expression indicated by
start_line_no
+ *
+ * @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's line
+ * @param iter callback function, iterator for values returned from the
Database
+ * @param iter_cls closure for the expression iterator, will contain the
scope-end line number
+ * @return MONKEY_OK on success, MONKEY_NO on failure
+ */
+int
+MONKEY_EDB_get_expression_scope_end (struct MONKEY_EDB_Context
+ *cntxt, const char *file_name,
+ int start_line_no,
+ MONKEY_ExpressionIterator
+ iter, void *iter_cls);
+
+
+
+/**
+ * Return all the source code file names available in the Expression Database
+ *
+ * @param cntxt context containing the Expression Database handle
+ * @param iter callback function, iterator for values returned from the
Database
+ * @param iter_cls closure for the file names iterator, will contain the file
names
+ * @return MONKEY_OK on success, MONKEY_NO on failure
+ */
+int
+MONKEY_EDB_get_file_names (struct MONKEY_EDB_Context *cntxt,
+ MONKEY_FileIterator iter,
+ void *iter_cls);
+
+
+int
+MONKEY_EDB_get_expressions_outer_scopes (struct MONKEY_EDB_Context *cntxt,
+ const char *file_name, int start_line_no,
+ int end_line_no,
+ MONKEY_ExpressionIterator iter,
+ void *iter_cls);
+
+/**
+ * Run an SQLite query to retrieve those expressions that are previous to
+ * given expression and are in the same scope of the given expression
+ * For example, consider the following code snippet:
+ *
+ * {
+ * struct Something whole; // line no.1
+ * struct SomethingElse part; // line no.2
+ * whole.part = ∂ // line no.3
+ * whole.part->member = 1; // line no.4
+ * }
+ *
+ * If the expression supplied to the function is that of line no.4
"whole.part->member = 1;"
+ * The returned list of expressions will be: whole.part (line no.4),
whole.part->member (line no.4),
+ * whole (line no.3), whole.part (line no.3), &part (line no.3), whole.part =
&part (line no.3)
+ *
+ * @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
+ */
+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);
+
+
+int
+MONKEY_EDB_get_sub_expressions (struct MONKEY_EDB_Context
+ *cntxt, const char *file_name,
+ int start_line_no, int end_line_no,
+ MONKEY_ExpressionIterator iter,
+ void *iter_cls);
+
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Copied:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_xml_writer.h (from
rev 19189,
monkey/branches/MonkeyBacktracking/monkey/src/monkey/gnunet_monkey_xml_writer.h)
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_xml_writer.h
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_xml_writer.h
2012-02-19 23:22:39 UTC (rev 19856)
@@ -0,0 +1,54 @@
+/**
+ * @file monkey/MONKEY_xml_writer.h
+ * @brief Monkey API for generating XML debug report
+ */
+
+
+#ifndef MONKEY_XML_WRITER_H
+#define MONKEY_XML_WRITER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+struct XmlAttribute {
+ struct XmlAttribute *next;
+ struct XmlAttribute *prev;
+ const char *name;
+ const char *value;
+};
+
+
+struct MONKEY_XML_Node {
+ struct MONKEY_XML_Node *next;
+ struct MONKEY_XML_Node *prev;
+ const char *name;
+ const char *value;
+ const char *innerText;
+ struct XmlAttribute* attributeListHead;
+ struct XmlAttribute* attributeListTail;
+ struct MONKEY_XML_Node *childrenListHead;
+ struct MONKEY_XML_Node *childrenListTail;
+};
+
+struct MONKEY_XML_Node* MONKEY_XML_WRITER_new_node(const char *name, const
char *innerText);
+int MONKEY_XML_WRITER_delete_tree(struct MONKEY_XML_Node *root);
+struct MONKEY_XML_Node* MONKEY_XML_WRITER_add_child(struct MONKEY_XML_Node
*parent, struct MONKEY_XML_Node *child);
+int MONKEY_XML_WRITER_write_document(FILE* file, struct MONKEY_XML_Node *root);
+FILE* MONKEY_XML_WRITER_create_document(const char *filePath);
+int MONKEY_XML_WRITER_add_attribute(struct MONKEY_XML_Node* node, const char
*attrName, const char *attrValue);
+int MONKEY_XML_WRITER_add_inner_text(struct MONKEY_XML_Node *node, const char
*innerText);
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
2012-02-18 22:28:04 UTC (rev 19855)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
2012-02-19 23:22:39 UTC (rev 19856)
@@ -1,37 +1,17 @@
-/*
- This file is part of GNUnet.
- (C) 2010, 2011 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
/**
* @file monkey/xml_writer.c
* @brief Monkey API for generating XML debug report
*/
-#include "platform.h"
-#include <gnunet/gnunet_common.h>
-#include <gnunet/gnunet_container_lib.h>
#include <stdio.h>
-#include "gnunet_monkey_xml_writer.h"
+#include <stdlib.h>
+#include <assert.h>
+#include "monkey_common.h"
+#include "monkey_xml_writer.h"
-struct GNUNET_MONKEY_XML_Node* GNUNET_MONKEY_XML_WRITER_new_node(const char
*name, const char *innerText) {
- struct GNUNET_MONKEY_XML_Node *node = GNUNET_malloc(sizeof(struct
GNUNET_MONKEY_XML_Node));
+struct MONKEY_XML_Node* MONKEY_XML_WRITER_new_node(const char *name, const
char *innerText) {
+ struct MONKEY_XML_Node *node = malloc(sizeof(struct MONKEY_XML_Node));
node->name = name;
node->innerText = innerText;
node->childrenListHead = NULL;
@@ -42,58 +22,58 @@
}
-int GNUNET_MONKEY_XML_WRITER_add_attribute(struct GNUNET_MONKEY_XML_Node*
node, const char *attrName, const char *attrValue)
+int MONKEY_XML_WRITER_add_attribute(struct MONKEY_XML_Node* node, const char
*attrName, const char *attrValue)
{
- struct XmlAttribute *attribute = GNUNET_malloc(sizeof(struct
XmlAttribute));
+ struct XmlAttribute *attribute = malloc(sizeof(struct XmlAttribute));
attribute->name = attrName;
attribute->value = attrValue;
- GNUNET_CONTAINER_DLL_insert_tail (node->attributeListHead,
node->attributeListTail,
+ MONKEY_CONTAINER_DLL_insert_tail (node->attributeListHead,
node->attributeListTail,
attribute);
- return GNUNET_OK;
+ return MONKEY_OK;
}
-int GNUNET_MONKEY_XML_WRITER_add_inner_text(struct GNUNET_MONKEY_XML_Node
*node, const char *innerText)
+int MONKEY_XML_WRITER_add_inner_text(struct MONKEY_XML_Node *node, const char
*innerText)
{
node->innerText = innerText;
- return GNUNET_OK;
+ return MONKEY_OK;
}
-int GNUNET_MONKEY_XML_WRITER_delete_tree(struct GNUNET_MONKEY_XML_Node *root)
+int MONKEY_XML_WRITER_delete_tree(struct MONKEY_XML_Node *root)
{
- struct GNUNET_MONKEY_XML_Node *tmp = NULL;
+ struct MONKEY_XML_Node *tmp = NULL;
struct XmlAttribute *tmpAttribute = NULL;
/* Freeing children list - Depth First */
while (NULL != root->childrenListHead) {
tmp = root->childrenListHead;
root->childrenListHead = tmp->next;
- GNUNET_MONKEY_XML_WRITER_delete_tree(tmp);
+ MONKEY_XML_WRITER_delete_tree(tmp);
}
/* Freeing Attributes List */
while (NULL != root->attributeListHead) {
tmpAttribute = root->attributeListHead;
root->attributeListHead = tmpAttribute->next;
- GNUNET_free(tmpAttribute);
+ free(tmpAttribute);
}
/* Freeing Leaf Node */
- GNUNET_free(root);
+ free(root);
- return GNUNET_OK;
+ return MONKEY_OK;
}
-struct GNUNET_MONKEY_XML_Node* GNUNET_MONKEY_XML_WRITER_add_child(struct
GNUNET_MONKEY_XML_Node *parent, struct GNUNET_MONKEY_XML_Node *child) {
- GNUNET_CONTAINER_DLL_insert_tail (parent->childrenListHead,
parent->childrenListTail,
+struct MONKEY_XML_Node* MONKEY_XML_WRITER_add_child(struct MONKEY_XML_Node
*parent, struct MONKEY_XML_Node *child) {
+ MONKEY_CONTAINER_DLL_insert_tail (parent->childrenListHead,
parent->childrenListTail,
child);
return child;
}
-FILE* GNUNET_MONKEY_XML_WRITER_create_document(const char *filePath) {
+FILE* MONKEY_XML_WRITER_create_document(const char *filePath) {
FILE* file = fopen(filePath, "w");
if (NULL != file) {
fprintf(file, "<?xml version=\"1.0\"?>\n");
@@ -103,8 +83,8 @@
}
-int GNUNET_MONKEY_XML_WRITER_write_document(FILE* file, struct
GNUNET_MONKEY_XML_Node *root) {
- struct GNUNET_MONKEY_XML_Node *tmp = root->childrenListHead;
+int MONKEY_XML_WRITER_write_document(FILE* file, struct MONKEY_XML_Node *root)
{
+ struct MONKEY_XML_Node *tmp = root->childrenListHead;
struct XmlAttribute *tmpAttribute = root->attributeListHead;
if (NULL == tmpAttribute)
fprintf(file, "<%s>", root->name);
@@ -120,9 +100,9 @@
fprintf(file, "%s", root->innerText);
while (NULL != tmp) {
- GNUNET_MONKEY_XML_WRITER_write_document(file, tmp);
+ MONKEY_XML_WRITER_write_document(file, tmp);
tmp = tmp->next;
}
fprintf(file, "</%s>\n", root->name);//End
- return GNUNET_OK;
+ return MONKEY_OK;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19856 - in monkey/branches/MonkeyBacktracking/monkey/src: include monkey,
gnunet <=