Tue Oct 29 16:56:01 1996 Geoffrey Noer <noer@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / exec.c
CommitLineData
bd5635a1 1/* Work with executable files, for GDB.
b83ed019 2 Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
bd5635a1
RP
3
4This file is part of GDB.
5
bdbd5f50 6This program is free software; you can redistribute it and/or modify
bd5635a1 7it under the terms of the GNU General Public License as published by
bdbd5f50
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
bd5635a1 10
bdbd5f50 11This program is distributed in the hope that it will be useful,
bd5635a1
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
bdbd5f50 17along with this program; if not, write to the Free Software
3f17fed8 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
bd5635a1 19
bd5635a1 20#include "defs.h"
bd5635a1
RP
21#include "frame.h"
22#include "inferior.h"
23#include "target.h"
bdbd5f50 24#include "gdbcmd.h"
b02fd8ca 25#include "language.h"
806f810b
SS
26#include "symfile.h"
27#include "objfiles.h"
bd5635a1
RP
28
29#ifdef USG
30#include <sys/types.h>
31#endif
32
33#include <sys/param.h>
34#include <fcntl.h>
2b576293 35#include "gdb_string.h"
bd5635a1
RP
36
37#include "gdbcore.h"
38
f2ebc25f 39#include <ctype.h>
2b576293 40#include "gdb_stat.h"
a8e033f2
SG
41#ifndef O_BINARY
42#define O_BINARY 0
43#endif
bd5635a1 44
806f810b
SS
45#include "xcoffsolib.h"
46
47struct vmap *map_vmap PARAMS ((bfd *, bfd *));
48
be772100
JG
49/* Prototypes for local functions */
50
806f810b 51static void add_to_section_table PARAMS ((bfd *, sec_ptr, PTR));
be772100 52
806f810b 53static void exec_close PARAMS ((int));
be772100 54
806f810b 55static void file_command PARAMS ((char *, int));
be772100 56
806f810b 57static void set_section_command PARAMS ((char *, int));
be772100 58
806f810b 59static void exec_files_info PARAMS ((struct target_ops *));
be772100 60
b607efe7
FF
61static void bfdsec_to_vmap PARAMS ((bfd *, sec_ptr, PTR));
62
63static int ignore PARAMS ((CORE_ADDR, char *));
64
be772100 65extern int info_verbose;
bd5635a1
RP
66
67/* The Binary File Descriptor handle for the executable file. */
68
69bfd *exec_bfd = NULL;
70
bdbd5f50 71/* Whether to open exec and core files read-only or read-write. */
bd5635a1 72
bdbd5f50 73int write_files = 0;
bd5635a1 74
7730bd5a
JG
75/* Text start and end addresses (KLUDGE) if needed */
76
dad0e12d 77#ifdef NEED_TEXT_START_END
7730bd5a
JG
78CORE_ADDR text_start = 0;
79CORE_ADDR text_end = 0;
80#endif
81
806f810b
SS
82struct vmap *vmap;
83
bd5635a1
RP
84/* Forward decl */
85
86extern struct target_ops exec_ops;
87
bdbd5f50 88/* ARGSUSED */
be772100 89static void
bd5635a1
RP
90exec_close (quitting)
91 int quitting;
92{
806f810b
SS
93 int need_symtab_cleanup = 0;
94 struct vmap *vp, *nxt;
95
96 for (nxt = vmap; nxt != NULL; )
97 {
98 vp = nxt;
99 nxt = vp->nxt;
100
101 /* if there is an objfile associated with this bfd,
102 free_objfile() will do proper cleanup of objfile *and* bfd. */
103
104 if (vp->objfile)
105 {
106 free_objfile (vp->objfile);
107 need_symtab_cleanup = 1;
108 }
109 else if (vp->bfd != exec_bfd)
e7b5942b
JK
110 /* FIXME-leak: We should be freeing vp->name too, I think. */
111 if (!bfd_close (vp->bfd))
112 warning ("cannot close \"%s\": %s",
113 vp->name, bfd_errmsg (bfd_get_error ()));
806f810b
SS
114
115 /* FIXME: This routine is #if 0'd in symfile.c. What should we
116 be doing here? Should we just free everything in
e7b5942b
JK
117 vp->objfile->symtabs? Should free_objfile do that?
118 FIXME-as-well: free_objfile already free'd vp->name, so it isn't
119 valid here. */
806f810b
SS
120 free_named_symtabs (vp->name);
121 free (vp);
122 }
e7b5942b 123
806f810b
SS
124 vmap = NULL;
125
126 if (exec_bfd)
127 {
128 char *name = bfd_get_filename (exec_bfd);
129
e7b5942b
JK
130 if (!bfd_close (exec_bfd))
131 warning ("cannot close \"%s\": %s",
132 name, bfd_errmsg (bfd_get_error ()));
806f810b
SS
133 free (name);
134 exec_bfd = NULL;
135 }
136
137 if (exec_ops.to_sections)
138 {
139 free ((PTR)exec_ops.to_sections);
140 exec_ops.to_sections = NULL;
141 exec_ops.to_sections_end = NULL;
142 }
bd5635a1
RP
143}
144
be772100
JG
145/* Process the first arg in ARGS as the new exec file.
146
147 Note that we have to explicitly ignore additional args, since we can
148 be called from file_command(), which also calls symbol_file_command()
149 which can take multiple args. */
150
bd5635a1 151void
be772100
JG
152exec_file_command (args, from_tty)
153 char *args;
bd5635a1
RP
154 int from_tty;
155{
be772100
JG
156 char **argv;
157 char *filename;
158
f2fc6e7a 159 target_preopen (from_tty);
bd5635a1
RP
160
161 /* Remove any previous exec file. */
162 unpush_target (&exec_ops);
163
164 /* Now open and digest the file the user requested, if any. */
165
be772100 166 if (args)
bd5635a1
RP
167 {
168 char *scratch_pathname;
169 int scratch_chan;
170
be772100 171 /* Scan through the args and pick up the first non option arg
806f810b
SS
172 as the filename. */
173
174 argv = buildargv (args);
175 if (argv == NULL)
176 nomem (0);
be772100 177
be772100
JG
178 make_cleanup (freeargv, (char *) argv);
179
180 for (; (*argv != NULL) && (**argv == '-'); argv++) {;}
181 if (*argv == NULL)
806f810b 182 error ("no exec file name was specified");
be772100
JG
183
184 filename = tilde_expand (*argv);
bd5635a1
RP
185 make_cleanup (free, filename);
186
bdbd5f50 187 scratch_chan = openp (getenv ("PATH"), 1, filename,
a8e033f2 188 write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0,
bd5635a1 189 &scratch_pathname);
3f17fed8
GN
190#if defined(__GO32__) || defined(__WIN32__)
191 if (scratch_chan < 0)
192 {
193 char *exename = alloca (strlen (filename) + 5);
194 strcat (strcpy (exename, filename), ".exe");
195 scratch_chan = openp (getenv ("PATH"), 1, exename, write_files ?
196 O_RDWR|O_BINARY : O_RDONLY|O_BINARY, 0, &scratch_pathname);
197 }
198#endif
bd5635a1
RP
199 if (scratch_chan < 0)
200 perror_with_name (filename);
b1eaba9a 201 exec_bfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);
3f17fed8 202
bd5635a1 203 if (!exec_bfd)
806f810b 204 error ("\"%s\": could not open as an executable file: %s",
c4a081e1 205 scratch_pathname, bfd_errmsg (bfd_get_error ()));
3f17fed8
GN
206
207 /* At this point, scratch_pathname and exec_bfd->name both point to the
208 same malloc'd string. However exec_close() will attempt to free it
209 via the exec_bfd->name pointer, so we need to make another copy and
210 leave exec_bfd as the new owner of the original copy. */
211 scratch_pathname = strdup (scratch_pathname);
212 make_cleanup (free, scratch_pathname);
213
bd5635a1 214 if (!bfd_check_format (exec_bfd, bfd_object))
b02fd8ca
JK
215 {
216 /* Make sure to close exec_bfd, or else "run" might try to use
217 it. */
218 exec_close (0);
806f810b
SS
219 error ("\"%s\": not in executable format: %s",
220 scratch_pathname, bfd_errmsg (bfd_get_error ()));
221 }
222
223 /* FIXME - This should only be run for RS6000, but the ifdef is a poor
224 way to accomplish. */
225#ifdef IBM6000_TARGET
226 /* Setup initial vmap. */
227
228 map_vmap (exec_bfd, 0);
229 if (vmap == NULL)
230 {
231 /* Make sure to close exec_bfd, or else "run" might try to use
232 it. */
233 exec_close (0);
234 error ("\"%s\": can't find the file sections: %s",
c4a081e1 235 scratch_pathname, bfd_errmsg (bfd_get_error ()));
b02fd8ca 236 }
806f810b 237#endif /* IBM6000_TARGET */
bd5635a1 238
be772100
JG
239 if (build_section_table (exec_bfd, &exec_ops.to_sections,
240 &exec_ops.to_sections_end))
b02fd8ca
JK
241 {
242 /* Make sure to close exec_bfd, or else "run" might try to use
243 it. */
244 exec_close (0);
806f810b
SS
245 error ("\"%s\": can't find the file sections: %s",
246 scratch_pathname, bfd_errmsg (bfd_get_error ()));
b02fd8ca 247 }
bd5635a1 248
dad0e12d 249#ifdef NEED_TEXT_START_END
b02fd8ca
JK
250
251 /* text_end is sometimes used for where to put call dummies. A
252 few ports use these for other purposes too. */
253
7730bd5a
JG
254 {
255 struct section_table *p;
b02fd8ca
JK
256
257 /* Set text_start to the lowest address of the start of any
258 readonly code section and set text_end to the highest
259 address of the end of any readonly code section. */
e7b5942b
JK
260 /* FIXME: The comment above does not match the code. The code
261 checks for sections with are either code *or* readonly. */
b02fd8ca
JK
262
263 text_start = ~(CORE_ADDR)0;
264 text_end = (CORE_ADDR)0;
be772100 265 for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
b83ed019 266 if (bfd_get_section_flags (p->bfd, p->the_bfd_section)
b02fd8ca 267 & (SEC_CODE | SEC_READONLY))
dad0e12d 268 {
b02fd8ca
JK
269 if (text_start > p->addr)
270 text_start = p->addr;
271 if (text_end < p->endaddr)
272 text_end = p->endaddr;
dad0e12d 273 }
7730bd5a
JG
274 }
275#endif
276
bd5635a1
RP
277 validate_files ();
278
b83ed019
ILT
279 set_endian_from_file (exec_bfd);
280
bd5635a1
RP
281 push_target (&exec_ops);
282
283 /* Tell display code (if any) about the changed file name. */
284 if (exec_file_display_hook)
285 (*exec_file_display_hook) (filename);
286 }
287 else if (from_tty)
b02fd8ca 288 printf_unfiltered ("No exec file now.\n");
bd5635a1
RP
289}
290
291/* Set both the exec file and the symbol file, in one command.
292 What a novelty. Why did GDB go through four major releases before this
293 command was added? */
294
be772100 295static void
bd5635a1
RP
296file_command (arg, from_tty)
297 char *arg;
298 int from_tty;
299{
300 /* FIXME, if we lose on reading the symbol file, we should revert
301 the exec file, but that's rough. */
302 exec_file_command (arg, from_tty);
303 symbol_file_command (arg, from_tty);
304}
305
306\f
bdbd5f50
JG
307/* Locate all mappable sections of a BFD file.
308 table_pp_char is a char * to get it through bfd_map_over_sections;
309 we cast it back to its proper type. */
bd5635a1 310
be772100 311static void
bdbd5f50 312add_to_section_table (abfd, asect, table_pp_char)
bd5635a1
RP
313 bfd *abfd;
314 sec_ptr asect;
be772100 315 PTR table_pp_char;
bd5635a1 316{
bdbd5f50 317 struct section_table **table_pp = (struct section_table **)table_pp_char;
bd5635a1
RP
318 flagword aflag;
319
320 aflag = bfd_get_section_flags (abfd, asect);
c4a081e1 321 if (!(aflag & SEC_ALLOC))
bd5635a1 322 return;
dad0e12d
JG
323 if (0 == bfd_section_size (abfd, asect))
324 return;
bdbd5f50 325 (*table_pp)->bfd = abfd;
b83ed019 326 (*table_pp)->the_bfd_section = asect;
bd5635a1
RP
327 (*table_pp)->addr = bfd_section_vma (abfd, asect);
328 (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect);
329 (*table_pp)++;
330}
331
be772100
JG
332/* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
333 Returns 0 if OK, 1 on error. */
334
bd5635a1
RP
335int
336build_section_table (some_bfd, start, end)
337 bfd *some_bfd;
338 struct section_table **start, **end;
339{
340 unsigned count;
341
342 count = bfd_count_sections (some_bfd);
777bef06 343 if (*start)
be772100 344 free ((PTR)*start);
bd5635a1
RP
345 *start = (struct section_table *) xmalloc (count * sizeof (**start));
346 *end = *start;
bdbd5f50 347 bfd_map_over_sections (some_bfd, add_to_section_table, (char *)end);
bd5635a1
RP
348 if (*end > *start + count)
349 abort();
350 /* We could realloc the table, but it probably loses for most files. */
351 return 0;
352}
353\f
806f810b
SS
354static void
355bfdsec_to_vmap(abfd, sect, arg3)
356 bfd *abfd;
357 sec_ptr sect;
358 PTR arg3;
359{
360 struct vmap_and_bfd *vmap_bfd = (struct vmap_and_bfd *) arg3;
361 struct vmap *vp;
362
363 vp = vmap_bfd->pvmap;
364
365 if ((bfd_get_section_flags (abfd, sect) & SEC_LOAD) == 0)
366 return;
367
368 if (STREQ (bfd_section_name (abfd, sect), ".text"))
369 {
370 vp->tstart = 0;
371 vp->tend = vp->tstart + bfd_section_size (abfd, sect);
372
373 /* When it comes to this adjustment value, in contrast to our previous
374 belief shared objects should behave the same as the main load segment.
375 This is the offset from the beginning of text section to the first
376 real instruction. */
377
378 vp->tadj = sect->filepos - bfd_section_vma (abfd, sect);
379 }
380 else if (STREQ (bfd_section_name (abfd, sect), ".data"))
381 {
382 vp->dstart = 0;
383 vp->dend = vp->dstart + bfd_section_size (abfd, sect);
384 }
385 /* Silently ignore other types of sections. (FIXME?) */
386}
387
388/* Make a vmap for ABFD which might be a member of the archive ARCH.
389 Return the new vmap. */
390
391struct vmap *
392map_vmap (abfd, arch)
393 bfd *abfd;
394 bfd *arch;
395{
396 struct vmap_and_bfd vmap_bfd;
397 struct vmap *vp, **vpp;
398
e7b5942b 399 vp = (struct vmap *) xmalloc (sizeof (*vp));
806f810b
SS
400 memset ((char *) vp, '\0', sizeof (*vp));
401 vp->nxt = 0;
402 vp->bfd = abfd;
403 vp->name = bfd_get_filename (arch ? arch : abfd);
404 vp->member = arch ? bfd_get_filename (abfd) : "";
405
406 vmap_bfd.pbfd = arch;
407 vmap_bfd.pvmap = vp;
408 bfd_map_over_sections (abfd, bfdsec_to_vmap, &vmap_bfd);
409
410 /* Find the end of the list and append. */
411 for (vpp = &vmap; *vpp; vpp = &(*vpp)->nxt)
412 ;
413 *vpp = vp;
414
415 return vp;
416}
417\f
bd5635a1
RP
418/* Read or write the exec file.
419
bdbd5f50 420 Args are address within a BFD file, address within gdb address-space,
bd5635a1
RP
421 length, and a flag indicating whether to read or write.
422
423 Result is a length:
424
425 0: We cannot handle this address and length.
426 > 0: We have handled N bytes starting at this address.
427 (If N == length, we did it all.) We might be able
428 to handle more bytes beyond this length, but no
429 promises.
430 < 0: We cannot handle this address, but if somebody
431 else handles (-N) bytes, we can start from there.
432
433 The same routine is used to handle both core and exec files;
434 we just tail-call it with more arguments to select between them. */
435
436int
bdbd5f50 437xfer_memory (memaddr, myaddr, len, write, target)
bd5635a1
RP
438 CORE_ADDR memaddr;
439 char *myaddr;
440 int len;
441 int write;
bdbd5f50 442 struct target_ops *target;
bd5635a1
RP
443{
444 boolean res;
445 struct section_table *p;
446 CORE_ADDR nextsectaddr, memend;
be772100 447 boolean (*xfer_fn) PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
bd5635a1
RP
448
449 if (len <= 0)
450 abort();
451
452 memend = memaddr + len;
806f810b 453 xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
bd5635a1
RP
454 nextsectaddr = memend;
455
be772100 456 for (p = target->to_sections; p < target->to_sections_end; p++)
bd5635a1
RP
457 {
458 if (p->addr <= memaddr)
459 if (p->endaddr >= memend)
460 {
461 /* Entire transfer is within this section. */
806f810b
SS
462 res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
463 memaddr - p->addr, len);
b83ed019 464 return (res != 0) ? len : 0;
bd5635a1
RP
465 }
466 else if (p->endaddr <= memaddr)
467 {
468 /* This section ends before the transfer starts. */
469 continue;
470 }
471 else
472 {
473 /* This section overlaps the transfer. Just do half. */
474 len = p->endaddr - memaddr;
806f810b
SS
475 res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
476 memaddr - p->addr, len);
b83ed019 477 return (res != 0) ? len : 0;
bd5635a1
RP
478 }
479 else if (p->addr < nextsectaddr)
480 nextsectaddr = p->addr;
481 }
482
483 if (nextsectaddr >= memend)
484 return 0; /* We can't help */
485 else
486 return - (nextsectaddr - memaddr); /* Next boundary where we can help */
487}
488
bd5635a1
RP
489#ifdef FIXME
490#ifdef REG_STACK_SEGMENT
491/* MOVE TO BFD... */
492 /* Pyramids and AM29000s have an extra segment in the virtual address space
493 for the (control) stack of register-window frames. The AM29000 folk
494 call it the "register stack" rather than the "memory stack". */
495 else if (memaddr >= reg_stack_start && memaddr < reg_stack_end)
496 {
497 i = min (len, reg_stack_end - memaddr);
498 fileptr = memaddr - reg_stack_start + reg_stack_offset;
499 wanna_xfer = coredata;
500 }
501#endif /* REG_STACK_SEGMENT */
117f631e 502#endif /* FIXME */
bd5635a1 503\f
be772100
JG
504void
505print_section_info (t, abfd)
506 struct target_ops *t;
507 bfd *abfd;
bd5635a1
RP
508{
509 struct section_table *p;
510
be772100 511 printf_filtered ("\t`%s', ", bfd_get_filename(abfd));
7d9884b9 512 wrap_here (" ");
be772100 513 printf_filtered ("file type %s.\n", bfd_get_target(abfd));
b83ed019
ILT
514 if (abfd == exec_bfd)
515 {
516 printf_filtered ("\tEntry point: ");
517 print_address_numeric (bfd_get_start_address (abfd), 1, gdb_stdout);
518 printf_filtered ("\n");
519 }
c4a081e1
DM
520 for (p = t->to_sections; p < t->to_sections_end; p++)
521 {
522 /* FIXME-32x64 need a print_address_numeric with field width */
523 printf_filtered ("\t%s", local_hex_string_custom ((unsigned long) p->addr, "08l"));
524 printf_filtered (" - %s", local_hex_string_custom ((unsigned long) p->endaddr, "08l"));
525 if (info_verbose)
526 printf_filtered (" @ %s",
b83ed019
ILT
527 local_hex_string_custom ((unsigned long) p->the_bfd_section->filepos, "08l"));
528 printf_filtered (" is %s", bfd_section_name (p->bfd, p->the_bfd_section));
c4a081e1
DM
529 if (p->bfd != abfd)
530 {
531 printf_filtered (" in %s", bfd_get_filename (p->bfd));
532 }
533 printf_filtered ("\n");
be772100 534 }
bd5635a1
RP
535}
536
be772100
JG
537static void
538exec_files_info (t)
806f810b 539 struct target_ops *t;
be772100
JG
540{
541 print_section_info (t, exec_bfd);
806f810b
SS
542
543 if (vmap)
544 {
545 struct vmap *vp;
546
547 printf_unfiltered ("\tMapping info for file `%s'.\n", vmap->name);
548 printf_unfiltered ("\t %8.8s %8.8s %8.8s %8.8s %8.8s %s\n",
549 "tstart", "tend", "dstart", "dend", "section",
550 "file(member)");
551
552 for (vp = vmap; vp; vp = vp->nxt)
553 printf_unfiltered ("\t0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x %s%s%s%s\n",
554 vp->tstart, vp->tend, vp->dstart, vp->dend, vp->name,
555 *vp->member ? "(" : "", vp->member,
556 *vp->member ? ")" : "");
557 }
be772100
JG
558}
559
f2fc6e7a
JK
560static void
561set_section_command (args, from_tty)
562 char *args;
563 int from_tty;
564{
565 struct section_table *p;
566 char *secname;
567 unsigned seclen;
568 unsigned long secaddr;
569 char secprint[100];
570 long offset;
571
572 if (args == 0)
573 error ("Must specify section name and its virtual address");
574
575 /* Parse out section name */
576 for (secname = args; !isspace(*args); args++) ;
577 seclen = args - secname;
578
579 /* Parse out new virtual address */
580 secaddr = parse_and_eval_address (args);
581
be772100 582 for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++) {
b83ed019
ILT
583 if (!strncmp (secname, bfd_section_name (exec_bfd, p->the_bfd_section), seclen)
584 && bfd_section_name (exec_bfd, p->the_bfd_section)[seclen] == '\0') {
f2fc6e7a
JK
585 offset = secaddr - p->addr;
586 p->addr += offset;
587 p->endaddr += offset;
be772100
JG
588 if (from_tty)
589 exec_files_info(&exec_ops);
f2fc6e7a
JK
590 return;
591 }
592 }
593 if (seclen >= sizeof (secprint))
594 seclen = sizeof (secprint) - 1;
595 strncpy (secprint, secname, seclen);
596 secprint[seclen] = '\0';
597 error ("Section %s not found", secprint);
598}
599
b1eaba9a 600/* If mourn is being called in all the right places, this could be say
b02fd8ca 601 `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
b1eaba9a
SG
602
603static int
604ignore (addr, contents)
605 CORE_ADDR addr;
606 char *contents;
607{
608 return 0;
609}
610
bd5635a1 611struct target_ops exec_ops = {
2b576293
C
612 "exec", /* to_shortname */
613 "Local exec file", /* to_longname */
614 "Use an executable file as a target.\n\
615Specify the filename of the executable file.", /* to_doc */
616 exec_file_command, /* to_open */
617 exec_close, /* to_close */
618 find_default_attach, /* to_attach */
619 0, /* to_detach */
620 0, /* to_resume */
621 0, /* to_wait */
622 0, /* to_fetch_registers */
623 0, /* to_store_registers */
624 0, /* to_prepare_to_store */
625 xfer_memory, /* to_xfer_memory */
626 exec_files_info, /* to_files_info */
627 ignore, /* to_insert_breakpoint */
628 ignore, /* to_remove_breakpoint */
629 0, /* to_terminal_init */
630 0, /* to_terminal_inferior */
631 0, /* to_terminal_ours_for_output */
632 0, /* to_terminal_ours */
633 0, /* to_terminal_info */
634 0, /* to_kill */
635 0, /* to_load */
636 0, /* to_lookup_symbol */
637 find_default_create_inferior, /* to_create_inferior */
638 0, /* to_mourn_inferior */
639 0, /* to_can_run */
640 0, /* to_notice_signals */
641 0, /* to_thread_alive */
642 0, /* to_stop */
643 file_stratum, /* to_stratum */
644 0, /* to_next */
645 0, /* to_has_all_memory */
646 1, /* to_has_memory */
647 0, /* to_has_stack */
648 0, /* to_has_registers */
649 0, /* to_has_execution */
650 0, /* to_sections */
651 0, /* to_sections_end */
652 OPS_MAGIC, /* to_magic */
bd5635a1
RP
653};
654
655void
656_initialize_exec()
657{
b1eaba9a 658 struct cmd_list_element *c;
bd5635a1 659
b1eaba9a
SG
660 c = add_cmd ("file", class_files, file_command,
661 "Use FILE as program to be debugged.\n\
bd5635a1
RP
662It is read for its symbols, for getting the contents of pure memory,\n\
663and it is the program executed when you use the `run' command.\n\
664If FILE cannot be found as specified, your execution directory path\n\
665($PATH) is searched for a command of that name.\n\
b1eaba9a
SG
666No arg means to have no executable file and no symbols.", &cmdlist);
667 c->completer = filename_completer;
bd5635a1 668
b1eaba9a 669 c = add_cmd ("exec-file", class_files, exec_file_command,
bd5635a1
RP
670 "Use FILE as program for getting contents of pure memory.\n\
671If FILE cannot be found as specified, your execution directory path\n\
672is searched for a command of that name.\n\
b1eaba9a
SG
673No arg means have no executable file.", &cmdlist);
674 c->completer = filename_completer;
bd5635a1 675
f2fc6e7a
JK
676 add_com ("section", class_files, set_section_command,
677 "Change the base address of section SECTION of the exec file to ADDR.\n\
678This can be used if the exec file does not contain section addresses,\n\
679(such as in the a.out format), or when the addresses specified in the\n\
680file itself are wrong. Each section must be changed separately. The\n\
681``info files'' command lists all the sections and their addresses.");
682
bdbd5f50
JG
683 add_show_from_set
684 (add_set_cmd ("write", class_support, var_boolean, (char *)&write_files,
685 "Set writing into executable and core files.",
686 &setlist),
687 &showlist);
688
bd5635a1
RP
689 add_target (&exec_ops);
690}
This page took 0.441961 seconds and 4 git commands to generate.