aboutsummaryrefslogtreecommitdiff
path: root/src/monkey/gnunet-monkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/monkey/gnunet-monkey.c')
-rw-r--r--src/monkey/gnunet-monkey.c173
1 files changed, 91 insertions, 82 deletions
diff --git a/src/monkey/gnunet-monkey.c b/src/monkey/gnunet-monkey.c
index 61579817d..13bd71e84 100644
--- a/src/monkey/gnunet-monkey.c
+++ b/src/monkey/gnunet-monkey.c
@@ -17,6 +17,7 @@
17#include "gnunet_common.h" 17#include "gnunet_common.h"
18#include "gnunet_getopt_lib.h" 18#include "gnunet_getopt_lib.h"
19#include "gnunet_program_lib.h" 19#include "gnunet_program_lib.h"
20#include "gnunet_monkey_action.h"
20 21
21extern void sendMail (const char *messageContents); 22extern void sendMail (const char *messageContents);
22static const char* mode; 23static const char* mode;
@@ -128,88 +129,96 @@ run (void *cls,
128 const char *cfgfile, 129 const char *cfgfile,
129 const struct GNUNET_CONFIGURATION_Handle *c) 130 const struct GNUNET_CONFIGURATION_Handle *c)
130{ 131{
131 mi_aux_term *xterm_tty=NULL; 132 struct GNUNET_MONKEY_ACTION_Context* cntxt =
132 133 GNUNET_malloc(sizeof(struct GNUNET_MONKEY_ACTION_Context));
133 /* This is like a file-handle for fopen. 134 cntxt->binary_name = binaryName;
134 Here we have all the state of gdb "connection". */ 135 if (GNUNET_OK == GNUNET_MONKEY_ACTION_rerun_with_gdb(cntxt)) {
135 mi_h *h; 136 GNUNET_MONKEY_ACTION_format_report(cntxt);
136 137 GNUNET_MONKEY_ACTION_report_file(cntxt, dumpFileName);
137 /* Connect to gdb child. */ 138 }
138 h=mi_connect_local(); 139
139 if (!h) 140// mi_aux_term *xterm_tty=NULL;
140 { 141//
141 printf("Connect failed\n"); 142// /* This is like a file-handle for fopen.
142 ret = 1; 143// Here we have all the state of gdb "connection". */
143 return; 144// mi_h *h;
144 } 145//
145 printf("Connected to gdb!\n"); 146// /* Connect to gdb child. */
146 147// h=mi_connect_local();
147 /* Set all callbacks. */ 148// if (!h)
148 mi_set_console_cb(h,cb_console,NULL); 149// {
149 mi_set_target_cb(h,cb_target,NULL); 150// printf("Connect failed\n");
150 mi_set_log_cb(h,cb_log,NULL); 151// ret = 1;
151 mi_set_async_cb(h,cb_async,NULL); 152// return;
152 mi_set_to_gdb_cb(h,cb_to,NULL); 153// }
153 mi_set_from_gdb_cb(h,cb_from,NULL); 154// printf("Connected to gdb!\n");
154 155//
155 /* Set the name of the child and the command line aguments. */ 156// /* Set all callbacks. */
156 if (!gmi_set_exec(h, binaryName, NULL)) 157// mi_set_console_cb(h,cb_console,NULL);
157 { 158// mi_set_target_cb(h,cb_target,NULL);
158 printf("Error setting exec y args\n"); 159// mi_set_log_cb(h,cb_log,NULL);
159 mi_disconnect(h); 160// mi_set_async_cb(h,cb_async,NULL);
160 ret = 1; 161// mi_set_to_gdb_cb(h,cb_to,NULL);
161 return; 162// mi_set_from_gdb_cb(h,cb_from,NULL);
162 } 163//
163 164// /* Set the name of the child and the command line aguments. */
164 /* Tell gdb to attach the child to a terminal. */ 165// if (!gmi_set_exec(h, binaryName, NULL))
165 if (!gmi_target_terminal(h, ttyname(STDIN_FILENO))) 166// {
166 { 167// printf("Error setting exec y args\n");
167 printf("Error selecting target terminal\n"); 168// mi_disconnect(h);
168 mi_disconnect(h); 169// ret = 1;
169 ret = 1; 170// return;
170 return; 171// }
171 } 172//
172 173// /* Tell gdb to attach the child to a terminal. */
173 /* Run the program. */ 174// if (!gmi_target_terminal(h, ttyname(STDIN_FILENO)))
174 if (!gmi_exec_run(h)) 175// {
175 { 176// printf("Error selecting target terminal\n");
176 printf("Error in run!\n"); 177// mi_disconnect(h);
177 mi_disconnect(h); 178// ret = 1;
178 ret = 1; 179// return;
179 return; 180// }
180 } 181//
181 /* Here we should be stopped when the program crashes */ 182// /* Run the program. */
182 if (!wait_for_stop(h)) 183// if (!gmi_exec_run(h))
183 { 184// {
184 mi_disconnect(h); 185// printf("Error in run!\n");
185 ret = 1; 186// mi_disconnect(h);
186 return; 187// ret = 1;
187 } 188// return;
188 189// }
189 /* Continue execution. */ 190// /* Here we should be stopped when the program crashes */
190 if (!gmi_exec_continue(h)) 191// if (!wait_for_stop(h))
191 { 192// {
192 printf("Error in continue!\n"); 193// mi_disconnect(h);
193 mi_disconnect(h); 194// ret = 1;
194 ret = 1; 195// return;
195 return; 196// }
196 } 197//
197 /* Here we should be terminated. */ 198// /* Continue execution. */
198 if (!wait_for_stop(h)) 199// if (!gmi_exec_continue(h))
199 { 200// {
200 mi_disconnect(h); 201// printf("Error in continue!\n");
201 ret = 1; 202// mi_disconnect(h);
202 return; 203// ret = 1;
203 } 204// return;
204 205// }
205 /* Exit from gdb. */ 206// /* Here we should be terminated. */
206 gmi_gdb_exit(h); 207// if (!wait_for_stop(h))
207 /* Close the connection. */ 208// {
208 mi_disconnect(h); 209// mi_disconnect(h);
209 /* Wait 5 seconds and close the auxiliar terminal. */ 210// ret = 1;
210 printf("Waiting 5 seconds\n"); 211// return;
211 sleep(5); 212// }
212 gmi_end_aux_term(xterm_tty); 213//
214// /* Exit from gdb. */
215// gmi_gdb_exit(h);
216// /* Close the connection. */
217// mi_disconnect(h);
218// /* Wait 5 seconds and close the auxiliar terminal. */
219// printf("Waiting 5 seconds\n");
220// sleep(5);
221// gmi_end_aux_term(xterm_tty);
213} 222}
214 223
215 224