1 /* Remote debugging interface for Zilog Z8000 simulator
2 Copyright 1992,1993 Free Software Foundation, Inc.
3 Contributed by Cygnus Support. Written by Steve Chamberlain
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
35 #include "../sim/z8k/sim.h"
37 /* External data declarations */
38 extern int stop_soon_quietly
; /* for wait_for_inferior */
40 /* Forward data declarations */
41 extern struct target_ops sim_ops
; /* Forward declaration */
43 void sim_store_register ();
47 sim_write_inferior_memory (memaddr
, myaddr
, len
)
49 unsigned char *myaddr
;
52 sim_write (memaddr
, myaddr
, len
);
57 store_register (regno
)
62 for (regno
= 0; regno
< 16; regno
++)
64 store_register (regno
);
69 sim_store_register (regno
, read_register (regno
));
74 sim_kill (arg
, from_tty
)
82 * Download a file specified in 'args', to the sim.
85 sim_load (args
, fromtty
)
93 abfd
= bfd_openr (args
, "coff-z8k");
97 printf_filtered ("Unable to open file %s\n", args
);
101 if (bfd_check_format (abfd
, bfd_object
) == 0)
103 printf_filtered ("File is not an object file\n");
108 while (s
!= (asection
*) NULL
)
110 if (s
->flags
& SEC_LOAD
)
114 char *buffer
= xmalloc (delta
);
116 printf_filtered ("%s\t: 0x%4x .. 0x%4x ",
117 s
->name
, s
->vma
, s
->vma
+ s
->_raw_size
);
118 for (i
= 0; i
< s
->_raw_size
; i
+= delta
)
120 int sub_delta
= delta
;
122 if (sub_delta
> s
->_raw_size
- i
)
123 sub_delta
= s
->_raw_size
- i
;
125 bfd_get_section_contents (abfd
, s
, buffer
, i
, sub_delta
);
126 sim_write_inferior_memory (s
->vma
+ i
, buffer
, sub_delta
);
127 printf_filtered ("*");
130 printf_filtered ("\n");
136 sim_set_pc (abfd
->start_address
);
139 /* This is called not only when we first attach, but also when the
140 user types "run" after having attached. */
142 sim_create_inferior (execfile
, args
, env
)
150 error ("Can't pass arguments to remote sim process.");
152 if (execfile
== 0 || exec_bfd
== 0)
153 error ("No exec file specified");
155 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
157 sim_kill (NULL
, NULL
);
158 sim_clear_breakpoints ();
159 init_wait_for_inferior ();
160 insert_breakpoints ();
161 proceed (entry_pt
, -1, 0);
165 sim_open (name
, from_tty
)
174 /* Clear any break points */
175 sim_clear_breakpoints ();
177 push_target (&sim_ops
);
178 target_fetch_registers (-1);
180 printf_filtered ("Connected to the Z8000 Simulator.\n");
183 /* Close out all files and local state before this target loses control. */
189 sim_clear_breakpoints ();
192 /* Terminate the open connection to the remote debugger.
193 Use this when you want to detach and do something else
196 sim_detach (args
, from_tty
)
200 sim_clear_breakpoints ();
202 pop_target (); /* calls sim_close to do the real work */
204 printf_filtered ("Ending remote %s debugging\n", target_shortname
);
207 /* Tell the remote machine to resume. */
209 /* Wait until the remote machine stops, then return,
210 storing status in STATUS just as `wait' would. */
216 *status
= sim_stop_signal ();
220 /* Get ready to modify the registers array. On machines which store
221 individual registers, this doesn't need to do anything. On machines
222 which store all the registers in one fell swoop, this makes sure
223 that registers contains all the registers from the program being
227 sim_prepare_to_store ()
229 /* Do nothing, since we can store individual regs */
233 fetch_register (regno
)
238 for (regno
= 0; regno
< 16; regno
++)
239 fetch_register (regno
);
243 char buf
[MAX_REGISTER_RAW_SIZE
];
245 sim_fetch_register (regno
, buf
);
246 supply_register (regno
, buf
);
250 /* Write a word WORD into remote address ADDR.
251 This goes through the data cache. */
254 sim_store_word (addr
, word
)
258 /* dcache_poke (addr, word);*/
262 sim_xfer_inferior_memory (memaddr
, myaddr
, len
, write
, target
)
267 struct target_ops
*target
; /* ignored */
271 sim_write (memaddr
, myaddr
, len
);
276 sim_read (memaddr
, myaddr
, len
);
284 char *file
= "nothing";
287 file
= bfd_get_filename (exec_bfd
);
289 printf_filtered ("\tAttached to %s running on the z8k simulator\n", file
);
292 /* This routine is run as a hook, just before the main command loop is
293 entered. If gdb is configured for the H8, but has not had its
294 target specified yet, this will loop prompting the user to do so.
298 sim_before_main_loop ()
300 push_target (&sim_ops
);
303 /* Clear the sims notion of what the break points are */
307 sim_clear_breakpoints ();
308 unpush_target (&sim_ops
);
309 generic_mourn_inferior ();
320 /* Define the target subroutine names */
322 struct target_ops sim_ops
=
324 "sim", "Remote SIM monitor",
325 "Use the Z8000 simulator",
327 0, sim_detach
, rem_resume
, sim_wait
, /* attach */
328 fetch_register
, store_register
,
329 sim_prepare_to_store
,
330 sim_xfer_inferior_memory
,
332 0, 0, /* Breakpoints */
333 0, 0, 0, 0, 0, /* Terminal handling */
334 sim_kill
, /* FIXME, kill */
336 0, /* lookup_symbol */
337 sim_create_inferior
, /* create_inferior */
338 sim_mourn
, /* mourn_inferior FIXME */
340 0, /* notice_signals */
341 process_stratum
, 0, /* next */
342 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
343 0, 0, /* Section pointers */
344 OPS_MAGIC
, /* Always the last thing */
347 /***********************************************************************/
350 _initialize_remote_sim ()
352 extern int sim_z8001_mode
;
354 sim_z8001_mode
= z8001_mode
;
355 add_target (&sim_ops
);
This page took 0.035633 seconds and 4 git commands to generate.