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