Add __FILE__ and __LINE__ parameter to internal_error() /
[deliverable/binutils-gdb.git] / gdb / remote-vx.c
CommitLineData
c906108c 1/* Memory-access and commands for remote VxWorks processes, for GDB.
29e57380 2 Copyright (C) 1990-95, 1997-98, 1999, 2001 Free Software Foundation, Inc.
c906108c
SS
3 Contributed by Wind River Systems and Cygnus Support.
4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
c906108c 11
c5aa993b
JM
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
c906108c 16
c5aa993b
JM
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#include "defs.h"
23#include "frame.h"
24#include "inferior.h"
c906108c
SS
25#include "target.h"
26#include "gdbcore.h"
27#include "command.h"
28#include "symtab.h"
29#include "complaints.h"
30#include "gdbcmd.h"
c5aa993b 31#include "bfd.h" /* Required by objfiles.h. */
1adeb98a 32#include "symfile.h"
c906108c
SS
33#include "objfiles.h"
34#include "gdb-stabs.h"
35
36#include "gdb_string.h"
37#include <errno.h>
38#include <signal.h>
39#include <fcntl.h>
40#include <sys/types.h>
41#include <sys/socket.h>
42#define malloc bogon_malloc /* Sun claims "char *malloc()" not void * */
43#define free bogon_free /* Sun claims "int free()" not void */
44#define realloc bogon_realloc /* Sun claims "char *realloc()", not void * */
45#include <rpc/rpc.h>
46#undef malloc
47#undef free
48#undef realloc
49#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
50#include <netdb.h>
51#include "vx-share/ptrace.h"
52#include "vx-share/xdr_ptrace.h"
53#include "vx-share/xdr_ld.h"
54#include "vx-share/xdr_rdb.h"
55#include "vx-share/dbgRpcLib.h"
56
57#include <symtab.h>
58
59/* Maximum number of bytes to transfer in a single
60 PTRACE_{READ,WRITE}DATA request. */
61#define VX_MEMXFER_MAX 4096
62
63extern void vx_read_register ();
64extern void vx_write_register ();
65extern void symbol_file_command ();
c5aa993b 66extern int stop_soon_quietly; /* for wait_for_inferior */
c906108c
SS
67
68static int net_step ();
69static int net_ptrace_clnt_call (); /* Forward decl */
c5aa993b 70static enum clnt_stat net_clnt_call (); /* Forward decl */
c906108c
SS
71
72/* Target ops structure for accessing memory and such over the net */
73
74static struct target_ops vx_ops;
75
76/* Target ops structure for accessing VxWorks child processes over the net */
77
78static struct target_ops vx_run_ops;
79
80/* Saved name of target host and called function for "info files".
81 Both malloc'd. */
82
83static char *vx_host;
c5aa993b 84static char *vx_running; /* Called function */
c906108c
SS
85
86/* Nonzero means target that is being debugged remotely has a floating
87 point processor. */
88
89int target_has_fp;
90
91/* Default error message when the network is forking up. */
92
93static const char rpcerr[] = "network target debugging: rpc error";
94
c5aa993b 95CLIENT *pClient; /* client used in net debugging */
c906108c
SS
96static int ptraceSock = RPC_ANYSOCK;
97
c5aa993b 98enum clnt_stat net_clnt_call ();
c906108c
SS
99static void parse_args ();
100
c5aa993b
JM
101static struct timeval rpcTimeout =
102{10, 0};
c906108c
SS
103
104static char *skip_white_space ();
105static char *find_white_space ();
c5aa993b 106
c906108c
SS
107/* Tell the VxWorks target system to download a file.
108 The load addresses of the text, data, and bss segments are
109 stored in *pTextAddr, *pDataAddr, and *pBssAddr (respectively).
110 Returns 0 for success, -1 for failure. */
111
112static int
fba45db2
KB
113net_load (char *filename, CORE_ADDR *pTextAddr, CORE_ADDR *pDataAddr,
114 CORE_ADDR *pBssAddr)
c906108c
SS
115{
116 enum clnt_stat status;
117 struct ldfile ldstruct;
118 struct timeval load_timeout;
119
120 memset ((char *) &ldstruct, '\0', sizeof (ldstruct));
121
122 /* We invoke clnt_call () here directly, instead of through
123 net_clnt_call (), because we need to set a large timeout value.
124 The load on the target side can take quite a while, easily
125 more than 10 seconds. The user can kill this call by typing
126 CTRL-C if there really is a problem with the load.
127
128 Do not change the tv_sec value without checking -- select() imposes
129 a limit of 10**8 on it for no good reason that I can see... */
130
c5aa993b 131 load_timeout.tv_sec = 99999999; /* A large number, effectively inf. */
c906108c 132 load_timeout.tv_usec = 0;
c5aa993b 133
c906108c
SS
134 status = clnt_call (pClient, VX_LOAD, xdr_wrapstring, &filename, xdr_ldfile,
135 &ldstruct, load_timeout);
136
137 if (status == RPC_SUCCESS)
138 {
139 if (*ldstruct.name == 0) /* load failed on VxWorks side */
140 return -1;
141 *pTextAddr = ldstruct.txt_addr;
142 *pDataAddr = ldstruct.data_addr;
143 *pBssAddr = ldstruct.bss_addr;
144 return 0;
145 }
146 else
147 return -1;
148}
149
150/* returns 0 if successful, errno if RPC failed or VxWorks complains. */
151
152static int
fba45db2 153net_break (int addr, u_long procnum)
c906108c
SS
154{
155 enum clnt_stat status;
156 int break_status;
c5aa993b
JM
157 Rptrace ptrace_in; /* XXX This is stupid. It doesn't need to be a ptrace
158 structure. How about something smaller? */
c906108c
SS
159
160 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
161 break_status = 0;
162
163 ptrace_in.addr = addr;
164 ptrace_in.pid = inferior_pid;
165
166 status = net_clnt_call (procnum, xdr_rptrace, &ptrace_in, xdr_int,
167 &break_status);
168
169 if (status != RPC_SUCCESS)
c5aa993b 170 return errno;
c906108c
SS
171
172 if (break_status == -1)
173 return ENOMEM;
c5aa993b 174 return break_status; /* probably (FIXME) zero */
c906108c
SS
175}
176
177/* returns 0 if successful, errno otherwise */
178
179static int
fba45db2 180vx_insert_breakpoint (int addr)
c906108c
SS
181{
182 return net_break (addr, VX_BREAK_ADD);
183}
184
185/* returns 0 if successful, errno otherwise */
186
187static int
fba45db2 188vx_remove_breakpoint (int addr)
c906108c
SS
189{
190 return net_break (addr, VX_BREAK_DELETE);
191}
192
193/* Start an inferior process and sets inferior_pid to its pid.
194 EXEC_FILE is the file to run.
195 ALLARGS is a string containing the arguments to the program.
196 ENV is the environment vector to pass.
197 Returns process id. Errors reported with error().
198 On VxWorks, we ignore exec_file. */
c5aa993b 199
c906108c 200static void
fba45db2 201vx_create_inferior (char *exec_file, char *args, char **env)
c906108c
SS
202{
203 enum clnt_stat status;
204 arg_array passArgs;
205 TASK_START taskStart;
206
207 memset ((char *) &passArgs, '\0', sizeof (passArgs));
208 memset ((char *) &taskStart, '\0', sizeof (taskStart));
209
210 /* parse arguments, put them in passArgs */
211
212 parse_args (args, &passArgs);
213
214 if (passArgs.arg_array_len == 0)
215 error ("You must specify a function name to run, and arguments if any");
216
217 status = net_clnt_call (PROCESS_START, xdr_arg_array, &passArgs,
218 xdr_TASK_START, &taskStart);
219
220 if ((status != RPC_SUCCESS) || (taskStart.status == -1))
221 error ("Can't create process on remote target machine");
222
223 /* Save the name of the running function */
224 vx_running = savestring (passArgs.arg_array_val[0],
225 strlen (passArgs.arg_array_val[0]));
226
227 push_target (&vx_run_ops);
228 inferior_pid = taskStart.pid;
229
230 /* We will get a trace trap after one instruction.
231 Insert breakpoints and continue. */
232
233 init_wait_for_inferior ();
234
235 /* Set up the "saved terminal modes" of the inferior
236 based on what modes we are starting it with. */
237 target_terminal_init ();
238
239 /* Install inferior's terminal modes. */
240 target_terminal_inferior ();
241
242 stop_soon_quietly = 1;
243 wait_for_inferior (); /* Get the task spawn event */
244 stop_soon_quietly = 0;
245
246 /* insert_step_breakpoint (); FIXME, do we need this? */
247 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
248}
249
250/* Fill ARGSTRUCT in argc/argv form with the arguments from the
251 argument string ARGSTRING. */
252
253static void
fba45db2 254parse_args (register char *arg_string, arg_array *arg_struct)
c906108c
SS
255{
256 register int arg_count = 0; /* number of arguments */
257 register int arg_index = 0;
258 register char *p0;
c5aa993b 259
c906108c 260 memset ((char *) arg_struct, '\0', sizeof (arg_array));
c5aa993b 261
c906108c
SS
262 /* first count how many arguments there are */
263
264 p0 = arg_string;
265 while (*p0 != '\0')
266 {
267 if (*(p0 = skip_white_space (p0)) == '\0')
268 break;
269 p0 = find_white_space (p0);
270 arg_count++;
271 }
272
273 arg_struct->arg_array_len = arg_count;
274 arg_struct->arg_array_val = (char **) xmalloc ((arg_count + 1)
275 * sizeof (char *));
276
277 /* now copy argument strings into arg_struct. */
278
279 while (*(arg_string = skip_white_space (arg_string)))
280 {
281 p0 = find_white_space (arg_string);
282 arg_struct->arg_array_val[arg_index++] = savestring (arg_string,
283 p0 - arg_string);
284 arg_string = p0;
285 }
286
287 arg_struct->arg_array_val[arg_count] = NULL;
288}
289
290/* Advance a string pointer across whitespace and return a pointer
291 to the first non-white character. */
292
293static char *
fba45db2 294skip_white_space (register char *p)
c906108c
SS
295{
296 while (*p == ' ' || *p == '\t')
297 p++;
298 return p;
299}
c5aa993b 300
c906108c
SS
301/* Search for the first unquoted whitespace character in a string.
302 Returns a pointer to the character, or to the null terminator
303 if no whitespace is found. */
304
305static char *
fba45db2 306find_white_space (register char *p)
c906108c
SS
307{
308 register int c;
309
310 while ((c = *p) != ' ' && c != '\t' && c)
311 {
312 if (c == '\'' || c == '"')
313 {
314 while (*++p != c && *p)
315 {
316 if (*p == '\\')
317 p++;
318 }
319 if (!*p)
320 break;
321 }
322 p++;
323 }
324 return p;
325}
c5aa993b 326
c906108c
SS
327/* Poll the VxWorks target system for an event related
328 to the debugged task.
329 Returns -1 if remote wait failed, task status otherwise. */
330
331static int
fba45db2 332net_wait (RDB_EVENT *pEvent)
c906108c 333{
c5aa993b
JM
334 int pid;
335 enum clnt_stat status;
c906108c 336
c5aa993b 337 memset ((char *) pEvent, '\0', sizeof (RDB_EVENT));
c906108c 338
c5aa993b
JM
339 pid = inferior_pid;
340 status = net_clnt_call (PROCESS_WAIT, xdr_int, &pid, xdr_RDB_EVENT,
341 pEvent);
342
343 /* return (status == RPC_SUCCESS)? pEvent->status: -1; */
344 if (status == RPC_SUCCESS)
345 return ((pEvent->status) ? 1 : 0);
346 else if (status == RPC_TIMEDOUT)
347 return (1);
348 else
349 return (-1);
c906108c 350}
c5aa993b 351
c906108c
SS
352/* Suspend the remote task.
353 Returns -1 if suspend fails on target system, 0 otherwise. */
354
355static int
fba45db2 356net_quit (void)
c906108c
SS
357{
358 int pid;
359 int quit_status;
360 enum clnt_stat status;
361
362 quit_status = 0;
363
364 /* don't let rdbTask suspend itself by passing a pid of 0 */
365
366 if ((pid = inferior_pid) == 0)
367 return -1;
368
369 status = net_clnt_call (VX_TASK_SUSPEND, xdr_int, &pid, xdr_int,
370 &quit_status);
371
c5aa993b 372 return (status == RPC_SUCCESS) ? quit_status : -1;
c906108c
SS
373}
374
375/* Read a register or registers from the remote system. */
376
377void
fba45db2 378net_read_registers (char *reg_buf, int len, u_long procnum)
c906108c
SS
379{
380 int status;
381 Rptrace ptrace_in;
382 Ptrace_return ptrace_out;
383 C_bytes out_data;
384 char message[100];
385
386 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
387 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
388
389 /* Initialize RPC input argument structure. */
390
391 ptrace_in.pid = inferior_pid;
392 ptrace_in.info.ttype = NOINFO;
393
394 /* Initialize RPC return value structure. */
395
396 out_data.bytes = reg_buf;
397 out_data.len = len;
c5aa993b 398 ptrace_out.info.more_data = (caddr_t) & out_data;
c906108c
SS
399
400 /* Call RPC; take an error exit if appropriate. */
401
402 status = net_ptrace_clnt_call (procnum, &ptrace_in, &ptrace_out);
403 if (status)
404 error (rpcerr);
405 if (ptrace_out.status == -1)
406 {
407 errno = ptrace_out.errno_num;
408 sprintf (message, "reading %s registers", (procnum == PTRACE_GETREGS)
c5aa993b
JM
409 ? "general-purpose"
410 : "floating-point");
c906108c
SS
411 perror_with_name (message);
412 }
413}
414
415/* Write register values to a VxWorks target. REG_BUF points to a buffer
416 containing the raw register values, LEN is the length of REG_BUF in
417 bytes, and PROCNUM is the RPC procedure number (PTRACE_SETREGS or
418 PTRACE_SETFPREGS). An error exit is taken if the RPC call fails or
419 if an error status is returned by the remote debug server. This is
420 a utility routine used by vx_write_register (). */
421
422void
fba45db2 423net_write_registers (char *reg_buf, int len, u_long procnum)
c906108c
SS
424{
425 int status;
426 Rptrace ptrace_in;
427 Ptrace_return ptrace_out;
428 C_bytes in_data;
429 char message[100];
430
431 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
432 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
433
434 /* Initialize RPC input argument structure. */
435
436 in_data.bytes = reg_buf;
437 in_data.len = len;
438
439 ptrace_in.pid = inferior_pid;
440 ptrace_in.info.ttype = DATA;
c5aa993b 441 ptrace_in.info.more_data = (caddr_t) & in_data;
c906108c
SS
442
443 /* Call RPC; take an error exit if appropriate. */
444
445 status = net_ptrace_clnt_call (procnum, &ptrace_in, &ptrace_out);
446 if (status)
447 error (rpcerr);
448 if (ptrace_out.status == -1)
449 {
450 errno = ptrace_out.errno_num;
451 sprintf (message, "writing %s registers", (procnum == PTRACE_SETREGS)
c5aa993b
JM
452 ? "general-purpose"
453 : "floating-point");
c906108c
SS
454 perror_with_name (message);
455 }
456}
457
458/* Prepare to store registers. Since we will store all of them,
459 read out their current values now. */
460
461static void
fba45db2 462vx_prepare_to_store (void)
c906108c
SS
463{
464 /* Fetch all registers, if any of them are not yet fetched. */
465 read_register_bytes (0, NULL, REGISTER_BYTES);
466}
467
468/* Copy LEN bytes to or from remote inferior's memory starting at MEMADDR
469 to debugger memory starting at MYADDR. WRITE is true if writing to the
832c69cf 470 inferior. TARGET is unused.
c906108c
SS
471 Result is the number of bytes written or read (zero if error). The
472 protocol allows us to return a negative count, indicating that we can't
473 handle the current address but can handle one N bytes further, but
474 vxworks doesn't give us that information. */
475
476static int
832c69cf 477vx_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
29e57380
C
478 struct mem_attrib *attrib ATTRIBUTE_UNUSED,
479 struct target_ops *target ATTRIBUTE_UNUSED)
c906108c
SS
480{
481 int status;
482 Rptrace ptrace_in;
483 Ptrace_return ptrace_out;
484 C_bytes data;
485 enum ptracereq request;
486 int nleft, nxfer;
487
488 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
489 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
490
c5aa993b 491 ptrace_in.pid = inferior_pid; /* XXX pid unnecessary for READDATA */
c906108c 492 ptrace_in.addr = (int) memaddr; /* Where from */
c5aa993b 493 ptrace_in.data = len; /* How many bytes */
c906108c
SS
494
495 if (write)
496 {
c5aa993b
JM
497 ptrace_in.info.ttype = DATA;
498 ptrace_in.info.more_data = (caddr_t) & data;
c906108c
SS
499
500 data.bytes = (caddr_t) myaddr; /* Where from */
c5aa993b 501 data.len = len; /* How many bytes (again, for XDR) */
c906108c
SS
502 request = PTRACE_WRITEDATA;
503 }
504 else
505 {
c5aa993b 506 ptrace_out.info.more_data = (caddr_t) & data;
c906108c
SS
507 request = PTRACE_READDATA;
508 }
509 /* Loop until the entire request has been satisfied, transferring
510 at most VX_MEMXFER_MAX bytes per iteration. Break from the loop
511 if an error status is returned by the remote debug server. */
512
513 nleft = len;
514 status = 0;
515
516 while (nleft > 0 && status == 0)
517 {
518 nxfer = min (nleft, VX_MEMXFER_MAX);
519
520 ptrace_in.addr = (int) memaddr;
521 ptrace_in.data = nxfer;
522 data.bytes = (caddr_t) myaddr;
523 data.len = nxfer;
524
525 /* Request a block from the remote debug server; if RPC fails,
526 report an error and return to debugger command level. */
527
528 if (net_ptrace_clnt_call (request, &ptrace_in, &ptrace_out))
c5aa993b 529 error (rpcerr);
c906108c
SS
530
531 status = ptrace_out.status;
532 if (status == 0)
c5aa993b
JM
533 {
534 memaddr += nxfer;
535 myaddr += nxfer;
536 nleft -= nxfer;
537 }
c906108c 538 else
c5aa993b
JM
539 {
540 /* A target-side error has ocurred. Set errno to the error
541 code chosen by the target so that a later perror () will
542 say something meaningful. */
c906108c 543
c5aa993b
JM
544 errno = ptrace_out.errno_num;
545 }
c906108c
SS
546 }
547
548 /* Return the number of bytes transferred. */
549
550 return (len - nleft);
551}
552
553static void
fba45db2 554vx_files_info (void)
c906108c
SS
555{
556 printf_unfiltered ("\tAttached to host `%s'", vx_host);
c5aa993b 557 printf_unfiltered (", which has %sfloating point", target_has_fp ? "" : "no ");
c906108c
SS
558 printf_unfiltered (".\n");
559}
560
561static void
fba45db2 562vx_run_files_info (void)
c906108c 563{
c5aa993b 564 printf_unfiltered ("\tRunning %s VxWorks process %s",
c906108c
SS
565 vx_running ? "child" : "attached",
566 local_hex_string (inferior_pid));
567 if (vx_running)
568 printf_unfiltered (", function `%s'", vx_running);
c5aa993b 569 printf_unfiltered (".\n");
c906108c
SS
570}
571
572static void
fba45db2 573vx_resume (int pid, int step, enum target_signal siggnal)
c906108c
SS
574{
575 int status;
576 Rptrace ptrace_in;
577 Ptrace_return ptrace_out;
578 CORE_ADDR cont_addr;
579
580 if (pid == -1)
581 pid = inferior_pid;
582
583 if (siggnal != 0 && siggnal != stop_signal)
584 error ("Cannot send signals to VxWorks processes");
585
586 /* Set CONT_ADDR to the address at which we are continuing,
587 or to 1 if we are continuing from where the program stopped.
588 This conforms to traditional ptrace () usage, but at the same
589 time has special meaning for the VxWorks remote debug server.
590 If the address is not 1, the server knows that the target
591 program is jumping to a new address, which requires special
592 handling if there is a breakpoint at the new address. */
593
594 cont_addr = read_register (PC_REGNUM);
595 if (cont_addr == stop_pc)
596 cont_addr = 1;
597
598 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
599 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
600
601 ptrace_in.pid = pid;
c5aa993b 602 ptrace_in.addr = cont_addr; /* Target side insists on this, or it panics. */
c906108c
SS
603
604 if (step)
c5aa993b 605 status = net_step ();
c906108c
SS
606 else
607 status = net_ptrace_clnt_call (PTRACE_CONT, &ptrace_in, &ptrace_out);
608
609 if (status)
610 error (rpcerr);
611 if (ptrace_out.status == -1)
612 {
613 errno = ptrace_out.errno_num;
614 perror_with_name ("Resuming remote process");
615 }
616}
617
618static void
fba45db2 619vx_mourn_inferior (void)
c906108c
SS
620{
621 pop_target (); /* Pop back to no-child state */
622 generic_mourn_inferior ();
623}
c906108c 624\f
c5aa993b 625
a14ed312 626static void vx_add_symbols (char *, int, CORE_ADDR, CORE_ADDR, CORE_ADDR);
c906108c 627
c5aa993b
JM
628struct find_sect_args
629 {
630 CORE_ADDR text_start;
631 CORE_ADDR data_start;
632 CORE_ADDR bss_start;
633 };
c906108c 634
a14ed312 635static void find_sect (bfd *, asection *, void *);
c906108c
SS
636
637static void
fba45db2 638find_sect (bfd *abfd, asection *sect, PTR obj)
c906108c 639{
c5aa993b 640 struct find_sect_args *args = (struct find_sect_args *) obj;
c906108c
SS
641
642 if (bfd_get_section_flags (abfd, sect) & (SEC_CODE & SEC_READONLY))
643 args->text_start = bfd_get_section_vma (abfd, sect);
644 else if (bfd_get_section_flags (abfd, sect) & SEC_ALLOC)
645 {
646 if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
647 {
648 /* Exclude .ctor and .dtor sections which have SEC_CODE set but not
649 SEC_DATA. */
650 if (bfd_get_section_flags (abfd, sect) & SEC_DATA)
651 args->data_start = bfd_get_section_vma (abfd, sect);
652 }
653 else
654 args->bss_start = bfd_get_section_vma (abfd, sect);
655 }
656}
657
658static void
fba45db2
KB
659vx_add_symbols (char *name, int from_tty, CORE_ADDR text_addr,
660 CORE_ADDR data_addr, CORE_ADDR bss_addr)
c906108c
SS
661{
662 struct section_offsets *offs;
663 struct objfile *objfile;
664 struct find_sect_args ss;
665
666 /* It might be nice to suppress the breakpoint_re_set which happens here
667 because we are going to do one again after the objfile_relocate. */
2df3850c 668 objfile = symbol_file_add (name, from_tty, NULL, 0, 0);
c906108c
SS
669
670 /* This is a (slightly cheesy) way of superceding the old symbols. A less
671 cheesy way would be to find the objfile with the same name and
672 free_objfile it. */
673 objfile_to_front (objfile);
674
d4f3574e
SS
675 offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
676 memcpy (offs, objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
c906108c
SS
677
678 ss.text_start = 0;
679 ss.data_start = 0;
680 ss.bss_start = 0;
681 bfd_map_over_sections (objfile->obfd, find_sect, &ss);
682
683 /* Both COFF and b.out frontends use these SECT_OFF_* values. */
f0a58b0b
EZ
684 offs->offsets[SECT_OFF_TEXT (objfile)] = text_addr - ss.text_start;
685 offs->offsets[SECT_OFF_DATA (objfile)] = data_addr - ss.data_start;
686 offs->offsets[SECT_OFF_BSS (objfile)] = bss_addr - ss.bss_start;
c906108c
SS
687 objfile_relocate (objfile, offs);
688}
689
690/* This function allows the addition of incrementally linked object files. */
691
692static void
fba45db2 693vx_load_command (char *arg_string, int from_tty)
c906108c
SS
694{
695 CORE_ADDR text_addr;
696 CORE_ADDR data_addr;
697 CORE_ADDR bss_addr;
698
699 if (arg_string == 0)
700 error ("The load command takes a file name");
701
702 arg_string = tilde_expand (arg_string);
b8c9b27d 703 make_cleanup (xfree, arg_string);
c906108c
SS
704
705 dont_repeat ();
706
707 /* Refuse to load the module if a debugged task is running. Doing so
708 can have a number of unpleasant consequences to the running task. */
709
710 if (inferior_pid != 0 && target_has_execution)
711 {
712 if (query ("You may not load a module while the target task is running.\n\
713Kill the target task? "))
c5aa993b 714 target_kill ();
c906108c 715 else
8e1a459b 716 error ("Load canceled.");
c906108c
SS
717 }
718
719 QUIT;
720 immediate_quit++;
721 if (net_load (arg_string, &text_addr, &data_addr, &bss_addr) == -1)
722 error ("Load failed on target machine");
723 immediate_quit--;
724
725 vx_add_symbols (arg_string, from_tty, text_addr, data_addr, bss_addr);
726
727 /* Getting new symbols may change our opinion about what is
728 frameless. */
729 reinit_frame_cache ();
730}
731
732/* Single step the target program at the source or machine level.
733 Takes an error exit if rpc fails.
734 Returns -1 if remote single-step operation fails, else 0. */
735
736static int
fba45db2 737net_step (void)
c906108c
SS
738{
739 enum clnt_stat status;
740 int step_status;
741 SOURCE_STEP source_step;
742
743 source_step.taskId = inferior_pid;
744
745 if (step_range_end)
746 {
747 source_step.startAddr = step_range_start;
748 source_step.endAddr = step_range_end;
749 }
750 else
751 {
752 source_step.startAddr = 0;
753 source_step.endAddr = 0;
754 }
755
756 status = net_clnt_call (VX_SOURCE_STEP, xdr_SOURCE_STEP, &source_step,
757 xdr_int, &step_status);
758
759 if (status == RPC_SUCCESS)
760 return step_status;
c5aa993b 761 else
c906108c
SS
762 error (rpcerr);
763}
764
765/* Emulate ptrace using RPC calls to the VxWorks target system.
766 Returns nonzero (-1) if RPC status to VxWorks is bad, 0 otherwise. */
767
768static int
fba45db2
KB
769net_ptrace_clnt_call (enum ptracereq request, Rptrace *pPtraceIn,
770 Ptrace_return *pPtraceOut)
c906108c
SS
771{
772 enum clnt_stat status;
773
774 status = net_clnt_call (request, xdr_rptrace, pPtraceIn, xdr_ptrace_return,
775 pPtraceOut);
776
777 if (status != RPC_SUCCESS)
c5aa993b 778 return -1;
c906108c
SS
779
780 return 0;
781}
782
783/* Query the target for the name of the file from which VxWorks was
784 booted. pBootFile is the address of a pointer to the buffer to
785 receive the file name; if the pointer pointed to by pBootFile is
786 NULL, memory for the buffer will be allocated by XDR.
787 Returns -1 if rpc failed, 0 otherwise. */
788
789static int
fba45db2 790net_get_boot_file (char **pBootFile)
c906108c
SS
791{
792 enum clnt_stat status;
793
794 status = net_clnt_call (VX_BOOT_FILE_INQ, xdr_void, (char *) 0,
795 xdr_wrapstring, pBootFile);
796 return (status == RPC_SUCCESS) ? 0 : -1;
797}
798
832c69cf
KB
799/* Fetch a list of loaded object modules from the VxWorks target
800 and store in PLOADTABLE.
c906108c
SS
801 Returns -1 if rpc failed, 0 otherwise
802 There's no way to check if the returned loadTable is correct.
803 VxWorks doesn't check it. */
804
805static int
832c69cf 806net_get_symbols (ldtabl *pLoadTable)
c906108c
SS
807{
808 enum clnt_stat status;
809
810 memset ((char *) pLoadTable, '\0', sizeof (struct ldtabl));
811
812 status = net_clnt_call (VX_STATE_INQ, xdr_void, 0, xdr_ldtabl, pLoadTable);
813 return (status == RPC_SUCCESS) ? 0 : -1;
814}
815
816/* Look up a symbol in the VxWorks target's symbol table.
817 Returns status of symbol read on target side (0=success, -1=fail)
818 Returns -1 and complain()s if rpc fails. */
819
820struct complaint cant_contact_target =
c5aa993b 821{"Lost contact with VxWorks target", 0, 0};
c906108c
SS
822
823static int
fba45db2
KB
824vx_lookup_symbol (char *name, /* symbol name */
825 CORE_ADDR *pAddr)
c906108c
SS
826{
827 enum clnt_stat status;
828 SYMBOL_ADDR symbolAddr;
829
830 *pAddr = 0;
831 memset ((char *) &symbolAddr, '\0', sizeof (symbolAddr));
832
833 status = net_clnt_call (VX_SYMBOL_INQ, xdr_wrapstring, &name,
834 xdr_SYMBOL_ADDR, &symbolAddr);
835 if (status != RPC_SUCCESS)
836 {
837 complain (&cant_contact_target);
838 return -1;
839 }
840
841 *pAddr = symbolAddr.addr;
842 return symbolAddr.status;
843}
844
845/* Check to see if the VxWorks target has a floating point coprocessor.
846 Returns 1 if target has floating point processor, 0 otherwise.
847 Calls error() if rpc fails. */
848
849static int
fba45db2 850net_check_for_fp (void)
c906108c
SS
851{
852 enum clnt_stat status;
c5aa993b 853 bool_t fp = 0; /* true if fp processor is present on target board */
c906108c
SS
854
855 status = net_clnt_call (VX_FP_INQUIRE, xdr_void, 0, xdr_bool, &fp);
856 if (status != RPC_SUCCESS)
857 error (rpcerr);
858
c5aa993b 859 return (int) fp;
c906108c
SS
860}
861
862/* Establish an RPC connection with the VxWorks target system.
863 Calls error () if unable to establish connection. */
864
865static void
fba45db2 866net_connect (char *host)
c906108c
SS
867{
868 struct sockaddr_in destAddr;
869 struct hostent *destHost;
870 unsigned long addr;
871
872 /* Get the internet address for the given host. Allow a numeric
873 IP address or a hostname. */
874
875 addr = inet_addr (host);
876 if (addr == -1)
877 {
878 destHost = (struct hostent *) gethostbyname (host);
879 if (destHost == NULL)
880 /* FIXME: Probably should include hostname here in quotes.
881 For example if the user types "target vxworks vx960 " it should
882 say "Invalid host `vx960 '." not just "Invalid hostname". */
883 error ("Invalid hostname. Couldn't find remote host address.");
c5aa993b 884 addr = *(unsigned long *) destHost->h_addr;
c906108c
SS
885 }
886
887 memset (&destAddr, '\0', sizeof (destAddr));
888
889 destAddr.sin_addr.s_addr = addr;
c5aa993b
JM
890 destAddr.sin_family = AF_INET;
891 destAddr.sin_port = 0; /* set to actual port that remote
892 ptrace is listening on. */
c906108c
SS
893
894 /* Create a tcp client transport on which to issue
895 calls to the remote ptrace server. */
896
897 ptraceSock = RPC_ANYSOCK;
898 pClient = clnttcp_create (&destAddr, RDBPROG, RDBVERS, &ptraceSock, 0, 0);
899 /* FIXME, here is where we deal with different version numbers of the
900 proto */
901
902 if (pClient == NULL)
903 {
904 clnt_pcreateerror ("\tnet_connect");
905 error ("Couldn't connect to remote target.");
906 }
907}
908\f
909/* Sleep for the specified number of milliseconds
910 * (assumed to be less than 1000).
911 * If select () is interrupted, returns immediately;
912 * takes an error exit if select () fails for some other reason.
913 */
914
915static void
fba45db2 916sleep_ms (long ms)
c906108c
SS
917{
918 struct timeval select_timeout;
919 int status;
920
921 select_timeout.tv_sec = 0;
922 select_timeout.tv_usec = ms * 1000;
923
924 status = select (0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0,
925 &select_timeout);
926
927 if (status < 0 && errno != EINTR)
928 perror_with_name ("select");
929}
930
931static int
fba45db2 932vx_wait (int pid_to_wait_for, struct target_waitstatus *status)
c906108c
SS
933{
934 register int pid;
935 RDB_EVENT rdbEvent;
936 int quit_failed;
937
938 do
939 {
940 /* If CTRL-C is hit during this loop,
c5aa993b 941 suspend the inferior process. */
c906108c
SS
942
943 quit_failed = 0;
944 if (quit_flag)
945 {
946 quit_failed = (net_quit () == -1);
947 quit_flag = 0;
948 }
949
950 /* If a net_quit () or net_wait () call has failed,
c5aa993b
JM
951 allow the user to break the connection with the target.
952 We can't simply error () out of this loop, since the
953 data structures representing the state of the inferior
954 are in an inconsistent state. */
c906108c
SS
955
956 if (quit_failed || net_wait (&rdbEvent) == -1)
957 {
958 terminal_ours ();
959 if (query ("Can't %s. Disconnect from target system? ",
960 (quit_failed) ? "suspend remote task"
c5aa993b 961 : "get status of remote task"))
c906108c 962 {
c5aa993b 963 target_mourn_inferior ();
c906108c
SS
964 error ("Use the \"target\" command to reconnect.");
965 }
966 else
967 {
968 terminal_inferior ();
969 continue;
970 }
971 }
c5aa993b 972
c906108c
SS
973 pid = rdbEvent.taskId;
974 if (pid == 0)
975 {
976 sleep_ms (200); /* FIXME Don't kill the network too badly */
977 }
978 else if (pid != inferior_pid)
8e65ff28
AC
979 internal_error (__FILE__, __LINE__,
980 "Bad pid for debugged task: %s\n",
96baa820 981 local_hex_string ((unsigned long) pid));
c5aa993b
JM
982 }
983 while (pid == 0);
c906108c
SS
984
985 /* The mostly likely kind. */
986 status->kind = TARGET_WAITKIND_STOPPED;
987
988 switch (rdbEvent.eventType)
989 {
990 case EVENT_EXIT:
991 status->kind = TARGET_WAITKIND_EXITED;
992 /* FIXME is it possible to distinguish between a
c5aa993b 993 normal vs abnormal exit in VxWorks? */
c906108c
SS
994 status->value.integer = 0;
995 break;
996
997 case EVENT_START:
998 /* Task was just started. */
999 status->value.sig = TARGET_SIGNAL_TRAP;
1000 break;
1001
1002 case EVENT_STOP:
1003 status->value.sig = TARGET_SIGNAL_TRAP;
1004 /* XXX was it stopped by a signal? act accordingly */
1005 break;
1006
1007 case EVENT_BREAK: /* Breakpoint was hit. */
1008 status->value.sig = TARGET_SIGNAL_TRAP;
1009 break;
1010
c5aa993b 1011 case EVENT_SUSPEND: /* Task was suspended, probably by ^C. */
c906108c
SS
1012 status->value.sig = TARGET_SIGNAL_INT;
1013 break;
1014
c5aa993b 1015 case EVENT_BUS_ERR: /* Task made evil nasty reference. */
c906108c
SS
1016 status->value.sig = TARGET_SIGNAL_BUS;
1017 break;
1018
1019 case EVENT_ZERO_DIV: /* Division by zero */
1020 status->value.sig = TARGET_SIGNAL_FPE;
1021 break;
1022
1023 case EVENT_SIGNAL:
1024#ifdef I80960
1025 status->value.sig = i960_fault_to_signal (rdbEvent.sigType);
1026#else
1027 /* Back in the old days, before enum target_signal, this code used
c5aa993b
JM
1028 to add NSIG to the signal number and claim that PRINT_RANDOM_SIGNAL
1029 would take care of it. But PRINT_RANDOM_SIGNAL has never been
1030 defined except on the i960, so I don't really know what we are
1031 supposed to do on other architectures. */
c906108c
SS
1032 status->value.sig = TARGET_SIGNAL_UNKNOWN;
1033#endif
1034 break;
c5aa993b 1035 } /* switch */
c906108c
SS
1036 return pid;
1037}
1038\f
1039static int
fba45db2 1040symbol_stub (char *arg)
c906108c 1041{
1adeb98a 1042 symbol_file_add_main (arg, 0);
c906108c
SS
1043 return 1;
1044}
1045
1046static int
fba45db2 1047add_symbol_stub (char *arg)
c906108c 1048{
c5aa993b 1049 struct ldfile *pLoadFile = (struct ldfile *) arg;
c906108c 1050
c5aa993b 1051 printf_unfiltered ("\t%s: ", pLoadFile->name);
c906108c
SS
1052 vx_add_symbols (pLoadFile->name, 0, pLoadFile->txt_addr,
1053 pLoadFile->data_addr, pLoadFile->bss_addr);
1054 printf_unfiltered ("ok\n");
1055 return 1;
1056}
1057/* Target command for VxWorks target systems.
1058
1059 Used in vxgdb. Takes the name of a remote target machine
1060 running vxWorks and connects to it to initialize remote network
1061 debugging. */
1062
1063static void
fba45db2 1064vx_open (char *args, int from_tty)
c906108c
SS
1065{
1066 extern int close ();
1067 char *bootFile;
1068 extern char *source_path;
1069 struct ldtabl loadTable;
1070 struct ldfile *pLoadFile;
1071 int i;
1072 extern CLIENT *pClient;
1073 int symbols_added = 0;
1074
1075 if (!args)
1076 error_no_arg ("target machine name");
1077
1078 target_preopen (from_tty);
c5aa993b 1079
c906108c
SS
1080 unpush_target (&vx_ops);
1081 printf_unfiltered ("Attaching remote machine across net...\n");
1082 gdb_flush (gdb_stdout);
1083
1084 /* Allow the user to kill the connect attempt by typing ^C.
1085 Wait until the call to target_has_fp () completes before
1086 disallowing an immediate quit, since even if net_connect ()
1087 is successful, the remote debug server might be hung. */
1088
1089 immediate_quit++;
1090
1091 net_connect (args);
1092 target_has_fp = net_check_for_fp ();
1093 printf_filtered ("Connected to %s.\n", args);
1094
1095 immediate_quit--;
1096
1097 push_target (&vx_ops);
1098
1099 /* Save a copy of the target host's name. */
1100 vx_host = savestring (args, strlen (args));
1101
1102 /* Find out the name of the file from which the target was booted
1103 and load its symbol table. */
1104
1105 printf_filtered ("Looking in Unix path for all loaded modules:\n");
1106 bootFile = NULL;
1107 if (!net_get_boot_file (&bootFile))
1108 {
1109 if (*bootFile)
1110 {
1111 printf_filtered ("\t%s: ", bootFile);
1112 /* This assumes that the kernel is never relocated. Hope that is an
1113 accurate assumption. */
1114 if (catch_errors
1115 (symbol_stub,
1116 bootFile,
1117 "Error while reading symbols from boot file:\n",
1118 RETURN_MASK_ALL))
1119 puts_filtered ("ok\n");
1120 }
1121 else if (from_tty)
1122 printf_unfiltered ("VxWorks kernel symbols not loaded.\n");
1123 }
1124 else
1125 error ("Can't retrieve boot file name from target machine.");
1126
1127 clnt_freeres (pClient, xdr_wrapstring, &bootFile);
1128
1129 if (net_get_symbols (&loadTable) != 0)
1130 error ("Can't read loaded modules from target machine");
1131
c5aa993b 1132 i = 0 - 1;
c906108c
SS
1133 while (++i < loadTable.tbl_size)
1134 {
c5aa993b
JM
1135 QUIT; /* FIXME, avoids clnt_freeres below: mem leak */
1136 pLoadFile = &loadTable.tbl_ent[i];
c906108c 1137#ifdef WRS_ORIG
c5aa993b
JM
1138 {
1139 register int desc;
1140 struct cleanup *old_chain;
1141 char *fullname = NULL;
1142
1143 desc = openp (source_path, 0, pLoadFile->name, O_RDONLY, 0, &fullname);
1144 if (desc < 0)
1145 perror_with_name (pLoadFile->name);
1146 old_chain = make_cleanup (close, desc);
1147 add_file_at_addr (fullname, desc, pLoadFile->txt_addr, pLoadFile->data_addr,
1148 pLoadFile->bss_addr);
1149 do_cleanups (old_chain);
1150 }
c906108c
SS
1151#else
1152 /* FIXME: Is there something better to search than the PATH? (probably
c5aa993b
JM
1153 not the source path, since source might be in different directories
1154 than objects. */
c906108c 1155
c5aa993b 1156 if (catch_errors (add_symbol_stub, (char *) pLoadFile, (char *) 0,
c906108c
SS
1157 RETURN_MASK_ALL))
1158 symbols_added = 1;
1159#endif
1160 }
1161 printf_filtered ("Done.\n");
1162
1163 clnt_freeres (pClient, xdr_ldtabl, &loadTable);
1164
1165 /* Getting new symbols may change our opinion about what is
1166 frameless. */
1167 if (symbols_added)
1168 reinit_frame_cache ();
1169}
1170\f
1171/* Takes a task started up outside of gdb and ``attaches'' to it.
1172 This stops it cold in its tracks and allows us to start tracing it. */
1173
1174static void
fba45db2 1175vx_attach (char *args, int from_tty)
c906108c
SS
1176{
1177 unsigned long pid;
1178 char *cptr = 0;
1179 Rptrace ptrace_in;
1180 Ptrace_return ptrace_out;
1181 int status;
1182
1183 if (!args)
1184 error_no_arg ("process-id to attach");
1185
1186 pid = strtoul (args, &cptr, 0);
1187 if ((cptr == args) || (*cptr != '\0'))
1188 error ("Invalid process-id -- give a single number in decimal or 0xhex");
1189
1190 if (from_tty)
1191 printf_unfiltered ("Attaching pid %s.\n",
c5aa993b 1192 local_hex_string ((unsigned long) pid));
c906108c 1193
c5aa993b
JM
1194 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
1195 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
c906108c
SS
1196 ptrace_in.pid = pid;
1197
1198 status = net_ptrace_clnt_call (PTRACE_ATTACH, &ptrace_in, &ptrace_out);
1199 if (status == -1)
1200 error (rpcerr);
1201 if (ptrace_out.status == -1)
1202 {
1203 errno = ptrace_out.errno_num;
1204 perror_with_name ("Attaching remote process");
1205 }
1206
1207 /* It worked... */
1208
1209 inferior_pid = pid;
1210 push_target (&vx_run_ops);
1211
1212 if (vx_running)
b8c9b27d 1213 xfree (vx_running);
c906108c
SS
1214 vx_running = 0;
1215}
1216
1217/* detach_command --
1218 takes a program previously attached to and detaches it.
1219 The program resumes execution and will no longer stop
1220 on signals, etc. We better not have left any breakpoints
1221 in the program or it'll die when it hits one. For this
1222 to work, it may be necessary for the process to have been
1223 previously attached. It *might* work if the program was
1224 started via the normal ptrace (PTRACE_TRACEME). */
1225
1226static void
fba45db2 1227vx_detach (char *args, int from_tty)
c906108c
SS
1228{
1229 Rptrace ptrace_in;
1230 Ptrace_return ptrace_out;
1231 int signal = 0;
1232 int status;
1233
1234 if (args)
1235 error ("Argument given to VxWorks \"detach\".");
1236
1237 if (from_tty)
c5aa993b
JM
1238 printf_unfiltered ("Detaching pid %s.\n",
1239 local_hex_string ((unsigned long) inferior_pid));
c906108c 1240
c5aa993b 1241 if (args) /* FIXME, should be possible to leave suspended */
c906108c 1242 signal = atoi (args);
c5aa993b
JM
1243
1244 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
1245 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
c906108c
SS
1246 ptrace_in.pid = inferior_pid;
1247
1248 status = net_ptrace_clnt_call (PTRACE_DETACH, &ptrace_in, &ptrace_out);
1249 if (status == -1)
1250 error (rpcerr);
1251 if (ptrace_out.status == -1)
1252 {
1253 errno = ptrace_out.errno_num;
1254 perror_with_name ("Detaching VxWorks process");
1255 }
1256
1257 inferior_pid = 0;
c5aa993b 1258 pop_target (); /* go back to non-executing VxWorks connection */
c906108c
SS
1259}
1260
1261/* vx_kill -- takes a running task and wipes it out. */
1262
1263static void
fba45db2 1264vx_kill (void)
c906108c
SS
1265{
1266 Rptrace ptrace_in;
1267 Ptrace_return ptrace_out;
1268 int status;
1269
c5aa993b 1270 printf_unfiltered ("Killing pid %s.\n", local_hex_string ((unsigned long) inferior_pid));
c906108c 1271
c5aa993b
JM
1272 memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
1273 memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
c906108c
SS
1274 ptrace_in.pid = inferior_pid;
1275
1276 status = net_ptrace_clnt_call (PTRACE_KILL, &ptrace_in, &ptrace_out);
1277 if (status == -1)
1278 warning (rpcerr);
1279 else if (ptrace_out.status == -1)
1280 {
1281 errno = ptrace_out.errno_num;
1282 perror_with_name ("Killing VxWorks process");
1283 }
1284
1285 /* If it gives good status, the process is *gone*, no events remain.
1286 If the kill failed, assume the process is gone anyhow. */
1287 inferior_pid = 0;
c5aa993b 1288 pop_target (); /* go back to non-executing VxWorks connection */
c906108c
SS
1289}
1290
1291/* Clean up from the VxWorks process target as it goes away. */
1292
1293static void
fba45db2 1294vx_proc_close (int quitting)
c906108c
SS
1295{
1296 inferior_pid = 0; /* No longer have a process. */
1297 if (vx_running)
b8c9b27d 1298 xfree (vx_running);
c906108c
SS
1299 vx_running = 0;
1300}
1301\f
1302/* Make an RPC call to the VxWorks target.
1303 Returns RPC status. */
1304
1305static enum clnt_stat
fba45db2
KB
1306net_clnt_call (enum ptracereq procNum, xdrproc_t inProc, char *in,
1307 xdrproc_t outProc, char *out)
c906108c
SS
1308{
1309 enum clnt_stat status;
c5aa993b 1310
c906108c
SS
1311 status = clnt_call (pClient, procNum, inProc, in, outProc, out, rpcTimeout);
1312
1313 if (status != RPC_SUCCESS)
c5aa993b 1314 clnt_perrno (status);
c906108c
SS
1315
1316 return status;
1317}
1318
1319/* Clean up before losing control. */
1320
1321static void
fba45db2 1322vx_close (int quitting)
c906108c
SS
1323{
1324 if (pClient)
1325 clnt_destroy (pClient); /* The net connection */
1326 pClient = 0;
1327
1328 if (vx_host)
b8c9b27d 1329 xfree (vx_host); /* The hostname */
c906108c
SS
1330 vx_host = 0;
1331}
1332
1333/* A vxprocess target should be started via "run" not "target". */
c5aa993b 1334/*ARGSUSED */
c906108c 1335static void
fba45db2 1336vx_proc_open (char *name, int from_tty)
c906108c
SS
1337{
1338 error ("Use the \"run\" command to start a VxWorks process.");
1339}
1340
1341static void
fba45db2 1342init_vx_ops (void)
c906108c
SS
1343{
1344 vx_ops.to_shortname = "vxworks";
1345 vx_ops.to_longname = "VxWorks target memory via RPC over TCP/IP";
1346 vx_ops.to_doc = "Use VxWorks target memory. \n\
1347Specify the name of the machine to connect to.";
1348 vx_ops.to_open = vx_open;
1349 vx_ops.to_close = vx_close;
1350 vx_ops.to_attach = vx_attach;
1351 vx_ops.to_xfer_memory = vx_xfer_memory;
1352 vx_ops.to_files_info = vx_files_info;
1353 vx_ops.to_load = vx_load_command;
1354 vx_ops.to_lookup_symbol = vx_lookup_symbol;
1355 vx_ops.to_create_inferior = vx_create_inferior;
1356 vx_ops.to_stratum = core_stratum;
1357 vx_ops.to_has_all_memory = 1;
1358 vx_ops.to_has_memory = 1;
c5aa993b 1359 vx_ops.to_magic = OPS_MAGIC; /* Always the last thing */
c906108c
SS
1360};
1361
1362static void
fba45db2 1363init_vx_run_ops (void)
c906108c
SS
1364{
1365 vx_run_ops.to_shortname = "vxprocess";
1366 vx_run_ops.to_longname = "VxWorks process";
1367 vx_run_ops.to_doc = "VxWorks process; started by the \"run\" command.";
1368 vx_run_ops.to_open = vx_proc_open;
1369 vx_run_ops.to_close = vx_proc_close;
1370 vx_run_ops.to_detach = vx_detach;
1371 vx_run_ops.to_resume = vx_resume;
1372 vx_run_ops.to_wait = vx_wait;
1373 vx_run_ops.to_fetch_registers = vx_read_register;
1374 vx_run_ops.to_store_registers = vx_write_register;
1375 vx_run_ops.to_prepare_to_store = vx_prepare_to_store;
1376 vx_run_ops.to_xfer_memory = vx_xfer_memory;
1377 vx_run_ops.to_files_info = vx_run_files_info;
1378 vx_run_ops.to_insert_breakpoint = vx_insert_breakpoint;
1379 vx_run_ops.to_remove_breakpoint = vx_remove_breakpoint;
1380 vx_run_ops.to_kill = vx_kill;
1381 vx_run_ops.to_load = vx_load_command;
1382 vx_run_ops.to_lookup_symbol = vx_lookup_symbol;
c5aa993b 1383 vx_run_ops.to_mourn_inferior = vx_mourn_inferior;
c906108c
SS
1384 vx_run_ops.to_stratum = process_stratum;
1385 vx_run_ops.to_has_memory = 1;
1386 vx_run_ops.to_has_stack = 1;
1387 vx_run_ops.to_has_registers = 1;
c5aa993b
JM
1388 vx_run_ops.to_has_execution = 1;
1389 vx_run_ops.to_magic = OPS_MAGIC;
c906108c
SS
1390}
1391\f
1392void
fba45db2 1393_initialize_vx (void)
c906108c
SS
1394{
1395 init_vx_ops ();
1396 add_target (&vx_ops);
1397 init_vx_run_ops ();
1398 add_target (&vx_run_ops);
1399
1400 add_show_from_set
1401 (add_set_cmd ("vxworks-timeout", class_support, var_uinteger,
1402 (char *) &rpcTimeout.tv_sec,
1403 "Set seconds to wait for rpc calls to return.\n\
1404Set the number of seconds to wait for rpc calls to return.", &setlist),
1405 &showlist);
1406}
This page took 0.153186 seconds and 4 git commands to generate.