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
));
66 * Download a file specified in 'args', to the sim.
69 sim_load(args
,fromtty
)
77 abfd
= bfd_openr(args
, (char*)0);
81 printf_filtered("Unable to open file %s\n", args
);
85 if (bfd_check_format(abfd
, bfd_object
) ==0)
87 printf_filtered("File is not an object file\n");
92 while (s
!= (asection
*)NULL
)
94 if (s
->flags
& SEC_LOAD
)
98 char *buffer
= xmalloc(delta
);
99 printf_filtered("%s\t: 0x%4x .. 0x%4x ",
100 s
->name
, s
->vma
, s
->vma
+ s
->_raw_size
);
101 for (i
= 0; i
< s
->_raw_size
; i
+= delta
)
103 int sub_delta
= delta
;
104 if (sub_delta
> s
->_raw_size
- i
)
105 sub_delta
= s
->_raw_size
- i
;
107 bfd_get_section_contents(abfd
, s
, buffer
, i
, sub_delta
);
108 sim_write_inferior_memory(s
->vma
+ i
, buffer
, sub_delta
);
109 printf_filtered("*");
112 printf_filtered( "\n");
118 sim_store_register(PC_REGNUM
, abfd
->start_address
);
121 /* This is called not only when we first attach, but also when the
122 user types "run" after having attached. */
124 sim_create_inferior (execfile
, args
, env
)
132 error ("Can't pass arguments to remote sim process.");
134 if (execfile
== 0 || exec_bfd
== 0)
135 error ("No exec file specified");
137 entry_pt
= (int) bfd_get_start_address (exec_bfd
);
138 init_wait_for_inferior ();
139 insert_breakpoints ();
140 proceed(entry_pt
, -1, 0);
146 sim_open (name
, from_tty
)
155 push_target (&sim_ops
);
156 target_fetch_registers(-1);
157 printf_filtered("Connected to the simulator.\n");
160 /* Close out all files and local state before this target loses control. */
168 /* Terminate the open connection to the remote debugger.
169 Use this when you want to detach and do something else
172 sim_detach (args
,from_tty
)
176 pop_target(); /* calls sim_close to do the real work */
178 printf_filtered ("Ending remote %s debugging\n", target_shortname
);
182 /* Tell the remote machine to resume. */
185 /* Wait until the remote machine stops, then return,
186 storing status in STATUS just as `wait' would. */
192 WSETSTOP(*status
, sim_stop_signal());
199 fetch_register(regno
)
204 for (regno
= 0; regno
< NUM_REGS
; regno
++)
205 fetch_register(regno
);
209 char buf
[MAX_REGISTER_RAW_SIZE
];
210 sim_fetch_register(regno
, buf
);
211 supply_register(regno
, buf
);
217 sim_xfer_inferior_memory(memaddr
, myaddr
, len
, write
, target
)
222 struct target_ops
*target
; /* ignored */
226 sim_write(memaddr
, myaddr
, len
);
230 sim_read(memaddr
, myaddr
, len
);
236 /* This routine is run as a hook, just before the main command loop is
237 entered. If gdb is configured for the H8, but has not had its
238 target specified yet, this will loop prompting the user to do so.
242 sim_before_main_loop ()
244 push_target (&sim_ops
);
248 static int rem_resume(a
,b
)
258 /* Define the target subroutine names */
260 struct target_ops sim_ops
=
265 0, sim_detach
, rem_resume
, sim_wait
, /* attach */
266 fetch_register
, store_register
,
268 sim_xfer_inferior_memory
,
270 0, 0, /* Breakpoints */
271 0, 0, 0, 0, 0, /* Terminal handling */
274 0, /* lookup_symbol */
275 sim_create_inferior
, /* create_inferior */
276 pstore
, /* mourn_inferior FIXME */
278 0, /* notice_signals */
279 process_stratum
, 0, /* next */
280 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
281 0,0, /* Section pointers */
282 OPS_MAGIC
, /* Always the last thing */
285 /***********************************************************************/
288 _initialize_remote_sim ()
290 add_target (&sim_ops
);
This page took 0.034798 seconds and 4 git commands to generate.