1 |
578 |
markom |
/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
|
2 |
|
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
|
3 |
|
|
2001 Free Software Foundation, Inc.
|
4 |
|
|
Originally written by Daniel Mann at AMD.
|
5 |
|
|
|
6 |
|
|
This file is part of GDB.
|
7 |
|
|
|
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.
|
12 |
|
|
|
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.
|
17 |
|
|
|
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. */
|
22 |
|
|
|
23 |
|
|
/* This is like remote.c but ecpects MiniMON to be running on the Am29000
|
24 |
|
|
target hardware.
|
25 |
|
|
- David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this
|
26 |
|
|
file to gdb 3.95. I was unable to get this working on sun3os4
|
27 |
|
|
with termio, only with sgtty. Because we are only attempting to
|
28 |
|
|
use this module to debug our kernel, which is already loaded when
|
29 |
|
|
gdb is started up, I did not code up the file downloading facilities.
|
30 |
|
|
As a result this module has only the stubs to download files.
|
31 |
|
|
You should get tagged at compile time if you need to make any
|
32 |
|
|
changes/additions. */
|
33 |
|
|
|
34 |
|
|
#include "defs.h"
|
35 |
|
|
#include "inferior.h"
|
36 |
|
|
#include "value.h"
|
37 |
|
|
#include <ctype.h>
|
38 |
|
|
#include <fcntl.h>
|
39 |
|
|
#include <signal.h>
|
40 |
|
|
#include <errno.h>
|
41 |
|
|
#include "gdb_string.h"
|
42 |
|
|
#include "terminal.h"
|
43 |
|
|
#include "minimon.h"
|
44 |
|
|
#include "target.h"
|
45 |
|
|
#include "regcache.h"
|
46 |
|
|
|
47 |
|
|
/* Offset of member MEMBER in a struct of type TYPE. */
|
48 |
|
|
#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
|
49 |
|
|
|
50 |
|
|
#define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0))
|
51 |
|
|
|
52 |
|
|
extern int stop_soon_quietly; /* for wait_for_inferior */
|
53 |
|
|
|
54 |
|
|
static void mm_resume (ptid_t ptid, int step, enum target_signal sig)
|
55 |
|
|
static void mm_fetch_registers ();
|
56 |
|
|
static int fetch_register ();
|
57 |
|
|
static void mm_store_registers ();
|
58 |
|
|
static int store_register ();
|
59 |
|
|
static int regnum_to_srnum ();
|
60 |
|
|
static void mm_close ();
|
61 |
|
|
static char *msg_str ();
|
62 |
|
|
static char *error_msg_str ();
|
63 |
|
|
static int expect_msg ();
|
64 |
|
|
static void init_target_mm ();
|
65 |
|
|
static int mm_memory_space ();
|
66 |
|
|
|
67 |
|
|
#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
|
68 |
|
|
#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
|
69 |
|
|
|
70 |
|
|
/* FIXME: Replace with `set remotedebug'. */
|
71 |
|
|
#define LLOG_FILE "minimon.log"
|
72 |
|
|
#if defined (LOG_FILE)
|
73 |
|
|
FILE *log_file;
|
74 |
|
|
#endif
|
75 |
|
|
|
76 |
|
|
/*
|
77 |
|
|
* Size of message buffers. I couldn't get memory reads to work when
|
78 |
|
|
* the byte_count was larger than 512 (it may be a baud rate problem).
|
79 |
|
|
*/
|
80 |
|
|
#define BUFER_SIZE 512
|
81 |
|
|
/*
|
82 |
|
|
* Size of data area in message buffer on the TARGET (remote system).
|
83 |
|
|
*/
|
84 |
|
|
#define MAXDATA_T (target_config.max_msg_size - \
|
85 |
|
|
offsetof(struct write_r_msg_t,data[0]))
|
86 |
|
|
/*
|
87 |
|
|
* Size of data area in message buffer on the HOST (gdb).
|
88 |
|
|
*/
|
89 |
|
|
#define MAXDATA_H (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0]))
|
90 |
|
|
/*
|
91 |
|
|
* Defined as the minimum size of data areas of the two message buffers
|
92 |
|
|
*/
|
93 |
|
|
#define MAXDATA (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T)
|
94 |
|
|
|
95 |
|
|
static char out_buf[BUFER_SIZE];
|
96 |
|
|
static char in_buf[BUFER_SIZE];
|
97 |
|
|
|
98 |
|
|
int msg_recv_serial ();
|
99 |
|
|
int msg_send_serial ();
|
100 |
|
|
|
101 |
|
|
#define MAX_RETRIES 5000
|
102 |
|
|
extern struct target_ops mm_ops; /* Forward declaration */
|
103 |
|
|
struct config_msg_t target_config; /* HIF needs this */
|
104 |
|
|
union msg_t *out_msg_buf = (union msg_t *) out_buf;
|
105 |
|
|
union msg_t *in_msg_buf = (union msg_t *) in_buf;
|
106 |
|
|
|
107 |
|
|
static int timeout = 5;
|
108 |
|
|
|
109 |
|
|
/* Descriptor for I/O to remote machine. Initialize it to -1 so that
|
110 |
|
|
mm_open knows that we don't have a file open when the program
|
111 |
|
|
starts. */
|
112 |
|
|
int mm_desc = -1;
|
113 |
|
|
|
114 |
|
|
/* stream which is fdopen'd from mm_desc. Only valid when
|
115 |
|
|
mm_desc != -1. */
|
116 |
|
|
FILE *mm_stream;
|
117 |
|
|
|
118 |
|
|
/* Called when SIGALRM signal sent due to alarm() timeout. */
|
119 |
|
|
#ifndef HAVE_TERMIO
|
120 |
|
|
|
121 |
|
|
volatile int n_alarms;
|
122 |
|
|
|
123 |
|
|
static void
|
124 |
|
|
mm_timer (void)
|
125 |
|
|
{
|
126 |
|
|
#if 0
|
127 |
|
|
if (kiodebug)
|
128 |
|
|
printf ("mm_timer called\n");
|
129 |
|
|
#endif
|
130 |
|
|
n_alarms++;
|
131 |
|
|
}
|
132 |
|
|
#endif /* HAVE_TERMIO */
|
133 |
|
|
|
134 |
|
|
/* malloc'd name of the program on the remote system. */
|
135 |
|
|
static char *prog_name = NULL;
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
/* Number of SIGTRAPs we need to simulate. That is, the next
|
139 |
|
|
NEED_ARTIFICIAL_TRAP calls to mm_wait should just return
|
140 |
|
|
SIGTRAP without actually waiting for anything. */
|
141 |
|
|
|
142 |
|
|
/**************************************************** REMOTE_CREATE_INFERIOR */
|
143 |
|
|
/* This is called not only when we first attach, but also when the
|
144 |
|
|
user types "run" after having attached. */
|
145 |
|
|
static void
|
146 |
|
|
mm_create_inferior (char *execfile, char *args, char **env)
|
147 |
|
|
{
|
148 |
|
|
#define MAX_TOKENS 25
|
149 |
|
|
#define BUFFER_SIZE 256
|
150 |
|
|
int token_count;
|
151 |
|
|
int result;
|
152 |
|
|
char *token[MAX_TOKENS];
|
153 |
|
|
char cmd_line[BUFFER_SIZE];
|
154 |
|
|
|
155 |
|
|
if (args && *args)
|
156 |
|
|
error ("Can't pass arguments to remote mm process (yet).");
|
157 |
|
|
|
158 |
|
|
if (execfile == 0 /* || exec_bfd == 0 */ )
|
159 |
|
|
error ("No executable file specified");
|
160 |
|
|
|
161 |
|
|
if (!mm_stream)
|
162 |
|
|
{
|
163 |
|
|
printf ("Minimon not open yet.\n");
|
164 |
|
|
return;
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
/* On ultra3 (NYU) we assume the kernel is already running so there is
|
168 |
|
|
no file to download.
|
169 |
|
|
FIXME: Fixed required here -> load your program, possibly with mm_load().
|
170 |
|
|
*/
|
171 |
|
|
printf_filtered ("\n\
|
172 |
|
|
Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n");
|
173 |
|
|
|
174 |
|
|
/* We will get a task spawn event immediately. */
|
175 |
|
|
init_wait_for_inferior ();
|
176 |
|
|
clear_proceed_status ();
|
177 |
|
|
stop_soon_quietly = 1;
|
178 |
|
|
proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
|
179 |
|
|
normal_stop ();
|
180 |
|
|
}
|
181 |
|
|
/**************************************************** REMOTE_MOURN_INFERIOR */
|
182 |
|
|
static void
|
183 |
|
|
mm_mourn (void)
|
184 |
|
|
{
|
185 |
|
|
pop_target (); /* Pop back to no-child state */
|
186 |
|
|
generic_mourn_inferior ();
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
/********************************************************************** damn_b
|
190 |
|
|
*/
|
191 |
|
|
/* Translate baud rates from integers to damn B_codes. Unix should
|
192 |
|
|
have outgrown this crap years ago, but even POSIX wouldn't buck it. */
|
193 |
|
|
|
194 |
|
|
#ifndef B19200
|
195 |
|
|
#define B19200 EXTA
|
196 |
|
|
#endif
|
197 |
|
|
#ifndef B38400
|
198 |
|
|
#define B38400 EXTB
|
199 |
|
|
#endif
|
200 |
|
|
|
201 |
|
|
static struct
|
202 |
|
|
{
|
203 |
|
|
int rate, damn_b;
|
204 |
|
|
}
|
205 |
|
|
baudtab[] =
|
206 |
|
|
{
|
207 |
|
|
{
|
208 |
|
|
0, B0
|
209 |
|
|
}
|
210 |
|
|
,
|
211 |
|
|
{
|
212 |
|
|
50, B50
|
213 |
|
|
}
|
214 |
|
|
,
|
215 |
|
|
{
|
216 |
|
|
75, B75
|
217 |
|
|
}
|
218 |
|
|
,
|
219 |
|
|
{
|
220 |
|
|
110, B110
|
221 |
|
|
}
|
222 |
|
|
,
|
223 |
|
|
{
|
224 |
|
|
134, B134
|
225 |
|
|
}
|
226 |
|
|
,
|
227 |
|
|
{
|
228 |
|
|
150, B150
|
229 |
|
|
}
|
230 |
|
|
,
|
231 |
|
|
{
|
232 |
|
|
200, B200
|
233 |
|
|
}
|
234 |
|
|
,
|
235 |
|
|
{
|
236 |
|
|
300, B300
|
237 |
|
|
}
|
238 |
|
|
,
|
239 |
|
|
{
|
240 |
|
|
600, B600
|
241 |
|
|
}
|
242 |
|
|
,
|
243 |
|
|
{
|
244 |
|
|
1200, B1200
|
245 |
|
|
}
|
246 |
|
|
,
|
247 |
|
|
{
|
248 |
|
|
1800, B1800
|
249 |
|
|
}
|
250 |
|
|
,
|
251 |
|
|
{
|
252 |
|
|
2400, B2400
|
253 |
|
|
}
|
254 |
|
|
,
|
255 |
|
|
{
|
256 |
|
|
4800, B4800
|
257 |
|
|
}
|
258 |
|
|
,
|
259 |
|
|
{
|
260 |
|
|
9600, B9600
|
261 |
|
|
}
|
262 |
|
|
,
|
263 |
|
|
{
|
264 |
|
|
19200, B19200
|
265 |
|
|
}
|
266 |
|
|
,
|
267 |
|
|
{
|
268 |
|
|
38400, B38400
|
269 |
|
|
}
|
270 |
|
|
,
|
271 |
|
|
{
|
272 |
|
|
-1, -1
|
273 |
|
|
}
|
274 |
|
|
,
|
275 |
|
|
};
|
276 |
|
|
|
277 |
|
|
static int
|
278 |
|
|
damn_b (int rate)
|
279 |
|
|
{
|
280 |
|
|
int i;
|
281 |
|
|
|
282 |
|
|
for (i = 0; baudtab[i].rate != -1; i++)
|
283 |
|
|
if (rate == baudtab[i].rate)
|
284 |
|
|
return baudtab[i].damn_b;
|
285 |
|
|
return B38400; /* Random */
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
/***************************************************************** REMOTE_OPEN
|
290 |
|
|
** Open a connection to remote minimon.
|
291 |
|
|
NAME is the filename used for communication, then a space,
|
292 |
|
|
then the baud rate.
|
293 |
|
|
'target adapt /dev/ttya 9600 [prognam]' for example.
|
294 |
|
|
*/
|
295 |
|
|
|
296 |
|
|
static char *dev_name;
|
297 |
|
|
int baudrate = 9600;
|
298 |
|
|
static void
|
299 |
|
|
mm_open (char *name, int from_tty)
|
300 |
|
|
{
|
301 |
|
|
TERMINAL sg;
|
302 |
|
|
unsigned int prl;
|
303 |
|
|
char *p;
|
304 |
|
|
|
305 |
|
|
/* Find the first whitespace character, it separates dev_name from
|
306 |
|
|
prog_name. */
|
307 |
|
|
for (p = name;
|
308 |
|
|
p && *p && !isspace (*p); p++)
|
309 |
|
|
;
|
310 |
|
|
if (p == 0 || *p == '\0')
|
311 |
|
|
erroid:
|
312 |
|
|
error ("Usage : <command> <serial-device> <baud-rate> [progname]");
|
313 |
|
|
dev_name = (char *) xmalloc (p - name + 1);
|
314 |
|
|
strncpy (dev_name, name, p - name);
|
315 |
|
|
dev_name[p - name] = '\0';
|
316 |
|
|
|
317 |
|
|
/* Skip over the whitespace after dev_name */
|
318 |
|
|
for (; isspace (*p); p++)
|
319 |
|
|
/*EMPTY */ ;
|
320 |
|
|
|
321 |
|
|
if (1 != sscanf (p, "%d ", &baudrate))
|
322 |
|
|
goto erroid;
|
323 |
|
|
|
324 |
|
|
/* Skip the number and then the spaces */
|
325 |
|
|
for (; isdigit (*p); p++)
|
326 |
|
|
/*EMPTY */ ;
|
327 |
|
|
for (; isspace (*p); p++)
|
328 |
|
|
/*EMPTY */ ;
|
329 |
|
|
|
330 |
|
|
if (prog_name != NULL)
|
331 |
|
|
xfree (prog_name);
|
332 |
|
|
prog_name = savestring (p, strlen (p));
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
if (mm_desc >= 0)
|
336 |
|
|
close (mm_desc);
|
337 |
|
|
|
338 |
|
|
mm_desc = open (dev_name, O_RDWR);
|
339 |
|
|
if (mm_desc < 0)
|
340 |
|
|
perror_with_name (dev_name);
|
341 |
|
|
ioctl (mm_desc, TIOCGETP, &sg);
|
342 |
|
|
#ifdef HAVE_TERMIO
|
343 |
|
|
sg.c_cc[VMIN] = 0; /* read with timeout. */
|
344 |
|
|
sg.c_cc[VTIME] = timeout * 10;
|
345 |
|
|
sg.c_lflag &= ~(ICANON | ECHO);
|
346 |
|
|
sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
|
347 |
|
|
#else
|
348 |
|
|
sg.sg_ispeed = damn_b (baudrate);
|
349 |
|
|
sg.sg_ospeed = damn_b (baudrate);
|
350 |
|
|
sg.sg_flags |= RAW;
|
351 |
|
|
sg.sg_flags |= ANYP;
|
352 |
|
|
sg.sg_flags &= ~ECHO;
|
353 |
|
|
#endif
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
ioctl (mm_desc, TIOCSETP, &sg);
|
357 |
|
|
mm_stream = fdopen (mm_desc, "r+");
|
358 |
|
|
|
359 |
|
|
push_target (&mm_ops);
|
360 |
|
|
|
361 |
|
|
#ifndef HAVE_TERMIO
|
362 |
|
|
#ifndef NO_SIGINTERRUPT
|
363 |
|
|
/* Cause SIGALRM's to make reads fail with EINTR instead of resuming
|
364 |
|
|
the read. */
|
365 |
|
|
if (siginterrupt (SIGALRM, 1) != 0)
|
366 |
|
|
perror ("mm_open: error in siginterrupt");
|
367 |
|
|
#endif
|
368 |
|
|
|
369 |
|
|
/* Set up read timeout timer. */
|
370 |
|
|
if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1)
|
371 |
|
|
perror ("mm_open: error in signal");
|
372 |
|
|
#endif
|
373 |
|
|
|
374 |
|
|
#if defined (LOG_FILE)
|
375 |
|
|
log_file = fopen (LOG_FILE, "w");
|
376 |
|
|
if (log_file == NULL)
|
377 |
|
|
perror_with_name (LOG_FILE);
|
378 |
|
|
#endif
|
379 |
|
|
/*
|
380 |
|
|
** Initialize target configuration structure (global)
|
381 |
|
|
*/
|
382 |
|
|
DRAIN_INPUT ();
|
383 |
|
|
out_msg_buf->config_req_msg.code = CONFIG_REQ;
|
384 |
|
|
out_msg_buf->config_req_msg.length = 4 * 0;
|
385 |
|
|
msg_send_serial (out_msg_buf); /* send config request message */
|
386 |
|
|
|
387 |
|
|
expect_msg (CONFIG, in_msg_buf, 1);
|
388 |
|
|
|
389 |
|
|
a29k_get_processor_type ();
|
390 |
|
|
|
391 |
|
|
/* Print out some stuff, letting the user now what's going on */
|
392 |
|
|
printf_filtered ("Connected to MiniMon via %s.\n", dev_name);
|
393 |
|
|
/* FIXME: can this restriction be removed? */
|
394 |
|
|
printf_filtered ("Remote debugging using virtual addresses works only\n");
|
395 |
|
|
printf_filtered ("\twhen virtual addresses map 1:1 to physical addresses.\n")
|
396 |
|
|
;
|
397 |
|
|
if (processor_type != a29k_freeze_mode)
|
398 |
|
|
{
|
399 |
|
|
fprintf_filtered (gdb_stderr,
|
400 |
|
|
"Freeze-mode debugging not available, and can only be done on an A29050.\n");
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
target_config.code = CONFIG;
|
404 |
|
|
target_config.length = 0;
|
405 |
|
|
target_config.processor_id = in_msg_buf->config_msg.processor_id;
|
406 |
|
|
target_config.version = in_msg_buf->config_msg.version;
|
407 |
|
|
target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start;
|
408 |
|
|
target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size;
|
409 |
|
|
target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start;
|
410 |
|
|
target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size;
|
411 |
|
|
target_config.ROM_start = in_msg_buf->config_msg.ROM_start;
|
412 |
|
|
target_config.ROM_size = in_msg_buf->config_msg.ROM_size;
|
413 |
|
|
target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size;
|
414 |
|
|
target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts;
|
415 |
|
|
target_config.coprocessor = in_msg_buf->config_msg.coprocessor;
|
416 |
|
|
target_config.reserved = in_msg_buf->config_msg.reserved;
|
417 |
|
|
if (from_tty)
|
418 |
|
|
{
|
419 |
|
|
printf ("Connected to MiniMON :\n");
|
420 |
|
|
printf (" Debugcore version %d.%d\n",
|
421 |
|
|
0x0f & (target_config.version >> 4),
|
422 |
|
|
0x0f & (target_config.version));
|
423 |
|
|
printf (" Configuration version %d.%d\n",
|
424 |
|
|
0x0f & (target_config.version >> 12),
|
425 |
|
|
0x0f & (target_config.version >> 8));
|
426 |
|
|
printf (" Message system version %d.%d\n",
|
427 |
|
|
0x0f & (target_config.version >> 20),
|
428 |
|
|
0x0f & (target_config.version >> 16));
|
429 |
|
|
printf (" Communication driver version %d.%d\n",
|
430 |
|
|
0x0f & (target_config.version >> 28),
|
431 |
|
|
0x0f & (target_config.version >> 24));
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
/* Leave the target running...
|
435 |
|
|
* The above message stopped the target in the dbg core (MiniMon),
|
436 |
|
|
* so restart the target out of MiniMon,
|
437 |
|
|
*/
|
438 |
|
|
out_msg_buf->go_msg.code = GO;
|
439 |
|
|
out_msg_buf->go_msg.length = 0;
|
440 |
|
|
msg_send_serial (out_msg_buf);
|
441 |
|
|
/* No message to expect after a GO */
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
/**************************************************************** REMOTE_CLOSE
|
445 |
|
|
** Close the open connection to the minimon debugger.
|
446 |
|
|
Use this when you want to detach and do something else
|
447 |
|
|
with your gdb. */
|
448 |
|
|
static void
|
449 |
|
|
mm_close ( /*FIXME: how is quitting used */
|
450 |
|
|
int quitting)
|
451 |
|
|
{
|
452 |
|
|
if (mm_desc < 0)
|
453 |
|
|
error ("Can't close remote connection: not debugging remotely.");
|
454 |
|
|
|
455 |
|
|
/* We should never get here if there isn't something valid in
|
456 |
|
|
mm_desc and mm_stream.
|
457 |
|
|
|
458 |
|
|
Due to a bug in Unix, fclose closes not only the stdio stream,
|
459 |
|
|
but also the file descriptor. So we don't actually close
|
460 |
|
|
mm_desc. */
|
461 |
|
|
DRAIN_INPUT ();
|
462 |
|
|
fclose (mm_stream);
|
463 |
|
|
/* close (mm_desc); */
|
464 |
|
|
|
465 |
|
|
/* Do not try to close mm_desc again, later in the program. */
|
466 |
|
|
mm_stream = NULL;
|
467 |
|
|
mm_desc = -1;
|
468 |
|
|
|
469 |
|
|
#if defined (LOG_FILE)
|
470 |
|
|
if (ferror (log_file))
|
471 |
|
|
printf ("Error writing log file.\n");
|
472 |
|
|
if (fclose (log_file) != 0)
|
473 |
|
|
printf ("Error closing log file.\n");
|
474 |
|
|
#endif
|
475 |
|
|
|
476 |
|
|
printf ("Ending remote debugging\n");
|
477 |
|
|
}
|
478 |
|
|
|
479 |
|
|
/************************************************************* REMOTE_ATACH */
|
480 |
|
|
/* Attach to a program that is already loaded and running
|
481 |
|
|
* Upon exiting the process's execution is stopped.
|
482 |
|
|
*/
|
483 |
|
|
static void
|
484 |
|
|
mm_attach (char *args, int from_tty)
|
485 |
|
|
{
|
486 |
|
|
|
487 |
|
|
if (!mm_stream)
|
488 |
|
|
error ("MiniMon not opened yet, use the 'target minimon' command.\n");
|
489 |
|
|
|
490 |
|
|
if (from_tty)
|
491 |
|
|
printf ("Attaching to remote program %s...\n", prog_name);
|
492 |
|
|
|
493 |
|
|
/* Make sure the target is currently running, it is supposed to be. */
|
494 |
|
|
/* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in
|
495 |
|
|
* the dbg core. If so, we don't need to send this GO.
|
496 |
|
|
*/
|
497 |
|
|
out_msg_buf->go_msg.code = GO;
|
498 |
|
|
out_msg_buf->go_msg.length = 0;
|
499 |
|
|
msg_send_serial (out_msg_buf);
|
500 |
|
|
sleep (2); /* At the worst it will stop, receive a message, continue */
|
501 |
|
|
|
502 |
|
|
/* Send the mm a break. */
|
503 |
|
|
out_msg_buf->break_msg.code = BREAK;
|
504 |
|
|
out_msg_buf->break_msg.length = 0;
|
505 |
|
|
msg_send_serial (out_msg_buf);
|
506 |
|
|
}
|
507 |
|
|
/********************************************************** REMOTE_DETACH */
|
508 |
|
|
/* Terminate the open connection to the remote debugger.
|
509 |
|
|
Use this when you want to detach and do something else
|
510 |
|
|
with your gdb. Leave remote process running (with no breakpoints set). */
|
511 |
|
|
static void
|
512 |
|
|
mm_detach (char *args, int from_tty)
|
513 |
|
|
{
|
514 |
|
|
remove_breakpoints (); /* Just in case there were any left in */
|
515 |
|
|
out_msg_buf->go_msg.code = GO;
|
516 |
|
|
out_msg_buf->go_msg.length = 0;
|
517 |
|
|
msg_send_serial (out_msg_buf);
|
518 |
|
|
pop_target (); /* calls mm_close to do the real work */
|
519 |
|
|
}
|
520 |
|
|
|
521 |
|
|
|
522 |
|
|
/*************************************************************** REMOTE_RESUME
|
523 |
|
|
** Tell the remote machine to resume. */
|
524 |
|
|
|
525 |
|
|
static void
|
526 |
|
|
mm_resume (ptid_t ptid, int step, enum target_signal sig)
|
527 |
|
|
{
|
528 |
|
|
if (sig != TARGET_SIGNAL_0)
|
529 |
|
|
warning ("Can't send signals to a remote MiniMon system.");
|
530 |
|
|
|
531 |
|
|
if (step)
|
532 |
|
|
{
|
533 |
|
|
out_msg_buf->step_msg.code = STEP;
|
534 |
|
|
out_msg_buf->step_msg.length = 1 * 4;
|
535 |
|
|
out_msg_buf->step_msg.count = 1; /* step 1 instruction */
|
536 |
|
|
msg_send_serial (out_msg_buf);
|
537 |
|
|
}
|
538 |
|
|
else
|
539 |
|
|
{
|
540 |
|
|
out_msg_buf->go_msg.code = GO;
|
541 |
|
|
out_msg_buf->go_msg.length = 0;
|
542 |
|
|
msg_send_serial (out_msg_buf);
|
543 |
|
|
}
|
544 |
|
|
}
|
545 |
|
|
|
546 |
|
|
/***************************************************************** REMOTE_WAIT
|
547 |
|
|
** Wait until the remote machine stops, then return,
|
548 |
|
|
storing status in STATUS just as `wait' would. */
|
549 |
|
|
|
550 |
|
|
static ptid_t
|
551 |
|
|
mm_wait (ptid_t ptid, struct target_waitstatus *status)
|
552 |
|
|
{
|
553 |
|
|
int i, result;
|
554 |
|
|
int old_timeout = timeout;
|
555 |
|
|
int old_immediate_quit = immediate_quit;
|
556 |
|
|
|
557 |
|
|
status->kind = TARGET_WAITKIND_EXITED;
|
558 |
|
|
status->value.integer = 0;
|
559 |
|
|
|
560 |
|
|
/* wait for message to arrive. It should be:
|
561 |
|
|
- A HIF service request.
|
562 |
|
|
- A HIF exit service request.
|
563 |
|
|
- A CHANNEL0_ACK.
|
564 |
|
|
- A CHANNEL1 request.
|
565 |
|
|
- a debugcore HALT message.
|
566 |
|
|
HIF services must be responded too, and while-looping continued.
|
567 |
|
|
If the target stops executing, mm_wait() should return.
|
568 |
|
|
*/
|
569 |
|
|
timeout = 0; /* Wait indefinetly for a message */
|
570 |
|
|
immediate_quit = 1; /* Helps ability to QUIT */
|
571 |
|
|
while (1)
|
572 |
|
|
{
|
573 |
|
|
while (msg_recv_serial (in_msg_buf))
|
574 |
|
|
{
|
575 |
|
|
QUIT; /* Let user quit if they want */
|
576 |
|
|
}
|
577 |
|
|
switch (in_msg_buf->halt_msg.code)
|
578 |
|
|
{
|
579 |
|
|
case HIF_CALL:
|
580 |
|
|
i = in_msg_buf->hif_call_rtn_msg.service_number;
|
581 |
|
|
result = service_HIF (in_msg_buf);
|
582 |
|
|
if (i == 1) /* EXIT */
|
583 |
|
|
goto exit;
|
584 |
|
|
if (result)
|
585 |
|
|
printf ("Warning: failure during HIF service %d\n", i);
|
586 |
|
|
break;
|
587 |
|
|
case CHANNEL0_ACK:
|
588 |
|
|
service_HIF (in_msg_buf);
|
589 |
|
|
break;
|
590 |
|
|
case CHANNEL1:
|
591 |
|
|
i = in_msg_buf->channel1_msg.length;
|
592 |
|
|
in_msg_buf->channel1_msg.data[i] = '\0';
|
593 |
|
|
printf ("%s", in_msg_buf->channel1_msg.data);
|
594 |
|
|
gdb_flush (gdb_stdout);
|
595 |
|
|
/* Send CHANNEL1_ACK message */
|
596 |
|
|
out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK;
|
597 |
|
|
out_msg_buf->channel1_ack_msg.length = 0;
|
598 |
|
|
result = msg_send_serial (out_msg_buf);
|
599 |
|
|
break;
|
600 |
|
|
case HALT:
|
601 |
|
|
goto halted;
|
602 |
|
|
default:
|
603 |
|
|
goto halted;
|
604 |
|
|
}
|
605 |
|
|
}
|
606 |
|
|
halted:
|
607 |
|
|
/* FIXME, these printfs should not be here. This is a source level
|
608 |
|
|
debugger, guys! */
|
609 |
|
|
if (in_msg_buf->halt_msg.trap_number == 0)
|
610 |
|
|
{
|
611 |
|
|
printf ("Am290*0 received vector number %d (break point)\n",
|
612 |
|
|
in_msg_buf->halt_msg.trap_number);
|
613 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
614 |
|
|
status->value.sig = TARGET_SIGNAL_TRAP;
|
615 |
|
|
}
|
616 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 1)
|
617 |
|
|
{
|
618 |
|
|
printf ("Am290*0 received vector number %d\n",
|
619 |
|
|
in_msg_buf->halt_msg.trap_number);
|
620 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
621 |
|
|
status->value.sig = TARGET_SIGNAL_BUS;
|
622 |
|
|
}
|
623 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 3
|
624 |
|
|
|| in_msg_buf->halt_msg.trap_number == 4)
|
625 |
|
|
{
|
626 |
|
|
printf ("Am290*0 received vector number %d\n",
|
627 |
|
|
in_msg_buf->halt_msg.trap_number);
|
628 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
629 |
|
|
status->value.sig = TARGET_SIGNAL_FPE;
|
630 |
|
|
}
|
631 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 5)
|
632 |
|
|
{
|
633 |
|
|
printf ("Am290*0 received vector number %d\n",
|
634 |
|
|
in_msg_buf->halt_msg.trap_number);
|
635 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
636 |
|
|
status->value.sig = TARGET_SIGNAL_ILL;
|
637 |
|
|
}
|
638 |
|
|
else if (in_msg_buf->halt_msg.trap_number >= 6
|
639 |
|
|
&& in_msg_buf->halt_msg.trap_number <= 11)
|
640 |
|
|
{
|
641 |
|
|
printf ("Am290*0 received vector number %d\n",
|
642 |
|
|
in_msg_buf->halt_msg.trap_number);
|
643 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
644 |
|
|
status->value.sig = TARGET_SIGNAL_SEGV;
|
645 |
|
|
}
|
646 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 12
|
647 |
|
|
|| in_msg_buf->halt_msg.trap_number == 13)
|
648 |
|
|
{
|
649 |
|
|
printf ("Am290*0 received vector number %d\n",
|
650 |
|
|
in_msg_buf->halt_msg.trap_number);
|
651 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
652 |
|
|
status->value.sig = TARGET_SIGNAL_ILL;
|
653 |
|
|
}
|
654 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 14)
|
655 |
|
|
{
|
656 |
|
|
printf ("Am290*0 received vector number %d\n",
|
657 |
|
|
in_msg_buf->halt_msg.trap_number);
|
658 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
659 |
|
|
status->value.sig = TARGET_SIGNAL_ALRM;
|
660 |
|
|
}
|
661 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 15)
|
662 |
|
|
{
|
663 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
664 |
|
|
status->value.sig = TARGET_SIGNAL_TRAP;
|
665 |
|
|
}
|
666 |
|
|
else if (in_msg_buf->halt_msg.trap_number >= 16
|
667 |
|
|
&& in_msg_buf->halt_msg.trap_number <= 21)
|
668 |
|
|
{
|
669 |
|
|
printf ("Am290*0 received vector number %d\n",
|
670 |
|
|
in_msg_buf->halt_msg.trap_number);
|
671 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
672 |
|
|
status->value.sig = TARGET_SIGNAL_INT;
|
673 |
|
|
}
|
674 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 22)
|
675 |
|
|
{
|
676 |
|
|
printf ("Am290*0 received vector number %d\n",
|
677 |
|
|
in_msg_buf->halt_msg.trap_number);
|
678 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
679 |
|
|
status->value.sig = TARGET_SIGNAL_ILL;
|
680 |
|
|
} /* BREAK message was sent */
|
681 |
|
|
else if (in_msg_buf->halt_msg.trap_number == 75)
|
682 |
|
|
{
|
683 |
|
|
status->kind = TARGET_WAITKIND_STOPPED;
|
684 |
|
|
status->value.sig = TARGET_SIGNAL_TRAP;
|
685 |
|
|
}
|
686 |
|
|
else
|
687 |
|
|
exit:
|
688 |
|
|
{
|
689 |
|
|
status->kind = TARGET_WAITKIND_EXITED;
|
690 |
|
|
status->value.integer = 0;
|
691 |
|
|
}
|
692 |
|
|
|
693 |
|
|
timeout = old_timeout; /* Restore original timeout value */
|
694 |
|
|
immediate_quit = old_immediate_quit;
|
695 |
|
|
return inferior_ptid;
|
696 |
|
|
}
|
697 |
|
|
|
698 |
|
|
/******************************************************* REMOTE_FETCH_REGISTERS
|
699 |
|
|
* Read a remote register 'regno'.
|
700 |
|
|
* If regno==-1 then read all the registers.
|
701 |
|
|
*/
|
702 |
|
|
static void
|
703 |
|
|
mm_fetch_registers (int regno)
|
704 |
|
|
{
|
705 |
|
|
INT32 *data_p;
|
706 |
|
|
|
707 |
|
|
if (regno >= 0)
|
708 |
|
|
{
|
709 |
|
|
fetch_register (regno);
|
710 |
|
|
return;
|
711 |
|
|
}
|
712 |
|
|
|
713 |
|
|
/* Gr1/rsp */
|
714 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * 1;
|
715 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
716 |
|
|
out_msg_buf->read_req_msg.address = 1;
|
717 |
|
|
msg_send_serial (out_msg_buf);
|
718 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
719 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
720 |
|
|
supply_register (GR1_REGNUM, data_p);
|
721 |
|
|
|
722 |
|
|
#if defined(GR64_REGNUM) /* Read gr64-127 */
|
723 |
|
|
/* Global Registers gr64-gr95 */
|
724 |
|
|
out_msg_buf->read_req_msg.code = READ_REQ;
|
725 |
|
|
out_msg_buf->read_req_msg.length = 4 * 3;
|
726 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * 32;
|
727 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
728 |
|
|
out_msg_buf->read_req_msg.address = 64;
|
729 |
|
|
msg_send_serial (out_msg_buf);
|
730 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
731 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
732 |
|
|
|
733 |
|
|
for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++)
|
734 |
|
|
{
|
735 |
|
|
supply_register (regno, data_p++);
|
736 |
|
|
}
|
737 |
|
|
#endif /* GR64_REGNUM */
|
738 |
|
|
|
739 |
|
|
/* Global Registers gr96-gr127 */
|
740 |
|
|
out_msg_buf->read_req_msg.code = READ_REQ;
|
741 |
|
|
out_msg_buf->read_req_msg.length = 4 * 3;
|
742 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * 32;
|
743 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
744 |
|
|
out_msg_buf->read_req_msg.address = 96;
|
745 |
|
|
msg_send_serial (out_msg_buf);
|
746 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
747 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
748 |
|
|
|
749 |
|
|
for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++)
|
750 |
|
|
{
|
751 |
|
|
supply_register (regno, data_p++);
|
752 |
|
|
}
|
753 |
|
|
|
754 |
|
|
/* Local Registers */
|
755 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * (128);
|
756 |
|
|
out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
|
757 |
|
|
out_msg_buf->read_req_msg.address = 0;
|
758 |
|
|
msg_send_serial (out_msg_buf);
|
759 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
760 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
761 |
|
|
|
762 |
|
|
for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++)
|
763 |
|
|
{
|
764 |
|
|
supply_register (regno, data_p++);
|
765 |
|
|
}
|
766 |
|
|
|
767 |
|
|
/* Protected Special Registers */
|
768 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * 15;
|
769 |
|
|
out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
|
770 |
|
|
out_msg_buf->read_req_msg.address = 0;
|
771 |
|
|
msg_send_serial (out_msg_buf);
|
772 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
773 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
774 |
|
|
|
775 |
|
|
for (regno = 0; regno <= 14; regno++)
|
776 |
|
|
{
|
777 |
|
|
supply_register (SR_REGNUM (regno), data_p++);
|
778 |
|
|
}
|
779 |
|
|
if (USE_SHADOW_PC)
|
780 |
|
|
{ /* Let regno_to_srnum() handle the register number */
|
781 |
|
|
fetch_register (NPC_REGNUM);
|
782 |
|
|
fetch_register (PC_REGNUM);
|
783 |
|
|
fetch_register (PC2_REGNUM);
|
784 |
|
|
}
|
785 |
|
|
|
786 |
|
|
/* Unprotected Special Registers */
|
787 |
|
|
out_msg_buf->read_req_msg.byte_count = 4 * 8;
|
788 |
|
|
out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
|
789 |
|
|
out_msg_buf->read_req_msg.address = 128;
|
790 |
|
|
msg_send_serial (out_msg_buf);
|
791 |
|
|
expect_msg (READ_ACK, in_msg_buf, 1);
|
792 |
|
|
data_p = &(in_msg_buf->read_r_ack_msg.data[0]);
|
793 |
|
|
|
794 |
|
|
for (regno = 128; regno <= 135; regno++)
|
795 |
|
|
{
|
796 |
|
|
supply_register (SR_REGNUM (regno), data_p++);
|
797 |
|
|
}
|
798 |
|
|
|
799 |
|
|
/* There doesn't seem to be any way to get these. */
|
800 |
|
|
{
|
801 |
|
|
int val = -1;
|
802 |
|
|
supply_register (FPE_REGNUM, &val);
|
803 |
|
|
supply_register (INTE_REGNUM, &val);
|
804 |
|
|
supply_register (FPS_REGNUM, &val);
|
805 |
|
|
supply_register (EXO_REGNUM, &val);
|
806 |
|
|
}
|
807 |
|
|
}
|
808 |
|
|
|
809 |
|
|
|
810 |
|
|
/****************************************************** REMOTE_STORE_REGISTERS
|
811 |
|
|
* Store register regno into the target.
|
812 |
|
|
* If regno==-1 then store all the registers.
|
813 |
|
|
* Result is 0 for success, -1 for failure.
|
814 |
|
|
*/
|
815 |
|
|
|
816 |
|
|
static void
|
817 |
|
|
mm_store_registers (int regno)
|
818 |
|
|
{
|
819 |
|
|
int result;
|
820 |
|
|
|
821 |
|
|
if (regno >= 0)
|
822 |
|
|
{
|
823 |
|
|
store_register (regno);
|
824 |
|
|
return;
|
825 |
|
|
}
|
826 |
|
|
|
827 |
|
|
result = 0;
|
828 |
|
|
|
829 |
|
|
out_msg_buf->write_r_msg.code = WRITE_REQ;
|
830 |
|
|
|
831 |
|
|
/* Gr1/rsp */
|
832 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 1;
|
833 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
834 |
|
|
out_msg_buf->write_r_msg.memory_space = GLOBAL_REG;
|
835 |
|
|
out_msg_buf->write_r_msg.address = 1;
|
836 |
|
|
out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM);
|
837 |
|
|
|
838 |
|
|
msg_send_serial (out_msg_buf);
|
839 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
840 |
|
|
{
|
841 |
|
|
result = -1;
|
842 |
|
|
}
|
843 |
|
|
|
844 |
|
|
#if defined(GR64_REGNUM)
|
845 |
|
|
/* Global registers gr64-gr95 */
|
846 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * (32);
|
847 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
848 |
|
|
out_msg_buf->write_r_msg.address = 64;
|
849 |
|
|
|
850 |
|
|
for (regno = GR64_REGNUM; regno < GR64_REGNUM + 32; regno++)
|
851 |
|
|
{
|
852 |
|
|
out_msg_buf->write_r_msg.data[regno - GR64_REGNUM] = read_register (regno);
|
853 |
|
|
}
|
854 |
|
|
msg_send_serial (out_msg_buf);
|
855 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
856 |
|
|
{
|
857 |
|
|
result = -1;
|
858 |
|
|
}
|
859 |
|
|
#endif /* GR64_REGNUM */
|
860 |
|
|
|
861 |
|
|
/* Global registers gr96-gr127 */
|
862 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * (32);
|
863 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
864 |
|
|
out_msg_buf->write_r_msg.address = 96;
|
865 |
|
|
for (regno = GR96_REGNUM; regno < GR96_REGNUM + 32; regno++)
|
866 |
|
|
{
|
867 |
|
|
out_msg_buf->write_r_msg.data[regno - GR96_REGNUM] = read_register (regno);
|
868 |
|
|
}
|
869 |
|
|
msg_send_serial (out_msg_buf);
|
870 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
871 |
|
|
{
|
872 |
|
|
result = -1;
|
873 |
|
|
}
|
874 |
|
|
|
875 |
|
|
/* Local Registers */
|
876 |
|
|
out_msg_buf->write_r_msg.memory_space = LOCAL_REG;
|
877 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 128;
|
878 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
879 |
|
|
out_msg_buf->write_r_msg.address = 0;
|
880 |
|
|
|
881 |
|
|
for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++)
|
882 |
|
|
{
|
883 |
|
|
out_msg_buf->write_r_msg.data[regno - LR0_REGNUM] = read_register (regno);
|
884 |
|
|
}
|
885 |
|
|
msg_send_serial (out_msg_buf);
|
886 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
887 |
|
|
{
|
888 |
|
|
result = -1;
|
889 |
|
|
}
|
890 |
|
|
|
891 |
|
|
/* Protected Special Registers */
|
892 |
|
|
/* VAB through TMR */
|
893 |
|
|
out_msg_buf->write_r_msg.memory_space = SPECIAL_REG;
|
894 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 10;
|
895 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
896 |
|
|
out_msg_buf->write_r_msg.address = 0;
|
897 |
|
|
for (regno = 0; regno <= 9; regno++) /* VAB through TMR */
|
898 |
|
|
out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM (regno));
|
899 |
|
|
msg_send_serial (out_msg_buf);
|
900 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
901 |
|
|
{
|
902 |
|
|
result = -1;
|
903 |
|
|
}
|
904 |
|
|
|
905 |
|
|
/* PC0, PC1, PC2 possibly as shadow registers */
|
906 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 3;
|
907 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
908 |
|
|
for (regno = 10; regno <= 12; regno++) /* LRU and MMU */
|
909 |
|
|
out_msg_buf->write_r_msg.data[regno - 10] = read_register (SR_REGNUM (regno));
|
910 |
|
|
if (USE_SHADOW_PC)
|
911 |
|
|
out_msg_buf->write_r_msg.address = 20; /* SPC0 */
|
912 |
|
|
else
|
913 |
|
|
out_msg_buf->write_r_msg.address = 10; /* PC0 */
|
914 |
|
|
msg_send_serial (out_msg_buf);
|
915 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
916 |
|
|
{
|
917 |
|
|
result = -1;
|
918 |
|
|
}
|
919 |
|
|
|
920 |
|
|
/* LRU and MMU */
|
921 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 2;
|
922 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
923 |
|
|
out_msg_buf->write_r_msg.address = 13;
|
924 |
|
|
for (regno = 13; regno <= 14; regno++) /* LRU and MMU */
|
925 |
|
|
out_msg_buf->write_r_msg.data[regno - 13] = read_register (SR_REGNUM (regno));
|
926 |
|
|
msg_send_serial (out_msg_buf);
|
927 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
928 |
|
|
{
|
929 |
|
|
result = -1;
|
930 |
|
|
}
|
931 |
|
|
|
932 |
|
|
/* Unprotected Special Registers */
|
933 |
|
|
out_msg_buf->write_r_msg.byte_count = 4 * 8;
|
934 |
|
|
out_msg_buf->write_r_msg.length = 3 * 4 + out_msg_buf->write_r_msg.byte_count;
|
935 |
|
|
out_msg_buf->write_r_msg.address = 128;
|
936 |
|
|
for (regno = 128; regno <= 135; regno++)
|
937 |
|
|
out_msg_buf->write_r_msg.data[regno - 128] = read_register (SR_REGNUM (regno));
|
938 |
|
|
msg_send_serial (out_msg_buf);
|
939 |
|
|
if (!expect_msg (WRITE_ACK, in_msg_buf, 1))
|
940 |
|
|
{
|
941 |
|
|
result = -1;
|
942 |
|
|
}
|
943 |
|
|
|
944 |
|
|
registers_changed ();
|
945 |
|
|
}
|
946 |
|
|
|
947 |
|
|
/*************************************************** REMOTE_PREPARE_TO_STORE */
|
948 |
|
|
/* Get ready to modify the registers array. On machines which store
|
949 |
|
|
individual registers, this doesn't need to do anything. On machines
|
950 |
|
|
which store all the registers in one fell swoop, this makes sure
|
951 |
|
|
that registers contains all the registers from the program being
|
952 |
|
|
debugged. */
|
953 |
|
|
|
954 |
|
|
static void
|
955 |
|
|
mm_prepare_to_store (void)
|
956 |
|
|
{
|
957 |
|
|
/* Do nothing, since we can store individual regs */
|
958 |
|
|
}
|
959 |
|
|
|
960 |
|
|
/******************************************************* REMOTE_XFER_MEMORY */
|
961 |
|
|
static CORE_ADDR
|
962 |
|
|
translate_addr (CORE_ADDR addr)
|
963 |
|
|
{
|
964 |
|
|
#if defined(KERNEL_DEBUGGING)
|
965 |
|
|
/* Check for a virtual address in the kernel */
|
966 |
|
|
/* Assume physical address of ublock is in paddr_u register */
|
967 |
|
|
/* FIXME: doesn't work for user virtual addresses */
|
968 |
|
|
if (addr >= UVADDR)
|
969 |
|
|
{
|
970 |
|
|
/* PADDR_U register holds the physical address of the ublock */
|
971 |
|
|
CORE_ADDR i = (CORE_ADDR) read_register (PADDR_U_REGNUM);
|
972 |
|
|
return (i + addr - (CORE_ADDR) UVADDR);
|
973 |
|
|
}
|
974 |
|
|
else
|
975 |
|
|
{
|
976 |
|
|
return (addr);
|
977 |
|
|
}
|
978 |
|
|
#else
|
979 |
|
|
return (addr);
|
980 |
|
|
#endif
|
981 |
|
|
}
|
982 |
|
|
|
983 |
|
|
/******************************************************* REMOTE_FILES_INFO */
|
984 |
|
|
static void
|
985 |
|
|
mm_files_info (void)
|
986 |
|
|
{
|
987 |
|
|
printf ("\tAttached to %s at %d baud and running program %s.\n",
|
988 |
|
|
dev_name, baudrate, prog_name);
|
989 |
|
|
}
|
990 |
|
|
|
991 |
|
|
/************************************************* REMOTE_INSERT_BREAKPOINT */
|
992 |
|
|
static int
|
993 |
|
|
mm_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
|
994 |
|
|
{
|
995 |
|
|
out_msg_buf->bkpt_set_msg.code = BKPT_SET;
|
996 |
|
|
out_msg_buf->bkpt_set_msg.length = 4 * 4;
|
997 |
|
|
out_msg_buf->bkpt_set_msg.memory_space = I_MEM;
|
998 |
|
|
out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr;
|
999 |
|
|
out_msg_buf->bkpt_set_msg.pass_count = 1;
|
1000 |
|
|
out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */
|
1001 |
|
|
msg_send_serial (out_msg_buf);
|
1002 |
|
|
if (expect_msg (BKPT_SET_ACK, in_msg_buf, 1))
|
1003 |
|
|
{
|
1004 |
|
|
return 0; /* Success */
|
1005 |
|
|
}
|
1006 |
|
|
else
|
1007 |
|
|
{
|
1008 |
|
|
return 1; /* Failure */
|
1009 |
|
|
}
|
1010 |
|
|
}
|
1011 |
|
|
|
1012 |
|
|
/************************************************* REMOTE_DELETE_BREAKPOINT */
|
1013 |
|
|
static int
|
1014 |
|
|
mm_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
|
1015 |
|
|
{
|
1016 |
|
|
out_msg_buf->bkpt_rm_msg.code = BKPT_RM;
|
1017 |
|
|
out_msg_buf->bkpt_rm_msg.length = 4 * 3;
|
1018 |
|
|
out_msg_buf->bkpt_rm_msg.memory_space = I_MEM;
|
1019 |
|
|
out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr;
|
1020 |
|
|
msg_send_serial (out_msg_buf);
|
1021 |
|
|
if (expect_msg (BKPT_RM_ACK, in_msg_buf, 1))
|
1022 |
|
|
{
|
1023 |
|
|
return 0; /* Success */
|
1024 |
|
|
}
|
1025 |
|
|
else
|
1026 |
|
|
{
|
1027 |
|
|
return 1; /* Failure */
|
1028 |
|
|
}
|
1029 |
|
|
}
|
1030 |
|
|
|
1031 |
|
|
|
1032 |
|
|
/******************************************************* REMOTE_KILL */
|
1033 |
|
|
static void
|
1034 |
|
|
mm_kill (char *arg, int from_tty)
|
1035 |
|
|
{
|
1036 |
|
|
char buf[4];
|
1037 |
|
|
|
1038 |
|
|
#if defined(KERNEL_DEBUGGING)
|
1039 |
|
|
/* We don't ever kill the kernel */
|
1040 |
|
|
if (from_tty)
|
1041 |
|
|
{
|
1042 |
|
|
printf ("Kernel not killed, but left in current state.\n");
|
1043 |
|
|
printf ("Use detach to leave kernel running.\n");
|
1044 |
|
|
}
|
1045 |
|
|
#else
|
1046 |
|
|
out_msg_buf->break_msg.code = BREAK;
|
1047 |
|
|
out_msg_buf->bkpt_set_msg.length = 4 * 0;
|
1048 |
|
|
expect_msg (HALT, in_msg_buf, from_tty);
|
1049 |
|
|
if (from_tty)
|
1050 |
|
|
{
|
1051 |
|
|
printf ("Target has been stopped.");
|
1052 |
|
|
printf ("Would you like to do a hardware reset (y/n) [n] ");
|
1053 |
|
|
fgets (buf, 3, stdin);
|
1054 |
|
|
if (buf[0] == 'y')
|
1055 |
|
|
{
|
1056 |
|
|
out_msg_buf->reset_msg.code = RESET;
|
1057 |
|
|
out_msg_buf->bkpt_set_msg.length = 4 * 0;
|
1058 |
|
|
expect_msg (RESET_ACK, in_msg_buf, from_tty);
|
1059 |
|
|
printf ("Target has been reset.");
|
1060 |
|
|
}
|
1061 |
|
|
}
|
1062 |
|
|
pop_target ();
|
1063 |
|
|
#endif
|
1064 |
|
|
}
|
1065 |
|
|
|
1066 |
|
|
|
1067 |
|
|
|
1068 |
|
|
/***************************************************************************/
|
1069 |
|
|
/*
|
1070 |
|
|
* Load a program into the target.
|
1071 |
|
|
*/
|
1072 |
|
|
static void
|
1073 |
|
|
mm_load (char *arg_string, int from_tty)
|
1074 |
|
|
{
|
1075 |
|
|
dont_repeat ();
|
1076 |
|
|
|
1077 |
|
|
#if defined(KERNEL_DEBUGGING)
|
1078 |
|
|
printf ("The kernel had better be loaded already! Loading not done.\n");
|
1079 |
|
|
#else
|
1080 |
|
|
if (arg_string == 0)
|
1081 |
|
|
error ("The load command takes a file name");
|
1082 |
|
|
|
1083 |
|
|
arg_string = tilde_expand (arg_string);
|
1084 |
|
|
make_cleanup (xfree, arg_string);
|
1085 |
|
|
QUIT;
|
1086 |
|
|
immediate_quit++;
|
1087 |
|
|
error ("File loading is not yet supported for MiniMon.");
|
1088 |
|
|
/* FIXME, code to load your file here... */
|
1089 |
|
|
/* You may need to do an init_target_mm() */
|
1090 |
|
|
/* init_target_mm(?,?,?,?,?,?,?,?); */
|
1091 |
|
|
immediate_quit--;
|
1092 |
|
|
/* symbol_file_add (arg_string, from_tty, text_addr, 0, 0); */
|
1093 |
|
|
#endif
|
1094 |
|
|
|
1095 |
|
|
}
|
1096 |
|
|
|
1097 |
|
|
/************************************************ REMOTE_WRITE_INFERIOR_MEMORY
|
1098 |
|
|
** Copy LEN bytes of data from debugger memory at MYADDR
|
1099 |
|
|
to inferior's memory at MEMADDR. Returns number of bytes written. */
|
1100 |
|
|
static int
|
1101 |
|
|
mm_write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
1102 |
|
|
{
|
1103 |
|
|
int i, nwritten;
|
1104 |
|
|
|
1105 |
|
|
out_msg_buf->write_req_msg.code = WRITE_REQ;
|
1106 |
|
|
out_msg_buf->write_req_msg.memory_space = mm_memory_space (memaddr);
|
1107 |
|
|
|
1108 |
|
|
nwritten = 0;
|
1109 |
|
|
while (nwritten < len)
|
1110 |
|
|
{
|
1111 |
|
|
int num_to_write = len - nwritten;
|
1112 |
|
|
if (num_to_write > MAXDATA)
|
1113 |
|
|
num_to_write = MAXDATA;
|
1114 |
|
|
for (i = 0; i < num_to_write; i++)
|
1115 |
|
|
out_msg_buf->write_req_msg.data[i] = myaddr[i + nwritten];
|
1116 |
|
|
out_msg_buf->write_req_msg.byte_count = num_to_write;
|
1117 |
|
|
out_msg_buf->write_req_msg.length = 3 * 4 + num_to_write;
|
1118 |
|
|
out_msg_buf->write_req_msg.address = memaddr + nwritten;
|
1119 |
|
|
msg_send_serial (out_msg_buf);
|
1120 |
|
|
|
1121 |
|
|
if (expect_msg (WRITE_ACK, in_msg_buf, 1))
|
1122 |
|
|
{
|
1123 |
|
|
nwritten += in_msg_buf->write_ack_msg.byte_count;
|
1124 |
|
|
}
|
1125 |
|
|
else
|
1126 |
|
|
{
|
1127 |
|
|
break;
|
1128 |
|
|
}
|
1129 |
|
|
}
|
1130 |
|
|
return (nwritten);
|
1131 |
|
|
}
|
1132 |
|
|
|
1133 |
|
|
/************************************************* REMOTE_READ_INFERIOR_MEMORY
|
1134 |
|
|
** Read LEN bytes from inferior memory at MEMADDR. Put the result
|
1135 |
|
|
at debugger address MYADDR. Returns number of bytes read. */
|
1136 |
|
|
static int
|
1137 |
|
|
mm_read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
1138 |
|
|
{
|
1139 |
|
|
int i, nread;
|
1140 |
|
|
|
1141 |
|
|
out_msg_buf->read_req_msg.code = READ_REQ;
|
1142 |
|
|
out_msg_buf->read_req_msg.memory_space = mm_memory_space (memaddr);
|
1143 |
|
|
|
1144 |
|
|
nread = 0;
|
1145 |
|
|
while (nread < len)
|
1146 |
|
|
{
|
1147 |
|
|
int num_to_read = (len - nread);
|
1148 |
|
|
if (num_to_read > MAXDATA)
|
1149 |
|
|
num_to_read = MAXDATA;
|
1150 |
|
|
out_msg_buf->read_req_msg.byte_count = num_to_read;
|
1151 |
|
|
out_msg_buf->read_req_msg.length = 3 * 4 + num_to_read;
|
1152 |
|
|
out_msg_buf->read_req_msg.address = memaddr + nread;
|
1153 |
|
|
msg_send_serial (out_msg_buf);
|
1154 |
|
|
|
1155 |
|
|
if (expect_msg (READ_ACK, in_msg_buf, 1))
|
1156 |
|
|
{
|
1157 |
|
|
for (i = 0; i < in_msg_buf->read_ack_msg.byte_count; i++)
|
1158 |
|
|
myaddr[i + nread] = in_msg_buf->read_ack_msg.data[i];
|
1159 |
|
|
nread += in_msg_buf->read_ack_msg.byte_count;
|
1160 |
|
|
}
|
1161 |
|
|
else
|
1162 |
|
|
{
|
1163 |
|
|
break;
|
1164 |
|
|
}
|
1165 |
|
|
}
|
1166 |
|
|
return (nread);
|
1167 |
|
|
}
|
1168 |
|
|
|
1169 |
|
|
/* FIXME! Merge these two. */
|
1170 |
|
|
static int
|
1171 |
|
|
mm_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
|
1172 |
|
|
struct mem_attrib *attrib ATTRIBUTE_UNUSED,
|
1173 |
|
|
struct target_ops *target ATTRIBUTE_UNUSED)
|
1174 |
|
|
{
|
1175 |
|
|
|
1176 |
|
|
memaddr = translate_addr (memaddr);
|
1177 |
|
|
|
1178 |
|
|
if (write)
|
1179 |
|
|
return mm_write_inferior_memory (memaddr, myaddr, len);
|
1180 |
|
|
else
|
1181 |
|
|
return mm_read_inferior_memory (memaddr, myaddr, len);
|
1182 |
|
|
}
|
1183 |
|
|
|
1184 |
|
|
|
1185 |
|
|
/********************************************************** MSG_SEND_SERIAL
|
1186 |
|
|
** This function is used to send a message over the
|
1187 |
|
|
** serial line.
|
1188 |
|
|
**
|
1189 |
|
|
** If the message is successfully sent, a zero is
|
1190 |
|
|
** returned. If the message was not sendable, a -1
|
1191 |
|
|
** is returned. This function blocks. That is, it
|
1192 |
|
|
** does not return until the message is completely
|
1193 |
|
|
** sent, or until an error is encountered.
|
1194 |
|
|
**
|
1195 |
|
|
*/
|
1196 |
|
|
|
1197 |
|
|
int
|
1198 |
|
|
msg_send_serial (union msg_t *msg_ptr)
|
1199 |
|
|
{
|
1200 |
|
|
INT32 message_size;
|
1201 |
|
|
int byte_count;
|
1202 |
|
|
int result;
|
1203 |
|
|
char c;
|
1204 |
|
|
|
1205 |
|
|
/* Send message header */
|
1206 |
|
|
byte_count = 0;
|
1207 |
|
|
message_size = msg_ptr->generic_msg.length + (2 * sizeof (INT32));
|
1208 |
|
|
do
|
1209 |
|
|
{
|
1210 |
|
|
c = *((char *) msg_ptr + byte_count);
|
1211 |
|
|
result = write (mm_desc, &c, 1);
|
1212 |
|
|
if (result == 1)
|
1213 |
|
|
{
|
1214 |
|
|
byte_count = byte_count + 1;
|
1215 |
|
|
}
|
1216 |
|
|
}
|
1217 |
|
|
while ((byte_count < message_size));
|
1218 |
|
|
|
1219 |
|
|
return (0);
|
1220 |
|
|
} /* end msg_send_serial() */
|
1221 |
|
|
|
1222 |
|
|
/********************************************************** MSG_RECV_SERIAL
|
1223 |
|
|
** This function is used to receive a message over a
|
1224 |
|
|
** serial line.
|
1225 |
|
|
**
|
1226 |
|
|
** If the message is waiting in the buffer, a zero is
|
1227 |
|
|
** returned and the buffer pointed to by msg_ptr is filled
|
1228 |
|
|
** in. If no message was available, a -1 is returned.
|
1229 |
|
|
** If timeout==0, wait indefinetly for a character.
|
1230 |
|
|
**
|
1231 |
|
|
*/
|
1232 |
|
|
|
1233 |
|
|
int
|
1234 |
|
|
msg_recv_serial (union msg_t *msg_ptr)
|
1235 |
|
|
{
|
1236 |
|
|
static INT32 length = 0;
|
1237 |
|
|
static INT32 byte_count = 0;
|
1238 |
|
|
int result;
|
1239 |
|
|
char c;
|
1240 |
|
|
if (msg_ptr == 0) /* re-sync request */
|
1241 |
|
|
{
|
1242 |
|
|
length = 0;
|
1243 |
|
|
byte_count = 0;
|
1244 |
|
|
#ifdef HAVE_TERMIO
|
1245 |
|
|
/* The timeout here is the prevailing timeout set with VTIME */
|
1246 |
|
|
->"timeout==0 semantics not supported"
|
1247 |
|
|
read (mm_desc, in_buf, BUFER_SIZE);
|
1248 |
|
|
#else
|
1249 |
|
|
alarm (1);
|
1250 |
|
|
read (mm_desc, in_buf, BUFER_SIZE);
|
1251 |
|
|
alarm (0);
|
1252 |
|
|
#endif
|
1253 |
|
|
return (0);
|
1254 |
|
|
}
|
1255 |
|
|
/* Receive message */
|
1256 |
|
|
#ifdef HAVE_TERMIO
|
1257 |
|
|
/* Timeout==0, help support the mm_wait() routine */
|
1258 |
|
|
->"timeout==0 semantics not supported (and its nice if they are)"
|
1259 |
|
|
result = read (mm_desc, &c, 1);
|
1260 |
|
|
#else
|
1261 |
|
|
alarm (timeout);
|
1262 |
|
|
result = read (mm_desc, &c, 1);
|
1263 |
|
|
alarm (0);
|
1264 |
|
|
#endif
|
1265 |
|
|
if (result < 0)
|
1266 |
|
|
{
|
1267 |
|
|
if (errno == EINTR)
|
1268 |
|
|
{
|
1269 |
|
|
error ("Timeout reading from remote system.");
|
1270 |
|
|
}
|
1271 |
|
|
else
|
1272 |
|
|
perror_with_name ("remote");
|
1273 |
|
|
}
|
1274 |
|
|
else if (result == 1)
|
1275 |
|
|
{
|
1276 |
|
|
*((char *) msg_ptr + byte_count) = c;
|
1277 |
|
|
byte_count = byte_count + 1;
|
1278 |
|
|
}
|
1279 |
|
|
|
1280 |
|
|
/* Message header received. Save message length. */
|
1281 |
|
|
if (byte_count == (2 * sizeof (INT32)))
|
1282 |
|
|
length = msg_ptr->generic_msg.length;
|
1283 |
|
|
|
1284 |
|
|
if (byte_count >= (length + (2 * sizeof (INT32))))
|
1285 |
|
|
{
|
1286 |
|
|
/* Message received */
|
1287 |
|
|
byte_count = 0;
|
1288 |
|
|
return (0);
|
1289 |
|
|
}
|
1290 |
|
|
else
|
1291 |
|
|
return (-1);
|
1292 |
|
|
|
1293 |
|
|
} /* end msg_recv_serial() */
|
1294 |
|
|
|
1295 |
|
|
/********************************************************************* KBD_RAW
|
1296 |
|
|
** This function is used to put the keyboard in "raw"
|
1297 |
|
|
** mode for BSD Unix. The original status is saved
|
1298 |
|
|
** so that it may be restored later.
|
1299 |
|
|
*/
|
1300 |
|
|
TERMINAL kbd_tbuf;
|
1301 |
|
|
|
1302 |
|
|
int
|
1303 |
|
|
kbd_raw (void)
|
1304 |
|
|
{
|
1305 |
|
|
int result;
|
1306 |
|
|
TERMINAL tbuf;
|
1307 |
|
|
|
1308 |
|
|
/* Get keyboard termio (to save to restore original modes) */
|
1309 |
|
|
#ifdef HAVE_TERMIO
|
1310 |
|
|
result = ioctl (0, TCGETA, &kbd_tbuf);
|
1311 |
|
|
#else
|
1312 |
|
|
result = ioctl (0, TIOCGETP, &kbd_tbuf);
|
1313 |
|
|
#endif
|
1314 |
|
|
if (result == -1)
|
1315 |
|
|
return (errno);
|
1316 |
|
|
|
1317 |
|
|
/* Get keyboard TERMINAL (for modification) */
|
1318 |
|
|
#ifdef HAVE_TERMIO
|
1319 |
|
|
result = ioctl (0, TCGETA, &tbuf);
|
1320 |
|
|
#else
|
1321 |
|
|
result = ioctl (0, TIOCGETP, &tbuf);
|
1322 |
|
|
#endif
|
1323 |
|
|
if (result == -1)
|
1324 |
|
|
return (errno);
|
1325 |
|
|
|
1326 |
|
|
/* Set up new parameters */
|
1327 |
|
|
#ifdef HAVE_TERMIO
|
1328 |
|
|
tbuf.c_iflag = tbuf.c_iflag &
|
1329 |
|
|
~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT);
|
1330 |
|
|
tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO);
|
1331 |
|
|
tbuf.c_cc[4] = 0; /* MIN */
|
1332 |
|
|
tbuf.c_cc[5] = 0; /* TIME */
|
1333 |
|
|
#else
|
1334 |
|
|
/* FIXME: not sure if this is correct (matches HAVE_TERMIO). */
|
1335 |
|
|
tbuf.sg_flags |= RAW;
|
1336 |
|
|
tbuf.sg_flags |= ANYP;
|
1337 |
|
|
tbuf.sg_flags &= ~ECHO;
|
1338 |
|
|
#endif
|
1339 |
|
|
|
1340 |
|
|
/* Set keyboard termio to new mode (RAW) */
|
1341 |
|
|
#ifdef HAVE_TERMIO
|
1342 |
|
|
result = ioctl (0, TCSETAF, &tbuf);
|
1343 |
|
|
#else
|
1344 |
|
|
result = ioctl (0, TIOCSETP, &tbuf);
|
1345 |
|
|
#endif
|
1346 |
|
|
if (result == -1)
|
1347 |
|
|
return (errno);
|
1348 |
|
|
|
1349 |
|
|
return (0);
|
1350 |
|
|
} /* end kbd_raw() */
|
1351 |
|
|
|
1352 |
|
|
|
1353 |
|
|
|
1354 |
|
|
/***************************************************************** KBD_RESTORE
|
1355 |
|
|
** This function is used to put the keyboard back in the
|
1356 |
|
|
** mode it was in before kbk_raw was called. Note that
|
1357 |
|
|
** kbk_raw() must have been called at least once before
|
1358 |
|
|
** kbd_restore() is called.
|
1359 |
|
|
*/
|
1360 |
|
|
|
1361 |
|
|
int
|
1362 |
|
|
kbd_restore (void)
|
1363 |
|
|
{
|
1364 |
|
|
int result;
|
1365 |
|
|
|
1366 |
|
|
/* Set keyboard termio to original mode */
|
1367 |
|
|
#ifdef HAVE_TERMIO
|
1368 |
|
|
result = ioctl (0, TCSETAF, &kbd_tbuf);
|
1369 |
|
|
#else
|
1370 |
|
|
result = ioctl (0, TIOCGETP, &kbd_tbuf);
|
1371 |
|
|
#endif
|
1372 |
|
|
|
1373 |
|
|
if (result == -1)
|
1374 |
|
|
return (errno);
|
1375 |
|
|
|
1376 |
|
|
return (0);
|
1377 |
|
|
} /* end kbd_cooked() */
|
1378 |
|
|
|
1379 |
|
|
|
1380 |
|
|
/*****************************************************************************/
|
1381 |
|
|
/* Fetch a single register indicatated by 'regno'.
|
1382 |
|
|
* Returns 0/-1 on success/failure.
|
1383 |
|
|
*/
|
1384 |
|
|
static int
|
1385 |
|
|
fetch_register (int regno)
|
1386 |
|
|
{
|
1387 |
|
|
int result;
|
1388 |
|
|
out_msg_buf->read_req_msg.code = READ_REQ;
|
1389 |
|
|
out_msg_buf->read_req_msg.length = 4 * 3;
|
1390 |
|
|
out_msg_buf->read_req_msg.byte_count = 4;
|
1391 |
|
|
|
1392 |
|
|
if (regno == GR1_REGNUM)
|
1393 |
|
|
{
|
1394 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
1395 |
|
|
out_msg_buf->read_req_msg.address = 1;
|
1396 |
|
|
}
|
1397 |
|
|
else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
|
1398 |
|
|
{
|
1399 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
1400 |
|
|
out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96;
|
1401 |
|
|
}
|
1402 |
|
|
#if defined(GR64_REGNUM)
|
1403 |
|
|
else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
|
1404 |
|
|
{
|
1405 |
|
|
out_msg_buf->read_req_msg.memory_space = GLOBAL_REG;
|
1406 |
|
|
out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64;
|
1407 |
|
|
}
|
1408 |
|
|
#endif /* GR64_REGNUM */
|
1409 |
|
|
else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
|
1410 |
|
|
{
|
1411 |
|
|
out_msg_buf->read_req_msg.memory_space = LOCAL_REG;
|
1412 |
|
|
out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM);
|
1413 |
|
|
}
|
1414 |
|
|
else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
|
1415 |
|
|
{
|
1416 |
|
|
int val = -1;
|
1417 |
|
|
supply_register (160 + (regno - FPE_REGNUM), &val);
|
1418 |
|
|
return 0; /* Pretend Success */
|
1419 |
|
|
}
|
1420 |
|
|
else
|
1421 |
|
|
{
|
1422 |
|
|
out_msg_buf->read_req_msg.memory_space = SPECIAL_REG;
|
1423 |
|
|
out_msg_buf->read_req_msg.address = regnum_to_srnum (regno);
|
1424 |
|
|
}
|
1425 |
|
|
|
1426 |
|
|
msg_send_serial (out_msg_buf);
|
1427 |
|
|
|
1428 |
|
|
if (expect_msg (READ_ACK, in_msg_buf, 1))
|
1429 |
|
|
{
|
1430 |
|
|
supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0]));
|
1431 |
|
|
result = 0;
|
1432 |
|
|
}
|
1433 |
|
|
else
|
1434 |
|
|
{
|
1435 |
|
|
result = -1;
|
1436 |
|
|
}
|
1437 |
|
|
return result;
|
1438 |
|
|
}
|
1439 |
|
|
/*****************************************************************************/
|
1440 |
|
|
/* Store a single register indicated by 'regno'.
|
1441 |
|
|
* Returns 0/-1 on success/failure.
|
1442 |
|
|
*/
|
1443 |
|
|
static int
|
1444 |
|
|
store_register (int regno)
|
1445 |
|
|
{
|
1446 |
|
|
int result;
|
1447 |
|
|
|
1448 |
|
|
out_msg_buf->write_req_msg.code = WRITE_REQ;
|
1449 |
|
|
out_msg_buf->write_req_msg.length = 4 * 4;
|
1450 |
|
|
out_msg_buf->write_req_msg.byte_count = 4;
|
1451 |
|
|
out_msg_buf->write_r_msg.data[0] = read_register (regno);
|
1452 |
|
|
|
1453 |
|
|
if (regno == GR1_REGNUM)
|
1454 |
|
|
{
|
1455 |
|
|
out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
|
1456 |
|
|
out_msg_buf->write_req_msg.address = 1;
|
1457 |
|
|
/* Setting GR1 changes the numbers of all the locals, so invalidate the
|
1458 |
|
|
* register cache. Do this *after* calling read_register, because we want
|
1459 |
|
|
* read_register to return the value that write_register has just stuffed
|
1460 |
|
|
* into the registers array, not the value of the register fetched from
|
1461 |
|
|
* the inferior.
|
1462 |
|
|
*/
|
1463 |
|
|
registers_changed ();
|
1464 |
|
|
}
|
1465 |
|
|
#if defined(GR64_REGNUM)
|
1466 |
|
|
else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32)
|
1467 |
|
|
{
|
1468 |
|
|
out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
|
1469 |
|
|
out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64;
|
1470 |
|
|
}
|
1471 |
|
|
#endif /* GR64_REGNUM */
|
1472 |
|
|
else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
|
1473 |
|
|
{
|
1474 |
|
|
out_msg_buf->write_req_msg.memory_space = GLOBAL_REG;
|
1475 |
|
|
out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96;
|
1476 |
|
|
}
|
1477 |
|
|
else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
|
1478 |
|
|
{
|
1479 |
|
|
out_msg_buf->write_req_msg.memory_space = LOCAL_REG;
|
1480 |
|
|
out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM);
|
1481 |
|
|
}
|
1482 |
|
|
else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
|
1483 |
|
|
{
|
1484 |
|
|
return 0; /* Pretend Success */
|
1485 |
|
|
}
|
1486 |
|
|
else
|
1487 |
|
|
/* An unprotected or protected special register */
|
1488 |
|
|
{
|
1489 |
|
|
out_msg_buf->write_req_msg.memory_space = SPECIAL_REG;
|
1490 |
|
|
out_msg_buf->write_req_msg.address = regnum_to_srnum (regno);
|
1491 |
|
|
}
|
1492 |
|
|
|
1493 |
|
|
msg_send_serial (out_msg_buf);
|
1494 |
|
|
|
1495 |
|
|
if (expect_msg (WRITE_ACK, in_msg_buf, 1))
|
1496 |
|
|
{
|
1497 |
|
|
result = 0;
|
1498 |
|
|
}
|
1499 |
|
|
else
|
1500 |
|
|
{
|
1501 |
|
|
result = -1;
|
1502 |
|
|
}
|
1503 |
|
|
return result;
|
1504 |
|
|
}
|
1505 |
|
|
/****************************************************************************/
|
1506 |
|
|
/*
|
1507 |
|
|
* Convert a gdb special register number to a 29000 special register number.
|
1508 |
|
|
*/
|
1509 |
|
|
static int
|
1510 |
|
|
regnum_to_srnum (int regno)
|
1511 |
|
|
{
|
1512 |
|
|
switch (regno)
|
1513 |
|
|
{
|
1514 |
|
|
case VAB_REGNUM:
|
1515 |
|
|
return (0);
|
1516 |
|
|
case OPS_REGNUM:
|
1517 |
|
|
return (1);
|
1518 |
|
|
case CPS_REGNUM:
|
1519 |
|
|
return (2);
|
1520 |
|
|
case CFG_REGNUM:
|
1521 |
|
|
return (3);
|
1522 |
|
|
case CHA_REGNUM:
|
1523 |
|
|
return (4);
|
1524 |
|
|
case CHD_REGNUM:
|
1525 |
|
|
return (5);
|
1526 |
|
|
case CHC_REGNUM:
|
1527 |
|
|
return (6);
|
1528 |
|
|
case RBP_REGNUM:
|
1529 |
|
|
return (7);
|
1530 |
|
|
case TMC_REGNUM:
|
1531 |
|
|
return (8);
|
1532 |
|
|
case TMR_REGNUM:
|
1533 |
|
|
return (9);
|
1534 |
|
|
case NPC_REGNUM:
|
1535 |
|
|
return (USE_SHADOW_PC ? (20) : (10));
|
1536 |
|
|
case PC_REGNUM:
|
1537 |
|
|
return (USE_SHADOW_PC ? (21) : (11));
|
1538 |
|
|
case PC2_REGNUM:
|
1539 |
|
|
return (USE_SHADOW_PC ? (22) : (12));
|
1540 |
|
|
case MMU_REGNUM:
|
1541 |
|
|
return (13);
|
1542 |
|
|
case LRU_REGNUM:
|
1543 |
|
|
return (14);
|
1544 |
|
|
case IPC_REGNUM:
|
1545 |
|
|
return (128);
|
1546 |
|
|
case IPA_REGNUM:
|
1547 |
|
|
return (129);
|
1548 |
|
|
case IPB_REGNUM:
|
1549 |
|
|
return (130);
|
1550 |
|
|
case Q_REGNUM:
|
1551 |
|
|
return (131);
|
1552 |
|
|
case ALU_REGNUM:
|
1553 |
|
|
return (132);
|
1554 |
|
|
case BP_REGNUM:
|
1555 |
|
|
return (133);
|
1556 |
|
|
case FC_REGNUM:
|
1557 |
|
|
return (134);
|
1558 |
|
|
case CR_REGNUM:
|
1559 |
|
|
return (135);
|
1560 |
|
|
case FPE_REGNUM:
|
1561 |
|
|
return (160);
|
1562 |
|
|
case INTE_REGNUM:
|
1563 |
|
|
return (161);
|
1564 |
|
|
case FPS_REGNUM:
|
1565 |
|
|
return (162);
|
1566 |
|
|
case EXO_REGNUM:
|
1567 |
|
|
return (164);
|
1568 |
|
|
default:
|
1569 |
|
|
return (255); /* Failure ? */
|
1570 |
|
|
}
|
1571 |
|
|
}
|
1572 |
|
|
/****************************************************************************/
|
1573 |
|
|
/*
|
1574 |
|
|
* Initialize the target debugger (minimon only).
|
1575 |
|
|
*/
|
1576 |
|
|
static void
|
1577 |
|
|
init_target_mm (ADDR32 tstart, ADDR32 tend, ADDR32 dstart, ADDR32 dend,
|
1578 |
|
|
ADDR32 entry, INT32 ms_size, INT32 rs_size, ADDR32 arg_start)
|
1579 |
|
|
{
|
1580 |
|
|
out_msg_buf->init_msg.code = INIT;
|
1581 |
|
|
out_msg_buf->init_msg.length = sizeof (struct init_msg_t) - 2 * sizeof (INT32);
|
1582 |
|
|
out_msg_buf->init_msg.text_start = tstart;
|
1583 |
|
|
out_msg_buf->init_msg.text_end = tend;
|
1584 |
|
|
out_msg_buf->init_msg.data_start = dstart;
|
1585 |
|
|
out_msg_buf->init_msg.data_end = dend;
|
1586 |
|
|
out_msg_buf->init_msg.entry_point = entry;
|
1587 |
|
|
out_msg_buf->init_msg.mem_stack_size = ms_size;
|
1588 |
|
|
out_msg_buf->init_msg.reg_stack_size = rs_size;
|
1589 |
|
|
out_msg_buf->init_msg.arg_start = arg_start;
|
1590 |
|
|
msg_send_serial (out_msg_buf);
|
1591 |
|
|
expect_msg (INIT_ACK, in_msg_buf, 1);
|
1592 |
|
|
}
|
1593 |
|
|
/****************************************************************************/
|
1594 |
|
|
/*
|
1595 |
|
|
* Return a pointer to a string representing the given message code.
|
1596 |
|
|
* Not all messages are represented here, only the ones that we expect
|
1597 |
|
|
* to be called with.
|
1598 |
|
|
*/
|
1599 |
|
|
static char *
|
1600 |
|
|
msg_str (INT32 code)
|
1601 |
|
|
{
|
1602 |
|
|
static char cbuf[32];
|
1603 |
|
|
|
1604 |
|
|
switch (code)
|
1605 |
|
|
{
|
1606 |
|
|
case BKPT_SET_ACK:
|
1607 |
|
|
sprintf (cbuf, "%s (%d)", "BKPT_SET_ACK", code);
|
1608 |
|
|
break;
|
1609 |
|
|
case BKPT_RM_ACK:
|
1610 |
|
|
sprintf (cbuf, "%s (%d)", "BKPT_RM_ACK", code);
|
1611 |
|
|
break;
|
1612 |
|
|
case INIT_ACK:
|
1613 |
|
|
sprintf (cbuf, "%s (%d)", "INIT_ACK", code);
|
1614 |
|
|
break;
|
1615 |
|
|
case READ_ACK:
|
1616 |
|
|
sprintf (cbuf, "%s (%d)", "READ_ACK", code);
|
1617 |
|
|
break;
|
1618 |
|
|
case WRITE_ACK:
|
1619 |
|
|
sprintf (cbuf, "%s (%d)", "WRITE_ACK", code);
|
1620 |
|
|
break;
|
1621 |
|
|
case ERROR:
|
1622 |
|
|
sprintf (cbuf, "%s (%d)", "ERROR", code);
|
1623 |
|
|
break;
|
1624 |
|
|
case HALT:
|
1625 |
|
|
sprintf (cbuf, "%s (%d)", "HALT", code);
|
1626 |
|
|
break;
|
1627 |
|
|
default:
|
1628 |
|
|
sprintf (cbuf, "UNKNOWN (%d)", code);
|
1629 |
|
|
break;
|
1630 |
|
|
}
|
1631 |
|
|
return (cbuf);
|
1632 |
|
|
}
|
1633 |
|
|
/****************************************************************************/
|
1634 |
|
|
/*
|
1635 |
|
|
* Selected (not all of them) error codes that we might get.
|
1636 |
|
|
*/
|
1637 |
|
|
static char *
|
1638 |
|
|
error_msg_str (INT32 code)
|
1639 |
|
|
{
|
1640 |
|
|
static char cbuf[50];
|
1641 |
|
|
|
1642 |
|
|
switch (code)
|
1643 |
|
|
{
|
1644 |
|
|
case EMFAIL:
|
1645 |
|
|
return ("EMFAIL: unrecoverable error");
|
1646 |
|
|
case EMBADADDR:
|
1647 |
|
|
return ("EMBADADDR: Illegal address");
|
1648 |
|
|
case EMBADREG:
|
1649 |
|
|
return ("EMBADREG: Illegal register ");
|
1650 |
|
|
case EMACCESS:
|
1651 |
|
|
return ("EMACCESS: Could not access memory");
|
1652 |
|
|
case EMBADMSG:
|
1653 |
|
|
return ("EMBADMSG: Unknown message type");
|
1654 |
|
|
case EMMSG2BIG:
|
1655 |
|
|
return ("EMMSG2BIG: Message to large");
|
1656 |
|
|
case EMNOSEND:
|
1657 |
|
|
return ("EMNOSEND: Could not send message");
|
1658 |
|
|
case EMNORECV:
|
1659 |
|
|
return ("EMNORECV: Could not recv message");
|
1660 |
|
|
case EMRESET:
|
1661 |
|
|
return ("EMRESET: Could not RESET target");
|
1662 |
|
|
case EMCONFIG:
|
1663 |
|
|
return ("EMCONFIG: Could not get target CONFIG");
|
1664 |
|
|
case EMSTATUS:
|
1665 |
|
|
return ("EMSTATUS: Could not get target STATUS");
|
1666 |
|
|
case EMREAD:
|
1667 |
|
|
return ("EMREAD: Could not READ target memory");
|
1668 |
|
|
case EMWRITE:
|
1669 |
|
|
return ("EMWRITE: Could not WRITE target memory");
|
1670 |
|
|
case EMBKPTSET:
|
1671 |
|
|
return ("EMBKPTSET: Could not set breakpoint");
|
1672 |
|
|
case EMBKPTRM:
|
1673 |
|
|
return ("EMBKPTRM: Could not remove breakpoint");
|
1674 |
|
|
case EMBKPTSTAT:
|
1675 |
|
|
return ("EMBKPTSTAT: Could not get breakpoint status");
|
1676 |
|
|
case EMBKPTNONE:
|
1677 |
|
|
return ("EMBKPTNONE: All breakpoints in use");
|
1678 |
|
|
case EMBKPTUSED:
|
1679 |
|
|
return ("EMBKPTUSED: Breakpoints already in use");
|
1680 |
|
|
case EMINIT:
|
1681 |
|
|
return ("EMINIT: Could not init target memory");
|
1682 |
|
|
case EMGO:
|
1683 |
|
|
return ("EMGO: Could not start execution");
|
1684 |
|
|
case EMSTEP:
|
1685 |
|
|
return ("EMSTEP: Could not single step");
|
1686 |
|
|
case EMBREAK:
|
1687 |
|
|
return ("EMBREAK: Could not BREAK");
|
1688 |
|
|
case EMCOMMERR:
|
1689 |
|
|
return ("EMCOMMERR: Communication error");
|
1690 |
|
|
default:
|
1691 |
|
|
sprintf (cbuf, "error number %d", code);
|
1692 |
|
|
break;
|
1693 |
|
|
} /* end switch */
|
1694 |
|
|
|
1695 |
|
|
return (cbuf);
|
1696 |
|
|
}
|
1697 |
|
|
/****************************************************************************/
|
1698 |
|
|
|
1699 |
|
|
/* Receive a message, placing it in MSG_BUF, and expect it to be of
|
1700 |
|
|
type MSGCODE. If an error occurs, a non-zero FROM_TTY indicates
|
1701 |
|
|
that the message should be printed.
|
1702 |
|
|
|
1703 |
|
|
Return 0 for failure, 1 for success. */
|
1704 |
|
|
|
1705 |
|
|
static int
|
1706 |
|
|
expect_msg (INT32 msgcode, union msg_t *msg_buf, int from_tty)
|
1707 |
|
|
{
|
1708 |
|
|
int retries = 0;
|
1709 |
|
|
while (msg_recv_serial (msg_buf) && (retries++ < MAX_RETRIES));
|
1710 |
|
|
if (retries >= MAX_RETRIES)
|
1711 |
|
|
{
|
1712 |
|
|
printf ("Expected msg %s, ", msg_str (msgcode));
|
1713 |
|
|
printf ("no message received!\n");
|
1714 |
|
|
return (0); /* Failure */
|
1715 |
|
|
}
|
1716 |
|
|
|
1717 |
|
|
if (msg_buf->generic_msg.code != msgcode)
|
1718 |
|
|
{
|
1719 |
|
|
if (from_tty)
|
1720 |
|
|
{
|
1721 |
|
|
printf ("Expected msg %s, ", msg_str (msgcode));
|
1722 |
|
|
printf ("got msg %s\n", msg_str (msg_buf->generic_msg.code));
|
1723 |
|
|
if (msg_buf->generic_msg.code == ERROR)
|
1724 |
|
|
printf ("%s\n", error_msg_str (msg_buf->error_msg.error_code));
|
1725 |
|
|
}
|
1726 |
|
|
return (0); /* Failure */
|
1727 |
|
|
}
|
1728 |
|
|
return (1); /* Success */
|
1729 |
|
|
}
|
1730 |
|
|
/****************************************************************************/
|
1731 |
|
|
/*
|
1732 |
|
|
* Determine the MiniMon memory space qualifier based on the addr.
|
1733 |
|
|
* FIXME: Can't distinguis I_ROM/D_ROM.
|
1734 |
|
|
* FIXME: Doesn't know anything about I_CACHE/D_CACHE.
|
1735 |
|
|
*/
|
1736 |
|
|
static int
|
1737 |
|
|
mm_memory_space (CORE_ADDR *addr)
|
1738 |
|
|
{
|
1739 |
|
|
ADDR32 tstart = target_config.I_mem_start;
|
1740 |
|
|
ADDR32 tend = tstart + target_config.I_mem_size;
|
1741 |
|
|
ADDR32 dstart = target_config.D_mem_start;
|
1742 |
|
|
ADDR32 dend = tstart + target_config.D_mem_size;
|
1743 |
|
|
ADDR32 rstart = target_config.ROM_start;
|
1744 |
|
|
ADDR32 rend = tstart + target_config.ROM_size;
|
1745 |
|
|
|
1746 |
|
|
if (((ADDR32) addr >= tstart) && ((ADDR32) addr < tend))
|
1747 |
|
|
{
|
1748 |
|
|
return I_MEM;
|
1749 |
|
|
}
|
1750 |
|
|
else if (((ADDR32) addr >= dstart) && ((ADDR32) addr < dend))
|
1751 |
|
|
{
|
1752 |
|
|
return D_MEM;
|
1753 |
|
|
}
|
1754 |
|
|
else if (((ADDR32) addr >= rstart) && ((ADDR32) addr < rend))
|
1755 |
|
|
{
|
1756 |
|
|
/* FIXME: how do we determine between D_ROM and I_ROM */
|
1757 |
|
|
return D_ROM;
|
1758 |
|
|
}
|
1759 |
|
|
else /* FIXME: what do me do now? */
|
1760 |
|
|
return D_MEM; /* Hmmm! */
|
1761 |
|
|
}
|
1762 |
|
|
|
1763 |
|
|
/****************************************************************************/
|
1764 |
|
|
/*
|
1765 |
|
|
* Define the target subroutine names
|
1766 |
|
|
*/
|
1767 |
|
|
struct target_ops mm_ops;
|
1768 |
|
|
|
1769 |
|
|
static void
|
1770 |
|
|
init_mm_ops (void)
|
1771 |
|
|
{
|
1772 |
|
|
mm_ops.to_shortname = "minimon";
|
1773 |
|
|
mm_ops.to_longname = "Remote AMD/Minimon target";
|
1774 |
|
|
mm_ops.to_doc = "Remote debug an AMD 290*0 using the MiniMon dbg core on the target";
|
1775 |
|
|
mm_ops.to_open = mm_open;
|
1776 |
|
|
mm_ops.to_close = mm_close;
|
1777 |
|
|
mm_ops.to_attach = mm_attach;
|
1778 |
|
|
mm_ops.to_post_attach = NULL;
|
1779 |
|
|
mm_ops.to_require_attach = NULL;
|
1780 |
|
|
mm_ops.to_detach = mm_detach;
|
1781 |
|
|
mm_ops.to_require_detach = NULL;
|
1782 |
|
|
mm_ops.to_resume = mm_resume;
|
1783 |
|
|
mm_ops.to_wait = mm_wait;
|
1784 |
|
|
mm_ops.to_post_wait = NULL;
|
1785 |
|
|
mm_ops.to_fetch_registers = mm_fetch_registers;
|
1786 |
|
|
mm_ops.to_store_registers = mm_store_registers;
|
1787 |
|
|
mm_ops.to_prepare_to_store = mm_prepare_to_store;
|
1788 |
|
|
mm_ops.to_xfer_memory = mm_xfer_inferior_memory;
|
1789 |
|
|
mm_ops.to_files_info = mm_files_info;
|
1790 |
|
|
mm_ops.to_insert_breakpoint = mm_insert_breakpoint;
|
1791 |
|
|
mm_ops.to_remove_breakpoint = mm_remove_breakpoint;
|
1792 |
|
|
mm_ops.to_terminal_init = 0;
|
1793 |
|
|
mm_ops.to_terminal_inferior = 0;
|
1794 |
|
|
mm_ops.to_terminal_ours_for_output = 0;
|
1795 |
|
|
mm_ops.to_terminal_ours = 0;
|
1796 |
|
|
mm_ops.to_terminal_info = 0;
|
1797 |
|
|
mm_ops.to_kill = mm_kill;
|
1798 |
|
|
mm_ops.to_load = mm_load;
|
1799 |
|
|
mm_ops.to_lookup_symbol = 0;
|
1800 |
|
|
mm_ops.to_create_inferior = mm_create_inferior;
|
1801 |
|
|
mm_ops.to_post_startup_inferior = NULL;
|
1802 |
|
|
mm_ops.to_acknowledge_created_inferior = NULL;
|
1803 |
|
|
mm_ops.to_clone_and_follow_inferior = NULL;
|
1804 |
|
|
mm_ops.to_post_follow_inferior_by_clone = NULL;
|
1805 |
|
|
mm_ops.to_insert_fork_catchpoint = NULL;
|
1806 |
|
|
mm_ops.to_remove_fork_catchpoint = NULL;
|
1807 |
|
|
mm_ops.to_insert_vfork_catchpoint = NULL;
|
1808 |
|
|
mm_ops.to_remove_vfork_catchpoint = NULL;
|
1809 |
|
|
mm_ops.to_has_forked = NULL;
|
1810 |
|
|
mm_ops.to_has_vforked = NULL;
|
1811 |
|
|
mm_ops.to_can_follow_vfork_prior_to_exec = NULL;
|
1812 |
|
|
mm_ops.to_post_follow_vfork = NULL;
|
1813 |
|
|
mm_ops.to_insert_exec_catchpoint = NULL;
|
1814 |
|
|
mm_ops.to_remove_exec_catchpoint = NULL;
|
1815 |
|
|
mm_ops.to_has_execd = NULL;
|
1816 |
|
|
mm_ops.to_reported_exec_events_per_exec_call = NULL;
|
1817 |
|
|
mm_ops.to_has_exited = NULL;
|
1818 |
|
|
mm_ops.to_mourn_inferior = mm_mourn;
|
1819 |
|
|
mm_ops.to_can_run = 0;
|
1820 |
|
|
mm_ops.to_notice_signals = 0;
|
1821 |
|
|
mm_ops.to_thread_alive = 0;
|
1822 |
|
|
mm_ops.to_stop = 0;
|
1823 |
|
|
mm_ops.to_pid_to_exec_file = NULL;
|
1824 |
|
|
mm_ops.to_stratum = process_stratum;
|
1825 |
|
|
mm_ops.DONT_USE = 0;
|
1826 |
|
|
mm_ops.to_has_all_memory = 1;
|
1827 |
|
|
mm_ops.to_has_memory = 1;
|
1828 |
|
|
mm_ops.to_has_stack = 1;
|
1829 |
|
|
mm_ops.to_has_registers = 1;
|
1830 |
|
|
mm_ops.to_has_execution = 1;
|
1831 |
|
|
mm_ops.to_sections = 0;
|
1832 |
|
|
mm_ops.to_sections_end = 0;
|
1833 |
|
|
mm_ops.to_magic = OPS_MAGIC;
|
1834 |
|
|
};
|
1835 |
|
|
|
1836 |
|
|
void
|
1837 |
|
|
_initialize_remote_mm (void)
|
1838 |
|
|
{
|
1839 |
|
|
init_mm_ops ();
|
1840 |
|
|
add_target (&mm_ops);
|
1841 |
|
|
}
|
1842 |
|
|
|
1843 |
|
|
#ifdef NO_HIF_SUPPORT
|
1844 |
|
|
service_HIF (union msg_t *msg)
|
1845 |
|
|
{
|
1846 |
|
|
return (0); /* Emulate a failure */
|
1847 |
|
|
}
|
1848 |
|
|
#endif
|