[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20337 - monkey/branches/MonkeyBacktracking/monkey/src/monk
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20337 - monkey/branches/MonkeyBacktracking/monkey/src/monkey |
Date: |
Wed, 7 Mar 2012 14:38:04 +0100 |
Author: safey
Date: 2012-03-07 14:38:04 +0100 (Wed, 07 Mar 2012)
New Revision: 20337
Modified:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
Log:
Valgrind report appended to XML bug reports.
Check for valgrind existence.
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-03-07 12:45:04 UTC (rev 20336)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-03-07 13:38:04 UTC (rev 20337)
@@ -661,11 +661,21 @@
{
char *valgrindCommand;
FILE *valgrindPipe;
+ const char *valgrindPath = cntxt->valgrind_binary_path;
MONKEY_asprintf (&cntxt->valgrind_output_tmp_file_name, "%d", rand ());
cntxt->debug_mode = DEBUG_MODE_VALGRIND;
+ if (NULL == valgrindPath)
+ valgrindPath = "/usr/bin/valgrind"; /* Assumption for valgrind
installation */
+
+ if (0 != access(valgrindPath, X_OK)) {
+ /* Valgrind is not installed, stop */
+ fprintf(stderr, "Warning: Valgrind is not installed. Memory check
aborted!\n");
+ return MONKEY_NO;
+ }
+
MONKEY_asprintf (&valgrindCommand,
- "valgrind --leak-check=yes --log-file=%s %s",
+ "%s --leak-check=yes --log-file=%s %s", valgrindPath,
cntxt->valgrind_output_tmp_file_name, cntxt->binary_name);
valgrindPipe = popen (valgrindCommand, "r");
if (NULL == valgrindPipe)
@@ -677,6 +687,7 @@
pclose (valgrindPipe);
MONKEY_free (valgrindCommand);
+ cntxt->bug_detected = BUG_BAD_MEM_ACCESS;
return MONKEY_OK;
}
@@ -861,9 +872,9 @@
}
-static struct MONKEY_XML_Node * createXmlSimpleNode(const char *nodeName) {
+static struct MONKEY_XML_Node * createXmlSimpleNode(const char *nodeName,
const char *nodeInnerText) {
struct MONKEY_XML_Node *node =
- MONKEY_XML_WRITER_new_node(nodeName, NULL);
+ MONKEY_XML_WRITER_new_node(nodeName, nodeInnerText);
return node;
}
@@ -925,37 +936,36 @@
struct Function *functionPtr = trace->functionListHead;
struct Expression *expressionPtr;
- switch (cntxt->debug_mode) {
- case DEBUG_MODE_GDB:
+
switch (cntxt->bug_detected) {
case BUG_NULL_POINTER:
cntxt->xmlReportRootNode = createXmlCrashNode("npe",
functionPtr->name, functionPtr->line, functionPtr->file);
- node =
MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode,
createXmlSimpleNode("history"));
- node = MONKEY_XML_WRITER_add_child(node,
createXmlEpochStep(0));
- traceNode = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("trace"));
- while (NULL != functionPtr) {
- node = MONKEY_XML_WRITER_add_child(traceNode,
createXmlFunctionNode(functionPtr->name, functionPtr->line, functionPtr->file,
functionPtr->depth));
- node = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("expressions"));
-
- expressionPtr = functionPtr->expressionListHead;
- while (NULL != expressionPtr) {
- MONKEY_XML_WRITER_add_child(node,
createXmlExpressionNode(expressionPtr->expressionSyntax,
- (NULL ==
expressionPtr->expressionValue) ? "Not Evaluated" :
expressionPtr->expressionValue)); // node = "expressions" node
- expressionPtr = expressionPtr->next;
- }
-
- functionPtr = functionPtr->next;
- }
break;
+ case BUG_BAD_MEM_ACCESS:
+ cntxt->xmlReportRootNode = createXmlCrashNode("Bad
memory access", functionPtr->name, functionPtr->line, functionPtr->file);
+ node =
MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode,
createXmlSimpleNode("valgrind", getValgrindOutput(cntxt)));
+ break;
case BUG_CUSTOM:
default:
return MONKEY_NO; //problem!
}
- break;
- case DEBUG_MODE_VALGRIND:
- break;
- default:
- return MONKEY_NO; //problem!
+
+ /* Adding Stack Trace Nodes to XML Report */
+ node = MONKEY_XML_WRITER_add_child(cntxt->xmlReportRootNode,
createXmlSimpleNode("history", NULL));
+ node = MONKEY_XML_WRITER_add_child(node, createXmlEpochStep(0));
+ traceNode = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("trace", NULL));
+ while (NULL != functionPtr) {
+ node = MONKEY_XML_WRITER_add_child(traceNode,
createXmlFunctionNode(functionPtr->name, functionPtr->line, functionPtr->file,
functionPtr->depth));
+ node = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("expressions", NULL));
+
+ expressionPtr = functionPtr->expressionListHead;
+ while (NULL != expressionPtr) {
+ MONKEY_XML_WRITER_add_child(node,
createXmlExpressionNode(expressionPtr->expressionSyntax,
+ (NULL ==
expressionPtr->expressionValue) ? "Not Evaluated" :
expressionPtr->expressionValue)); // node = "expressions" node
+ expressionPtr = expressionPtr->next;
+ }
+
+ functionPtr = functionPtr->next;
}
return MONKEY_OK;
}
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-03-07 12:45:04 UTC (rev 20336)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-03-07 13:38:04 UTC (rev 20337)
@@ -37,6 +37,7 @@
static const char *emailAddress = NULL;
static const char *edbFilePath = NULL;
static const char *gdbBinaryPath = NULL;
+static const char *valgrindBinaryPath = NULL;
static const char *inspectExpression = NULL;
static const char *inspectFunction = NULL;
static int ret = 0;
@@ -88,6 +89,7 @@
cntxt->binary_name = binaryName;
cntxt->expression_database_path = edbFilePath;
cntxt->gdb_binary_path = gdbBinaryPath;
+ cntxt->valgrind_binary_path = valgrindBinaryPath;
cntxt->inspect_expression = inspectExpression;
cntxt->inspect_function = inspectFunction;
cntxt->function_start_line = 0;
@@ -166,10 +168,11 @@
printf ("\t-m: mode: monkey's mode of operation: options are \"text\" or
\"email\" [mandatory]\n");
printf ("\t-a: address: email address to which monkey will send debug
report [optional]\n");
printf ("\t-f: function: function name at which monkey will set a
breakpoint [optional]\n");
- printf ("\t-g: gdb: path to gdb binary to use. If not passed, monkey will
look for gdb at /usr/bin/gdb [optional]\n");
+ printf ("\t-g: gdb: path to gdb binary to use. If not passed, monkey will
set it to /usr/bin/gdb [optional]\n");
+ printf ("\t-l: valgrind: path to valgrind binary. If not passed, monkey
will set it to /usr/bin/valgrind [optional]\n");
printf ("\t-h: help: print this help [optional]\n");
printf ("\t-i: inspect: expression to inspect in the function specified
after argument f [optional]\n");
- printf ("\t-o: output: path to the debug report generated by monkey. If not
provided monkey will save the report in a file named monkey_output in the
current working directory [optional]\n");
+ printf ("\t-o: output: path to the debug report generated by monkey.\n If
not provided monkey will save the report in a file named monkey_output in the
current working directory [optional]\n");
printf ("\t-v: version: monkey's version [optional]\n");
printf ("Report bugs to address@hidden");
printf ("GNUnet home page: http://www.gnu.org/software/gnunet/\n");
@@ -190,6 +193,8 @@
MONKEY_free(edbFilePath);
if (NULL != gdbBinaryPath)
MONKEY_free(gdbBinaryPath);
+ if (NULL != valgrindBinaryPath)
+ MONKEY_free(valgrindBinaryPath);
if (NULL != inspectExpression)
MONKEY_free(inspectExpression);
if (NULL != inspectFunction)
@@ -239,6 +244,9 @@
else if (strcmp("-g", argv[i]) == 0) {
gdbBinaryPath = MONKEY_strdup(argv[++i]);
}
+ else if (strcmp("-l", argv[i]) == 0) {
+ valgrindBinaryPath = MONKEY_strdup(argv[++i]);
+ }
else if (strcmp("-f", argv[i]) == 0) {
inspectFunction = MONKEY_strdup(argv[++i]);
}
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
2012-03-07 12:45:04 UTC (rev 20336)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
2012-03-07 13:38:04 UTC (rev 20337)
@@ -27,6 +27,7 @@
#define DEBUG_MODE_REPORT_READY 5
#define BUG_NULL_POINTER 6
#define BUG_CUSTOM 7
+#define BUG_BAD_MEM_ACCESS 8
#define EXPRESSION_EVALUATION_DEPTH 0
@@ -39,6 +40,7 @@
const char *email_address;
const char *expression_database_path;
const char *gdb_binary_path;
+ const char *valgrind_binary_path;
const char *inspect_expression;
const char *inspect_function;
int debug_mode;
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
2012-03-07 12:45:04 UTC (rev 20336)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/xml_writer.c
2012-03-07 13:38:04 UTC (rev 20337)
@@ -85,7 +85,6 @@
return NULL;
}
-
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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20337 - monkey/branches/MonkeyBacktracking/monkey/src/monkey,
gnunet <=