[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18819 - monkey/src/monkey
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18819 - monkey/src/monkey |
Date: |
Sun, 25 Dec 2011 22:11:23 +0100 |
Author: safey
Date: 2011-12-25 22:11:23 +0100 (Sun, 25 Dec 2011)
New Revision: 18819
Added:
monkey/src/monkey/gnunet_monkey_xml_writer.h
monkey/src/monkey/xml_writer.c
Modified:
monkey/src/monkey/Makefile.am
monkey/src/monkey/action_api.c
monkey/src/monkey/gnunet-monkey.c
monkey/src/monkey/gnunet_monkey_action.h
Log:
GNUnet Monkey XML Writer API
Modified: monkey/src/monkey/Makefile.am
===================================================================
--- monkey/src/monkey/Makefile.am 2011-12-25 20:51:03 UTC (rev 18818)
+++ monkey/src/monkey/Makefile.am 2011-12-25 21:11:23 UTC (rev 18819)
@@ -16,7 +16,8 @@
lib_LTLIBRARIES = libmonkeyedb.la \
- libmonkeyaction.la
+ libmonkeyaction.la \
+ libmonkeyxml.la
libmonkeyedb_la_SOURCES = \
edb_api.c \
@@ -35,6 +36,14 @@
-lgnunetutil \
$(GN_LIBINTL) $(XLIB)
+libmonkeyxml_la_LIBADD = \
+ -lgnunetutil \
+ $(GN_LIBINTL) $(XLIB)
+
+libmonkeyxml_la_SOURCES = \
+ xml_writer.c \
+ gnunet_monkey_xml_writer.h
+
bin_PROGRAMS = \
gnunet-monkey \
gnunet-service-monkey \
@@ -75,6 +84,7 @@
-lgnunetutil \
$(top_builddir)/src/monkey/libmonkeyedb.la \
$(top_builddir)/src/monkey/libmonkeyaction.la \
+ $(top_builddir)/src/monkey/libmonkeyxml.la \
-lesmtp \
$(GN_LIBINTL)
Modified: monkey/src/monkey/action_api.c
===================================================================
--- monkey/src/monkey/action_api.c 2011-12-25 20:51:03 UTC (rev 18818)
+++ monkey/src/monkey/action_api.c 2011-12-25 21:11:23 UTC (rev 18819)
@@ -27,6 +27,7 @@
#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 <libesmtp.h>
@@ -239,12 +240,20 @@
int
GNUNET_MONKEY_ACTION_report_file (struct GNUNET_MONKEY_ACTION_Context *cntxt,
- const char *dumpFileName)
+ const char *dumpFileName, int isXML)
{
- FILE *file = fopen (dumpFileName, "w");
- GNUNET_assert (NULL != file);
- fprintf (file, "%s", cntxt->debug_report);
- fclose (file);
+ FILE *file = NULL;
+ if (!isXML) {
+ file = fopen (dumpFileName, "w");
+ GNUNET_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);
+ }
+
+ if (NULL != file)
+ fclose(file);
return GNUNET_OK;
}
@@ -774,7 +783,89 @@
}
+static struct GNUNET_MONKEY_XML_Node * createXmlSimpleNode(const char
*nodeName) {
+ struct GNUNET_MONKEY_XML_Node *node =
+ GNUNET_MONKEY_XML_WRITER_new_node(nodeName, NULL,
nodeName);
+ return node;
+}
+
+
+static struct GNUNET_MONKEY_XML_Node * createXmlCrashNode(const char
*category, const char *function, int line, const char *file) {
+ char *tag;
+ struct GNUNET_MONKEY_XML_Node * node;
+
+ GNUNET_asprintf(&tag, "crash category= \"%s\" function=\"%s\"
line=\"%d\" file=\"%s\"", category, function, line, file);
+ node = GNUNET_MONKEY_XML_WRITER_new_node(tag, NULL, "crash");
+ return node;
+}
+
+
+static struct GNUNET_MONKEY_XML_Node * createXmlEpochStep(int step) {
+ char *tag;
+ struct GNUNET_MONKEY_XML_Node * node;
+
+ GNUNET_asprintf(&tag, "epoch step=\"%d\"", step);
+ node = GNUNET_MONKEY_XML_WRITER_new_node(tag, NULL, "epoch");
+ return node;
+}
+
+
+static struct GNUNET_MONKEY_XML_Node * createXmlFunctionNode(const char *name,
int line, const char *file, int depth) {
+ char *tag;
+ struct GNUNET_MONKEY_XML_Node * node;
+
+ GNUNET_asprintf(&tag, "function name=\"%s\" line=\"%d\" file=\"%s\"
depth=\"%d\"", name, line, file, depth);
+ node = GNUNET_MONKEY_XML_WRITER_new_node(tag, NULL, "function");
+ return node;
+}
+
+
+static struct GNUNET_MONKEY_XML_Node * createXmlExpressionNode(const char
*name, const char *value) {
+ char *tag;
+ char *v;
+ struct GNUNET_MONKEY_XML_Node * node;
+
+ GNUNET_asprintf(&tag, "expression name=\"%s\"", name);
+ GNUNET_asprintf(&v, "%s", value);
+ node = GNUNET_MONKEY_XML_WRITER_new_node(tag, v, "expression");
+ return node;
+}
+
+
int
+GNUNET_MONKEY_ACTION_format_report_xml (struct GNUNET_MONKEY_ACTION_Context
+ *cntxt) {
+ struct GNUNET_MONKEY_XML_Node *node;
+ char *str;
+
+ 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"));
+
+ break;
+ case BUG_CUSTOM:
+ default:
+ return GNUNET_NO; //problem!
+ }
+ break;
+ case DEBUG_MODE_VALGRIND:
+ break;
+ default:
+ return GNUNET_NO; //problem!
+ }
+ return GNUNET_OK;
+}
+
+
+int
GNUNET_MONKEY_ACTION_format_report (struct GNUNET_MONKEY_ACTION_Context
*cntxt)
{
@@ -863,6 +954,8 @@
remove (cntxt->valgrind_output_tmp_file_name);
GNUNET_free (cntxt->valgrind_output_tmp_file_name);
}
+ if (NULL != cntxt->xmlReportRootNode)
+ GNUNET_MONKEY_XML_WRITER_delete_tree(cntxt->xmlReportRootNode);
GNUNET_free (cntxt);
return GNUNET_OK;
Modified: monkey/src/monkey/gnunet-monkey.c
===================================================================
--- monkey/src/monkey/gnunet-monkey.c 2011-12-25 20:51:03 UTC (rev 18818)
+++ monkey/src/monkey/gnunet-monkey.c 2011-12-25 21:11:23 UTC (rev 18819)
@@ -98,6 +98,7 @@
cntxt->inspect_function = inspectFunction;
cntxt->function_start_line = 0;
cntxt->scope_depth = 0;
+ cntxt->xmlReportRootNode = NULL;
result = GNUNET_MONKEY_ACTION_rerun_with_gdb (cntxt);
switch (result)
@@ -131,7 +132,7 @@
break;
}
}
- if (GNUNET_OK != GNUNET_MONKEY_ACTION_format_report (cntxt))
+ if (GNUNET_OK != GNUNET_MONKEY_ACTION_format_report_xml (cntxt))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error in generating debug report!\n");
@@ -149,7 +150,7 @@
{
/* text mode */
if (GNUNET_OK !=
- GNUNET_MONKEY_ACTION_report_file (cntxt, dumpFileName))
+ GNUNET_MONKEY_ACTION_report_file (cntxt, dumpFileName,
GNUNET_YES))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error in saving debug file!\n");
Modified: monkey/src/monkey/gnunet_monkey_action.h
===================================================================
--- monkey/src/monkey/gnunet_monkey_action.h 2011-12-25 20:51:03 UTC (rev
18818)
+++ monkey/src/monkey/gnunet_monkey_action.h 2011-12-25 21:11:23 UTC (rev
18819)
@@ -63,6 +63,7 @@
int debug_mode;
int bug_detected;
char *debug_report;
+ struct GNUNET_MONKEY_XML_WRITER_node *xmlReportRootNode;
/* gdb debugging attributes */
int run_reverse;
@@ -80,7 +81,7 @@
int GNUNET_MONKEY_ACTION_report_file (struct GNUNET_MONKEY_ACTION_Context
- *cntxt, const char *dumpFileName);
+ *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
@@ -93,6 +94,9 @@
*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);
Added: monkey/src/monkey/gnunet_monkey_xml_writer.h
===================================================================
--- monkey/src/monkey/gnunet_monkey_xml_writer.h
(rev 0)
+++ monkey/src/monkey/gnunet_monkey_xml_writer.h 2011-12-25 21:11:23 UTC
(rev 18819)
@@ -0,0 +1,62 @@
+/*
+ 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 GNUNET_MONKEY_XML_Node {
+ struct GNUNET_MONKEY_XML_Node *next;
+ struct GNUNET_MONKEY_XML_Node *prev;
+ const char *name;
+ const char *value;
+ const char *closingTag;
+ 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 *value, const char *closingTag);
+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);
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Property changes on: monkey/src/monkey/gnunet_monkey_xml_writer.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: monkey/src/monkey/xml_writer.c
===================================================================
--- monkey/src/monkey/xml_writer.c (rev 0)
+++ monkey/src/monkey/xml_writer.c 2011-12-25 21:11:23 UTC (rev 18819)
@@ -0,0 +1,84 @@
+/*
+ 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"
+
+struct GNUNET_MONKEY_XML_Node* GNUNET_MONKEY_XML_WRITER_new_node(const char
*name, const char *value, const char *closingTag) {
+ struct GNUNET_MONKEY_XML_Node *node = GNUNET_malloc(sizeof(struct
GNUNET_MONKEY_XML_Node));
+ node->name = name;
+ node->value = value;
+ node->closingTag = closingTag;
+ node->childrenListHead = NULL;
+ node->childrenListTail = NULL;
+ return node;
+}
+
+
+int GNUNET_MONKEY_XML_WRITER_delete_tree(struct GNUNET_MONKEY_XML_Node *root) {
+ struct GNUNET_MONKEY_XML_Node *tmp = root->childrenListHead;
+ while (NULL != tmp) {
+ GNUNET_MONKEY_XML_WRITER_delete_tree(tmp);
+ tmp = tmp->next;
+ }
+ GNUNET_free(root);
+
+ return GNUNET_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 (parent->childrenListHead,
parent->childrenListTail,
+ child);
+ return child;
+}
+
+
+FILE* GNUNET_MONKEY_XML_WRITER_create_document(const char *filePath) {
+ FILE* file = fopen(filePath, "w");
+ if (NULL != file) {
+ fprintf(file, "<?xml version=\"1.0\"?>\n");
+ return file;
+ }
+ return NULL;
+}
+
+
+int GNUNET_MONKEY_XML_WRITER_write_document(FILE* file, struct
GNUNET_MONKEY_XML_Node *root) {
+ struct GNUNET_MONKEY_XML_Node *tmp = root->childrenListHead;
+ if (NULL == root->value)
+ fprintf(file, "<%s>\n", root->name);
+ else
+ fprintf(file, "<%s> %s", root->name, root->value);
+ while (NULL != tmp) {
+ GNUNET_MONKEY_XML_WRITER_write_document(file, tmp);
+ tmp = tmp->next;
+ }
+ fprintf(file, "</%s>\n", root->closingTag);//End
+ return GNUNET_OK;
+}
Property changes on: monkey/src/monkey/xml_writer.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18819 - monkey/src/monkey,
gnunet <=