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