From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27105 invoked by alias); 20 Dec 2001 22:35:10 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25515 invoked from network); 20 Dec 2001 22:33:48 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 20 Dec 2001 22:33:48 -0000 Received: from reddwarf.cygnus.com (reddwarf.cygnus.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id OAA00951 for ; Thu, 20 Dec 2001 14:33:47 -0800 (PST) Received: (from msnyder@localhost) by reddwarf.cygnus.com (8.11.2/8.11.2) id fBKMUAO31066 for gdb-patches@sources.redhat.com; Thu, 20 Dec 2001 14:30:10 -0800 Date: Thu, 20 Dec 2001 14:35:00 -0000 From: Michael Snyder Message-Id: <200112202230.fBKMUAO31066@reddwarf.cygnus.com> To: gdb-patches@sources.redhat.com Subject: [PATCH] Further extend "maint info sections" cmd with ALLOBJ X-SW-Source: 2001-12/txt/msg00544.txt.bz2 As a further extension, the "maint info sections" command will now accept an argument "ALLOBJ" to iterate over all known object files (which includes shared libraries. You can now do (for instance): (gdb) maint info sect .bss ALLOBJ to see info on the .bss sections of all loaded object files. 2001-12-20 Michael Snyder * maint.c (maintenance_info_sections): Accept new argument 'ALLOBJ', iterate over all object files. (print_section_table): Delete. Replaced by: (print_section_info): New function. (print_bfd_section_info): New function. (print_objfile_section_info): New function. (_initialize_maint_commands): Add help for new features. Index: maint.c =================================================================== RCS file: /cvs/src/src/gdb/maint.c,v retrieving revision 1.17 diff -p -r1.17 maint.c *** maint.c 2001/12/20 21:03:03 1.17 --- maint.c 2001/12/20 22:27:53 *************** print_bfd_flags (flagword flags) *** 259,293 **** } static void ! print_section_table (bfd *abfd, asection *asect, void *arg) ! { ! flagword flags; ! char *string = arg; ! flags = bfd_get_section_flags (abfd, asect); if (string == NULL || *string == '\0' || ! strstr (string, bfd_get_section_name (abfd, asect)) || match_bfd_flags (string, flags)) { ! /* FIXME-32x64: Need print_address_numeric with field width. */ ! printf_filtered (" %s", ! local_hex_string_custom ! ((unsigned long) bfd_section_vma (abfd, asect), ! "08l")); ! printf_filtered ("->%s", ! local_hex_string_custom ! ((unsigned long) (bfd_section_vma (abfd, asect) ! + bfd_section_size (abfd, asect)), ! "08l")); ! printf_filtered (" at %s", ! local_hex_string_custom ! ((unsigned long) asect->filepos, "08l")); ! printf_filtered (": %s", bfd_section_name (abfd, asect)); ! ! print_bfd_flags (flags); ! ! printf_filtered ("\n"); } } --- 259,312 ---- } static void ! print_section_info (const char *name, flagword flags, ! CORE_ADDR addr, CORE_ADDR endaddr, ! unsigned long filepos) ! { ! /* FIXME-32x64: Need print_address_numeric with field width. */ ! printf_filtered (" 0x%s", paddr (addr)); ! printf_filtered ("->0x%s", paddr (endaddr)); ! printf_filtered (" at 0x%s", ! local_hex_string_custom ((unsigned long) filepos, "08l")); ! printf_filtered (": %s", name); ! print_bfd_flags (flags); ! printf_filtered ("\n"); ! } ! ! static void ! print_bfd_section_info (bfd *abfd, ! asection *asect, ! void *arg) ! { ! flagword flags = bfd_get_section_flags (abfd, asect); ! const char *name = bfd_section_name (abfd, asect); ! ! if (arg == NULL || *((char *) arg) == '\0' || ! strstr ((char *) arg, name) || ! match_bfd_flags ((char *) arg, flags)) ! { ! CORE_ADDR addr, endaddr; ! addr = bfd_section_vma (abfd, asect); ! endaddr = addr + bfd_section_size (abfd, asect); ! print_section_info (name, flags, addr, endaddr, asect->filepos); ! } ! } ! ! static void ! print_objfile_section_info (bfd *abfd, ! struct obj_section *asect, ! char *string) ! { ! flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section); ! const char *name = bfd_section_name (abfd, asect->the_bfd_section); if (string == NULL || *string == '\0' || ! strstr (string, name) || match_bfd_flags (string, flags)) { ! print_section_info (name, flags, asect->addr, asect->endaddr, ! asect->the_bfd_section->filepos); } } *************** maintenance_info_sections (char *arg, in *** 301,307 **** printf_filtered (" `%s', ", bfd_get_filename (exec_bfd)); wrap_here (" "); printf_filtered ("file type %s.\n", bfd_get_target (exec_bfd)); ! bfd_map_over_sections (exec_bfd, print_section_table, arg); } if (core_bfd) --- 320,349 ---- printf_filtered (" `%s', ", bfd_get_filename (exec_bfd)); wrap_here (" "); printf_filtered ("file type %s.\n", bfd_get_target (exec_bfd)); ! if (arg && *arg && strstr (arg, "ALLOBJ")) ! { ! struct objfile *ofile; ! struct obj_section *osect; ! ! /* Only this function cares about the 'ALLOBJ' argument; ! if 'ALLOBJ' is the only argument, discard it rather than ! passing it down to print_objfile_section_info (which ! wouldn't know how to handle it). */ ! if (strcmp (arg, "ALLOBJ") == 0) ! arg = NULL; ! ! ALL_OBJFILES (ofile) ! { ! printf_filtered (" Object file: %s\n", ! bfd_get_filename (ofile->obfd)); ! ALL_OBJFILE_OSECTIONS (ofile, osect) ! { ! print_objfile_section_info (ofile->obfd, osect, arg); ! } ! } ! } ! else ! bfd_map_over_sections (exec_bfd, print_bfd_section_info, arg); } if (core_bfd) *************** maintenance_info_sections (char *arg, in *** 310,316 **** printf_filtered (" `%s', ", bfd_get_filename (core_bfd)); wrap_here (" "); printf_filtered ("file type %s.\n", bfd_get_target (core_bfd)); ! bfd_map_over_sections (core_bfd, print_section_table, arg); } } --- 352,358 ---- printf_filtered (" `%s', ", bfd_get_filename (core_bfd)); wrap_here (" "); printf_filtered ("file type %s.\n", bfd_get_target (core_bfd)); ! bfd_map_over_sections (core_bfd, print_bfd_section_info, arg); } } *************** to test internal functions such as the C *** 580,586 **** add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist); add_cmd ("sections", class_maintenance, maintenance_info_sections, ! "List the BFD sections of the exec and core files.", &maintenanceinfolist); add_prefix_cmd ("print", class_maintenance, maintenance_print_command, --- 622,636 ---- add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist); add_cmd ("sections", class_maintenance, maintenance_info_sections, ! "List the BFD sections of the exec and core files. \n ! Arguments may be any combination of:\n\ ! [one or more section names]\n\ ! ALLOC LOAD RELOC READONLY CODE DATA ROM CONSTRUCTOR\n\ ! HAS_CONTENTS NEVER_LOAD COFF_SHARED_LIBRARY IS_COMMON\n\ ! Sections matching any argument will be listed (no argument\n\ ! implies all sections). In addition, the special argument\n\ ! ALLOBJ\n\ ! lists all sections from all object files, including shared libraries.", &maintenanceinfolist); add_prefix_cmd ("print", class_maintenance, maintenance_print_command,