- 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, (file_ptr)0,
- size))
- {
- fetch_core_registers (the_regs, size, 2,
- (unsigned) bfd_section_vma (abfd,reg_sec));
- }
- else
- {
- fprintf_filtered (stderr, "Couldn't fetch register set 2 from core file: %s\n",
- bfd_errmsg (bfd_error));
- }
- }
- registers_fetched();
+ if (reg_sec)
+ {
+ size = bfd_section_size (core_bfd, reg_sec);
+ the_regs = alloca (size);
+ if (cf != NULL &&
+ bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr) 0, size) &&
+ cf->core_read_registers != NULL)
+ {
+ (cf->core_read_registers (the_regs, size, 2,
+ (unsigned) bfd_section_vma (abfd, reg_sec)));
+ }
+ else
+ {
+ fprintf_filtered (gdb_stderr,
+ "Couldn't fetch register set 2 from core file: %s\n",
+ bfd_errmsg (bfd_get_error ()));
+ }
+ }
+ registers_fetched ();
+}
+
+static char *
+core_file_to_sym_file (core)
+ char *core;
+{
+ CONST char *failing_command;
+ char *p;
+ char *temp;
+ bfd *temp_bfd;
+ int scratch_chan;
+
+ if (!core)
+ error ("No core file specified.");
+
+ core = tilde_expand (core);
+ if (core[0] != '/')
+ {
+ temp = concat (current_directory, "/", core, NULL);
+ core = temp;
+ }
+
+ scratch_chan = open (core, write_files ? O_RDWR : O_RDONLY, 0);
+ if (scratch_chan < 0)
+ perror_with_name (core);
+
+ temp_bfd = bfd_fdopenr (core, gnutarget, scratch_chan);
+ if (temp_bfd == NULL)
+ perror_with_name (core);
+
+ if (!bfd_check_format (temp_bfd, bfd_core))
+ {
+ /* Do it after the err msg */
+ /* FIXME: should be checking for errors from bfd_close (for one thing,
+ on error it does not free all the storage associated with the
+ bfd). */
+ make_cleanup ((make_cleanup_func) bfd_close, temp_bfd);
+ error ("\"%s\" is not a core dump: %s",
+ core, bfd_errmsg (bfd_get_error ()));
+ }
+
+ /* Find the data section */
+ if (build_section_table (temp_bfd, &core_ops.to_sections,
+ &core_ops.to_sections_end))
+ error ("\"%s\": Can't find sections: %s",
+ bfd_get_filename (temp_bfd), bfd_errmsg (bfd_get_error ()));
+
+ failing_command = bfd_core_file_failing_command (temp_bfd);
+
+ bfd_close (temp_bfd);
+
+ /* If we found a filename, remember that it is probably saved
+ relative to the executable that created it. If working directory
+ isn't there now, we may not be able to find the executable. Rather
+ than trying to be sauve about finding it, just check if the file
+ exists where we are now. If not, then punt and tell our client
+ we couldn't find the sym file.
+ */
+ p = (char *) failing_command;
+ if ((p != NULL) && (access (p, F_OK) != 0))
+ p = NULL;
+
+ return p;