This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Further extend "maint info sections" cmd with ALLOBJ
- From: Michael Snyder <msnyder at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 20 Dec 2001 14:30:10 -0800
- Subject: [PATCH] Further extend "maint info sections" cmd with ALLOBJ
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 <msnyder@redhat.com>
* 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,