1 /* Remote debugging interface for Zilog Z8000 simulator
2 Copyright 1992 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 "../z8ksim/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();
48 sim_write_inferior_memory (memaddr
, myaddr
, len
)
50 unsigned char *myaddr
;
53 sim_write(memaddr
, myaddr
, len
);
63 for (regno
= 0; regno
< 16; regno
++)
64 store_register(regno
);
68 sim_store_register(regno
,read_register(regno
));
75 sim_kill(arg
,from_tty
)
85 * Download a file specified in 'args', to the sim.
88 sim_load(args
,fromtty
)
96 abfd
= bfd_openr(args
,"coff-z8k");
100 printf_filtered("Unable to open file %s\n", args
);
104 if (bfd_check_format(abfd
, bfd_object
) ==0)
106 printf_filtered("File is not an object file\n");
111 while (s
!= (asection
*)NULL
)
113 if (s
->flags
& SEC_LOAD
)
117 char *buffer
= xmalloc(delta
);
118 printf_filtered("%s\t: 0x%4x .. 0x%4x ",
119 s
->name
, s
->vma
, s
->vma
+ s
->_raw_size
);
120 for (i
= 0; i
< s
->_raw_size
; i
+= delta
)
122 int sub_delta
= delta
;
123 if (sub_delta
> s
->_raw_size
- i
)
124 sub_delta
= s
->_raw_size
- i
;
126 bfd_get_section_contents(abfd
, s
, buffer
, i
, sub_delta
);
127 sim_write_inferior_memory(s
->vma
+ i
, buffer
, sub_delta
);
128 printf_filtered("*");
131 printf_filtered( "\n");
137 sim_set_pc(abfd
->start_address
);
140 /* This is called not only when we first attach, but also when the
141 user types "run" after having attached. */
143 sim_create_inferior (execfile
, args
, env
)
151 error ("Can't pass arguments to remote sim process.");
153 if (execfile
== 0 || exec_bfd
== 0)
154 error ("No exec file specified");
156 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
159 sim_clear_breakpoints();
160 init_wait_for_inferior ();
161 insert_breakpoints ();
162 proceed(entry_pt
, -1, 0);
168 sim_open (name
, from_tty
)
177 /* Clear any break points */
178 sim_clear_breakpoints();
180 push_target (&sim_ops
);
181 target_fetch_registers(-1);
183 printf_filtered("Connected to the Z8000 Simulator.\n");
186 /* Close out all files and local state before this target loses control. */
192 sim_clear_breakpoints();
195 /* Terminate the open connection to the remote debugger.
196 Use this when you want to detach and do something else
199 sim_detach (args
,from_tty
)
203 sim_clear_breakpoints();
205 pop_target(); /* calls sim_close to do the real work */
207 printf_filtered ("Ending remote %s debugging\n", target_shortname
);
210 /* Tell the remote machine to resume. */
213 /* Wait until the remote machine stops, then return,
214 storing status in STATUS just as `wait' would. */
220 *status
= sim_stop_signal();
225 /* Get ready to modify the registers array. On machines which store
226 individual registers, this doesn't need to do anything. On machines
227 which store all the registers in one fell swoop, this makes sure
228 that registers contains all the registers from the program being
232 sim_prepare_to_store ()
234 /* Do nothing, since we can store individual regs */
239 fetch_register(regno
)
244 for (regno
= 0; regno
< 16; regno
++)
245 fetch_register(regno
);
248 char buf
[MAX_REGISTER_RAW_SIZE
];
249 sim_fetch_register(regno
, buf
);
250 supply_register(regno
, buf
);
254 /* Write a word WORD into remote address ADDR.
255 This goes through the data cache. */
258 sim_store_word (addr
, word
)
262 /* dcache_poke (addr, word);*/
266 sim_xfer_inferior_memory(memaddr
, myaddr
, len
, write
, target
)
271 struct target_ops
*target
; /* ignored */
275 sim_write(memaddr
, myaddr
, len
);
280 sim_read(memaddr
, myaddr
, len
);
288 char *file
= "nothing";
290 file
= bfd_get_filename(exec_bfd
);
294 printf_filtered("\tAttached to DOS asynctsr and running program %s\n",file
);
296 printf_filtered("\tAttached to %s at %d baud and running program %s\n",file
);
298 printf_filtered("\ton an H8/300 processor.\n");
301 /* This routine is run as a hook, just before the main command loop is
302 entered. If gdb is configured for the H8, but has not had its
303 target specified yet, this will loop prompting the user to do so.
307 sim_before_main_loop ()
309 push_target (&sim_ops
);
313 /* Clear the sims notion of what the break points are */
317 sim_clear_breakpoints();
318 generic_mourn_inferior ();
321 static void rem_resume(a
,b
)
328 /* Define the target subroutine names */
330 struct target_ops sim_ops
=
332 "sim", "Remote SIM monitor",
333 "Use the Z8000 simulator",
335 0, sim_detach
, rem_resume
, sim_wait
, /* attach */
336 fetch_register
, store_register
,
337 sim_prepare_to_store
,
338 sim_xfer_inferior_memory
,
340 0, 0, /* Breakpoints */
341 0, 0, 0, 0, 0, /* Terminal handling */
342 sim_kill
, /* FIXME, kill */
344 0, /* lookup_symbol */
345 sim_create_inferior
, /* create_inferior */
346 sim_mourn
, /* mourn_inferior FIXME */
348 0, /* notice_signals */
349 process_stratum
, 0, /* next */
350 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
351 0,0, /* Section pointers */
352 OPS_MAGIC
, /* Always the last thing */
360 /***********************************************************************/
363 _initialize_remote_sim ()
365 extern int sim_z8001_mode
;
366 sim_z8001_mode
= z8001_mode
;
367 add_target (&sim_ops
);
This page took 0.037734 seconds and 4 git commands to generate.