From mboxrd@z Thu Jan 1 00:00:00 1970 From: fnf@toadfish.ninemoons.com To: binutils@sourceware.cygnus.com Subject: revised patch for objdump'ing core files Date: Tue, 26 Oct 1999 16:46:00 -0000 Message-id: <199910262354.QAA24845@toadfish.ninemoons.com> X-SW-Source: 1999-10/msg00138.html Some time back, I submitted a patch that allowed objdump to recognize and dump core files. However that patch had a couple of problems with properly handling ambiguously recognized files, particularly bfd_object files. I believe this patch fixes that. This patch is modeled after how display_bfd works in size.c, by moving the actual code to process the bfd out of display_bfd and into a separate function called by display_bfd, once a match is found. Could someone please review this and check it in if it looks OK now? Thanks! -Fred 1999-10-26 Fred Fish * objdump.c (display_bfd): Break into two functions. The actual dumping code moves to dump_bfd. If bfd is not unambiguously recognized as a bfd_object, attempt to dump it as a bfd_core. (dump_bfd): New function. Index: objdump.c =================================================================== RCS file: /cvs/binutils/binutils/binutils/objdump.c,v retrieving revision 1.12 diff -c -p -r1.12 objdump.c *** objdump.c 1999/09/19 22:39:49 1.12 --- objdump.c 1999/10/26 23:33:50 *************** bfd *abfd; *** 2042,2064 **** bfd_print_private_bfd_data (abfd, stdout); } static void ! display_bfd (abfd) bfd *abfd; { - char **matching; - - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) - { - nonfatal (bfd_get_filename (abfd)); - if (bfd_get_error () == bfd_error_file_ambiguously_recognized) - { - list_matching_formats (matching); - free (matching); - } - return; - } - /* If we are adjusting section VMA's, change them all now. Changing the BFD information is a hack. However, we must do it, or bfd_find_nearest_line will not do the right thing. */ --- 2042,2053 ---- bfd_print_private_bfd_data (abfd, stdout); } + /* Dump selected contents of ABFD */ + static void ! dump_bfd (abfd) bfd *abfd; { /* If we are adjusting section VMA's, change them all now. Changing the BFD information is a hack. However, we must do it, or bfd_find_nearest_line will not do the right thing. */ *************** display_bfd (abfd) *** 2131,2136 **** --- 2120,2160 ---- { free (dynsyms); dynsyms = NULL; + } + } + + static void + display_bfd (abfd) + bfd *abfd; + { + char **matching; + + if (bfd_check_format_matches (abfd, bfd_object, &matching)) + { + dump_bfd (abfd); + return; + } + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + nonfatal (bfd_get_filename (abfd)); + list_matching_formats (matching); + free (matching); + return; + } + + if (bfd_check_format_matches (abfd, bfd_core, &matching)) + { + dump_bfd (abfd); + return; + } + + nonfatal (bfd_get_filename (abfd)); + + if (bfd_get_error () == bfd_error_file_ambiguously_recognized) + { + list_matching_formats (matching); + free (matching); } }