-/* Read or write the core file.
-
- Args are address within core file, address within gdb address-space,
- length, and a flag indicating whether to read or write.
-
- Result is a length:
-
- 0: We cannot handle this address and length.
- > 0: We have handled N bytes starting at this address.
- (If N == length, we did it all.) We might be able
- to handle more bytes beyond this length, but no
- promises.
- < 0: We cannot handle this address, but if somebody
- else handles (-N) bytes, we can start from there.
-
- The actual work is done by xfer_memory in exec.c, which we share
- in common with exec_xfer_memory(). */
-
-static int
-core_xfer_memory (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
-{
- return xfer_memory (memaddr, myaddr, len, write,
- core_bfd, core_sections, core_sections_end);
-}
-\f
-/* Get the registers out of a core file. This is the machine-
- independent part. Fetch_core_registers is the machine-dependent
- part, typically implemented in the xm-file for each architecture. */
-
-static int
-get_core_registers (regno)
- int regno;
-{
- sec_ptr reg_sec;
- unsigned size;
- char *the_regs;
-
- reg_sec = bfd_get_section_by_name (core_bfd, ".reg");
- size = bfd_section_size (core_bfd, reg_sec);
- the_regs = alloca (size);
- if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
- (unsigned)0, size))
- {
- fetch_core_registers (the_regs, size, 0);
- }
- else
- {
- fprintf (stderr, "Couldn't fetch registers from core file: %s\n",
- bfd_errmsg (bfd_error));
- }
-
- /* Now do it again for the float registers, if they exist. */
- reg_sec = bfd_get_section_by_name (core_bfd, ".reg2");
- if (reg_sec) {
- size = bfd_section_size (core_bfd, reg_sec);
- the_regs = alloca (size);
- if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
- (unsigned)0, size))
- {
- fetch_core_registers (the_regs, size, 2);
- }
- else
- {
- fprintf (stderr, "Couldn't fetch register set 2 from core file: %s\n",
- bfd_errmsg (bfd_error));
- }
- }
- registers_fetched();
- return 0; /* FIXME, what result goes here? */
-}
-\f
-struct target_ops core_ops = {
- "core", "Local core dump file",
- core_open, core_close,
- child_attach, core_detach, 0, 0, /* resume, wait */
- get_core_registers,
- 0, 0, 0, 0, /* store_regs, prepare_to_store, conv_to, conv_from */
- core_xfer_memory, core_files_info,
- 0, 0, /* core_insert_breakpoint, core_remove_breakpoint, */
- 0, 0, 0, 0, 0, /* terminal stuff */
- 0, 0, 0, 0, 0, /* kill, load, add_syms, call fn, lookup sym */
- child_create_inferior, 0, /* mourn_inferior */
- core_stratum, 0, /* next */
- 0, 1, 1, 1, 0, /* all mem, mem, stack, regs, exec */
- OPS_MAGIC, /* Always the last thing */
-};
-