1 /* GDB interface to ARM RDI library.
2 Copyright 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GDB.
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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include "gdb_string.h"
32 #include "gdb-stabs.h"
33 #include "gdbthread.h"
35 #include "breakpoint.h"
38 #include <sys/types.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 target_ops
*target
);
57 static void arm_rdi_prepare_to_store (void);
59 static void arm_rdi_fetch_registers (int regno
);
61 static void arm_rdi_resume (int pid
, int step
, enum target_signal siggnal
);
63 static int arm_rdi_start_remote (char *dummy
);
65 static void arm_rdi_open (char *name
, int from_tty
);
67 static void arm_rdi_create_inferior (char *exec_file
, char *args
, char **env
);
69 static void arm_rdi_close (int quitting
);
71 static void arm_rdi_store_registers (int regno
);
73 static void arm_rdi_mourn (void);
75 static void arm_rdi_send (char *buf
);
77 static int arm_rdi_wait (int pid
, struct target_waitstatus
*status
);
79 static void arm_rdi_kill (void);
81 static void arm_rdi_detach (char *args
, int from_tty
);
83 static void arm_rdi_interrupt (int signo
);
85 static void arm_rdi_interrupt_twice (int signo
);
87 static void interrupt_query (void);
89 static int arm_rdi_insert_breakpoint (CORE_ADDR
, char *);
91 static int arm_rdi_remove_breakpoint (CORE_ADDR
, char *);
93 static char *rdi_error_message (int err
);
95 static enum target_signal
rdi_error_signal (int err
);
97 /* Global variables. */
99 struct target_ops arm_rdi_ops
;
101 static struct Dbg_ConfigBlock gdb_config
;
103 static struct Dbg_HostosInterface gdb_hostif
;
105 static int max_load_size
;
107 static int execute_status
;
109 /* Send heatbeat packets? */
110 static int rdi_heartbeat
= 0;
112 /* Target has ROM at address 0. */
113 static int rom_at_zero
= 0;
115 /* Enable logging? */
116 static int log_enable
= 0;
118 /* Name of the log file. Default is "rdi.log". */
119 static char *log_filename
;
121 /* A little list of breakpoints that have been set. */
123 static struct local_bp_list_entry
127 struct local_bp_list_entry
*next
;
132 /* Stub for catch_errors. */
135 arm_rdi_start_remote (char *dummy
)
140 /* Helper callbacks for the "host interface" structure. RDI functions call
141 these to forward output from the target system and so forth. */
146 fprintf_unfiltered (gdb_stdout
, "void dummy\n");
150 myprint (PTR arg
, const char *format
, va_list ap
)
152 vfprintf_unfiltered (gdb_stdout
, format
, ap
);
156 mywritec (PTR arg
, int c
)
159 fputc_unfiltered (c
, gdb_stdout
);
163 mywrite (PTR arg
, char const *buffer
, int len
)
169 for (i
= 0; i
< len
; i
++)
171 if (isascii ((int) *e
))
173 fputc_unfiltered ((int) *e
, gdb_stdout
);
186 /* These last two are tricky as we have to handle the special case of
187 being interrupted more carefully */
192 return fgetc (stdin
);
196 mygets (PTR arg
, char *buffer
, int len
)
198 return fgets (buffer
, len
, stdin
);
201 /* Prevent multiple calls to angel_RDI_close(). */
202 static int closed_already
= 1;
204 /* Open a connection to a remote debugger. NAME is the filename used
205 for communication. */
208 arm_rdi_open (char *name
, int from_tty
)
211 unsigned long arg1
, arg2
;
212 char *openArgs
= NULL
;
213 char *devName
= NULL
;
217 error ("To open an RDI connection, you need to specify what serial\n\
218 device is attached to the remote system (e.g. /dev/ttya).");
220 /* split name after whitespace, pass tail as arg to open command */
222 devName
= xstrdup (name
);
223 p
= strchr (devName
, ' ');
235 /* Make the basic low-level connection. */
238 rslt
= Adp_OpenDevice (devName
, openArgs
, rdi_heartbeat
);
241 error ("Could not open device \"%s\"", name
);
243 gdb_config
.bytesex
= 2 | (TARGET_BYTE_ORDER
== BIG_ENDIAN
? 1 : 0);
245 gdb_config
.rditype
= 2;
246 gdb_config
.heartbeat_on
= 1;
247 gdb_config
.flags
= 2;
249 gdb_hostif
.dbgprint
= myprint
;
250 gdb_hostif
.dbgpause
= mypause
;
251 gdb_hostif
.dbgarg
= NULL
;
252 gdb_hostif
.writec
= mywritec
;
253 gdb_hostif
.readc
= myreadc
;
254 gdb_hostif
.write
= mywrite
;
255 gdb_hostif
.gets
= mygets
;
256 gdb_hostif
.hostosarg
= NULL
;
257 gdb_hostif
.reset
= voiddummy
;
259 rslt
= angel_RDI_open (10, &gdb_config
, &gdb_hostif
, NULL
);
260 if (rslt
== RDIError_BigEndian
|| rslt
== RDIError_LittleEndian
)
261 ; /* do nothing, this is the expected return */
264 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
266 error ("RID_open failed\n");
269 rslt
= angel_RDI_info (RDIInfo_Target
, &arg1
, &arg2
);
272 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
274 rslt
= angel_RDI_info (RDIInfo_Points
, &arg1
, &arg2
);
277 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
279 rslt
= angel_RDI_info (RDIInfo_Step
, &arg1
, &arg2
);
282 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
284 rslt
= angel_RDI_info (RDIInfo_CoPro
, &arg1
, &arg2
);
287 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
289 rslt
= angel_RDI_info (RDIInfo_SemiHosting
, &arg1
, &arg2
);
292 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
295 rslt
= angel_RDI_info (RDIInfo_GetLoadSize
, &arg1
, &arg2
);
298 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
300 max_load_size
= arg1
;
302 push_target (&arm_rdi_ops
);
304 target_fetch_registers (-1);
306 rslt
= angel_RDI_open (1, &gdb_config
, NULL
, NULL
);
309 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
312 arg1
= rom_at_zero
? 0x0 : 0x13b;
314 rslt
= angel_RDI_info (RDIVector_Catch
, &arg1
, &arg2
);
317 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
320 arg1
= (unsigned long) "";
321 rslt
= angel_RDI_info (RDISet_Cmdline
, &arg1
, &arg2
);
324 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
327 /* Clear out any existing records of breakpoints. */
329 struct local_bp_list_entry
*entry
, *preventry
= NULL
;
331 for (entry
= local_bp_list
; entry
!= NULL
; entry
= entry
->next
)
338 printf_filtered ("Connected to ARM RDI target.\n");
343 /* Start an inferior process and set inferior_pid to its pid.
344 EXEC_FILE is the file to run.
345 ARGS is a string containing the arguments to the program.
346 ENV is the environment vector to pass. Errors reported with error().
347 On VxWorks and various standalone systems, we ignore exec_file. */
348 /* This is called not only when we first attach, but also when the
349 user types "run" after having attached. */
352 arm_rdi_create_inferior (char *exec_file
, char *args
, char **env
)
355 unsigned long arg1
, arg2
;
357 CORE_ADDR entry_point
;
359 if (exec_file
== 0 || exec_bfd
== 0)
360 error ("No executable file specified.");
362 entry_point
= (CORE_ADDR
) bfd_get_start_address (exec_bfd
);
365 remove_breakpoints ();
366 init_wait_for_inferior ();
368 len
= strlen (exec_file
) + 1 + strlen (args
) + 1 + /*slop */ 10;
369 arg_buf
= (char *) alloca (len
);
371 strcat (arg_buf
, exec_file
);
372 strcat (arg_buf
, " ");
373 strcat (arg_buf
, args
);
376 insert_breakpoints (); /* Needed to get correct instruction in cache */
382 if (strncmp (*env
, "MEMSIZE=", sizeof ("MEMSIZE=") - 1) == 0)
384 unsigned long top_of_memory
;
387 /* Set up memory limit */
388 top_of_memory
= strtoul (*env
+ sizeof ("MEMSIZE=") - 1,
390 printf_filtered ("Setting top-of-memory to 0x%lx\n",
393 rslt
= angel_RDI_info (RDIInfo_SetTopMem
, &top_of_memory
, &arg2
);
396 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
403 arg1
= (unsigned long) arg_buf
;
404 rslt
= angel_RDI_info (RDISet_Cmdline
, /* &arg1 */ (unsigned long *) arg_buf
, &arg2
);
407 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
410 proceed (entry_point
, TARGET_SIGNAL_DEFAULT
, 0);
413 /* This takes a program previously attached to and detaches it. After
414 this is done, GDB can be used to debug some other program. We
415 better not have left any breakpoints in the target program or it'll
416 die when it hits one. */
419 arm_rdi_detach (char *args
, int from_tty
)
424 /* Clean up connection to a remote debugger. */
427 arm_rdi_close (int quitting
)
433 rslt
= angel_RDI_close ();
436 printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt
));
441 generic_mourn_inferior ();
445 /* Tell the remote machine to resume. */
448 arm_rdi_resume (int pid
, int step
, enum target_signal siggnal
)
453 if (0 /* turn on when hardware supports single-stepping */ )
455 rslt
= angel_RDI_step (1, &point
);
458 printf_filtered ("RDI_step: %s\n", rdi_error_message (rslt
));
468 pc
= read_register (PC_REGNUM
);
469 pc
= arm_get_next_pc (pc
);
470 arm_rdi_insert_breakpoint (pc
, handle
);
472 execute_status
= rslt
= angel_RDI_execute (&point
);
473 if (rslt
== RDIError_BreakpointReached
)
477 printf_filtered ("RDI_execute: %s\n", rdi_error_message (rslt
));
481 arm_rdi_remove_breakpoint (pc
, handle
);
486 /* Send ^C to target to halt it. Target will respond, and send us a
490 arm_rdi_interrupt (int signo
)
494 static void (*ofunc
) ();
496 /* The user typed ^C twice. */
498 arm_rdi_interrupt_twice (int signo
)
502 /* Ask the user what to do when an interrupt is received. */
505 interrupt_query (void)
509 /* Wait until the remote machine stops, then return, storing status in
510 STATUS just as `wait' would. Returns "pid" (though it's not clear
511 what, if anything, that means in the case of this target). */
514 arm_rdi_wait (int pid
, struct target_waitstatus
*status
)
516 status
->kind
= (execute_status
== RDIError_NoError
?
517 TARGET_WAITKIND_EXITED
: TARGET_WAITKIND_STOPPED
);
519 /* convert stopped code from target into right signal */
520 status
->value
.sig
= rdi_error_signal (execute_status
);
525 /* Read the remote registers into the block REGS. */
529 arm_rdi_fetch_registers (int regno
)
531 int rslt
, rdi_regmask
;
532 unsigned long rawreg
, rawregs
[32];
537 rslt
= angel_RDI_CPUread (255, 0x27fff, rawregs
);
540 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt
));
543 for (regno
= 0; regno
< 15; regno
++)
545 store_unsigned_integer (cookedreg
, 4, rawregs
[regno
]);
546 supply_register (regno
, (char *) cookedreg
);
548 store_unsigned_integer (cookedreg
, 4, rawregs
[15]);
549 supply_register (PS_REGNUM
, (char *) cookedreg
);
550 arm_rdi_fetch_registers (PC_REGNUM
);
554 if (regno
== PC_REGNUM
)
555 rdi_regmask
= RDIReg_PC
;
556 else if (regno
== PS_REGNUM
)
557 rdi_regmask
= RDIReg_CPSR
;
558 else if (regno
< 0 || regno
> 15)
561 supply_register (regno
, (char *) &rawreg
);
565 rdi_regmask
= 1 << regno
;
567 rslt
= angel_RDI_CPUread (255, rdi_regmask
, &rawreg
);
570 printf_filtered ("RDI_CPUread: %s\n", rdi_error_message (rslt
));
572 store_unsigned_integer (cookedreg
, 4, rawreg
);
573 supply_register (regno
, (char *) cookedreg
);
578 arm_rdi_prepare_to_store (void)
583 /* Store register REGNO, or all registers if REGNO == -1, from the contents
584 of REGISTERS. FIXME: ignores errors. */
587 arm_rdi_store_registers (int regno
)
589 int rslt
, rdi_regmask
;
591 /* These need to be able to take 'floating point register' contents */
592 unsigned long rawreg
[3], rawerreg
[3];
596 for (regno
= 0; regno
< NUM_REGS
; regno
++)
597 arm_rdi_store_registers (regno
);
601 read_register_gen (regno
, (char *) rawreg
);
602 /* RDI manipulates data in host byte order, so convert now. */
603 store_unsigned_integer (rawerreg
, 4, rawreg
[0]);
605 if (regno
== PC_REGNUM
)
606 rdi_regmask
= RDIReg_PC
;
607 else if (regno
== PS_REGNUM
)
608 rdi_regmask
= RDIReg_CPSR
;
609 else if (regno
< 0 || regno
> 15)
612 rdi_regmask
= 1 << regno
;
614 rslt
= angel_RDI_CPUwrite (255, rdi_regmask
, rawerreg
);
617 printf_filtered ("RDI_CPUwrite: %s\n", rdi_error_message (rslt
));
622 /* Read or write LEN bytes from inferior memory at MEMADDR,
623 transferring to or from debugger address MYADDR. Write to inferior
624 if SHOULD_WRITE is nonzero. Returns length of data written or
625 read; 0 for error. */
629 arm_rdi_xfer_memory (memaddr
, myaddr
, len
, should_write
, target
)
634 struct target_ops
*target
; /* ignored */
640 rslt
= angel_RDI_write (myaddr
, memaddr
, &len
);
643 printf_filtered ("RDI_write: %s\n", rdi_error_message (rslt
));
648 rslt
= angel_RDI_read (memaddr
, myaddr
, &len
);
651 printf_filtered ("RDI_read: %s\n", rdi_error_message (rslt
));
658 /* Display random info collected from the target. */
661 arm_rdi_files_info (struct target_ops
*ignore
)
663 char *file
= "nothing";
665 unsigned long arg1
, arg2
;
667 rslt
= angel_RDI_info (RDIInfo_Target
, &arg1
, &arg2
);
670 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
672 if (arg1
& (1 << 15))
673 printf_filtered ("Target supports Thumb code.\n");
674 if (arg1
& (1 << 14))
675 printf_filtered ("Target can do profiling.\n");
677 printf_filtered ("Target is real hardware.\n");
679 rslt
= angel_RDI_info (RDIInfo_Step
, &arg1
, &arg2
);
682 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
684 printf_filtered ("Target can%s single-step.\n", (arg1
& 0x4 ? "" : "not"));
686 rslt
= angel_RDI_info (RDIInfo_Icebreaker
, &arg1
, &arg2
);
689 printf_filtered ("RDI_info: %s\n", rdi_error_message (rslt
));
692 printf_filtered ("Target includes an EmbeddedICE.\n");
700 rslt
= angel_RDI_open (1, &gdb_config
, NULL
, NULL
);
703 printf_filtered ("RDI_open: %s\n", rdi_error_message (rslt
));
708 arm_rdi_mourn_inferior (void)
710 /* We remove the inserted breakpoints in case the user wants to
711 issue another target and load commands to rerun his application;
712 This is something that wouldn't work on a native target, for instance,
713 as the process goes away when the inferior exits, but it works with
714 some remote targets like this one. That is why this is done here. */
715 remove_breakpoints();
716 unpush_target (&arm_rdi_ops
);
717 generic_mourn_inferior ();
720 /* While the RDI library keeps track of its own breakpoints, we need
721 to remember "handles" so that we can delete them later. Since
722 breakpoints get used for stepping, be careful not to leak memory
726 arm_rdi_insert_breakpoint (CORE_ADDR addr
, char *contents_cache
)
730 struct local_bp_list_entry
*entry
;
731 int type
= RDIPoint_EQ
;
733 if (arm_pc_is_thumb (addr
) || arm_pc_is_thumb_dummy (addr
))
734 type
|= RDIPoint_16Bit
;
735 rslt
= angel_RDI_setbreak (addr
, type
, 0, &point
);
738 printf_filtered ("RDI_setbreak: %s\n", rdi_error_message (rslt
));
741 (struct local_bp_list_entry
*) xmalloc (sizeof (struct local_bp_list_entry
));
743 entry
->point
= point
;
744 entry
->next
= local_bp_list
;
745 local_bp_list
= entry
;
750 arm_rdi_remove_breakpoint (CORE_ADDR addr
, char *contents_cache
)
754 struct local_bp_list_entry
*entry
, *preventry
;
756 for (entry
= local_bp_list
; entry
!= NULL
; entry
= entry
->next
)
758 if (entry
->addr
== addr
)
766 rslt
= angel_RDI_clearbreak (entry
->point
);
769 printf_filtered ("RDI_clearbreak: %s\n", rdi_error_message (rslt
));
771 /* Delete the breakpoint entry locally. */
772 if (entry
== local_bp_list
)
774 local_bp_list
= entry
->next
;
778 preventry
->next
= entry
->next
;
786 rdi_error_message (int err
)
790 case RDIError_NoError
:
793 return "debuggee reset";
794 case RDIError_UndefinedInstruction
:
795 return "undefined instruction";
796 case RDIError_SoftwareInterrupt
:
797 return "SWI trapped";
798 case RDIError_PrefetchAbort
:
799 return "prefetch abort, execution ran into unmapped memory?";
800 case RDIError_DataAbort
:
801 return "data abort, no memory at specified address?";
802 case RDIError_AddressException
:
803 return "address exception, access >26bit in 26bit mode";
805 return "IRQ, interrupt trapped";
807 return "FIQ, fast interrupt trapped";
809 return "a miscellaneous type of error";
810 case RDIError_BranchThrough0
:
811 return "branch through location 0";
812 case RDIError_NotInitialised
:
813 return "internal error, RDI_open not called first";
814 case RDIError_UnableToInitialise
:
815 return "internal error, target world is broken";
816 case RDIError_WrongByteSex
:
817 return "See Operator: WrongByteSex";
818 case RDIError_UnableToTerminate
:
819 return "See Operator: Unable to Terminate";
820 case RDIError_BadInstruction
:
821 return "bad instruction, illegal to execute this instruction";
822 case RDIError_IllegalInstruction
:
823 return "illegal instruction, the effect of executing it is undefined";
824 case RDIError_BadCPUStateSetting
:
825 return "internal error, tried to set SPSR of user mode";
826 case RDIError_UnknownCoPro
:
827 return "unknown co-processor";
828 case RDIError_UnknownCoProState
:
829 return "cannot execute co-processor request";
830 case RDIError_BadCoProState
:
831 return "recognizably broken co-processor request";
832 case RDIError_BadPointType
:
833 return "internal error, bad point yype";
834 case RDIError_UnimplementedType
:
835 return "internal error, unimplemented type";
836 case RDIError_BadPointSize
:
837 return "internal error, bad point size";
838 case RDIError_UnimplementedSize
:
839 return "internal error, unimplemented size";
840 case RDIError_NoMorePoints
:
841 return "last break/watch point was used";
842 case RDIError_BreakpointReached
:
843 return "breakpoint reached";
844 case RDIError_WatchpointAccessed
:
845 return "watchpoint accessed";
846 case RDIError_NoSuchPoint
:
847 return "attempted to clear non-existent break/watch point";
848 case RDIError_ProgramFinishedInStep
:
849 return "end of the program reached while stepping";
850 case RDIError_UserInterrupt
:
851 return "you pressed Escape";
852 case RDIError_CantSetPoint
:
853 return "no more break/watch points available";
854 case RDIError_IncompatibleRDILevels
:
855 return "incompatible RDI levels";
856 case RDIError_LittleEndian
:
857 return "debuggee is little endian";
858 case RDIError_BigEndian
:
859 return "debuggee is big endian";
860 case RDIError_SoftInitialiseError
:
861 return "recoverable error in RDI initialization";
862 case RDIError_InsufficientPrivilege
:
863 return "internal error, supervisor state not accessible to monitor";
864 case RDIError_UnimplementedMessage
:
865 return "internal error, unimplemented message";
866 case RDIError_UndefinedMessage
:
867 return "internal error, undefined message";
869 return "undefined error message, should reset target";
873 /* Convert the ARM error messages to signals that GDB knows about. */
875 static enum target_signal
876 rdi_error_signal (int err
)
880 case RDIError_NoError
:
883 return TARGET_SIGNAL_TERM
; /* ??? */
884 case RDIError_UndefinedInstruction
:
885 return TARGET_SIGNAL_ILL
;
886 case RDIError_SoftwareInterrupt
:
887 case RDIError_PrefetchAbort
:
888 case RDIError_DataAbort
:
889 return TARGET_SIGNAL_TRAP
;
890 case RDIError_AddressException
:
891 return TARGET_SIGNAL_SEGV
;
894 return TARGET_SIGNAL_TRAP
;
896 return TARGET_SIGNAL_TERM
;
897 case RDIError_BranchThrough0
:
898 return TARGET_SIGNAL_TRAP
;
899 case RDIError_NotInitialised
:
900 case RDIError_UnableToInitialise
:
901 case RDIError_WrongByteSex
:
902 case RDIError_UnableToTerminate
:
903 return TARGET_SIGNAL_UNKNOWN
;
904 case RDIError_BadInstruction
:
905 case RDIError_IllegalInstruction
:
906 return TARGET_SIGNAL_ILL
;
907 case RDIError_BadCPUStateSetting
:
908 case RDIError_UnknownCoPro
:
909 case RDIError_UnknownCoProState
:
910 case RDIError_BadCoProState
:
911 case RDIError_BadPointType
:
912 case RDIError_UnimplementedType
:
913 case RDIError_BadPointSize
:
914 case RDIError_UnimplementedSize
:
915 case RDIError_NoMorePoints
:
916 return TARGET_SIGNAL_UNKNOWN
;
917 case RDIError_BreakpointReached
:
918 case RDIError_WatchpointAccessed
:
919 return TARGET_SIGNAL_TRAP
;
920 case RDIError_NoSuchPoint
:
921 case RDIError_ProgramFinishedInStep
:
922 return TARGET_SIGNAL_UNKNOWN
;
923 case RDIError_UserInterrupt
:
924 return TARGET_SIGNAL_INT
;
925 case RDIError_IncompatibleRDILevels
:
926 case RDIError_LittleEndian
:
927 case RDIError_BigEndian
:
928 case RDIError_SoftInitialiseError
:
929 case RDIError_InsufficientPrivilege
:
930 case RDIError_UnimplementedMessage
:
931 case RDIError_UndefinedMessage
:
933 return TARGET_SIGNAL_UNKNOWN
;
937 /* Define the target operations structure. */
942 arm_rdi_ops
.to_shortname
= "rdi";
943 arm_rdi_ops
.to_longname
= "ARM RDI";
944 arm_rdi_ops
.to_doc
= "Use a remote ARM-based computer; via the RDI library.\n\
945 Specify the serial device it is connected to (e.g. /dev/ttya).";
946 arm_rdi_ops
.to_open
= arm_rdi_open
;
947 arm_rdi_ops
.to_close
= arm_rdi_close
;
948 arm_rdi_ops
.to_detach
= arm_rdi_detach
;
949 arm_rdi_ops
.to_resume
= arm_rdi_resume
;
950 arm_rdi_ops
.to_wait
= arm_rdi_wait
;
951 arm_rdi_ops
.to_fetch_registers
= arm_rdi_fetch_registers
;
952 arm_rdi_ops
.to_store_registers
= arm_rdi_store_registers
;
953 arm_rdi_ops
.to_prepare_to_store
= arm_rdi_prepare_to_store
;
954 arm_rdi_ops
.to_xfer_memory
= arm_rdi_xfer_memory
;
955 arm_rdi_ops
.to_files_info
= arm_rdi_files_info
;
956 arm_rdi_ops
.to_insert_breakpoint
= arm_rdi_insert_breakpoint
;
957 arm_rdi_ops
.to_remove_breakpoint
= arm_rdi_remove_breakpoint
;
958 arm_rdi_ops
.to_kill
= arm_rdi_kill
;
959 arm_rdi_ops
.to_load
= generic_load
;
960 arm_rdi_ops
.to_create_inferior
= arm_rdi_create_inferior
;
961 arm_rdi_ops
.to_mourn_inferior
= arm_rdi_mourn_inferior
;
962 arm_rdi_ops
.to_stratum
= process_stratum
;
963 arm_rdi_ops
.to_has_all_memory
= 1;
964 arm_rdi_ops
.to_has_memory
= 1;
965 arm_rdi_ops
.to_has_stack
= 1;
966 arm_rdi_ops
.to_has_registers
= 1;
967 arm_rdi_ops
.to_has_execution
= 1;
968 arm_rdi_ops
.to_magic
= OPS_MAGIC
;
972 rdilogfile_command (char *arg
, int from_tty
)
974 if (!arg
|| strlen (arg
) == 0)
976 printf_filtered ("rdi log file is '%s'\n", log_filename
);
983 log_filename
= xstrdup (arg
);
985 Adp_SetLogfile (log_filename
);
989 rdilogenable_command (char *args
, int from_tty
)
991 if (!args
|| strlen (args
) == 0)
993 printf_filtered ("rdi log is %s\n", log_enable
? "enabled" : "disabled");
997 if (!strcasecmp (args
, "1") ||
998 !strcasecmp (args
, "y") ||
999 !strcasecmp (args
, "yes") ||
1000 !strcasecmp (args
, "on") ||
1001 !strcasecmp (args
, "t") ||
1002 !strcasecmp (args
, "true"))
1003 Adp_SetLogEnable (log_enable
= 1);
1004 else if (!strcasecmp (args
, "0") ||
1005 !strcasecmp (args
, "n") ||
1006 !strcasecmp (args
, "no") ||
1007 !strcasecmp (args
, "off") ||
1008 !strcasecmp (args
, "f") ||
1009 !strcasecmp (args
, "false"))
1010 Adp_SetLogEnable (log_enable
= 0);
1012 printf_filtered ("rdilogenable: unrecognized argument '%s'\n"
1013 " try y or n\n", args
);
1017 _initialize_remote_rdi (void)
1020 add_target (&arm_rdi_ops
);
1022 log_filename
= xstrdup ("rdi.log");
1023 Adp_SetLogfile (log_filename
);
1024 Adp_SetLogEnable (log_enable
);
1026 add_cmd ("rdilogfile", class_maintenance
,
1028 "Set filename for ADP packet log.\n\
1029 This file is used to log Angel Debugger Protocol packets.\n\
1030 With a single argument, sets the logfile name to that value.\n\
1031 Without an argument, shows the current logfile name.\n\
1032 See also: rdilogenable\n",
1035 add_cmd ("rdilogenable", class_maintenance
,
1036 rdilogenable_command
,
1037 "Set enable logging of ADP packets.\n\
1038 This will log ADP packets exchanged between gdb and the\n\
1039 rdi target device.\n\
1040 An argument of 1,t,true,y,yes will enable.\n\
1041 An argument of 0,f,false,n,no will disabled.\n\
1042 Withough an argument, it will display current state.\n",
1046 (add_set_cmd ("rdiromatzero", no_class
,
1047 var_boolean
, (char *) &rom_at_zero
,
1048 "Set target has ROM at addr 0.\n\
1049 A true value disables vector catching, false enables vector catching.\n\
1050 This is evaluated at the time the 'target rdi' command is executed\n",
1055 (add_set_cmd ("rdiheartbeat", no_class
,
1056 var_boolean
, (char *) &rdi_heartbeat
,
1057 "Set enable for ADP heartbeat packets.\n\
1058 I don't know why you would want this. If you enable them,\n\
1059 it will confuse ARM and EPI JTAG interface boxes as well\n\
1060 as the Angel Monitor.\n",
1065 /* A little dummy to make linking with the library succeed. */