[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22873 - monkey/branches/MonkeyBacktracking/monkey/src/monk
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22873 - monkey/branches/MonkeyBacktracking/monkey/src/monkey |
Date: |
Tue, 24 Jul 2012 16:57:01 +0200 |
Author: safey
Date: 2012-07-24 16:57:01 +0200 (Tue, 24 Jul 2012)
New Revision: 22873
Modified:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
Log:
Fixing the improper freeing problem of the gdbmi handle
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-07-24 14:14:40 UTC (rev 22872)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-07-24 14:57:01 UTC (rev 22873)
@@ -756,12 +756,15 @@
*/
if (MONKEY_NO == stoppedInSharedLib) {
if (MONKEY_NO != gmi_exec_next_reverse(cntxt->gdb_handle)) {
- while (!mi_get_response(cntxt->gdb_handle))
- usleep(GDB_MI_ASYNC_WAIT);
+ while (!mi_get_response(cntxt->gdb_handle))
+ usleep(GDB_MI_ASYNC_WAIT);
} else {
- fprintf(stderr, "Error: Reverse Execution has failed!\n");
- mi_disconnect(cntxt->gdb_handle); // No need for gdb mi
at this point!
- return MONKEY_NO;
+ fprintf(stderr, "Error: Reverse Execution has failed!
Backtracking might not be supported for the current architecture.\n");
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle); // No
need for gdb mi at this point!
+ cntxt->gdb_connected = MONKEY_NO;
+ }
+ return MONKEY_NO;
}
}
@@ -860,6 +863,7 @@
return MONKEY_NO;
}
printf("Connected to gdb!\n");
+ cntxt->gdb_connected = MONKEY_YES;
/* Set all callbacks. */
mi_set_console_cb(cntxt->gdb_handle, cb_console, NULL);
@@ -872,14 +876,20 @@
/* Set the name of the child and the command line arguments. */
if (!gmi_set_exec(cntxt->gdb_handle, cntxt->binary_name,
cntxt->binaryArgs)) {
printf("Error setting exec y args\n");
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
return MONKEY_NO;
}
/* Tell gdb to attach the child to a terminal. */
if (!gmi_target_terminal(cntxt->gdb_handle, ttyname(STDIN_FILENO))) {
printf("Error selecting target terminal\n");
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
return MONKEY_NO;
}
@@ -892,7 +902,10 @@
if (NULL == bp) {
printf("Error setting breakpoint at function:%s\n",
cntxt->inspect_function);
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
return MONKEY_NO;
}
mi_free_bkpt(bp);
@@ -908,7 +921,10 @@
if (NULL == bp) {
printf("Error setting breakpoint at function:%s\n",
cntxt->inspect_function);
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
return MONKEY_NO;
}
mi_free_bkpt(bp);
@@ -932,24 +948,26 @@
/* Run the program. */
if (!gmi_exec_run(cntxt->gdb_handle)) {
printf("Error in run!\n");
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
return MONKEY_NO;
}
/* Backtracking is issued after running the program */
if (MONKEY_YES == cntxt->run_reverse) {
gmi_exec_record_process(cntxt->gdb_handle);
- if (strcmp((char*)cntxt->gdb_handle->to_gdb_echo_data,
- "Process record: the current architecture
doesn't support record function.") == 0) {
- fprintf(stderr, "Warning: Backtracking is not supported
for the current architecture");
- }
- return MONKEY_NO;
}
/* Here we should be stopped when the program crashes */
ret = wait_for_stop(cntxt);
- if (ret == GDB_STATE_ERROR || ret == GDB_STATE_EXIT_NORMALLY)
- mi_disconnect(cntxt->gdb_handle);
+ if (ret == GDB_STATE_ERROR || ret == GDB_STATE_EXIT_NORMALLY) {
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
+ }
return ret;
}
@@ -1207,8 +1225,10 @@
int MONKEY_ACTION_delete_context(struct MONKEY_ACTION_Context
*cntxt)
{
- if (NULL != cntxt->gdb_handle)
- mi_disconnect(cntxt->gdb_handle);
+ if (MONKEY_YES == cntxt->gdb_connected) {
+ mi_disconnect(cntxt->gdb_handle);
+ cntxt->gdb_connected = MONKEY_NO;
+ }
if (NULL != cntxt->debug_report)
MONKEY_free(cntxt->debug_report);
if (NULL != cntxt->valgrind_output_tmp_file_name) {
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-07-24 14:14:40 UTC (rev 22872)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-07-24 14:57:01 UTC (rev 22873)
@@ -101,6 +101,7 @@
cntxt->bug_detected = 0;
cntxt->xml_report_node = NULL;
cntxt->run_reverse = reverseExecutionAllowed;
+ cntxt->gdb_connected = MONKEY_NO;
result = MONKEY_ACTION_rerun_with_gdb (cntxt);
switch (result)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22873 - monkey/branches/MonkeyBacktracking/monkey/src/monkey,
gnunet <=