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