source: trunk/libs/newlib/src/libgloss/debug.h @ 675

Last change on this file since 675 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 5.8 KB
RevLine 
[444]1/*
2 * Copyright (c) 1995, 1996 Cygnus Support
3 *
4 * The authors hereby grant permission to use, copy, modify, distribute,
5 * and license this software and its documentation for any purpose, provided
6 * that existing copyright notices are retained in all copies and that this
7 * notice is included verbatim in any distributions. No written agreement,
8 * license, or royalty fee is required for any of the authorized uses.
9 * Modifications to this software may be copyrighted by their authors
10 * and need not follow the licensing terms described here, provided that
11 * the new terms are clearly indicated on the first page of each file where
12 * they apply.
13 */
14
15static const char hexchars[]="0123456789abcdef";
16
17typedef void (*exception_t)(int);   /* pointer to function with int parm */
18
19/*
20 * This is the default function handler to be called with all exceptions.
21 */
22extern exception_t default_trap_hook;
23
24/* this is used to make Unix style signale nukbers to an exception */
25struct trap_info
26{
27  unsigned char tt;             /* exception number */
28  unsigned char signo;          /* corresponding signal number */
29};
30
31/*
32 * prototypes for the functions in debug.c. As these'll only be used with GCC,
33 * we don't worry about no stinkin K&R comilers.
34 */
35extern void exception_handler (int, unsigned long);
36extern unsigned char *mem2hex(unsigned char *, unsigned char *, int, int);
37extern unsigned char *hex2mem(unsigned char *, unsigned char *, int, int);
38extern void getpacket(unsigned char *);
39extern void putpacket(unsigned char *);
40extern char *make_return_packet(int);
41extern void set_debug_traps();
42extern int computeSignal(int);
43extern char digit2hex(int);
44extern int hex2digit(int);
45extern void debuglogs(int level, char *msg);
46extern int hex2int();
47extern char *int2hex(int);
48extern void gdb_event_loop(int, unsigned long *);
49
50extern char *gdb_read_registers();              /* g - read registers */
51extern char *gdb_write_registers(char *);       /* G - write registers */
52extern char *gdb_read_memory(long, int);        /* m - read memory */
53extern char *gdb_write_memory(long, int, char *);/* M write memory */
54extern char *gdb_continue(int, long );          /* c - continue */
55extern char *gdb_step(int, long);               /* s - step instruction(s) */
56extern char *gdb_kill();                        /* k - kill program */
57extern char *gdb_last_signal();                 /* ? - last signal */
58extern char *gdb_baudrate(int);                 /* b - change baud rate */
59extern char *gdb_dump_state();                  /* T - dump state */
60extern char *gdb_set_thread(int, int);          /* H - set thread */
61extern char *gdb_detach();                      /* D - detach */
62extern char *gdb_read_reg(int);                 /* p - read one register */
63extern char *gdb_write_reg(int, long);          /* P - write one register */
64extern char *gdb_exited();                      /* W - process exited */
65extern char *gdb_terminated();                  /* X - process terminated */
66extern char *gdb_hex();                         /* O - hex encoding */
67extern char *gdb_thread_alive(int);             /* A - tread alive request */
68extern char *gdb_extended();                    /* ! - extended protocol */
69extern char *gdb_debug();                       /* d - toggle stub diagnostics */
70extern char *gdb_toggle();                      /* unsupported, toggle stub on/off */
71extern char *gdb_reset();                       /* r - reset target */
72extern char *gdb_search(long, long, long);      /* t - search backwards */
73extern char *gdb_query(char *);                 /* q - general query */
74extern char *gdb_set(char *);                   /* Q - set value */
75
76/*
77 * indicate to caller of mem2hex or hex2mem that there has been an error.
78 * 0 means ok, 1 means error
79 */
80extern volatile int mem_err;
81
82/*
83 * indicate whether the debug vectors have been initialized
84 * 0 means not yet, 1 means yep, it's ready.
85 */
86extern int initialized;
87
88/*
89 * 1 means print debugging messages from the target, 0 means be quiet.
90 */
91extern int remote_debug;
92
93/*
94 * Set up the command processing required for GDB
95 */
96
97struct gdb_ops {
98  /*
99   * these functions are the most minimal working subset top get full
100   * functionality for remote debugging
101   */
102  char  *(*gdb_read_registers);                 /* g - read registers */
103  char  *(*gdb_write_registers)(char *);        /* G - write registers */
104  char  *(*gdb_read_memory)(long, int);         /* m - read memory */
105  char  *(*gdb_write_memory)(long, int, char *);/* M write memory */
106  char  *(*gdb_continue)(int, long );           /* c - continue */
107  char  *(*gdb_step)(int, long);                /* s - step instruction(s) */
108  char  *(*gdb_kill);                           /* k - kill program */
109  char  *(*gdb_last_signal);                    /* ? - last signal */
110  char  *(*gdb_baudrate)(int);                  /* b - change baud rate */
111  char  *(*gdb_dump_state);                     /* T - dump state */
112  /*
113   * these functions are for a more sophisticated target, typically
114   * running a simple RTOS.
115   */
116  char  *(*gdb_set_thread)(int, int);           /* H - set thread */
117  char  *(*gdb_detach);                         /* D - detach */
118  char  *(*gdb_read_reg)(int);                  /* p - read one register */
119  char  *(*gdb_write_reg)(int, long);           /* P - write one register */
120  char  *(*gdb_exited);                         /* W - process exited */
121  char  *(*gdb_terminated);                     /* X - process terminated */
122  char  *(*gdb_hex);                            /* O - hex encoding */
123  char  *(*gdb_thread_alive)(int);              /* A - tread alive request */
124                                                /* FIXME: not standard yet */
125  char  *(*gdb_extended);                       /* ! - extended protocol */
126  char  *(*gdb_debug);                          /* d - toggle stub diagnostics */
127  char  *(*gdb_toggle);                         /* unsupported, toggle stub on/off */
128  char  *(*gdb_reset);                          /* r - reset target */
129  char  *(*gdb_search)(long, long, long);       /* t - search backwards */
130  char  *(*gdb_query)(char *);                  /* q - general query */
131  char  *(*gdb_set)(long);                      /* Q - set value */
132};
133
134/*
135 * BUFMAX defines the maximum number of characters in inbound/outbound buffers
136 * at least NUMREGBYTES*2 are needed for register packets
137 */
138#define BUFMAX 2048
139extern char packet_in_buf[BUFMAX];
140extern char packet_out_buf[BUFMAX];
141extern int  packet_index;
142
143#define DEBUG(x, y)             debuglog(x, y);
144#define set_debug_level(x)      remote_debug = x;
145#define OK 0
146#define ERROR -1
147#define ENN(x) "x"
148
149#define MAY_FAULT 1
150#define NO_FAULT 0
Note: See TracBrowser for help on using the repository browser.