summaryrefslogtreecommitdiff
path: root/gdb/maint.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2001-12-20 21:03:03 +0000
committerMichael Snyder <msnyder@specifix.com>2001-12-20 21:03:03 +0000
commit04407b14ba6eab9c3ab5acaf5b8128b1cd52d5c6 (patch)
treef93b4cb36ac209c3dbd1354eca3a7d7162434186 /gdb/maint.c
parent2132be3b51c254b732ee5262de0d97b269dc5fd9 (diff)
downloadgdb-04407b14ba6eab9c3ab5acaf5b8128b1cd52d5c6.tar.gz
2001-12-20 Michael Snyder <msnyder@redhat.com>
* maint.c (maintenance_info_sections): Pass string argument to print_section_table, so that it can be used to select sections. (print_section_table): Change PTR to void *. Look at string arg to select sections by name and by flag attributes. (match_bfd_flags): New function. (print_bfd_flags): New function.
Diffstat (limited to 'gdb/maint.c')
-rw-r--r--gdb/maint.c100
1 files changed, 78 insertions, 22 deletions
diff --git a/gdb/maint.c b/gdb/maint.c
index 31f97fc4f30..56f19f32c8a 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -52,7 +52,7 @@ static void maintenance_space_display (char *, int);
static void maintenance_info_command (char *, int);
-static void print_section_table (bfd *, asection *, PTR);
+static void print_section_table (bfd *, asection *, void *);
static void maintenance_info_sections (char *, int);
@@ -186,27 +186,52 @@ maintenance_info_command (char *arg, int from_tty)
help_list (maintenanceinfolist, "maintenance info ", -1, gdb_stdout);
}
-static void
-print_section_table (bfd *abfd, asection *asect, PTR ignore)
+static int
+match_bfd_flags (char *string, flagword flags)
{
- flagword flags;
-
- flags = bfd_get_section_flags (abfd, asect);
+ if (flags & SEC_ALLOC)
+ if (strstr (string, "ALLOC"))
+ return 1;
+ if (flags & SEC_LOAD)
+ if (strstr (string, "LOAD"))
+ return 1;
+ if (flags & SEC_RELOC)
+ if (strstr (string, "RELOC"))
+ return 1;
+ if (flags & SEC_READONLY)
+ if (strstr (string, "READONLY"))
+ return 1;
+ if (flags & SEC_CODE)
+ if (strstr (string, "CODE"))
+ return 1;
+ if (flags & SEC_DATA)
+ if (strstr (string, "DATA"))
+ return 1;
+ if (flags & SEC_ROM)
+ if (strstr (string, "ROM"))
+ return 1;
+ if (flags & SEC_CONSTRUCTOR)
+ if (strstr (string, "CONSTRUCTOR"))
+ return 1;
+ if (flags & SEC_HAS_CONTENTS)
+ if (strstr (string, "HAS_CONTENTS"))
+ return 1;
+ if (flags & SEC_NEVER_LOAD)
+ if (strstr (string, "NEVER_LOAD"))
+ return 1;
+ if (flags & SEC_COFF_SHARED_LIBRARY)
+ if (strstr (string, "COFF_SHARED_LIBRARY"))
+ return 1;
+ if (flags & SEC_IS_COMMON)
+ if (strstr (string, "IS_COMMON"))
+ return 1;
- /* 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));
+ return 0;
+}
+static void
+print_bfd_flags (flagword flags)
+{
if (flags & SEC_ALLOC)
printf_filtered (" ALLOC");
if (flags & SEC_LOAD)
@@ -231,8 +256,39 @@ print_section_table (bfd *abfd, asection *asect, PTR ignore)
printf_filtered (" COFF_SHARED_LIBRARY");
if (flags & SEC_IS_COMMON)
printf_filtered (" IS_COMMON");
+}
+
+static void
+print_section_table (bfd *abfd, asection *asect, void *arg)
+{
+ flagword flags;
+ char *string = arg;
- printf_filtered ("\n");
+ 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");
+ }
}
/* ARGSUSED */
@@ -245,7 +301,7 @@ maintenance_info_sections (char *arg, int from_tty)
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, 0);
+ bfd_map_over_sections (exec_bfd, print_section_table, arg);
}
if (core_bfd)
@@ -254,7 +310,7 @@ maintenance_info_sections (char *arg, int from_tty)
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, 0);
+ bfd_map_over_sections (core_bfd, print_section_table, arg);
}
}