1 /* Remote debugging interface for generalized 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. */
36 /* Forward data declarations */
37 extern struct target_ops sim_ops
; /* Forward declaration */
40 sim_write_inferior_memory (memaddr
, myaddr
, len
)
42 unsigned char *myaddr
;
45 return sim_write(memaddr
, myaddr
, len
);
54 for (regno
= 0; regno
< NUM_REGS
; regno
++)
55 store_register(regno
);
59 sim_store_register(regno
, read_register(regno
));
65 * Download a file specified in 'args', to the sim.
68 sim_load(args
,fromtty
)
76 abfd
= bfd_openr(args
, (char*)0);
80 printf_filtered("Unable to open file %s\n", args
);
84 if (bfd_check_format(abfd
, bfd_object
) ==0)
86 printf_filtered("File is not an object file\n");
91 while (s
!= (asection
*)NULL
)
93 if (s
->flags
& SEC_LOAD
)
97 char *buffer
= xmalloc(delta
);
98 printf_filtered("%s\t: 0x%4x .. 0x%4x ",
99 s
->name
, s
->vma
, s
->vma
+ s
->_raw_size
);
100 for (i
= 0; i
< s
->_raw_size
; i
+= delta
)
102 int sub_delta
= delta
;
103 if (sub_delta
> s
->_raw_size
- i
)
104 sub_delta
= s
->_raw_size
- i
;
106 bfd_get_section_contents(abfd
, s
, buffer
, i
, sub_delta
);
107 sim_write_inferior_memory(s
->vma
+ i
, buffer
, sub_delta
);
108 printf_filtered("*");
111 printf_filtered( "\n");
117 sim_store_register(PC_REGNUM
, abfd
->start_address
);
120 /* This is called not only when we first attach, but also when the
121 user types "run" after having attached. */
123 sim_create_inferior (execfile
, args
, env
)
131 error ("Can't pass arguments to remote sim process.");
133 if (execfile
== 0 || exec_bfd
== 0)
134 error ("No exec file specified");
136 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
137 init_wait_for_inferior ();
138 insert_breakpoints ();
139 proceed(entry_pt
, -1, 0);
145 sim_open (name
, from_tty
)
153 push_target (&sim_ops
);
154 target_fetch_registers(-1);
155 printf_filtered("Connected to the simulator.\n");
158 /* Close out all files and local state before this target loses control. */
166 /* Terminate the open connection to the remote debugger.
167 Use this when you want to detach and do something else
170 sim_detach (args
,from_tty
)
174 pop_target(); /* calls sim_close to do the real work */
176 printf_filtered ("Ending remote %s debugging\n", target_shortname
);
180 /* Tell the remote machine to resume. */
183 /* Wait until the remote machine stops, then return,
184 storing status in STATUS just as `wait' would. */
190 WSETSTOP(*status
, sim_stop_signal());
195 fetch_register(regno
)
200 for (regno
= 0; regno
< NUM_REGS
; regno
++)
201 fetch_register(regno
);
205 char buf
[MAX_REGISTER_RAW_SIZE
];
207 sim_fetch_register(regno
, buf
);
208 supply_register(regno
, buf
);
214 sim_xfer_inferior_memory(memaddr
, myaddr
, len
, write
, target
)
219 struct target_ops
*target
; /* ignored */
223 sim_write(memaddr
, myaddr
, len
);
227 sim_read(memaddr
, myaddr
, len
);
233 /* This routine is run as a hook, just before the main command loop is
234 entered. If gdb is configured for the H8, but has not had its
235 target specified yet, this will loop prompting the user to do so.
239 sim_before_main_loop ()
241 push_target (&sim_ops
);
245 static void rem_resume(a
,b
)
254 /* Define the target subroutine names */
256 struct target_ops sim_ops
=
261 0, sim_detach
, rem_resume
, sim_wait
, /* attach */
262 fetch_register
, store_register
,
264 sim_xfer_inferior_memory
,
266 0, 0, /* Breakpoints */
267 0, 0, 0, 0, 0, /* Terminal handling */
270 0, /* lookup_symbol */
271 sim_create_inferior
, /* create_inferior */
272 pstore
, /* mourn_inferior FIXME */
274 0, /* notice_signals */
275 process_stratum
, 0, /* next */
276 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
277 0,0, /* Section pointers */
278 OPS_MAGIC
, /* Always the last thing */
281 /***********************************************************************/
284 _initialize_remote_sim ()
286 add_target (&sim_ops
);
This page took 0.034172 seconds and 4 git commands to generate.