[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25638 - monkey/trunk/pathologist/src/pathologist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25638 - monkey/trunk/pathologist/src/pathologist |
Date: |
Fri, 21 Dec 2012 23:11:11 +0100 |
Author: teichm
Date: 2012-12-21 23:11:11 +0100 (Fri, 21 Dec 2012)
New Revision: 25638
Modified:
monkey/trunk/pathologist/src/pathologist/action_api.c
monkey/trunk/pathologist/src/pathologist/edb_api.c
monkey/trunk/pathologist/src/pathologist/pathologist_edb.h
Log:
reintroduced call stack trace traversal
Modified: monkey/trunk/pathologist/src/pathologist/action_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/action_api.c 2012-12-21
20:45:17 UTC (rev 25637)
+++ monkey/trunk/pathologist/src/pathologist/action_api.c 2012-12-21
22:11:11 UTC (rev 25638)
@@ -306,18 +306,6 @@
static int
-functionStartCallback(void *cls, int numColumns, char **colValues,
- char **colNames)
-{
- if (NULL == colValues[0])
- return 1; /* Error */
-
- failureFunctionStartLine = atoi(colValues[0]);
- return 0; /* OK */
-}
-
-
-static int
iterateExpressions(void *cls, int numColumns, char **colValues,
char **colNames)
{
@@ -479,12 +467,12 @@
int MONKEY_ACTION_inspect_expression_database(struct MONKEY_ACTION_Context
*cntxt)
{
int ret = MONKEY_OK;
+ int stackDepth = 0;
struct Function *function = NULL;
+ struct Trace *trace = NULL;
/* Variables used across recursive calls */
- static struct Trace *trace = NULL;
static int isBugClassified = MONKEY_NO;
- static int stackDepth = 0;
static struct MONKEY_EDB_Context *edbCntxt;
if (NULL == signalMeaning) {
@@ -498,82 +486,94 @@
epoch->traceListTail = NULL;
}
- if (0 == stackDepth) {
- // Initialize the trace structure for this particular epoch step
- trace = MONKEY_malloc(sizeof(struct Trace));
- MONKEY_CONTAINER_DLL_insert_tail(epoch->traceListHead,
- epoch->traceListTail, trace);
+ // Initialize the trace structure for this particular epoch step
+ trace = MONKEY_malloc(sizeof(struct Trace));
+ 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) {
- fprintf(stderr, "Unable to connect to Expression
Database file!\n");
- ret = MONKEY_NO;
- goto cleanup;
- }
- }
+ // Create a connection to the Expression Database
+ edbCntxt = MONKEY_EDB_connect(cntxt->expression_database_path);
+ if (NULL == edbCntxt) {
+ fprintf(stderr, "Unable to connect to Expression Database
file!\n");
+ ret = MONKEY_NO;
+ goto cleanup;
+ }
- // Now we know the end scope of the faulty expression. We can build the
function struct
- function = MONKEY_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;
- function->expressionListHead = NULL;
- function->expressionListTail = NULL;
- function->next = NULL;
- function->prev = NULL;
- MONKEY_CONTAINER_DLL_insert_tail(trace->functionListHead,
- trace->functionListTail, function);
+ while( cntxt->gdb_frames && stackDepth <= cntxt->scope_depth) {
+ gmi_stack_select_frame(cntxt->gdb_handle,
cntxt->gdb_frames->level);
+ gmi_stack_info_frame(cntxt->gdb_handle);
- // Retrieve scope expressions from the database
- MONKEY_EDB_get_expressions(edbCntxt,
-
cntxt->gdb_frames->file,
-
cntxt->gdb_frames->line,
- &iterateExpressions,
function);
+ // build the function struct
+ function = MONKEY_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;
+ function->expressionListHead = NULL;
+ function->expressionListTail = NULL;
+ function->next = NULL;
+ function->prev = NULL;
+ MONKEY_CONTAINER_DLL_insert_tail(trace->functionListHead,
+ trace->functionListTail,
function);
- // Do value analysis for relevant expressions
- analyzeExpressionValues(function, cntxt);
+ // Retrieve scope expressions from the database
+ MONKEY_EDB_get_expressions(edbCntxt,
+
cntxt->gdb_frames->file,
+
cntxt->gdb_frames->line,
+
&iterateExpressions, function);
- if (MONKEY_NO == isBugClassified) {
- isBugClassified = MONKEY_YES;
- if ((strcasecmp(signalMeaning, "Segmentation fault") == 0)
- || (strcasecmp(signalMeaning, "Signal 0") == 0)) {
- if (MONKEY_YES == cntxt->has_null) {
- cntxt->bug_detected = BUG_NULL_POINTER;
- }
- else {
- cntxt->bug_detected = BUG_BAD_MEM_ACCESS;
- }
- }
- else if (strcasecmp(signalMeaning, "Aborted") == 0) {
- cntxt->bug_detected = BUG_ABORT;
- }
- else if (strcasecmp(signalMeaning, "Arithmetic exception") ==
0) {
- cntxt->bug_detected = BUG_ARITHMETIC;
- }
- else if (strcasecmp(signalName, "SIGBUS") == 0) {
- cntxt->bug_detected = BUG_SIG_BUS;
- }
- }
+ // Do value analysis for relevant expressions
+ analyzeExpressionValues(function, cntxt);
+ //TODO Evil, bring it out of the loop!
+ if (MONKEY_NO == isBugClassified) {
+ if ((strcasecmp(signalMeaning, "Segmentation fault") ==
0)
+ || (strcasecmp(signalMeaning, "Signal 0") == 0)) {
+ if (MONKEY_YES == cntxt->has_null) {
+ cntxt->bug_detected = BUG_NULL_POINTER;
+ }
+ else {
+ cntxt->bug_detected =
BUG_BAD_MEM_ACCESS;
+ }
+ }
+ else if (strcasecmp(signalMeaning, "Aborted") == 0) {
+ cntxt->bug_detected = BUG_ABORT;
+ }
+ else if (strcasecmp(signalMeaning, "Arithmetic
exception") == 0) {
+ cntxt->bug_detected = BUG_ARITHMETIC;
+ }
+ else if (strcasecmp(signalName, "SIGBUS") == 0) {
+ cntxt->bug_detected = BUG_SIG_BUS;
+ }
+ isBugClassified = MONKEY_YES;
+ }
- /* Now, dive deeper into the stack trace */
- cntxt->gdb_frames = cntxt->gdb_frames->next;
+ /* Now, dive deeper into the stack trace */
+ cntxt->gdb_frames = cntxt->gdb_frames->next;
+ }
- if (NULL == cntxt->gdb_frames) {
- /* Cleanup function static variables that are used across
recursive calls */
+ // evaluate globals only once
+ function = MONKEY_malloc(sizeof(struct Function));
+ function->depth = 0;
+ 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(trace->functionListHead,
+ trace->functionListTail, function);
+
+ // Retrieve globals from the database
+ MONKEY_EDB_get_globals( edbCntxt,
+ &iterateExpressions,
function);
+
+ // Do value analysis for globals
+ analyzeExpressionValues(function, cntxt);
+
cleanup:
- stackDepth = 0;
- trace = NULL;
- MONKEY_EDB_disconnect(edbCntxt);
- } else {
- /* Recursively inspect the database for deeper frames */
-/* gmi_stack_select_frame(cntxt->gdb_handle, cntxt->gdb_frames->level);
- gmi_stack_info_frame(cntxt->gdb_handle);
- ret = MONKEY_ACTION_inspect_expression_database(cntxt); */
- return MONKEY_OK;
- }
+ MONKEY_EDB_disconnect(edbCntxt);
return ret;
}
Modified: monkey/trunk/pathologist/src/pathologist/edb_api.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/edb_api.c 2012-12-21 20:45:17 UTC
(rev 25637)
+++ monkey/trunk/pathologist/src/pathologist/edb_api.c 2012-12-21 22:11:11 UTC
(rev 25638)
@@ -272,30 +272,24 @@
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) {
+MONKEY_EDB_get_globals (struct MONKEY_EDB_Context *cntxt,
+ MONKEY_ExpressionIterator iter,
+ void *iter_cls) {
int err;
char *errMsg;
char *query;
if (MONKEY_asprintf
(&query,
- "select expr_syntax, start_lineno, is_call from Expression where
file_name LIKE \'%%%s\' and start_lineno >= %d and end_lineno <= %d",
- file_name, start_line_no, end_line_no) == -1)
+ "select distinct expr_syntax, start_lineno, is_call from Expression
where start_lineno = 0 and end_lineno = 32767") == -1)
{
- fprintf(stderr,
- "Memory allocation problem occurred!\n");
+ fprintf(stderr, "Memory allocation problem occurred!\n");
return MONKEY_NO;
}
err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg);
if (err)
{
- fprintf(stderr,
- "Error occurred while executing Database query. `%s'",
- errMsg);
+ fprintf(stderr, "Error occurred while executing Database query.
`%s'", errMsg);
return MONKEY_NO;
}
return MONKEY_OK;
@@ -323,7 +317,7 @@
char *query;
if (MONKEY_asprintf
(&query,
- "select expr_syntax, start_lineno, is_call from Expression where
file_name LIKE \'%%%s\' and ((start_lineno <= %d and end_lineno >= %d and
end_lineno != 32767) or (start_lineno = 0 and end_lineno = 32767))",
+ "select expr_syntax, start_lineno, is_call from Expression where
file_name LIKE \'%%%s\' and start_lineno <= %d and end_lineno >= %d and
end_lineno != 32767",
file_name, start_line_no, start_line_no) == -1)
{
fprintf(stderr, "Memory allocation problem occurred!\n");
Modified: monkey/trunk/pathologist/src/pathologist/pathologist_edb.h
===================================================================
--- monkey/trunk/pathologist/src/pathologist/pathologist_edb.h 2012-12-21
20:45:17 UTC (rev 25637)
+++ monkey/trunk/pathologist/src/pathologist/pathologist_edb.h 2012-12-21
22:11:11 UTC (rev 25638)
@@ -104,11 +104,9 @@
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);
+MONKEY_EDB_get_globals (struct MONKEY_EDB_Context *cntxt,
+ MONKEY_ExpressionIterator iter,
+ void *iter_cls);
/**
* Run an SQLite query to retrieve those expressions that are previous to
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25638 - monkey/trunk/pathologist/src/pathologist,
gnunet <=