1 /* GDB interface to ARM RDI library.
3 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #include "gdb_string.h"
33 #include "gdb-stabs.h"
34 #include "gdbthread.h"
36 #include "breakpoint.h"
37 #include "completer.h"
43 #include "rdi-share/ardi.h"
44 #include "rdi-share/adp.h"
45 #include "rdi-share/hsys.h"
47 extern int isascii (int);
49 /* Prototypes for local functions */
51 static void arm_rdi_files_info (struct target_ops
*ignore
);
53 static int arm_rdi_xfer_memory (CORE_ADDR memaddr
, char *myaddr
,
54 int len
, int should_write
,
55 struct mem_attrib
*attrib
,
56 struct target_ops
*target
);
58 static void arm_rdi_prepare_to_store (void);
60 static void arm_rdi_fetch_registers (int regno
);
62 static void arm_rdi_resume (ptid_t pid
, int step
,
63 enum target_signal siggnal
);
65 static void arm_rdi_open (char *name
, int from_tty
);
67 static void arm_rdi_close (int quitting
);
69 static void arm_rdi_store_registers (int regno
);
71 static ptid_t
arm_rdi_wait (ptid_t ptid
, struct target_waitstatus
*status
);
73 static void arm_rdi_kill (void);
75 static void arm_rdi_detach (char *args
, int from_tty
);
77 static int arm_rdi_insert_breakpoint (CORE_ADDR
, bfd_byte
*);
79 static int arm_rdi_remove_breakpoint (CORE_ADDR
, bfd_byte
*);
81 static char *rdi_error_message (int err
);
83 static enum target_signal
rdi_error_signal (int err
);
85 /* Global variables. */
87 struct target_ops arm_rdi_ops
;
89 static struct Dbg_ConfigBlock gdb_config
;
91 static struct Dbg_HostosInterface gdb_hostif
;
93 static int max_load_size
;
95 static int execute_status
;
97 /* Send heatbeat packets? */
98 static int rdi_heartbeat
= 0;
100 /* Target has ROM at address 0. */
101 static int rom_at_zero
= 0;
103 /* Enable logging? */
104 static int log_enable
= 0;
106 /* Name of the log file. Default is "rdi.log". */
107 static char *log_filename
;
109 /* A little list of breakpoints that have been set. */
111 static struct local_bp_list_entry
115 struct local_bp_list_entry
*next
;
119 /* Helper callbacks for the "host interface" structure. RDI functions call
120 these to forward output from the target system and so forth. */
123 voiddummy (void *dummy
)
125 fprintf_unfiltered (gdb_stdout
, "void dummy\n");
129 myprint (void *arg
, const char *format
, va_list ap
)
131 vfprintf_unfiltered (gdb_stdout
, format
, ap
);
135 mywritec (void *arg
, int c
)
138 fputc_unfiltered (c
, gdb_stdout
);
142 mywrite (void *arg
, char const *buffer
, int len
)
148 for (i
= 0; i
< len
; i
++)
150 if (isascii ((int) *e
))
152 fputc_unfiltered ((int) *e
, gdb_stdout
);
165 /* These last two are tricky as we have to handle the special case of
166 being interrupted more carefully */
171 return fgetc (stdin
);
175 mygets (void *arg
, char *buffer
, int len
)
177 return fgets (buffer
, len
, stdin
);
180 /* Prevent multiple calls to angel_RDI_close(). */
181 static int closed_already
= 1;
183 /* Open a connection to a remote debugger. NAME is the filename used
184 for communication. */
187 arm_rdi_open (char *name
, int from_tty
)
190 unsigned long arg1
, arg2
;
191 char *openArgs
= NULL
;
192 char *devName
= 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)."));
199 /* split name after whitespace, pass tail as arg to open command */
201 devName
= xstrdup (name
);
202 p
= strchr (devName
, ' ');
214 /* Make the basic low-level connection. */
217 rslt
= Adp_OpenDevice (devName
, openArgs
, rdi_heartbeat
);
220 error (_("Could not open device \"%s\""), name
);
222 gdb_config
.bytesex
= 2 | (TARGET_BYTE_ORDER
== BFD_ENDIAN_BIG
? 1 : 0);
224 gdb_config
.rditype
= 2;
225 gdb_config
.heartbeat_on
= 1;
226 gdb_config
.flags
= 2;
228 gdb_hostif
.dbgprint
= myprint
;
229 gdb_hostif
.dbgpause
= mypause
;
230 gdb_hostif
.dbgarg
= NULL
;
231 gdb_hostif
.writec
= mywritec
;
232 gdb_hostif
.readc
= myreadc
;
233 gdb_hostif
.write
= mywrite
;
234 gdb_hostif
.gets
= mygets
;
235 gdb_hostif
.hostosarg
= NULL
;
236 gdb_hostif
.reset
= voiddummy
;
238 rslt
= angel_RDI_open (10, &gdb_config
, &gdb_hostif
, NULL
);
239 if (rslt
== RDIError_BigEndian
|| rslt
== RDIError_LittleEndian
)
240 ; /* do nothing, this is the expected return */
241 else if (rslt
!= RDIError_NoError
)
243 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
245 error (_("RDI_open failed."));
248 rslt
= angel_RDI_info (RDIInfo_Target
, &arg1
, &arg2
);
249 if (rslt
!= RDIError_NoError
)
251 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
253 rslt
= angel_RDI_info (RDIInfo_Points
, &arg1
, &arg2
);
254 if (rslt
!= RDIError_NoError
)
256 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
258 rslt
= angel_RDI_info (RDIInfo_Step
, &arg1
, &arg2
);
259 if (rslt
!= RDIError_NoError
)
261 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
263 rslt
= angel_RDI_info (RDIInfo_CoPro
, &arg1
, &arg2
);
264 if (rslt
!= RDIError_NoError
)
266 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
268 rslt
= angel_RDI_info (RDIInfo_SemiHosting
, &arg1
, &arg2
);
269 if (rslt
!= RDIError_NoError
)
271 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
274 rslt
= angel_RDI_info (RDIInfo_GetLoadSize
, &arg1
, &arg2
);
275 if (rslt
!= RDIError_NoError
)
277 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
279 max_load_size
= arg1
;
281 push_target (&arm_rdi_ops
);
283 target_fetch_registers (-1);
285 rslt
= angel_RDI_open (1, &gdb_config
, NULL
, NULL
);
286 if (rslt
!= RDIError_NoError
)
288 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
291 arg1
= rom_at_zero
? 0x0 : 0x13b;
293 rslt
= angel_RDI_info (RDIVector_Catch
, &arg1
, &arg2
);
294 if (rslt
!= RDIError_NoError
)
296 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
299 arg1
= (unsigned long) "";
300 rslt
= angel_RDI_info (RDISet_Cmdline
, &arg1
, &arg2
);
301 if (rslt
!= RDIError_NoError
)
303 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
306 /* Clear out any existing records of breakpoints. */
308 struct local_bp_list_entry
*entry
, *preventry
= NULL
;
310 for (entry
= local_bp_list
; entry
!= NULL
; entry
= entry
->next
)
317 printf_filtered ("Connected to ARM RDI target.\n");
319 inferior_ptid
= pid_to_ptid (42);
322 /* Start an inferior process and set inferior_ptid to its pid.
323 EXEC_FILE is the file to run.
324 ARGS is a string containing the arguments to the program.
325 ENV is the environment vector to pass. Errors reported with error().
326 On VxWorks and various standalone systems, we ignore exec_file. */
327 /* This is called not only when we first attach, but also when the
328 user types "run" after having attached. */
331 arm_rdi_create_inferior (char *exec_file
, char *args
, char **env
, int from_tty
)
334 unsigned long arg1
, arg2
;
336 CORE_ADDR entry_point
;
338 if (exec_file
== 0 || exec_bfd
== 0)
339 error (_("No executable file specified."));
341 entry_point
= (CORE_ADDR
) bfd_get_start_address (exec_bfd
);
344 remove_breakpoints ();
345 init_wait_for_inferior ();
347 len
= strlen (exec_file
) + 1 + strlen (args
) + 1 + /*slop */ 10;
348 arg_buf
= (char *) alloca (len
);
350 strcat (arg_buf
, exec_file
);
351 strcat (arg_buf
, " ");
352 strcat (arg_buf
, args
);
354 inferior_ptid
= pid_to_ptid (42);
355 insert_breakpoints (); /* Needed to get correct instruction in cache */
361 if (strncmp (*env
, "MEMSIZE=", sizeof ("MEMSIZE=") - 1) == 0)
363 unsigned long top_of_memory
;
366 /* Set up memory limit */
367 top_of_memory
= strtoul (*env
+ sizeof ("MEMSIZE=") - 1,
369 printf_filtered ("Setting top-of-memory to 0x%lx\n",
372 rslt
= angel_RDI_info (RDIInfo_SetTopMem
, &top_of_memory
, &arg2
);
373 if (rslt
!= RDIError_NoError
)
375 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
382 arg1
= (unsigned long) arg_buf
;
383 rslt
= angel_RDI_info (RDISet_Cmdline
, /* &arg1 */ (unsigned long *) arg_buf
, &arg2
);
384 if (rslt
!= RDIError_NoError
)
386 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
389 proceed (entry_point
, TARGET_SIGNAL_DEFAULT
, 0);
392 /* This takes a program previously attached to and detaches it. After
393 this is done, GDB can be used to debug some other program. We
394 better not have left any breakpoints in the target program or it'll
395 die when it hits one. */
398 arm_rdi_detach (char *args
, int from_tty
)
403 /* Clean up connection to a remote debugger. */
406 arm_rdi_close (int quitting
)
412 rslt
= angel_RDI_close ();
413 if (rslt
!= RDIError_NoError
)
415 printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt
));
418 inferior_ptid
= null_ptid
;
420 generic_mourn_inferior ();
424 /* Tell the remote machine to resume. */
427 arm_rdi_resume (ptid_t ptid
, int step
, enum target_signal siggnal
)
432 if (0 /* turn on when hardware supports single-stepping */ )
434 rslt
= angel_RDI_step (1, &point
);
435 if (rslt
!= RDIError_NoError
)
436 printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt
));
445 pc
= read_register (ARM_PC_REGNUM
);
446 pc
= arm_get_next_pc (pc
);
447 arm_rdi_insert_breakpoint (pc
, handle
);
450 execute_status
= rslt
= angel_RDI_execute (&point
);
451 if (rslt
!= RDIError_NoError
&& rslt
!= RDIError_BreakpointReached
)
452 printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt
));
455 arm_rdi_remove_breakpoint (pc
, handle
);
459 /* Wait until the remote machine stops, then return, storing status in
460 STATUS just as `wait' would. Returns "pid" (though it's not clear
461 what, if anything, that means in the case of this target). */
464 arm_rdi_wait (ptid_t ptid
, struct target_waitstatus
*status
)
466 status
->kind
= (execute_status
== RDIError_NoError
?
467 TARGET_WAITKIND_EXITED
: TARGET_WAITKIND_STOPPED
);
469 /* convert stopped code from target into right signal */
470 status
->value
.sig
= rdi_error_signal (execute_status
);
472 return inferior_ptid
;
475 /* Read the remote registers into the block REGS. */
478 arm_rdi_fetch_registers (int regno
)
480 int rslt
, rdi_regmask
;
481 unsigned long rawreg
, rawregs
[32];
486 rslt
= angel_RDI_CPUread (255, 0x27fff, rawregs
);
487 if (rslt
!= RDIError_NoError
)
489 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt
));
492 for (regno
= 0; regno
< 15; regno
++)
494 store_unsigned_integer (cookedreg
, 4, rawregs
[regno
]);
495 regcache_raw_supply (current_regcache
, regno
, (char *) cookedreg
);
497 store_unsigned_integer (cookedreg
, 4, rawregs
[15]);
498 regcache_raw_supply (current_regcache
, ARM_PS_REGNUM
, (char *) cookedreg
);
499 arm_rdi_fetch_registers (ARM_PC_REGNUM
);
503 if (regno
== ARM_PC_REGNUM
)
504 rdi_regmask
= RDIReg_PC
;
505 else if (regno
== ARM_PS_REGNUM
)
506 rdi_regmask
= RDIReg_CPSR
;
507 else if (regno
< 0 || regno
> 15)
510 regcache_raw_supply (current_regcache
, regno
, (char *) &rawreg
);
514 rdi_regmask
= 1 << regno
;
516 rslt
= angel_RDI_CPUread (255, rdi_regmask
, &rawreg
);
517 if (rslt
!= RDIError_NoError
)
519 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt
));
521 store_unsigned_integer (cookedreg
, 4, rawreg
);
522 regcache_raw_supply (current_regcache
, regno
, (char *) cookedreg
);
527 arm_rdi_prepare_to_store (void)
532 /* Store register REGNO, or all registers if REGNO == -1, from the contents
533 of REGISTERS. FIXME: ignores errors. */
536 arm_rdi_store_registers (int regno
)
538 int rslt
, rdi_regmask
;
540 /* These need to be able to take 'floating point register' contents */
541 unsigned long rawreg
[3], rawerreg
[3];
545 for (regno
= 0; regno
< NUM_REGS
; regno
++)
546 arm_rdi_store_registers (regno
);
550 deprecated_read_register_gen (regno
, (char *) rawreg
);
551 /* RDI manipulates data in host byte order, so convert now. */
552 store_unsigned_integer (rawerreg
, 4, rawreg
[0]);
554 if (regno
== ARM_PC_REGNUM
)
555 rdi_regmask
= RDIReg_PC
;
556 else if (regno
== ARM_PS_REGNUM
)
557 rdi_regmask
= RDIReg_CPSR
;
558 else if (regno
< 0 || regno
> 15)
561 rdi_regmask
= 1 << regno
;
563 rslt
= angel_RDI_CPUwrite (255, rdi_regmask
, rawerreg
);
564 if (rslt
!= RDIError_NoError
)
566 printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt
));
571 /* Read or write LEN bytes from inferior memory at MEMADDR,
572 transferring to or from debugger address MYADDR. Write to inferior
573 if SHOULD_WRITE is nonzero. Returns length of data written or
574 read; 0 for error. TARGET is unused. */
577 arm_rdi_xfer_memory (CORE_ADDR memaddr
, char *myaddr
, int len
,
578 int should_write
, struct mem_attrib
*attrib
,
579 struct target_ops
*target
)
585 rslt
= angel_RDI_write (myaddr
, memaddr
, &len
);
586 if (rslt
!= RDIError_NoError
)
588 printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt
));
593 rslt
= angel_RDI_read (memaddr
, myaddr
, &len
);
594 if (rslt
!= RDIError_NoError
)
596 printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt
));
603 /* Display random info collected from the target. */
606 arm_rdi_files_info (struct target_ops
*ignore
)
608 char *file
= "nothing";
610 unsigned long arg1
, arg2
;
612 rslt
= angel_RDI_info (RDIInfo_Target
, &arg1
, &arg2
);
613 if (rslt
!= RDIError_NoError
)
615 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
617 if (arg1
& (1 << 15))
618 printf_filtered ("Target supports Thumb code.\n");
619 if (arg1
& (1 << 14))
620 printf_filtered ("Target can do profiling.\n");
622 printf_filtered ("Target is real hardware.\n");
624 rslt
= angel_RDI_info (RDIInfo_Step
, &arg1
, &arg2
);
625 if (rslt
!= RDIError_NoError
)
627 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
629 printf_filtered ("Target can%s single-step.\n", (arg1
& 0x4 ? "" : "not"));
631 rslt
= angel_RDI_info (RDIInfo_Icebreaker
, &arg1
, &arg2
);
632 if (rslt
!= RDIError_NoError
)
634 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
637 printf_filtered ("Target includes an EmbeddedICE.\n");
645 rslt
= angel_RDI_open (1, &gdb_config
, NULL
, NULL
);
646 if (rslt
!= RDIError_NoError
)
648 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
653 arm_rdi_mourn_inferior (void)
655 /* We remove the inserted breakpoints in case the user wants to
656 issue another target and load commands to rerun his application;
657 This is something that wouldn't work on a native target, for instance,
658 as the process goes away when the inferior exits, but it works with
659 some remote targets like this one. That is why this is done here. */
660 remove_breakpoints();
661 unpush_target (&arm_rdi_ops
);
662 generic_mourn_inferior ();
665 /* While the RDI library keeps track of its own breakpoints, we need
666 to remember "handles" so that we can delete them later. Since
667 breakpoints get used for stepping, be careful not to leak memory
671 arm_rdi_insert_breakpoint (CORE_ADDR addr
, bfd_byte
*contents_cache
)
675 struct local_bp_list_entry
*entry
;
676 int type
= RDIPoint_EQ
;
678 if (arm_pc_is_thumb (addr
))
679 type
|= RDIPoint_16Bit
;
680 rslt
= angel_RDI_setbreak (addr
, type
, 0, &point
);
681 if (rslt
!= RDIError_NoError
)
683 printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt
));
686 (struct local_bp_list_entry
*) xmalloc (sizeof (struct local_bp_list_entry
));
688 entry
->point
= point
;
689 entry
->next
= local_bp_list
;
690 local_bp_list
= entry
;
695 arm_rdi_remove_breakpoint (CORE_ADDR addr
, bfd_byte
*contents_cache
)
699 struct local_bp_list_entry
**entryp
, *dead
;
701 for (entryp
= &local_bp_list
; *entryp
!= NULL
; entryp
= &(*entryp
)->next
)
702 if ((*entryp
)->addr
== addr
)
708 rslt
= angel_RDI_clearbreak (dead
->point
);
709 if (rslt
!= RDIError_NoError
)
710 printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt
));
712 /* Delete the breakpoint entry locally. */
713 *entryp
= dead
->next
;
722 rdi_error_message (int err
)
726 case RDIError_NoError
:
729 return "debuggee reset";
730 case RDIError_UndefinedInstruction
:
731 return "undefined instruction";
732 case RDIError_SoftwareInterrupt
:
733 return "SWI trapped";
734 case RDIError_PrefetchAbort
:
735 return "prefetch abort, execution ran into unmapped memory?";
736 case RDIError_DataAbort
:
737 return "data abort, no memory at specified address?";
738 case RDIError_AddressException
:
739 return "address exception, access >26bit in 26bit mode";
741 return "IRQ, interrupt trapped";
743 return "FIQ, fast interrupt trapped";
745 return "a miscellaneous type of error";
746 case RDIError_BranchThrough0
:
747 return "branch through location 0";
748 case RDIError_NotInitialised
:
749 return "internal error, RDI_open not called first";
750 case RDIError_UnableToInitialise
:
751 return "internal error, target world is broken";
752 case RDIError_WrongByteSex
:
753 return "See Operator: WrongByteSex";
754 case RDIError_UnableToTerminate
:
755 return "See Operator: Unable to Terminate";
756 case RDIError_BadInstruction
:
757 return "bad instruction, illegal to execute this instruction";
758 case RDIError_IllegalInstruction
:
759 return "illegal instruction, the effect of executing it is undefined";
760 case RDIError_BadCPUStateSetting
:
761 return "internal error, tried to set SPSR of user mode";
762 case RDIError_UnknownCoPro
:
763 return "unknown co-processor";
764 case RDIError_UnknownCoProState
:
765 return "cannot execute co-processor request";
766 case RDIError_BadCoProState
:
767 return "recognizably broken co-processor request";
768 case RDIError_BadPointType
:
769 return "internal error, bad point yype";
770 case RDIError_UnimplementedType
:
771 return "internal error, unimplemented type";
772 case RDIError_BadPointSize
:
773 return "internal error, bad point size";
774 case RDIError_UnimplementedSize
:
775 return "internal error, unimplemented size";
776 case RDIError_NoMorePoints
:
777 return "last break/watch point was used";
778 case RDIError_BreakpointReached
:
779 return "breakpoint reached";
780 case RDIError_WatchpointAccessed
:
781 return "watchpoint accessed";
782 case RDIError_NoSuchPoint
:
783 return "attempted to clear non-existent break/watch point";
784 case RDIError_ProgramFinishedInStep
:
785 return "end of the program reached while stepping";
786 case RDIError_UserInterrupt
:
787 return "you pressed Escape";
788 case RDIError_CantSetPoint
:
789 return "no more break/watch points available";
790 case RDIError_IncompatibleRDILevels
:
791 return "incompatible RDI levels";
792 case RDIError_LittleEndian
:
793 return "debuggee is little endian";
794 case RDIError_BigEndian
:
795 return "debuggee is big endian";
796 case RDIError_SoftInitialiseError
:
797 return "recoverable error in RDI initialization";
798 case RDIError_InsufficientPrivilege
:
799 return "internal error, supervisor state not accessible to monitor";
800 case RDIError_UnimplementedMessage
:
801 return "internal error, unimplemented message";
802 case RDIError_UndefinedMessage
:
803 return "internal error, undefined message";
805 return "undefined error message, should reset target";
809 /* Convert the ARM error messages to signals that GDB knows about. */
811 static enum target_signal
812 rdi_error_signal (int err
)
816 case RDIError_NoError
:
819 return TARGET_SIGNAL_TERM
; /* ??? */
820 case RDIError_UndefinedInstruction
:
821 return TARGET_SIGNAL_ILL
;
822 case RDIError_SoftwareInterrupt
:
823 case RDIError_PrefetchAbort
:
824 case RDIError_DataAbort
:
825 return TARGET_SIGNAL_TRAP
;
826 case RDIError_AddressException
:
827 return TARGET_SIGNAL_SEGV
;
830 return TARGET_SIGNAL_TRAP
;
832 return TARGET_SIGNAL_TERM
;
833 case RDIError_BranchThrough0
:
834 return TARGET_SIGNAL_TRAP
;
835 case RDIError_NotInitialised
:
836 case RDIError_UnableToInitialise
:
837 case RDIError_WrongByteSex
:
838 case RDIError_UnableToTerminate
:
839 return TARGET_SIGNAL_UNKNOWN
;
840 case RDIError_BadInstruction
:
841 case RDIError_IllegalInstruction
:
842 return TARGET_SIGNAL_ILL
;
843 case RDIError_BadCPUStateSetting
:
844 case RDIError_UnknownCoPro
:
845 case RDIError_UnknownCoProState
:
846 case RDIError_BadCoProState
:
847 case RDIError_BadPointType
:
848 case RDIError_UnimplementedType
:
849 case RDIError_BadPointSize
:
850 case RDIError_UnimplementedSize
:
851 case RDIError_NoMorePoints
:
852 return TARGET_SIGNAL_UNKNOWN
;
853 case RDIError_BreakpointReached
:
854 case RDIError_WatchpointAccessed
:
855 return TARGET_SIGNAL_TRAP
;
856 case RDIError_NoSuchPoint
:
857 case RDIError_ProgramFinishedInStep
:
858 return TARGET_SIGNAL_UNKNOWN
;
859 case RDIError_UserInterrupt
:
860 return TARGET_SIGNAL_INT
;
861 case RDIError_IncompatibleRDILevels
:
862 case RDIError_LittleEndian
:
863 case RDIError_BigEndian
:
864 case RDIError_SoftInitialiseError
:
865 case RDIError_InsufficientPrivilege
:
866 case RDIError_UnimplementedMessage
:
867 case RDIError_UndefinedMessage
:
869 return TARGET_SIGNAL_UNKNOWN
;
876 angel_RDI_stop_request();
880 /* Define the target operations structure. */
885 arm_rdi_ops
.to_shortname
= "rdi";
886 arm_rdi_ops
.to_longname
= "ARM RDI";
887 arm_rdi_ops
.to_doc
= "Use a remote ARM-based computer; via the RDI library.\n\
888 Specify the serial device it is connected to (e.g. /dev/ttya).";
889 arm_rdi_ops
.to_open
= arm_rdi_open
;
890 arm_rdi_ops
.to_close
= arm_rdi_close
;
891 arm_rdi_ops
.to_detach
= arm_rdi_detach
;
892 arm_rdi_ops
.to_resume
= arm_rdi_resume
;
893 arm_rdi_ops
.to_wait
= arm_rdi_wait
;
894 arm_rdi_ops
.to_stop
= arm_rdi_stop
;
895 arm_rdi_ops
.to_fetch_registers
= arm_rdi_fetch_registers
;
896 arm_rdi_ops
.to_store_registers
= arm_rdi_store_registers
;
897 arm_rdi_ops
.to_prepare_to_store
= arm_rdi_prepare_to_store
;
898 arm_rdi_ops
.deprecated_xfer_memory
= arm_rdi_xfer_memory
;
899 arm_rdi_ops
.to_files_info
= arm_rdi_files_info
;
900 arm_rdi_ops
.to_insert_breakpoint
= arm_rdi_insert_breakpoint
;
901 arm_rdi_ops
.to_remove_breakpoint
= arm_rdi_remove_breakpoint
;
902 arm_rdi_ops
.to_kill
= arm_rdi_kill
;
903 arm_rdi_ops
.to_load
= generic_load
;
904 arm_rdi_ops
.to_create_inferior
= arm_rdi_create_inferior
;
905 arm_rdi_ops
.to_mourn_inferior
= arm_rdi_mourn_inferior
;
906 arm_rdi_ops
.to_stratum
= process_stratum
;
907 arm_rdi_ops
.to_has_all_memory
= 1;
908 arm_rdi_ops
.to_has_memory
= 1;
909 arm_rdi_ops
.to_has_stack
= 1;
910 arm_rdi_ops
.to_has_registers
= 1;
911 arm_rdi_ops
.to_has_execution
= 1;
912 arm_rdi_ops
.to_magic
= OPS_MAGIC
;
916 rdilogfile_command (char *arg
, int from_tty
)
918 if (!arg
|| strlen (arg
) == 0)
920 printf_filtered ("rdi log file is '%s'\n", log_filename
);
925 xfree (log_filename
);
927 log_filename
= xstrdup (arg
);
929 Adp_SetLogfile (log_filename
);
933 rdilogenable_command (char *args
, int from_tty
)
935 if (!args
|| strlen (args
) == 0)
937 printf_filtered ("rdi log is %s\n", log_enable
? "enabled" : "disabled");
941 if (!strcasecmp (args
, "1") ||
942 !strcasecmp (args
, "y") ||
943 !strcasecmp (args
, "yes") ||
944 !strcasecmp (args
, "on") ||
945 !strcasecmp (args
, "t") ||
946 !strcasecmp (args
, "true"))
947 Adp_SetLogEnable (log_enable
= 1);
948 else if (!strcasecmp (args
, "0") ||
949 !strcasecmp (args
, "n") ||
950 !strcasecmp (args
, "no") ||
951 !strcasecmp (args
, "off") ||
952 !strcasecmp (args
, "f") ||
953 !strcasecmp (args
, "false"))
954 Adp_SetLogEnable (log_enable
= 0);
956 printf_filtered ("rdilogenable: unrecognized argument '%s'\n"
957 " try y or n\n", args
);
960 extern initialize_file_ftype _initialize_remote_rdi
; /* -Wmissing-prototypes */
963 _initialize_remote_rdi (void)
965 struct cmd_list_element
*c
;
968 add_target (&arm_rdi_ops
);
970 log_filename
= xstrdup ("rdi.log");
971 Adp_SetLogfile (log_filename
);
972 Adp_SetLogEnable (log_enable
);
974 c
= add_cmd ("rdilogfile", class_maintenance
, rdilogfile_command
, _("\
975 Set filename for ADP packet log.\n\
976 This file is used to log Angel Debugger Protocol packets.\n\
977 With a single argument, sets the logfile name to that value.\n\
978 Without an argument, shows the current logfile name.\n\
979 See also: rdilogenable\n"),
981 set_cmd_completer (c
, filename_completer
);
983 add_cmd ("rdilogenable", class_maintenance
, rdilogenable_command
, _("\
984 Set enable logging of ADP packets.\n\
985 This will log ADP packets exchanged between gdb and the\n\
986 rdi target device.\n\
987 An argument of 1, t, true, y or yes will enable.\n\
988 An argument of 0, f, false, n or no will disabled.\n\
989 Withough an argument, it will display current state."),
992 add_setshow_boolean_cmd ("rdiromatzero", no_class
, &rom_at_zero
, _("\
993 Set target has ROM at addr 0."), _("\
994 Show if target has ROM at addr 0."), _("\
995 A true value disables vector catching, false enables vector catching.\n\
996 This is evaluated at the time the 'target rdi' command is executed."),
998 NULL
, /* FIXME: i18n: Target has ROM at addr 0 is %s. */
999 &setlist
, &showlist
);
1001 add_setshow_boolean_cmd ("rdiheartbeat", no_class
, &rdi_heartbeat
, _("\
1002 Set enable for ADP heartbeat packets."), _("\
1003 Show enable for ADP heartbeat packets."), _("\
1004 I don't know why you would want this. If you enable them,\n\
1005 it will confuse ARM and EPI JTAG interface boxes as well\n\
1006 as the Angel Monitor."),
1008 NULL
, /* FIXME: i18n: Enable for ADP heartbeat packets is %s. */
1009 &setlist
, &showlist
);
1012 /* A little dummy to make linking with the library succeed. */
1015 Fail (const char *ignored
, ...)