[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25657 - monkey/trunk/pathologist/src/pathologist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25657 - monkey/trunk/pathologist/src/pathologist |
Date: |
Thu, 27 Dec 2012 15:19:44 +0100 |
Author: teichm
Date: 2012-12-27 15:19:44 +0100 (Thu, 27 Dec 2012)
New Revision: 25657
Modified:
monkey/trunk/pathologist/src/pathologist/action_api.c
Log:
added globals node to the report
Modified: monkey/trunk/pathologist/src/pathologist/action_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/action_api.c 2012-12-27
13:32:18 UTC (rev 25656)
+++ monkey/trunk/pathologist/src/pathologist/action_api.c 2012-12-27
14:19:44 UTC (rev 25657)
@@ -73,6 +73,8 @@
struct Trace *prev;
struct Function *functionListHead;
struct Function *functionListTail;
+ struct Expression *globalsListHead;
+ struct Expression *globalsListTail;
};
@@ -331,6 +333,31 @@
static int
+iterateGlobals(void *cls, int numColumns, char **colValues,
+ char **colNames)
+{
+ struct Expression *expression;
+ struct Trace *trace = (struct Trace *) cls;
+
+ if (NULL == colValues[0] || NULL == colValues[1] || NULL == colValues[2])
+ return 1; /* Error */
+
+ expression = MONKEY_malloc(sizeof(struct Expression));
+ expression->expressionSyntax = MONKEY_strdup(colValues[0]);
+ expression->lineNo = atoi(colValues[1]);
+ expression->isCall = atoi(colValues[2]);
+ expression->expressionValue = NULL;
+ expression->next = NULL;
+ expression->prev = NULL;
+
+ MONKEY_CONTAINER_DLL_insert(trace->globalsListHead,
+ trace->globalsListTail, expression);
+
+ return 0; /* OK */
+}
+
+
+static int
scopeEndCallback(void *cls, int numColumns, char **colValues,
char **colNames)
{
@@ -394,6 +421,51 @@
}
+static int
+analyzeGlobalsValues(struct Trace *trace,
+ struct MONKEY_ACTION_Context *cntxt)
+{
+ struct Expression *tmp;
+
+ tmp = trace->globalsListHead;
+ while (NULL != tmp) {
+ if( tmp->isCall || tmp == faultyExpression ) {
+ // We will not evaluate function calls (because GDB
will evaluate by calling the function) or faultyExpressions
+ tmp = tmp->next;
+ continue;
+ }
+ else if( isAssignment(tmp->expressionSyntax) ) {
+ // We should NOT evaluate assignments, otherwise
subsequent expression evaluations will be spoiled
+ // Expressions with assignments should be removed from
the list of expressions
+ struct Expression *removedExpression = tmp;
+ tmp = tmp->next;
+ MONKEY_CONTAINER_DLL_remove(trace->globalsListHead,
+
trace->globalsListTail,
+
removedExpression);
+ continue;
+ }
+ if (strcmp(tmp->expressionSyntax, "NULL") == 0) {
+ tmp->expressionValue = "0x0";
+ tmp = tmp->next;
+ continue;
+ }
+ tmp->expressionValue =
+ gmi_data_evaluate_expression( cntxt->gdb_handle,
+
tmp->expressionSyntax);
+ if (NULL != tmp->expressionValue
+ && (strcmp(tmp->expressionValue, "0x0") == 0
+ || strcmp(tmp->expressionValue, "NULL") == 0))
+ {
+ cntxt->gdb_null_variable = tmp->expressionSyntax;
+ cntxt->has_null = MONKEY_YES;
+ }
+ tmp = tmp->next;
+ }
+
+ return MONKEY_OK;
+}
+
+
static int flushTrace(struct Trace *trace)
{
struct Function *functionPtr = NULL;
@@ -488,9 +560,12 @@
// Initialize the trace structure for this particular epoch step
trace = MONKEY_malloc(sizeof(struct Trace));
+ trace->globalsListHead = NULL;
+ trace->globalsListTail = NULL;
MONKEY_CONTAINER_DLL_insert_tail(epoch->traceListHead,
epoch->traceListTail, trace);
+
// Create a connection to the Expression Database
edbCntxt = MONKEY_EDB_connect(cntxt->expression_database_path);
if (NULL == edbCntxt) {
@@ -552,25 +627,12 @@
cntxt->gdb_frames = cntxt->gdb_frames->next;
}
- // evaluate globals only once
- function = MONKEY_malloc(sizeof(struct Function));
- function->depth = stackDepth;
- function->line = 0;
- function->name = "Global Variables";
- function->file = "all (not yet just relevant) files";
- function->expressionListHead = NULL;
- function->expressionListTail = NULL;
- function->next = NULL;
- function->prev = NULL;
- MONKEY_CONTAINER_DLL_insert_tail(trace->functionListHead,
- trace->functionListTail, function);
-
// Retrieve globals from the database
MONKEY_EDB_get_globals( edbCntxt,
- &iterateExpressions,
function);
+ &iterateGlobals, trace);
// Do value analysis for globals
- analyzeExpressionValues(function, cntxt);
+ analyzeGlobalsValues(trace, cntxt);
cleanup:
MONKEY_EDB_disconnect(edbCntxt);
@@ -940,6 +1002,17 @@
}
+static struct MONKEY_XML_Node *createXmlGlobalExpressionNode(const char *name,
+ const char *value)
+{
+ struct MONKEY_XML_Node *node;
+
+ node = MONKEY_XML_WRITER_new_node("expression", value);
+ MONKEY_XML_WRITER_add_attribute(node, "name", name);
+ return node;
+}
+
+
int MONKEY_ACTION_format_report_xml(struct MONKEY_ACTION_Context
*cntxt)
{
@@ -947,6 +1020,7 @@
struct MONKEY_XML_Node *node;
struct MONKEY_XML_Node *historyNode;
struct MONKEY_XML_Node *traceNode;
+ struct MONKEY_XML_Node *globalsNode;
struct Trace *tracePtr = epoch->traceListHead;
struct Function *functionPtr = tracePtr->functionListHead;
struct Expression *expressionPtr;
@@ -980,6 +1054,7 @@
while (NULL != tracePtr) {
node = MONKEY_XML_WRITER_add_child(historyNode,
createXmlEpochStep(i));
traceNode = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("trace", NULL));
+ globalsNode = MONKEY_XML_WRITER_add_child(node,
createXmlSimpleNode("globals", NULL));
functionPtr = tracePtr->functionListHead;
while (NULL != functionPtr) {
@@ -992,7 +1067,6 @@
expressionPtr = functionPtr->expressionListHead;
while (NULL != expressionPtr) {
// ignore non helpful expressions
- //if( expressionPtr->expressionValue &&
strcmp(expressionPtr->expressionValue, "<value optimized out>") != 0)
if( expressionPtr->expressionValue )
MONKEY_XML_WRITER_add_child(node,
createXmlExpressionNode(expressionPtr->expressionSyntax,
expressionPtr->expressionValue));
expressionPtr = expressionPtr->next;
@@ -1001,6 +1075,14 @@
functionPtr = functionPtr->next;
}
+ expressionPtr = tracePtr->globalsListHead;
+ while( expressionPtr ) {
+ if( expressionPtr->expressionValue )
+ MONKEY_XML_WRITER_add_child(globalsNode,
createXmlGlobalExpressionNode(expressionPtr->expressionSyntax,
expressionPtr->expressionValue));
+ expressionPtr = expressionPtr->next;
+ }
+
+
tracePtr = tracePtr->next;
i++;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25657 - monkey/trunk/pathologist/src/pathologist,
gnunet <=