]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/remote-rdi.c
import gdb-1999-07-07 post reformat
[thirdparty/binutils-gdb.git] / gdb / remote-rdi.c
1 /* GDB interface to ARM RDI library.
2 Copyright 1997, 1998 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 #include "defs.h"
22 #include "gdb_string.h"
23 #include <fcntl.h>
24 #include "frame.h"
25 #include "inferior.h"
26 #include "bfd.h"
27 #include "symfile.h"
28 #include "target.h"
29 #include "wait.h"
30 #include "gdbcmd.h"
31 #include "objfiles.h"
32 #include "gdb-stabs.h"
33 #include "gdbthread.h"
34 #include "gdbcore.h"
35
36 #ifdef USG
37 #include <sys/types.h>
38 #endif
39
40 #include <signal.h>
41
42 #include "rdi-share/ardi.h"
43 #include "rdi-share/adp.h"
44 #include "rdi-share/hsys.h"
45
46 extern int isascii PARAMS ((int));
47
48 /* Prototypes for local functions */
49
50 static void arm_rdi_files_info PARAMS ((struct target_ops * ignore));
51
52 static int arm_rdi_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
53 int len, int should_write,
54 struct target_ops * target));
55
56 static void arm_rdi_prepare_to_store PARAMS ((void));
57
58 static void arm_rdi_fetch_registers PARAMS ((int regno));
59
60 static void arm_rdi_resume PARAMS ((int pid, int step,
61 enum target_signal siggnal));
62
63 static int arm_rdi_start_remote PARAMS ((char *dummy));
64
65 static void arm_rdi_open PARAMS ((char *name, int from_tty));
66
67 static void arm_rdi_create_inferior PARAMS ((char *exec_file, char *args,
68 char **env));
69
70 static void arm_rdi_close PARAMS ((int quitting));
71
72 static void arm_rdi_store_registers PARAMS ((int regno));
73
74 static void arm_rdi_mourn PARAMS ((void));
75
76 static void arm_rdi_send PARAMS ((char *buf));
77
78 static int arm_rdi_wait PARAMS ((int pid, struct target_waitstatus * status));
79
80 static void arm_rdi_kill PARAMS ((void));
81
82 static void arm_rdi_detach PARAMS ((char *args, int from_tty));
83
84 static void arm_rdi_interrupt PARAMS ((int signo));
85
86 static void arm_rdi_interrupt_twice PARAMS ((int signo));
87
88 static void interrupt_query PARAMS ((void));
89
90 static int arm_rdi_insert_breakpoint PARAMS ((CORE_ADDR, char *));
91
92 static int arm_rdi_remove_breakpoint PARAMS ((CORE_ADDR, char *));
93
94 static char *rdi_error_message PARAMS ((int err));
95
96 static enum target_signal rdi_error_signal PARAMS ((int err));
97
98 /* Global variables. */
99
100 struct target_ops arm_rdi_ops;
101
102 static struct Dbg_ConfigBlock gdb_config;
103
104 static struct Dbg_HostosInterface gdb_hostif;
105
106 static int max_load_size;
107
108 static int execute_status;
109
110 /* A little list of breakpoints that have been set. */
111
112 static struct local_bp_list_entry
113 {
114 CORE_ADDR addr;
115 PointHandle point;
116 struct local_bp_list_entry *next;
117 }
118 *local_bp_list;
119 \f
120
121 /* Stub for catch_errors. */
122
123 static int
124 arm_rdi_start_remote (dummy)
125 char *dummy;
126 {
127 return 1;
128 }
129
130 /* Helper callbacks for the "host interface" structure. RDI functions call
131 these to forward output from the target system and so forth. */
132
133 void
134 voiddummy ()
135 {
136 fprintf_unfiltered (gdb_stdout, "void dummy\n");
137 }
138
139 static void
140 myprint (arg, format, ap)
141 PTR arg;
142 const char *format;
143 va_list ap;
144 {
145 vfprintf_unfiltered (gdb_stdout, format, ap);
146 }
147
148 static void
149 mywritec (arg, c)
150 PTR arg;
151 int c;
152 {
153 if (isascii (c))
154 fputc_unfiltered (c, gdb_stdout);
155 }
156
157 static int
158 mywrite (arg, buffer, len)
159 PTR arg;
160 char const *buffer;
161 int len;
162 {
163 int i;
164 char *e;
165
166 e = (char *) buffer;
167 for (i = 0; i < len; i++)
168 {
169 if (isascii ((int) *e))
170 {
171 fputc_unfiltered ((int) *e, gdb_stdout);
172 e++;
173 }
174 }
175
176 return len;
177 }
178
179 static void
180 mypause (arg)
181 PTR arg;
182 {
183 }
184
185 /* These last two are tricky as we have to handle the special case of
186 being interrupted more carefully */
187
188 static int
189 myreadc (arg)
190 PTR arg;
191 {
192 return fgetc (stdin);
193 }
194
195 static char *
196 mygets (arg, buffer, len)
197 PTR arg;
198 char *buffer;
199 int len;
200 {
201 return fgets (buffer, len, stdin);
202 }
203
204 /* Prevent multiple calls to angel_RDI_close(). */
205 static int closed_already = 1;
206
207 /* Open a connection to a remote debugger. NAME is the filename used
208 for communication. */
209
210 static void
211 arm_rdi_open (name, from_tty)
212 char *name;
213 int from_tty;
214 {
215 int rslt, i;
216 unsigned long arg1, arg2;
217
218 if (name == NULL)
219 error ("To open an RDI connection, you need to specify what serial\n\
220 device is attached to the remote system (e.g. /dev/ttya).");
221
222 /* Make the basic low-level connection. */
223
224 rslt = Adp_OpenDevice (name, NULL, 1);
225
226 if (rslt != adp_ok)
227 error ("Could not open device \"%s\"", name);
228
229 gdb_config.bytesex = 2 | (TARGET_BYTE_ORDER == BIG_ENDIAN ? 1 : 0);
230 gdb_config.fpe = 1;
231 gdb_config.rditype = 2;
232 gdb_config.heartbeat_on = 1;
233 gdb_config.flags = 2;
234
235 gdb_hostif.dbgprint = myprint;
236 gdb_hostif.dbgpause = mypause;
237 gdb_hostif.dbgarg = NULL;
238 gdb_hostif.writec = mywritec;
239 gdb_hostif.readc = myreadc;
240 gdb_hostif.write = mywrite;
241 gdb_hostif.gets = mygets;
242 gdb_hostif.hostosarg = NULL;
243 gdb_hostif.reset = voiddummy;
244
245 rslt = angel_RDI_open (10, &gdb_config, &gdb_hostif, NULL);
246 if (rslt == RDIError_BigEndian || rslt == RDIError_LittleEndian)
247 ; /* do nothing, this is the expected return */
248 else if (rslt)
249 {
250 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
251 }
252
253 rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
254 if (rslt)
255 {
256 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
257 }
258 rslt = angel_RDI_info (RDIInfo_Points, &arg1, &arg2);
259 if (rslt)
260 {
261 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
262 }
263 rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
264 if (rslt)
265 {
266 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
267 }
268 rslt = angel_RDI_info (RDIInfo_CoPro, &arg1, &arg2);
269 if (rslt)
270 {
271 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
272 }
273 rslt = angel_RDI_info (RDIInfo_SemiHosting, &arg1, &arg2);
274 if (rslt)
275 {
276 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
277 }
278
279 rslt = angel_RDI_info (RDIInfo_GetLoadSize, &arg1, &arg2);
280 if (rslt)
281 {
282 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
283 }
284 max_load_size = arg1;
285
286 push_target (&arm_rdi_ops);
287
288 target_fetch_registers (-1);
289
290 rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
291 if (rslt)
292 {
293 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
294 }
295
296 arg1 = 0x13b;
297 rslt = angel_RDI_info (RDIVector_Catch, &arg1, &arg2);
298 if (rslt)
299 {
300 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
301 }
302
303 arg1 = (unsigned long) "";
304 rslt = angel_RDI_info (RDISet_Cmdline, &arg1, &arg2);
305 if (rslt)
306 {
307 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
308 }
309
310 /* Clear out any existing records of breakpoints. */
311 {
312 struct local_bp_list_entry *entry, *preventry = NULL;
313
314 for (entry = local_bp_list; entry != NULL; entry = entry->next)
315 {
316 if (preventry)
317 free (preventry);
318 }
319 }
320
321 printf_filtered ("Connected to ARM RDI target.\n");
322 closed_already = 0;
323 inferior_pid = 42;
324 }
325
326 /* Start an inferior process and set inferior_pid to its pid.
327 EXEC_FILE is the file to run.
328 ARGS is a string containing the arguments to the program.
329 ENV is the environment vector to pass. Errors reported with error().
330 On VxWorks and various standalone systems, we ignore exec_file. */
331 /* This is called not only when we first attach, but also when the
332 user types "run" after having attached. */
333
334 static void
335 arm_rdi_create_inferior (exec_file, args, env)
336 char *exec_file;
337 char *args;
338 char **env;
339 {
340 int len, rslt;
341 unsigned long arg1, arg2;
342 char *arg_buf;
343 CORE_ADDR entry_point;
344
345 if (exec_file == 0 || exec_bfd == 0)
346 error ("No executable file specified.");
347
348 entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
349
350 arm_rdi_kill ();
351 remove_breakpoints ();
352 init_wait_for_inferior ();
353
354 len = strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
355 arg_buf = (char *) alloca (len);
356 arg_buf[0] = '\0';
357 strcat (arg_buf, exec_file);
358 strcat (arg_buf, " ");
359 strcat (arg_buf, args);
360
361 inferior_pid = 42;
362 insert_breakpoints (); /* Needed to get correct instruction in cache */
363
364 if (env != NULL)
365 {
366 while (*env)
367 {
368 if (strncmp (*env, "MEMSIZE=", sizeof ("MEMSIZE=") - 1) == 0)
369 {
370 unsigned long top_of_memory;
371 char *end_of_num;
372
373 /* Set up memory limit */
374 top_of_memory = strtoul (*env + sizeof ("MEMSIZE=") - 1,
375 &end_of_num, 0);
376 printf_filtered ("Setting top-of-memory to 0x%x\n",
377 top_of_memory);
378
379 rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2);
380 if (rslt)
381 {
382 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
383 }
384 }
385 env++;
386 }
387 }
388
389 arg1 = (unsigned long) arg_buf;
390 rslt = angel_RDI_info (RDISet_Cmdline, /* &arg1 */ (unsigned long *) arg_buf, &arg2);
391 if (rslt)
392 {
393 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
394 }
395
396 proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
397 }
398
399 /* This takes a program previously attached to and detaches it. After
400 this is done, GDB can be used to debug some other program. We
401 better not have left any breakpoints in the target program or it'll
402 die when it hits one. */
403
404 static void
405 arm_rdi_detach (args, from_tty)
406 char *args;
407 int from_tty;
408 {
409 pop_target ();
410 }
411
412 /* Clean up connection to a remote debugger. */
413
414 static void
415 arm_rdi_close (quitting)
416 int quitting;
417 {
418 int rslt;
419
420 if (!closed_already)
421 {
422 rslt = angel_RDI_close ();
423 if (rslt)
424 {
425 printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt));
426 }
427 closed_already = 1;
428 inferior_pid = 0;
429 }
430 }
431 \f
432 /* Tell the remote machine to resume. */
433
434 static void
435 arm_rdi_resume (pid, step, siggnal)
436 int pid, step;
437 enum target_signal siggnal;
438 {
439 int rslt;
440 PointHandle point;
441
442 if (0 /* turn on when hardware supports single-stepping */ )
443 {
444 rslt = angel_RDI_step (1, &point);
445 if (rslt)
446 {
447 printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt));
448 }
449 }
450 else
451 {
452 char handle[4];
453 CORE_ADDR pc;
454
455 if (step)
456 {
457 pc = read_register (PC_REGNUM);
458 pc = arm_get_next_pc (pc);
459 arm_rdi_insert_breakpoint (pc, handle);
460 }
461 execute_status = rslt = angel_RDI_execute (&point);
462 if (rslt == RDIError_BreakpointReached)
463 ;
464 else if (rslt)
465 {
466 printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt));
467 }
468 if (step)
469 {
470 arm_rdi_remove_breakpoint (pc, handle);
471 }
472 }
473 }
474 \f
475 /* Send ^C to target to halt it. Target will respond, and send us a
476 packet. */
477
478 static void
479 arm_rdi_interrupt (signo)
480 int signo;
481 {
482 }
483
484 static void (*ofunc) ();
485
486 /* The user typed ^C twice. */
487 static void
488 arm_rdi_interrupt_twice (signo)
489 int signo;
490 {
491 }
492
493 /* Ask the user what to do when an interrupt is received. */
494
495 static void
496 interrupt_query ()
497 {
498 }
499
500 /* Wait until the remote machine stops, then return, storing status in
501 STATUS just as `wait' would. Returns "pid" (though it's not clear
502 what, if anything, that means in the case of this target). */
503
504 static int
505 arm_rdi_wait (pid, status)
506 int pid;
507 struct target_waitstatus *status;
508 {
509 status->kind = (execute_status == RDIError_NoError ?
510 TARGET_WAITKIND_EXITED : TARGET_WAITKIND_STOPPED);
511
512 /* convert stopped code from target into right signal */
513 status->value.sig = rdi_error_signal (execute_status);
514
515 return inferior_pid;
516 }
517
518 /* Read the remote registers into the block REGS. */
519
520 /* ARGSUSED */
521 static void
522 arm_rdi_fetch_registers (regno)
523 int regno;
524 {
525 int rslt, rdi_regmask;
526 unsigned long rawreg, rawregs[32];
527 char cookedreg[4];
528
529 if (regno == -1)
530 {
531 rslt = angel_RDI_CPUread (255, 0x27fff, rawregs);
532 if (rslt)
533 {
534 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
535 }
536
537 for (regno = 0; regno < 15; regno++)
538 {
539 store_unsigned_integer (cookedreg, 4, rawregs[regno]);
540 supply_register (regno, (char *) cookedreg);
541 }
542 store_unsigned_integer (cookedreg, 4, rawregs[15]);
543 supply_register (PS_REGNUM, (char *) cookedreg);
544 arm_rdi_fetch_registers (PC_REGNUM);
545 }
546 else
547 {
548 if (regno == PC_REGNUM)
549 rdi_regmask = RDIReg_PC;
550 else if (regno == PS_REGNUM)
551 rdi_regmask = RDIReg_CPSR;
552 else if (regno < 0 || regno > 15)
553 {
554 rawreg = 0;
555 supply_register (regno, (char *) &rawreg);
556 return;
557 }
558 else
559 rdi_regmask = 1 << regno;
560
561 rslt = angel_RDI_CPUread (255, rdi_regmask, &rawreg);
562 if (rslt)
563 {
564 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt));
565 }
566 store_unsigned_integer (cookedreg, 4, rawreg);
567 supply_register (regno, (char *) cookedreg);
568 }
569 }
570
571 static void
572 arm_rdi_prepare_to_store ()
573 {
574 /* Nothing to do. */
575 }
576
577 /* Store register REGNO, or all registers if REGNO == -1, from the contents
578 of REGISTERS. FIXME: ignores errors. */
579
580 static void
581 arm_rdi_store_registers (regno)
582 int regno;
583 {
584 int rslt, rdi_regmask;
585
586 /* These need to be able to take 'floating point register' contents */
587 unsigned long rawreg[3], rawerreg[3];
588
589 if (regno == -1)
590 {
591 for (regno = 0; regno < NUM_REGS; regno++)
592 arm_rdi_store_registers (regno);
593 }
594 else
595 {
596 read_register_gen (regno, (char *) rawreg);
597 /* RDI manipulates data in host byte order, so convert now. */
598 store_unsigned_integer (rawerreg, 4, rawreg[0]);
599
600 if (regno == PC_REGNUM)
601 rdi_regmask = RDIReg_PC;
602 else if (regno == PS_REGNUM)
603 rdi_regmask = RDIReg_CPSR;
604 else if (regno < 0 || regno > 15)
605 return;
606 else
607 rdi_regmask = 1 << regno;
608
609 rslt = angel_RDI_CPUwrite (255, rdi_regmask, rawerreg);
610 if (rslt)
611 {
612 printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt));
613 }
614 }
615 }
616 \f
617 /* Read or write LEN bytes from inferior memory at MEMADDR,
618 transferring to or from debugger address MYADDR. Write to inferior
619 if SHOULD_WRITE is nonzero. Returns length of data written or
620 read; 0 for error. */
621
622 /* ARGSUSED */
623 static int
624 arm_rdi_xfer_memory (memaddr, myaddr, len, should_write, target)
625 CORE_ADDR memaddr;
626 char *myaddr;
627 int len;
628 int should_write;
629 struct target_ops *target; /* ignored */
630 {
631 int rslt, i;
632
633 if (should_write)
634 {
635 rslt = angel_RDI_write (myaddr, memaddr, &len);
636 if (rslt)
637 {
638 printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt));
639 }
640 }
641 else
642 {
643 rslt = angel_RDI_read (memaddr, myaddr, &len);
644 if (rslt)
645 {
646 printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt));
647 len = 0;
648 }
649 }
650 return len;
651 }
652 \f
653 /* Display random info collected from the target. */
654
655 static void
656 arm_rdi_files_info (ignore)
657 struct target_ops *ignore;
658 {
659 char *file = "nothing";
660 int rslt;
661 unsigned long arg1, arg2;
662
663 rslt = angel_RDI_info (RDIInfo_Target, &arg1, &arg2);
664 if (rslt)
665 {
666 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
667 }
668 if (arg1 & (1 << 15))
669 printf_filtered ("Target supports Thumb code.\n");
670 if (arg1 & (1 << 14))
671 printf_filtered ("Target can do profiling.\n");
672 if (arg1 & (1 << 4))
673 printf_filtered ("Target is real hardware.\n");
674
675 rslt = angel_RDI_info (RDIInfo_Step, &arg1, &arg2);
676 if (rslt)
677 {
678 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
679 }
680 printf_filtered ("Target can%s single-step.\n", (arg1 & 0x4 ? "" : "not"));
681
682 rslt = angel_RDI_info (RDIInfo_Icebreaker, &arg1, &arg2);
683 if (rslt)
684 {
685 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt));
686 }
687 else
688 printf_filtered ("Target includes an EmbeddedICE.\n");
689 }
690 \f
691 static void
692 arm_rdi_kill ()
693 {
694 int rslt;
695
696 rslt = angel_RDI_open (1, &gdb_config, NULL, NULL);
697 if (rslt)
698 {
699 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt));
700 }
701 }
702
703 static void
704 arm_rdi_mourn_inferior ()
705 {
706 unpush_target (&arm_rdi_ops);
707 generic_mourn_inferior ();
708 }
709 \f
710 /* While the RDI library keeps track of its own breakpoints, we need
711 to remember "handles" so that we can delete them later. Since
712 breakpoints get used for stepping, be careful not to leak memory
713 here. */
714
715 static int
716 arm_rdi_insert_breakpoint (addr, contents_cache)
717 CORE_ADDR addr;
718 char *contents_cache;
719 {
720 int rslt;
721 PointHandle point;
722 struct local_bp_list_entry *entry;
723 int type = RDIPoint_EQ;
724
725 if (arm_pc_is_thumb (addr) || arm_pc_is_thumb_dummy (addr))
726 type |= RDIPoint_16Bit;
727 rslt = angel_RDI_setbreak (addr, type, 0, &point);
728 if (rslt)
729 {
730 printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt));
731 }
732 entry =
733 (struct local_bp_list_entry *) xmalloc (sizeof (struct local_bp_list_entry));
734 entry->addr = addr;
735 entry->point = point;
736 entry->next = local_bp_list;
737 local_bp_list = entry;
738 return rslt;
739 }
740
741 static int
742 arm_rdi_remove_breakpoint (addr, contents_cache)
743 CORE_ADDR addr;
744 char *contents_cache;
745 {
746 int rslt;
747 PointHandle point;
748 struct local_bp_list_entry *entry, *preventry;
749
750 for (entry = local_bp_list; entry != NULL; entry = entry->next)
751 {
752 if (entry->addr == addr)
753 {
754 break;
755 }
756 preventry = entry;
757 }
758 if (entry)
759 {
760 rslt = angel_RDI_clearbreak (entry->point);
761 if (rslt)
762 {
763 printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt));
764 }
765 /* Delete the breakpoint entry locally. */
766 if (entry == local_bp_list)
767 {
768 local_bp_list = entry->next;
769 }
770 else
771 {
772 preventry->next = entry->next;
773 }
774 free (entry);
775 }
776 return 0;
777 }
778 \f
779 static char *
780 rdi_error_message (err)
781 int err;
782 {
783 switch (err)
784 {
785 case RDIError_NoError:
786 return "no error";
787 case RDIError_Reset:
788 return "debuggee reset";
789 case RDIError_UndefinedInstruction:
790 return "undefined instruction";
791 case RDIError_SoftwareInterrupt:
792 return "SWI trapped";
793 case RDIError_PrefetchAbort:
794 return "prefetch abort, execution ran into unmapped memory?";
795 case RDIError_DataAbort:
796 return "data abort, no memory at specified address?";
797 case RDIError_AddressException:
798 return "address exception, access >26bit in 26bit mode";
799 case RDIError_IRQ:
800 return "IRQ, interrupt trapped";
801 case RDIError_FIQ:
802 return "FIQ, fast interrupt trapped";
803 case RDIError_Error:
804 return "a miscellaneous type of error";
805 case RDIError_BranchThrough0:
806 return "branch through location 0";
807 case RDIError_NotInitialised:
808 return "internal error, RDI_open not called first";
809 case RDIError_UnableToInitialise:
810 return "internal error, target world is broken";
811 case RDIError_WrongByteSex:
812 return "See Operator: WrongByteSex";
813 case RDIError_UnableToTerminate:
814 return "See Operator: Unable to Terminate";
815 case RDIError_BadInstruction:
816 return "bad instruction, illegal to execute this instruction";
817 case RDIError_IllegalInstruction:
818 return "illegal instruction, the effect of executing it is undefined";
819 case RDIError_BadCPUStateSetting:
820 return "internal error, tried to set SPSR of user mode";
821 case RDIError_UnknownCoPro:
822 return "unknown co-processor";
823 case RDIError_UnknownCoProState:
824 return "cannot execute co-processor request";
825 case RDIError_BadCoProState:
826 return "recognizably broken co-processor request";
827 case RDIError_BadPointType:
828 return "internal error, bad point yype";
829 case RDIError_UnimplementedType:
830 return "internal error, unimplemented type";
831 case RDIError_BadPointSize:
832 return "internal error, bad point size";
833 case RDIError_UnimplementedSize:
834 return "internal error, unimplemented size";
835 case RDIError_NoMorePoints:
836 return "last break/watch point was used";
837 case RDIError_BreakpointReached:
838 return "breakpoint reached";
839 case RDIError_WatchpointAccessed:
840 return "watchpoint accessed";
841 case RDIError_NoSuchPoint:
842 return "attempted to clear non-existent break/watch point";
843 case RDIError_ProgramFinishedInStep:
844 return "end of the program reached while stepping";
845 case RDIError_UserInterrupt:
846 return "you pressed Escape";
847 case RDIError_CantSetPoint:
848 return "no more break/watch points available";
849 case RDIError_IncompatibleRDILevels:
850 return "incompatible RDI levels";
851 case RDIError_LittleEndian:
852 return "debuggee is little endian";
853 case RDIError_BigEndian:
854 return "debuggee is big endian";
855 case RDIError_SoftInitialiseError:
856 return "recoverable error in RDI initialization";
857 case RDIError_InsufficientPrivilege:
858 return "internal error, supervisor state not accessible to monitor";
859 case RDIError_UnimplementedMessage:
860 return "internal error, unimplemented message";
861 case RDIError_UndefinedMessage:
862 return "internal error, undefined message";
863 default:
864 return "undefined error message, should reset target";
865 }
866 }
867
868 /* Convert the ARM error messages to signals that GDB knows about. */
869
870 static enum target_signal
871 rdi_error_signal (err)
872 int err;
873 {
874 switch (err)
875 {
876 case RDIError_NoError:
877 return 0;
878 case RDIError_Reset:
879 return TARGET_SIGNAL_TERM; /* ??? */
880 case RDIError_UndefinedInstruction:
881 return TARGET_SIGNAL_ILL;
882 case RDIError_SoftwareInterrupt:
883 case RDIError_PrefetchAbort:
884 case RDIError_DataAbort:
885 return TARGET_SIGNAL_TRAP;
886 case RDIError_AddressException:
887 return TARGET_SIGNAL_SEGV;
888 case RDIError_IRQ:
889 case RDIError_FIQ:
890 return TARGET_SIGNAL_TRAP;
891 case RDIError_Error:
892 return TARGET_SIGNAL_TERM;
893 case RDIError_BranchThrough0:
894 return TARGET_SIGNAL_TRAP;
895 case RDIError_NotInitialised:
896 case RDIError_UnableToInitialise:
897 case RDIError_WrongByteSex:
898 case RDIError_UnableToTerminate:
899 return TARGET_SIGNAL_UNKNOWN;
900 case RDIError_BadInstruction:
901 case RDIError_IllegalInstruction:
902 return TARGET_SIGNAL_ILL;
903 case RDIError_BadCPUStateSetting:
904 case RDIError_UnknownCoPro:
905 case RDIError_UnknownCoProState:
906 case RDIError_BadCoProState:
907 case RDIError_BadPointType:
908 case RDIError_UnimplementedType:
909 case RDIError_BadPointSize:
910 case RDIError_UnimplementedSize:
911 case RDIError_NoMorePoints:
912 return TARGET_SIGNAL_UNKNOWN;
913 case RDIError_BreakpointReached:
914 case RDIError_WatchpointAccessed:
915 return TARGET_SIGNAL_TRAP;
916 case RDIError_NoSuchPoint:
917 case RDIError_ProgramFinishedInStep:
918 return TARGET_SIGNAL_UNKNOWN;
919 case RDIError_UserInterrupt:
920 return TARGET_SIGNAL_INT;
921 case RDIError_IncompatibleRDILevels:
922 case RDIError_LittleEndian:
923 case RDIError_BigEndian:
924 case RDIError_SoftInitialiseError:
925 case RDIError_InsufficientPrivilege:
926 case RDIError_UnimplementedMessage:
927 case RDIError_UndefinedMessage:
928 default:
929 return TARGET_SIGNAL_UNKNOWN;
930 }
931 }
932 \f
933 /* Define the target operations structure. */
934
935 static void
936 init_rdi_ops ()
937 {
938 arm_rdi_ops.to_shortname = "rdi";
939 arm_rdi_ops.to_longname = "ARM RDI";
940 arm_rdi_ops.to_doc = "Use a remote ARM-based computer; via the RDI library.\n\
941 Specify the serial device it is connected to (e.g. /dev/ttya).";
942 arm_rdi_ops.to_open = arm_rdi_open;
943 arm_rdi_ops.to_close = arm_rdi_close;
944 arm_rdi_ops.to_detach = arm_rdi_detach;
945 arm_rdi_ops.to_resume = arm_rdi_resume;
946 arm_rdi_ops.to_wait = arm_rdi_wait;
947 arm_rdi_ops.to_fetch_registers = arm_rdi_fetch_registers;
948 arm_rdi_ops.to_store_registers = arm_rdi_store_registers;
949 arm_rdi_ops.to_prepare_to_store = arm_rdi_prepare_to_store;
950 arm_rdi_ops.to_xfer_memory = arm_rdi_xfer_memory;
951 arm_rdi_ops.to_files_info = arm_rdi_files_info;
952 arm_rdi_ops.to_insert_breakpoint = arm_rdi_insert_breakpoint;
953 arm_rdi_ops.to_remove_breakpoint = arm_rdi_remove_breakpoint;
954 arm_rdi_ops.to_kill = arm_rdi_kill;
955 arm_rdi_ops.to_load = generic_load;
956 arm_rdi_ops.to_create_inferior = arm_rdi_create_inferior;
957 arm_rdi_ops.to_mourn_inferior = arm_rdi_mourn_inferior;
958 arm_rdi_ops.to_stratum = process_stratum;
959 arm_rdi_ops.to_has_all_memory = 1;
960 arm_rdi_ops.to_has_memory = 1;
961 arm_rdi_ops.to_has_stack = 1;
962 arm_rdi_ops.to_has_registers = 1;
963 arm_rdi_ops.to_has_execution = 1;
964 arm_rdi_ops.to_magic = OPS_MAGIC;
965 }
966
967 void
968 _initialize_remote_rdi ()
969 {
970 init_rdi_ops ();
971 add_target (&arm_rdi_ops);
972 }
973
974 /* A little dummy to make linking with the library succeed. */
975
976 int
977 Fail ()
978 {
979 return 0;
980 }