* plugins/debug-manager/command.c:
[anjuta-git-plugin.git] / plugins / debug-manager / command.c
blob7d3180f37b234e4541acb7e7ac6808322a8b78db
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 command.c
4 Copyright (C) 2007 Sébastien Granjoux
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * Wrap each debugger commands in a command object put in a FIFO queue
23 *---------------------------------------------------------------------------*/
25 #include <config.h>
27 #include "command.h"
29 #include "queue.h"
31 /*#define DEBUG*/
32 #include <libanjuta/anjuta-debug.h>
33 #include <libanjuta/interfaces/ianjuta-debugger-breakpoint.h>
34 #include <libanjuta/interfaces/ianjuta-debugger-register.h>
35 #include <libanjuta/interfaces/ianjuta-debugger-memory.h>
36 #include <libanjuta/interfaces/ianjuta-debugger-instruction.h>
37 #include <libanjuta/interfaces/ianjuta-debugger-variable.h>
39 #include <stdarg.h>
41 /* Contants defintion
42 *---------------------------------------------------------------------------*/
44 /* Private type
45 *---------------------------------------------------------------------------*/
47 typedef enum
49 EMPTY_COMMAND ,
50 CALLBACK_COMMAND,
51 LOAD_COMMAND, /* Debugger started */
52 ATTACH_COMMAND,
53 QUIT_COMMAND, /* Debugger started - Program stopped */
54 ABORT_COMMAND,
55 USER_COMMAND,
56 INSPECT_MEMORY_COMMAND,
57 DISASSEMBLE_COMMAND,
58 LIST_REGISTER_COMMAND,
59 UNLOAD_COMMAND, /* Program loaded */
60 START_COMMAND,
61 BREAK_LINE_COMMAND, /* Program loaded - Program stopped */
62 BREAK_FUNCTION_COMMAND,
63 BREAK_ADDRESS_COMMAND,
64 ENABLE_BREAK_COMMAND,
65 IGNORE_BREAK_COMMAND, /* 0x10 */
66 CONDITION_BREAK_COMMAND,
67 REMOVE_BREAK_COMMAND,
68 LIST_BREAK_COMMAND,
69 INFO_SHAREDLIB_COMMAND,
70 INFO_TARGET_COMMAND,
71 INFO_PROGRAM_COMMAND,
72 INFO_UDOT_COMMAND,
73 STEP_IN_COMMAND, /* Program stopped */
74 STEP_OVER_COMMAND,
75 STEP_OUT_COMMAND,
76 RUN_COMMAND,
77 RUN_TO_COMMAND,
78 STEPI_IN_COMMAND,
79 STEPI_OVER_COMMAND,
80 RUN_TO_ADDRESS_COMMAND,
81 EXIT_COMMAND, /* 0x20 */
82 HANDLE_SIGNAL_COMMAND,
83 LIST_LOCAL_COMMAND,
84 LIST_ARG_COMMAND,
85 LIST_THREAD_COMMAND,
86 SET_THREAD_COMMAND,
87 INFO_THREAD_COMMAND,
88 INFO_SIGNAL_COMMAND,
89 INFO_FRAME_COMMAND,
90 INFO_ARGS_COMMAND,
91 INFO_VARIABLES_COMMAND,
92 SET_FRAME_COMMAND,
93 LIST_FRAME_COMMAND,
94 UPDATE_REGISTER_COMMAND,
95 WRITE_REGISTER_COMMAND,
96 EVALUATE_COMMAND,
97 INSPECT_COMMAND, /* 0x30 */
98 PRINT_COMMAND,
99 CREATE_VARIABLE,
100 EVALUATE_VARIABLE,
101 LIST_VARIABLE_CHILDREN,
102 DELETE_VARIABLE,
103 ASSIGN_VARIABLE,
104 UPDATE_VARIABLE,
105 INTERRUPT_COMMAND /* Program running */
106 } DmaDebuggerCommandType;
108 typedef enum
110 DMA_CALLBACK_COMMAND =
111 CALLBACK_COMMAND |
112 NEED_DEBUGGER_STOPPED | NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
113 DMA_LOAD_COMMAND =
114 LOAD_COMMAND | LOAD_PROGRAM |
115 NEED_DEBUGGER_STOPPED | NEED_DEBUGGER_STARTED,
116 DMA_ATTACH_COMMAND =
117 ATTACH_COMMAND | RUN_PROGRAM |
118 NEED_DEBUGGER_STOPPED | NEED_DEBUGGER_STARTED,
119 DMA_QUIT_COMMAND =
120 QUIT_COMMAND | CANCEL_ALL_COMMAND | STOP_DEBUGGER |
121 HIGH_PRIORITY | NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
122 DMA_ABORT_COMMAND =
123 ABORT_COMMAND | CANCEL_ALL_COMMAND | STOP_DEBUGGER |
124 ASYNCHRONOUS | NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
125 DMA_USER_COMMAND =
126 USER_COMMAND |
127 NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
128 DMA_INSPECT_MEMORY_COMMAND =
129 INSPECT_MEMORY_COMMAND |
130 NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
131 DMA_DISASSEMBLE_COMMAND =
132 DISASSEMBLE_COMMAND |
133 NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
134 DMA_LIST_REGISTER_COMMAND =
135 LIST_REGISTER_COMMAND |
136 NEED_DEBUGGER_STARTED | NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
137 DMA_UNLOAD_COMMAND =
138 UNLOAD_COMMAND | START_DEBUGGER |
139 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
140 DMA_START_COMMAND =
141 START_COMMAND | RUN_PROGRAM |
142 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
143 DMA_BREAK_LINE_COMMAND =
144 BREAK_LINE_COMMAND |
145 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
146 DMA_BREAK_FUNCTION_COMMAND =
147 BREAK_FUNCTION_COMMAND |
148 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
149 DMA_BREAK_ADDRESS_COMMAND =
150 BREAK_ADDRESS_COMMAND |
151 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
152 DMA_ENABLE_BREAK_COMMAND =
153 ENABLE_BREAK_COMMAND |
154 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
155 DMA_IGNORE_BREAK_COMMAND =
156 IGNORE_BREAK_COMMAND |
157 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
158 DMA_CONDITION_BREAK_COMMAND =
159 CONDITION_BREAK_COMMAND |
160 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
161 DMA_REMOVE_BREAK_COMMAND =
162 REMOVE_BREAK_COMMAND |
163 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
164 DMA_LIST_BREAK_COMMAND =
165 LIST_BREAK_COMMAND |
166 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
167 DMA_INFO_SHAREDLIB_COMMAND =
168 INFO_SHAREDLIB_COMMAND |
169 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
170 DMA_INFO_TARGET_COMMAND =
171 INFO_TARGET_COMMAND |
172 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
173 DMA_INFO_PROGRAM_COMMAND =
174 INFO_PROGRAM_COMMAND |
175 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
176 DMA_INFO_UDOT_COMMAND =
177 INFO_UDOT_COMMAND |
178 NEED_PROGRAM_LOADED | NEED_PROGRAM_STOPPED,
179 DMA_STEP_IN_COMMAND =
180 STEP_IN_COMMAND | RUN_PROGRAM |
181 NEED_PROGRAM_STOPPED,
182 DMA_STEP_OVER_COMMAND =
183 STEP_OVER_COMMAND | RUN_PROGRAM |
184 NEED_PROGRAM_STOPPED,
185 DMA_STEP_OUT_COMMAND =
186 STEP_OUT_COMMAND | RUN_PROGRAM |
187 NEED_PROGRAM_STOPPED,
188 DMA_RUN_COMMAND =
189 RUN_COMMAND | RUN_PROGRAM |
190 NEED_PROGRAM_STOPPED,
191 DMA_RUN_TO_COMMAND =
192 RUN_TO_COMMAND | RUN_PROGRAM |
193 NEED_PROGRAM_STOPPED,
194 DMA_STEPI_IN_COMMAND =
195 STEPI_IN_COMMAND | RUN_PROGRAM |
196 NEED_PROGRAM_STOPPED,
197 DMA_STEPI_OVER_COMMAND =
198 STEPI_OVER_COMMAND | RUN_PROGRAM |
199 NEED_PROGRAM_STOPPED,
200 DMA_RUN_TO_ADDRESS_COMMAND =
201 RUN_TO_ADDRESS_COMMAND | RUN_PROGRAM |
202 NEED_PROGRAM_STOPPED,
203 DMA_EXIT_COMMAND =
204 EXIT_COMMAND | LOAD_PROGRAM |
205 NEED_PROGRAM_STOPPED,
206 DMA_HANDLE_SIGNAL_COMMAND =
207 HANDLE_SIGNAL_COMMAND |
208 NEED_PROGRAM_STOPPED,
209 DMA_LIST_LOCAL_COMMAND =
210 LIST_LOCAL_COMMAND |
211 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
212 DMA_LIST_ARG_COMMAND =
213 LIST_ARG_COMMAND |
214 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
215 DMA_LIST_THREAD_COMMAND =
216 LIST_THREAD_COMMAND |
217 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
218 DMA_SET_THREAD_COMMAND =
219 SET_THREAD_COMMAND |
220 NEED_PROGRAM_STOPPED,
221 DMA_INFO_THREAD_COMMAND =
222 INFO_THREAD_COMMAND |
223 NEED_PROGRAM_STOPPED,
224 DMA_INFO_SIGNAL_COMMAND =
225 INFO_SIGNAL_COMMAND |
226 NEED_PROGRAM_STOPPED,
227 DMA_INFO_FRAME_COMMAND =
228 INFO_FRAME_COMMAND |
229 NEED_PROGRAM_STOPPED,
230 DMA_INFO_ARGS_COMMAND =
231 INFO_ARGS_COMMAND |
232 NEED_PROGRAM_STOPPED,
233 DMA_INFO_VARIABLES_COMMAND =
234 INFO_VARIABLES_COMMAND |
235 NEED_PROGRAM_STOPPED,
236 DMA_SET_FRAME_COMMAND =
237 SET_FRAME_COMMAND |
238 NEED_PROGRAM_STOPPED,
239 DMA_LIST_FRAME_COMMAND =
240 LIST_FRAME_COMMAND |
241 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
242 DMA_UPDATE_REGISTER_COMMAND =
243 UPDATE_REGISTER_COMMAND |
244 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
245 DMA_WRITE_REGISTER_COMMAND =
246 WRITE_REGISTER_COMMAND |
247 NEED_PROGRAM_STOPPED,
248 DMA_EVALUATE_COMMAND =
249 EVALUATE_COMMAND |
250 NEED_PROGRAM_STOPPED,
251 DMA_INSPECT_COMMAND =
252 INSPECT_COMMAND |
253 NEED_PROGRAM_STOPPED,
254 DMA_PRINT_COMMAND =
255 PRINT_COMMAND |
256 NEED_PROGRAM_STOPPED,
257 DMA_CREATE_VARIABLE_COMMAND =
258 CREATE_VARIABLE |
259 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
260 DMA_EVALUATE_VARIABLE_COMMAND =
261 EVALUATE_VARIABLE | CANCEL_IF_PROGRAM_RUNNING |
262 NEED_PROGRAM_STOPPED,
263 DMA_LIST_VARIABLE_CHILDREN_COMMAND =
264 LIST_VARIABLE_CHILDREN |
265 NEED_PROGRAM_STOPPED,
266 DMA_DELETE_VARIABLE_COMMAND =
267 DELETE_VARIABLE |
268 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
269 DMA_ASSIGN_VARIABLE_COMMAND =
270 ASSIGN_VARIABLE |
271 NEED_PROGRAM_STOPPED,
272 DMA_UPDATE_VARIABLE_COMMAND =
273 UPDATE_VARIABLE | CANCEL_IF_PROGRAM_RUNNING |
274 NEED_PROGRAM_STOPPED | NEED_PROGRAM_RUNNING,
275 DMA_INTERRUPT_COMMAND =
276 INTERRUPT_COMMAND | STOP_PROGRAM |
277 ASYNCHRONOUS | NEED_PROGRAM_RUNNING,
278 } DmaDebuggerCommand;
280 struct _DmaQueueCommand
282 DmaDebuggerCommandType type;
283 IAnjutaDebuggerCallback callback;
284 gpointer user_data;
285 union {
286 struct {
287 gchar *file;
288 gchar *type;
289 GList *dirs;
290 } load;
291 struct {
292 gchar *args;
293 gboolean terminal;
294 gboolean stop;
295 } start;
296 struct {
297 pid_t pid;
298 GList *dirs;
299 } attach;
300 struct {
301 guint *id;
302 gchar *file;
303 guint line;
304 gulong address;
305 gchar *function;
306 } pos;
307 struct {
308 guint id;
309 guint ignore;
310 gchar *condition;
311 gboolean enable;
312 } brk;
313 struct {
314 guint id;
315 gchar *name;
316 gchar *value;
317 } watch;
318 struct {
319 gchar *cmd;
320 } user;
321 struct {
322 gchar *var;
323 } print;
324 struct {
325 guint id;
326 } info;
327 struct {
328 gchar *name;
329 gboolean stop;
330 gboolean print;
331 gboolean ignore;
332 } signal;
333 struct {
334 guint frame;
335 } frame;
336 struct {
337 gulong address;
338 guint length;
339 } mem;
340 struct {
341 gchar *name;
342 gchar *value;
343 } var;
344 } data;
345 struct _DmaQueueCommand *next;
348 /* Private function
349 *---------------------------------------------------------------------------*/
351 static DmaQueueCommand*
352 dma_command_new (DmaDebuggerCommand cmd_type,...)
354 DmaQueueCommand* cmd;
355 DmaDebuggerCommandType type = cmd_type & COMMAND_MASK;
356 IAnjutaDebuggerRegisterData* reg;
357 va_list args;
358 GList *list;
360 cmd = g_new0 (DmaQueueCommand, 1);
361 cmd->type = cmd_type;
363 va_start (args, cmd_type);
364 switch (type)
366 case EMPTY_COMMAND:
367 break;
368 case CALLBACK_COMMAND:
369 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
370 cmd->user_data = va_arg (args, gpointer);
371 break;
372 case LOAD_COMMAND:
373 cmd->data.load.file = g_strdup (va_arg (args, gchar *));
374 cmd->data.load.type = g_strdup (va_arg (args, gchar *));
375 cmd->data.load.dirs = NULL;
376 for (list = va_arg (args, GList *); list != NULL; list = g_list_next (list))
378 cmd->data.load.dirs = g_list_prepend (cmd->data.load.dirs, g_strdup (list->data));
380 cmd->data.load.dirs = g_list_reverse (cmd->data.load.dirs);
381 break;
382 case ATTACH_COMMAND:
383 cmd->data.attach.pid = va_arg (args,pid_t);
384 cmd->data.load.dirs = NULL;
385 for (list = va_arg (args, GList *); list != NULL; list = g_list_next (list))
387 cmd->data.load.dirs = g_list_prepend (cmd->data.load.dirs, g_strdup (list->data));
389 cmd->data.load.dirs = g_list_reverse (cmd->data.load.dirs);
390 break;
391 case UNLOAD_COMMAND:
392 break;
393 case QUIT_COMMAND:
394 break;
395 case ABORT_COMMAND:
396 break;
397 case START_COMMAND:
398 cmd->data.start.args = g_strdup (va_arg (args, gchar *));
399 cmd->data.start.terminal = va_arg (args, gboolean);
400 cmd->data.start.stop = va_arg (args, gboolean);
401 break;
402 case RUN_COMMAND:
403 break;
404 case RUN_TO_COMMAND:
405 cmd->data.pos.file = g_strdup (va_arg (args, gchar *));
406 cmd->data.pos.line = va_arg (args, guint);
407 break;
408 case STEP_IN_COMMAND:
409 break;
410 case STEP_OVER_COMMAND:
411 break;
412 case STEP_OUT_COMMAND:
413 break;
414 case RUN_TO_ADDRESS_COMMAND:
415 cmd->data.pos.address = va_arg (args, guint);
416 break;
417 case STEPI_IN_COMMAND:
418 break;
419 case STEPI_OVER_COMMAND:
420 break;
421 case EXIT_COMMAND:
422 break;
423 case INTERRUPT_COMMAND:
424 break;
425 case ENABLE_BREAK_COMMAND:
426 cmd->data.brk.id = va_arg (args, gint);
427 cmd->data.brk.enable = va_arg (args, gboolean);
428 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
429 cmd->user_data = va_arg (args, gpointer);
430 break;
431 case IGNORE_BREAK_COMMAND:
432 cmd->data.brk.id = va_arg (args, gint);
433 cmd->data.brk.ignore = va_arg (args, guint);
434 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
435 cmd->user_data = va_arg (args, gpointer);
436 break;
437 case REMOVE_BREAK_COMMAND:
438 cmd->data.brk.id = va_arg (args, gint);
439 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
440 cmd->user_data = va_arg (args, gpointer);
441 break;
442 case BREAK_LINE_COMMAND:
443 cmd->data.pos.id = va_arg (args, guint *);
444 cmd->data.pos.file = g_strdup (va_arg (args, gchar *));
445 cmd->data.pos.line = va_arg (args, guint);
446 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
447 cmd->user_data = va_arg (args, gpointer);
448 break;
449 case BREAK_FUNCTION_COMMAND:
450 cmd->data.pos.id = va_arg (args, guint *);
451 cmd->data.pos.file = g_strdup (va_arg (args, gchar *));
452 cmd->data.pos.function = g_strdup (va_arg (args, gchar *));
453 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
454 cmd->user_data = va_arg (args, gpointer);
455 break;
456 case BREAK_ADDRESS_COMMAND:
457 cmd->data.pos.id = va_arg (args, guint *);
458 cmd->data.pos.address = va_arg (args, gulong);
459 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
460 cmd->user_data = va_arg (args, gpointer);
461 break;
462 case CONDITION_BREAK_COMMAND:
463 cmd->data.brk.id = va_arg (args, gint);
464 cmd->data.brk.condition = g_strdup (va_arg (args, gchar *));
465 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
466 cmd->user_data = va_arg (args, gpointer);
467 break;
468 case LIST_BREAK_COMMAND:
469 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
470 cmd->user_data = va_arg (args, gpointer);
471 break;
472 case INSPECT_COMMAND:
473 cmd->data.watch.name = g_strdup (va_arg (args, gchar *));
474 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
475 cmd->user_data = va_arg (args, gpointer);
476 break;
477 case EVALUATE_COMMAND:
478 cmd->data.watch.name = g_strdup (va_arg (args, gchar *));
479 cmd->data.watch.value = g_strdup (va_arg (args, gchar *));
480 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
481 cmd->user_data = va_arg (args, gpointer);
482 break;
483 case LIST_LOCAL_COMMAND:
484 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
485 cmd->user_data = va_arg (args, gpointer);
486 break;
487 case LIST_ARG_COMMAND:
488 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
489 cmd->user_data = va_arg (args, gpointer);
490 break;
491 case LIST_THREAD_COMMAND:
492 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
493 cmd->user_data = va_arg (args, gpointer);
494 break;
495 case SET_THREAD_COMMAND:
496 cmd->data.frame.frame = va_arg (args, guint);
497 break;
498 case INFO_THREAD_COMMAND:
499 cmd->data.info.id = va_arg (args, guint);
500 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
501 cmd->user_data = va_arg (args, gpointer);
502 break;
503 case INFO_SIGNAL_COMMAND:
504 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
505 cmd->user_data = va_arg (args, gpointer);
506 break;
507 case INFO_SHAREDLIB_COMMAND:
508 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
509 cmd->user_data = va_arg (args, gpointer);
510 break;
511 case INFO_FRAME_COMMAND:
512 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
513 cmd->user_data = va_arg (args, gpointer);
514 break;
515 case INFO_ARGS_COMMAND:
516 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
517 cmd->user_data = va_arg (args, gpointer);
518 break;
519 case INFO_TARGET_COMMAND:
520 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
521 cmd->user_data = va_arg (args, gpointer);
522 break;
523 case INFO_PROGRAM_COMMAND:
524 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
525 cmd->user_data = va_arg (args, gpointer);
526 break;
527 case INFO_UDOT_COMMAND:
528 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
529 cmd->user_data = va_arg (args, gpointer);
530 break;
531 case INFO_VARIABLES_COMMAND:
532 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
533 cmd->user_data = va_arg (args, gpointer);
534 break;
535 case SET_FRAME_COMMAND:
536 cmd->data.frame.frame = va_arg (args, guint);
537 break;
538 case LIST_FRAME_COMMAND:
539 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
540 cmd->user_data = va_arg (args, gpointer);
541 break;
542 case LIST_REGISTER_COMMAND:
543 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
544 cmd->user_data = va_arg (args, gpointer);
545 break;
546 case UPDATE_REGISTER_COMMAND:
547 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
548 cmd->user_data = va_arg (args, gpointer);
549 break;
550 case WRITE_REGISTER_COMMAND:
551 reg = va_arg (args, IAnjutaDebuggerRegisterData *);
552 cmd->data.watch.id = reg->num;
553 cmd->data.watch.name = g_strdup (reg->name);
554 cmd->data.watch.value = g_strdup (reg->value);
555 break;
556 case INSPECT_MEMORY_COMMAND:
557 cmd->data.mem.address = va_arg (args, gulong);
558 cmd->data.mem.length = va_arg (args, guint);
559 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
560 cmd->user_data = va_arg (args, gpointer);
561 break;
562 case DISASSEMBLE_COMMAND:
563 cmd->data.mem.address = va_arg (args, gulong);
564 cmd->data.mem.length = va_arg (args, guint);
565 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
566 cmd->user_data = va_arg (args, gpointer);
567 break;
568 case USER_COMMAND:
569 cmd->data.user.cmd = g_strdup (va_arg (args, gchar *));
570 break;
571 case PRINT_COMMAND:
572 cmd->data.print.var = g_strdup (va_arg (args, gchar *));
573 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
574 cmd->user_data = va_arg (args, gpointer);
575 break;
576 case HANDLE_SIGNAL_COMMAND:
577 cmd->data.signal.name = g_strdup (va_arg (args, gchar *));
578 cmd->data.signal.stop = va_arg (args, gboolean);
579 cmd->data.signal.print = va_arg (args, gboolean);
580 cmd->data.signal.ignore = va_arg (args, gboolean);
581 break;
582 case DELETE_VARIABLE:
583 cmd->data.var.name = g_strdup (va_arg (args, gchar *));
584 break;
585 case ASSIGN_VARIABLE:
586 cmd->data.var.name = g_strdup (va_arg (args, gchar *));
587 cmd->data.var.value = g_strdup (va_arg (args, gchar *));
588 break;
589 case EVALUATE_VARIABLE:
590 cmd->data.var.name = g_strdup (va_arg (args, gchar *));
591 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
592 cmd->user_data = va_arg (args, gpointer);
593 break;
594 case LIST_VARIABLE_CHILDREN:
595 cmd->data.var.name = g_strdup (va_arg (args, gchar *));
596 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
597 cmd->user_data = va_arg (args, gpointer);
598 break;
599 case CREATE_VARIABLE:
600 cmd->data.var.name = g_strdup (va_arg (args, gchar *));
601 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
602 cmd->user_data = va_arg (args, gpointer);
603 break;
604 case UPDATE_VARIABLE:
605 cmd->callback = va_arg (args, IAnjutaDebuggerCallback);
606 cmd->user_data = va_arg (args, gpointer);
607 break;
610 return cmd;
613 /* Public function
614 *---------------------------------------------------------------------------*/
616 gboolean
617 dma_queue_load (DmaDebuggerQueue *self, const gchar *file, const gchar* mime_type, const GList *search_dirs)
619 if (!dma_debugger_queue_start (self, mime_type)) return FALSE;
621 return dma_debugger_queue_append (self, dma_command_new (DMA_LOAD_COMMAND, file, mime_type, search_dirs));
624 gboolean
625 dma_queue_attach (DmaDebuggerQueue *self, pid_t pid, const GList *search_dirs)
627 if (!dma_debugger_queue_start (self, NULL)) return FALSE;
629 return dma_debugger_queue_append (self, dma_command_new (DMA_ATTACH_COMMAND, pid, search_dirs));
632 gboolean
633 dma_queue_start (DmaDebuggerQueue *self, const gchar *args, gboolean terminal, gboolean stop)
635 return dma_debugger_queue_append (self, dma_command_new (DMA_START_COMMAND, args, terminal, stop));
638 gboolean
639 dma_queue_unload (DmaDebuggerQueue *self)
641 return dma_debugger_queue_append (self, dma_command_new (DMA_UNLOAD_COMMAND));
644 gboolean
645 dma_queue_quit (DmaDebuggerQueue *self)
647 return dma_debugger_queue_append (self, dma_command_new (DMA_QUIT_COMMAND));
650 gboolean
651 dma_queue_abort (DmaDebuggerQueue *self)
653 return dma_debugger_queue_append (self, dma_command_new (DMA_ABORT_COMMAND));
656 gboolean
657 dma_queue_run (DmaDebuggerQueue *self)
659 return dma_debugger_queue_append (self, dma_command_new (DMA_RUN_COMMAND));
662 gboolean
663 dma_queue_step_in (DmaDebuggerQueue *self)
665 return dma_debugger_queue_append (self, dma_command_new (DMA_STEP_IN_COMMAND));
668 gboolean
669 dma_queue_step_over (DmaDebuggerQueue *self)
671 return dma_debugger_queue_append (self, dma_command_new (DMA_STEP_OVER_COMMAND));
674 gboolean
675 dma_queue_run_to (DmaDebuggerQueue *self, const gchar *file, gint line)
677 return dma_debugger_queue_append (self, dma_command_new (DMA_RUN_TO_COMMAND, file, line));
680 gboolean
681 dma_queue_step_out (DmaDebuggerQueue *self)
683 return dma_debugger_queue_append (self, dma_command_new (DMA_STEP_OUT_COMMAND));
686 gboolean
687 dma_queue_stepi_in (DmaDebuggerQueue *self)
689 return dma_debugger_queue_append (self, dma_command_new (DMA_STEPI_IN_COMMAND));
692 gboolean
693 dma_queue_stepi_over (DmaDebuggerQueue *self)
695 return dma_debugger_queue_append (self, dma_command_new (DMA_STEPI_OVER_COMMAND));
698 gboolean
699 dma_queue_run_to_address (DmaDebuggerQueue *self, gulong address)
701 return dma_debugger_queue_append (self, dma_command_new (DMA_RUN_TO_ADDRESS_COMMAND, address));
704 gboolean
705 dma_queue_exit (DmaDebuggerQueue *self)
707 return dma_debugger_queue_append (self, dma_command_new (DMA_EXIT_COMMAND));
710 gboolean
711 dma_queue_interrupt (DmaDebuggerQueue *self)
713 return dma_debugger_queue_append (self, dma_command_new (DMA_INTERRUPT_COMMAND));
716 gboolean
717 dma_queue_inspect (DmaDebuggerQueue *self, const gchar *expression, IAnjutaDebuggerCallback callback, gpointer user_data)
719 return dma_debugger_queue_append (self, dma_command_new (DMA_INSPECT_COMMAND, expression, callback, user_data));
722 gboolean
723 dma_queue_evaluate (DmaDebuggerQueue *self, const gchar *name, const gchar* value, IAnjutaDebuggerCallback callback, gpointer user_data)
725 return dma_debugger_queue_append (self, dma_command_new (DMA_EVALUATE_COMMAND, name, value, callback, user_data));
728 gboolean
729 dma_queue_send_command (DmaDebuggerQueue *self, const gchar* command)
731 return dma_debugger_queue_append (self, dma_command_new (DMA_USER_COMMAND, command));
734 gboolean
735 dma_queue_print (DmaDebuggerQueue *self, const gchar* variable, IAnjutaDebuggerCallback callback, gpointer user_data)
737 return dma_debugger_queue_append (self, dma_command_new (DMA_PRINT_COMMAND, variable, callback, user_data));
740 gboolean
741 dma_queue_list_local (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
743 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_LOCAL_COMMAND, callback, user_data));
746 gboolean
747 dma_queue_list_argument (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
749 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_ARG_COMMAND, callback, user_data));
752 gboolean
753 dma_queue_list_thread (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
755 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_THREAD_COMMAND, callback, user_data));
758 gboolean
759 dma_queue_set_thread (DmaDebuggerQueue *self, gint thread)
761 return dma_debugger_queue_append (self, dma_command_new (DMA_SET_THREAD_COMMAND, thread));
764 gboolean
765 dma_queue_info_thread (DmaDebuggerQueue *self, gint thread, IAnjutaDebuggerCallback callback , gpointer user_data)
767 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_THREAD_COMMAND, thread, callback, user_data));
770 gboolean
771 dma_queue_info_signal (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
773 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_SIGNAL_COMMAND, callback, user_data));
776 gboolean
777 dma_queue_info_sharedlib (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
779 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_SHAREDLIB_COMMAND, callback, user_data));
782 gboolean
783 dma_queue_handle_signal (DmaDebuggerQueue *self, const gchar* name, gboolean stop, gboolean print, gboolean ignore)
785 return dma_debugger_queue_append (self, dma_command_new (DMA_HANDLE_SIGNAL_COMMAND, name, stop, print, ignore));
788 gboolean
789 dma_queue_info_frame (DmaDebuggerQueue *self, guint frame, IAnjutaDebuggerCallback callback , gpointer user_data)
791 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_FRAME_COMMAND, frame, callback, user_data));
794 gboolean
795 dma_queue_info_args (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
797 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_ARGS_COMMAND, callback, user_data));
800 gboolean
801 dma_queue_info_target (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
803 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_TARGET_COMMAND, callback, user_data));
806 gboolean
807 dma_queue_info_program (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
809 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_PROGRAM_COMMAND, callback, user_data));
812 gboolean
813 dma_queue_info_udot (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
815 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_UDOT_COMMAND, callback, user_data));
818 gboolean
819 dma_queue_info_variables (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
821 return dma_debugger_queue_append (self, dma_command_new (DMA_INFO_VARIABLES_COMMAND, callback, user_data));
824 gboolean
825 dma_queue_set_frame (DmaDebuggerQueue *self, guint frame)
827 return dma_debugger_queue_append (self, dma_command_new (DMA_SET_FRAME_COMMAND, frame));
830 gboolean
831 dma_queue_list_frame (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
833 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_FRAME_COMMAND, callback, user_data));
836 gboolean
837 dma_queue_callback (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
839 return dma_debugger_queue_append (self, dma_command_new (DMA_CALLBACK_COMMAND, callback, user_data));
842 gboolean
843 dma_queue_add_breakpoint_at_line (DmaDebuggerQueue *self, guint *id, const gchar* file, guint line, IAnjutaDebuggerCallback callback, gpointer user_data)
845 return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_LINE_COMMAND, id, file, line, callback, user_data));
848 gboolean
849 dma_queue_add_breakpoint_at_function (DmaDebuggerQueue *self, guint *id, const gchar* file, const gchar* function, IAnjutaDebuggerCallback callback, gpointer user_data)
851 return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_FUNCTION_COMMAND, id, file, function, callback, user_data));
854 gboolean
855 dma_queue_add_breakpoint_at_address (DmaDebuggerQueue *self, guint *id, gulong address, IAnjutaDebuggerCallback callback, gpointer user_data)
857 return dma_debugger_queue_append (self, dma_command_new (DMA_BREAK_ADDRESS_COMMAND, id, address, callback, user_data));
860 gboolean
861 dma_queue_enable_breakpoint (DmaDebuggerQueue *self, guint id, gboolean enable, IAnjutaDebuggerCallback callback, gpointer user_data)
863 return dma_debugger_queue_append (self, dma_command_new (DMA_ENABLE_BREAK_COMMAND, id, enable, callback, user_data));
866 gboolean
867 dma_queue_ignore_breakpoint (DmaDebuggerQueue *self, guint id, guint ignore, IAnjutaDebuggerCallback callback, gpointer user_data)
869 return dma_debugger_queue_append (self, dma_command_new (DMA_IGNORE_BREAK_COMMAND, id, ignore, callback, user_data));
872 gboolean
873 dma_queue_condition_breakpoint (DmaDebuggerQueue *self, guint id, const gchar *condition, IAnjutaDebuggerCallback callback, gpointer user_data)
875 return dma_debugger_queue_append (self, dma_command_new (DMA_CONDITION_BREAK_COMMAND, id, condition, callback, user_data));
878 gboolean
879 dma_queue_remove_breakpoint (DmaDebuggerQueue *self, guint id, IAnjutaDebuggerCallback callback, gpointer user_data)
881 return dma_debugger_queue_append (self, dma_command_new (DMA_REMOVE_BREAK_COMMAND, id, callback, user_data));
884 gboolean
885 dma_queue_list_breakpoint (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback, gpointer user_data)
887 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_BREAK_COMMAND, callback, user_data));
890 gboolean
891 dma_queue_list_register (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
893 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_REGISTER_COMMAND, callback, user_data));
896 gboolean
897 dma_queue_update_register (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback , gpointer user_data)
899 return dma_debugger_queue_append (self, dma_command_new (DMA_UPDATE_REGISTER_COMMAND, callback, user_data));
902 gboolean
903 dma_queue_write_register (DmaDebuggerQueue *self, IAnjutaDebuggerRegisterData *value)
905 return dma_debugger_queue_append (self, dma_command_new (DMA_WRITE_REGISTER_COMMAND, value));
908 gboolean
909 dma_queue_inspect_memory (DmaDebuggerQueue *self, gulong address, guint length, IAnjutaDebuggerCallback callback , gpointer user_data)
911 return dma_debugger_queue_append (self, dma_command_new (DMA_INSPECT_MEMORY_COMMAND, address, length, callback, user_data));
914 gboolean
915 dma_queue_disassemble (DmaDebuggerQueue *self, gulong address, guint length, IAnjutaDebuggerCallback callback , gpointer user_data)
917 return dma_debugger_queue_append (self, dma_command_new (DMA_DISASSEMBLE_COMMAND, address, length, callback, user_data));
920 gboolean
921 dma_queue_delete_variable (DmaDebuggerQueue *self, const gchar *name)
923 return dma_debugger_queue_append (self, dma_command_new (DMA_DELETE_VARIABLE_COMMAND, name));
926 gboolean
927 dma_queue_evaluate_variable (DmaDebuggerQueue *self, const gchar *name, IAnjutaDebuggerCallback callback, gpointer user_data)
929 return dma_debugger_queue_append (self, dma_command_new (DMA_EVALUATE_VARIABLE_COMMAND, name, callback, user_data));
932 gboolean
933 dma_queue_assign_variable (DmaDebuggerQueue *self, const gchar *name, const gchar *value)
935 return dma_debugger_queue_append (self, dma_command_new (DMA_ASSIGN_VARIABLE_COMMAND, name, value));
938 gboolean
939 dma_queue_list_children (DmaDebuggerQueue *self, const gchar *name, IAnjutaDebuggerCallback callback, gpointer user_data)
941 return dma_debugger_queue_append (self, dma_command_new (DMA_LIST_VARIABLE_CHILDREN_COMMAND, name, callback, user_data));
944 gboolean
945 dma_queue_create_variable (DmaDebuggerQueue *self, const gchar *name, IAnjutaDebuggerCallback callback, gpointer user_data)
947 return dma_debugger_queue_append (self, dma_command_new (DMA_CREATE_VARIABLE_COMMAND, name, callback, user_data));
950 gboolean
951 dma_queue_update_variable (DmaDebuggerQueue *self, IAnjutaDebuggerCallback callback, gpointer user_data)
953 return dma_debugger_queue_append (self, dma_command_new (DMA_UPDATE_VARIABLE_COMMAND, callback, user_data));
956 void
957 dma_command_free (DmaQueueCommand *cmd)
959 DmaDebuggerCommandType type = cmd->type & COMMAND_MASK;
961 switch (type)
963 case EMPTY_COMMAND:
964 case CALLBACK_COMMAND:
965 case UNLOAD_COMMAND:
966 case QUIT_COMMAND:
967 case ABORT_COMMAND:
968 case RUN_COMMAND:
969 case STEP_IN_COMMAND:
970 case STEP_OVER_COMMAND:
971 case STEP_OUT_COMMAND:
972 case STEPI_IN_COMMAND:
973 case STEPI_OVER_COMMAND:
974 case RUN_TO_ADDRESS_COMMAND:
975 case EXIT_COMMAND:
976 case INTERRUPT_COMMAND:
977 case ENABLE_BREAK_COMMAND:
978 case IGNORE_BREAK_COMMAND:
979 case REMOVE_BREAK_COMMAND:
980 case LIST_BREAK_COMMAND:
981 break;
982 case LIST_LOCAL_COMMAND:
983 case LIST_ARG_COMMAND:
984 case INFO_THREAD_COMMAND:
985 case LIST_THREAD_COMMAND:
986 case SET_THREAD_COMMAND:
987 case INFO_SIGNAL_COMMAND:
988 case INFO_SHAREDLIB_COMMAND:
989 case INFO_FRAME_COMMAND:
990 case INFO_ARGS_COMMAND:
991 case INFO_TARGET_COMMAND:
992 case INFO_PROGRAM_COMMAND:
993 case INFO_UDOT_COMMAND:
994 case INFO_VARIABLES_COMMAND:
995 case LIST_REGISTER_COMMAND:
996 case UPDATE_REGISTER_COMMAND:
997 break;
998 case SET_FRAME_COMMAND:
999 case LIST_FRAME_COMMAND:
1000 case INSPECT_MEMORY_COMMAND:
1001 case DISASSEMBLE_COMMAND:
1002 break;
1003 case INSPECT_COMMAND:
1004 case EVALUATE_COMMAND:
1005 case WRITE_REGISTER_COMMAND:
1006 if (cmd->data.watch.name != NULL) g_free (cmd->data.watch.name);
1007 if (cmd->data.watch.value != NULL) g_free (cmd->data.watch.value);
1008 break;
1009 case START_COMMAND:
1010 if (cmd->data.start.args) g_free (cmd->data.start.args);
1011 break;
1012 case LOAD_COMMAND:
1013 if (cmd->data.load.file) g_free (cmd->data.load.file);
1014 if (cmd->data.load.type) g_free (cmd->data.load.type);
1015 g_list_foreach (cmd->data.load.dirs, (GFunc)g_free, NULL);
1016 g_list_free (cmd->data.load.dirs);
1017 break;
1018 case ATTACH_COMMAND:
1019 g_list_foreach (cmd->data.attach.dirs, (GFunc)g_free, NULL);
1020 g_list_free (cmd->data.attach.dirs);
1021 break;
1022 case RUN_TO_COMMAND:
1023 case BREAK_LINE_COMMAND:
1024 case BREAK_FUNCTION_COMMAND:
1025 case BREAK_ADDRESS_COMMAND:
1026 if (cmd->data.pos.file) g_free (cmd->data.pos.file);
1027 if (cmd->data.pos.function) g_free (cmd->data.pos.function);
1028 break;
1029 case CONDITION_BREAK_COMMAND:
1030 if (cmd->data.brk.condition) g_free (cmd->data.brk.condition);
1031 break;
1032 case USER_COMMAND:
1033 if (cmd->data.user.cmd) g_free (cmd->data.user.cmd);
1034 break;
1035 case PRINT_COMMAND:
1036 if (cmd->data.print.var) g_free (cmd->data.print.var);
1037 break;
1038 case HANDLE_SIGNAL_COMMAND:
1039 if (cmd->data.signal.name) g_free (cmd->data.signal.name);
1040 break;
1041 case DELETE_VARIABLE:
1042 case ASSIGN_VARIABLE:
1043 case CREATE_VARIABLE:
1044 case EVALUATE_VARIABLE:
1045 case LIST_VARIABLE_CHILDREN:
1046 case UPDATE_VARIABLE:
1047 if (cmd->data.var.name) g_free (cmd->data.var.name);
1048 break;
1051 g_free (cmd);
1055 void
1056 dma_command_cancel (DmaQueueCommand *cmd)
1058 GError *err = g_error_new_literal (IANJUTA_DEBUGGER_ERROR , IANJUTA_DEBUGGER_CANCEL, "Command cancel");
1060 if (cmd->callback != NULL)
1062 cmd->callback (NULL, cmd->user_data, err);
1065 g_error_free (err);
1067 g_warning ("Cancel command %x\n", cmd->type);
1069 dma_command_free (cmd);
1072 /* It is possible that the queue contains several add breakpoint command
1073 * for the same one. Just before sending the command to the debugger check
1074 * that the breakpoint is still not set */
1076 static gboolean
1077 dma_command_is_breakpoint_pending (DmaQueueCommand *cmd)
1079 GError *err;
1081 if (*cmd->data.pos.id == 0) return TRUE; /* Breakpoint is not set, can add it */
1083 err = g_error_new (IANJUTA_DEBUGGER_ERROR , IANJUTA_DEBUGGER_ALREADY_DONE, "Breakpoint is already set with id %d", *cmd->data.pos.id);
1085 if (cmd->callback != NULL)
1087 cmd->callback (NULL, cmd->user_data, err);
1089 g_error_free (err);
1091 return FALSE;
1094 gboolean
1095 dma_command_run (DmaQueueCommand *cmd, IAnjutaDebugger *debugger,
1096 DmaDebuggerQueue *queue, GError **err)
1098 IAnjutaDebuggerRegisterData reg;
1099 gboolean ret = FALSE;
1100 DmaDebuggerCommandType type = cmd->type & COMMAND_MASK;
1101 IAnjutaDebuggerCallback callback = cmd->callback == NULL ? NULL : dma_debugger_queue_command_callback;
1103 switch (type)
1105 case EMPTY_COMMAND:
1106 ret = TRUE;
1107 break;
1108 case CALLBACK_COMMAND:
1109 ret = ianjuta_debugger_callback (debugger, callback, queue, err);
1110 break;
1111 case LOAD_COMMAND:
1112 ret = ianjuta_debugger_load (debugger, cmd->data.load.file, cmd->data.load.type, cmd->data.load.dirs, err);
1113 break;
1114 case ATTACH_COMMAND:
1115 ret = ianjuta_debugger_attach (debugger, cmd->data.attach.pid, cmd->data.load.dirs, err);
1116 break;
1117 case UNLOAD_COMMAND:
1118 ret = ianjuta_debugger_unload (debugger, err);
1119 break;
1120 case QUIT_COMMAND:
1121 ret = ianjuta_debugger_quit (debugger, err);
1122 break;
1123 case ABORT_COMMAND:
1124 ret = ianjuta_debugger_abort (debugger, err);
1125 break;
1126 case START_COMMAND:
1127 ret = ianjuta_debugger_start (debugger, cmd->data.start.args, cmd->data.start.terminal, cmd->data.start.stop, err);
1128 break;
1129 case RUN_COMMAND:
1130 ret = ianjuta_debugger_run (debugger, err);
1131 break;
1132 case RUN_TO_COMMAND:
1133 ret = ianjuta_debugger_run_to (debugger, cmd->data.pos.file, cmd->data.pos.line, err);
1134 break;
1135 case STEP_IN_COMMAND:
1136 ret = ianjuta_debugger_step_in (debugger, err);
1137 break;
1138 case STEP_OVER_COMMAND:
1139 ret = ianjuta_debugger_step_over (debugger, err);
1140 break;
1141 case STEP_OUT_COMMAND:
1142 ret = ianjuta_debugger_step_out (debugger, err);
1143 break;
1144 case RUN_TO_ADDRESS_COMMAND:
1145 ret = ianjuta_debugger_instruction_run_to_address (IANJUTA_DEBUGGER_INSTRUCTION (debugger), cmd->data.pos.address, err);
1146 break;
1147 case STEPI_IN_COMMAND:
1148 ret = ianjuta_debugger_instruction_step_in (IANJUTA_DEBUGGER_INSTRUCTION (debugger), err);
1149 break;
1150 case STEPI_OVER_COMMAND:
1151 ret = ianjuta_debugger_instruction_step_over (IANJUTA_DEBUGGER_INSTRUCTION (debugger), err);
1152 break;
1153 case EXIT_COMMAND:
1154 ret = ianjuta_debugger_exit (debugger, err);
1155 break;
1156 case INTERRUPT_COMMAND:
1157 ret = ianjuta_debugger_interrupt (debugger, err);
1158 break;
1159 case ENABLE_BREAK_COMMAND:
1160 ret = ianjuta_debugger_breakpoint_enable (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, cmd->data.brk.enable, callback, queue, err);
1161 break;
1162 case IGNORE_BREAK_COMMAND:
1163 ret = ianjuta_debugger_breakpoint_ignore (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, cmd->data.brk.ignore, callback, queue, err);
1164 break;
1165 case REMOVE_BREAK_COMMAND:
1166 ret = ianjuta_debugger_breakpoint_clear (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, callback, queue, err);
1167 break;
1168 case BREAK_LINE_COMMAND:
1169 if (dma_command_is_breakpoint_pending (cmd))
1171 ret = ianjuta_debugger_breakpoint_set_at_line (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.line, callback, queue, err);
1173 else
1175 ret = FALSE;
1177 break;
1178 case BREAK_FUNCTION_COMMAND:
1179 if (dma_command_is_breakpoint_pending (cmd))
1181 ret = ianjuta_debugger_breakpoint_set_at_function (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.file, cmd->data.pos.function, callback, queue, err);
1183 else
1185 ret = FALSE;
1187 break;
1188 case BREAK_ADDRESS_COMMAND:
1189 if (dma_command_is_breakpoint_pending (cmd))
1191 ret = ianjuta_debugger_breakpoint_set_at_address (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.pos.address, callback, queue, err);
1193 else
1195 ret = FALSE;
1197 break;
1198 case CONDITION_BREAK_COMMAND:
1199 ret = ianjuta_debugger_breakpoint_condition (IANJUTA_DEBUGGER_BREAKPOINT (debugger), cmd->data.brk.id, cmd->data.brk.condition, callback, queue, err);
1200 break;
1201 case LIST_BREAK_COMMAND:
1202 ret = ianjuta_debugger_breakpoint_list (IANJUTA_DEBUGGER_BREAKPOINT (debugger), callback, queue, err);
1203 break;
1204 case INSPECT_COMMAND:
1205 ret = ianjuta_debugger_inspect (debugger, cmd->data.watch.name, callback, queue, err);
1206 break;
1207 case EVALUATE_COMMAND:
1208 ret = ianjuta_debugger_evaluate (debugger, cmd->data.watch.name, cmd->data.watch.value, callback, queue, err);
1209 break;
1210 case LIST_LOCAL_COMMAND:
1211 ret = ianjuta_debugger_list_local (debugger, callback, queue, err);
1212 break;
1213 case LIST_ARG_COMMAND:
1214 ret = ianjuta_debugger_list_argument (debugger, callback, queue, err);
1215 break;
1216 case LIST_THREAD_COMMAND:
1217 ret = ianjuta_debugger_list_thread (debugger, callback, queue, err);
1218 break;
1219 case SET_THREAD_COMMAND:
1220 ret = ianjuta_debugger_set_thread (debugger, cmd->data.frame.frame, err);
1221 break;
1222 case INFO_THREAD_COMMAND:
1223 ret = ianjuta_debugger_info_thread (debugger, cmd->data.info.id, callback, queue, err);
1224 break;
1225 case INFO_SIGNAL_COMMAND:
1226 ret = ianjuta_debugger_info_signal (debugger, callback, queue, err);
1227 break;
1228 case INFO_SHAREDLIB_COMMAND:
1229 ret = ianjuta_debugger_info_sharedlib (debugger, callback, queue, err);
1230 break;
1231 case INFO_FRAME_COMMAND:
1232 ret = ianjuta_debugger_info_frame (debugger, 0, callback, queue, err);
1233 break;
1234 case INFO_ARGS_COMMAND:
1235 ret = ianjuta_debugger_info_args (debugger, callback, queue, err);
1236 break;
1237 case INFO_TARGET_COMMAND:
1238 ret = ianjuta_debugger_info_target (debugger, callback, queue, err);
1239 break;
1240 case INFO_PROGRAM_COMMAND:
1241 ret = ianjuta_debugger_info_program (debugger, callback, queue, err);
1242 break;
1243 case INFO_UDOT_COMMAND:
1244 ret = ianjuta_debugger_info_udot (debugger, callback, queue, err);
1245 break;
1246 case INFO_VARIABLES_COMMAND:
1247 ret = ianjuta_debugger_info_variables (debugger, callback, queue, err);
1248 break;
1249 case SET_FRAME_COMMAND:
1250 ret = ianjuta_debugger_set_frame (debugger, cmd->data.frame.frame, err);
1251 break;
1252 case LIST_FRAME_COMMAND:
1253 ret = ianjuta_debugger_list_frame (debugger, callback, queue, err);
1254 break;
1255 case LIST_REGISTER_COMMAND:
1256 ret = ianjuta_debugger_register_list (IANJUTA_DEBUGGER_REGISTER (debugger), callback, queue, err);
1257 break;
1258 case UPDATE_REGISTER_COMMAND:
1259 ret = ianjuta_debugger_register_update (IANJUTA_DEBUGGER_REGISTER (debugger), callback, queue, err);
1260 break;
1261 case WRITE_REGISTER_COMMAND:
1262 reg.num = cmd->data.watch.id;
1263 reg.name = cmd->data.watch.name;
1264 reg.value = cmd->data.watch.value;
1265 ret = ianjuta_debugger_register_write (IANJUTA_DEBUGGER_REGISTER (debugger), &reg, err);
1266 break;
1267 case INSPECT_MEMORY_COMMAND:
1268 ret = ianjuta_debugger_memory_inspect (IANJUTA_DEBUGGER_MEMORY (debugger), cmd->data.mem.address, cmd->data.mem.length, callback, queue, err);
1269 break;
1270 case DISASSEMBLE_COMMAND:
1271 ret = ianjuta_debugger_instruction_disassemble (IANJUTA_DEBUGGER_INSTRUCTION (debugger), cmd->data.mem.address, cmd->data.mem.length, callback, queue, err);
1272 break;
1273 case USER_COMMAND:
1274 ret = ianjuta_debugger_send_command (debugger, cmd->data.user.cmd, err);
1275 break;
1276 case PRINT_COMMAND:
1277 ret = ianjuta_debugger_print (debugger, cmd->data.print.var, callback, queue, err);
1278 break;
1279 case HANDLE_SIGNAL_COMMAND:
1280 ret = ianjuta_debugger_handle_signal (debugger, cmd->data.signal.name, cmd->data.signal.stop, cmd->data.signal.print, cmd->data.signal.ignore, err);
1281 break;
1282 case DELETE_VARIABLE:
1283 ret = ianjuta_debugger_variable_destroy (IANJUTA_DEBUGGER_VARIABLE (debugger), cmd->data.var.name, NULL);
1284 break;
1285 case ASSIGN_VARIABLE:
1286 ret = ianjuta_debugger_variable_assign (IANJUTA_DEBUGGER_VARIABLE (debugger), cmd->data.var.name, cmd->data.var.value, err);
1287 break;
1288 case EVALUATE_VARIABLE:
1289 ret = ianjuta_debugger_variable_evaluate (IANJUTA_DEBUGGER_VARIABLE (debugger), cmd->data.var.name, callback, queue, err);
1290 break;
1291 case LIST_VARIABLE_CHILDREN:
1292 ret = ianjuta_debugger_variable_list_children (IANJUTA_DEBUGGER_VARIABLE (debugger), cmd->data.var.name, callback, queue, err);
1293 break;
1294 case CREATE_VARIABLE:
1295 ret = ianjuta_debugger_variable_create (IANJUTA_DEBUGGER_VARIABLE (debugger), cmd->data.var.name, callback, queue, err);
1296 break;
1297 case UPDATE_VARIABLE:
1298 ret = ianjuta_debugger_variable_update (IANJUTA_DEBUGGER_VARIABLE (debugger), callback, queue, err);
1299 break;
1302 return ret;
1305 void
1306 dma_command_callback (DmaQueueCommand *cmd, const gpointer data, GError *err)
1308 DmaDebuggerCommandType type = cmd->type & COMMAND_MASK;
1310 switch (type)
1312 case EMPTY_COMMAND:
1313 case LOAD_COMMAND:
1314 case ATTACH_COMMAND:
1315 case UNLOAD_COMMAND:
1316 case QUIT_COMMAND:
1317 case ABORT_COMMAND:
1318 case START_COMMAND:
1319 case RUN_COMMAND:
1320 case RUN_TO_COMMAND:
1321 case STEP_IN_COMMAND:
1322 case STEP_OVER_COMMAND:
1323 case STEP_OUT_COMMAND:
1324 case RUN_TO_ADDRESS_COMMAND:
1325 case STEPI_IN_COMMAND:
1326 case STEPI_OVER_COMMAND:
1327 case EXIT_COMMAND:
1328 case INTERRUPT_COMMAND:
1329 case SET_THREAD_COMMAND:
1330 case SET_FRAME_COMMAND:
1331 case WRITE_REGISTER_COMMAND:
1332 case USER_COMMAND:
1333 case HANDLE_SIGNAL_COMMAND:
1334 case DELETE_VARIABLE:
1335 case ASSIGN_VARIABLE:
1336 g_return_if_reached ();
1337 break;
1338 case CALLBACK_COMMAND:
1339 case ENABLE_BREAK_COMMAND:
1340 case IGNORE_BREAK_COMMAND:
1341 case REMOVE_BREAK_COMMAND:
1342 case BREAK_LINE_COMMAND:
1343 case BREAK_FUNCTION_COMMAND:
1344 case BREAK_ADDRESS_COMMAND:
1345 case CONDITION_BREAK_COMMAND:
1346 case LIST_BREAK_COMMAND:
1347 case INSPECT_COMMAND:
1348 case EVALUATE_COMMAND:
1349 case LIST_LOCAL_COMMAND:
1350 case LIST_ARG_COMMAND:
1351 case LIST_THREAD_COMMAND:
1352 case INFO_THREAD_COMMAND:
1353 case INFO_SIGNAL_COMMAND:
1354 case INFO_SHAREDLIB_COMMAND:
1355 case INFO_FRAME_COMMAND:
1356 case INFO_ARGS_COMMAND:
1357 case INFO_TARGET_COMMAND:
1358 case INFO_PROGRAM_COMMAND:
1359 case INFO_UDOT_COMMAND:
1360 case INFO_VARIABLES_COMMAND:
1361 case LIST_FRAME_COMMAND:
1362 case LIST_REGISTER_COMMAND:
1363 case UPDATE_REGISTER_COMMAND:
1364 case INSPECT_MEMORY_COMMAND:
1365 case DISASSEMBLE_COMMAND:
1366 case PRINT_COMMAND:
1367 case EVALUATE_VARIABLE:
1368 case LIST_VARIABLE_CHILDREN:
1369 case CREATE_VARIABLE:
1370 case UPDATE_VARIABLE:
1371 if (cmd->callback != NULL)
1373 cmd->callback (data, cmd->user_data, err);
1375 break;
1379 gboolean
1380 dma_command_is_valid_in_state (DmaQueueCommand *cmd, IAnjutaDebuggerState state)
1382 return cmd->type & 1 << (state + STATE_TO_NEED - 1);
1385 IAnjutaDebuggerState
1386 dma_command_is_going_to_state (DmaQueueCommand *cmd)
1388 IAnjutaDebuggerState state;
1390 switch (cmd->type & CHANGE_MASK)
1392 case STOP_DEBUGGER:
1393 state = IANJUTA_DEBUGGER_STOPPED;
1394 break;
1395 case START_DEBUGGER:
1396 state = IANJUTA_DEBUGGER_STARTED;
1397 break;
1398 case LOAD_PROGRAM:
1399 state = IANJUTA_DEBUGGER_PROGRAM_LOADED;
1400 break;
1401 case STOP_PROGRAM:
1402 state = IANJUTA_DEBUGGER_PROGRAM_STOPPED;
1403 break;
1404 case RUN_PROGRAM:
1405 state = IANJUTA_DEBUGGER_PROGRAM_RUNNING;
1406 break;
1407 default:
1408 state = IANJUTA_DEBUGGER_BUSY;
1411 return state;
1414 gboolean
1415 dma_command_has_flag (DmaQueueCommand *cmd, DmaCommandFlag flag)
1417 return cmd->type & flag;
1421 dma_command_get_type (DmaQueueCommand *cmd)
1423 return (int)cmd->type;