Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tristan Gingold <gingold@adacore.com>
Subject: [PATCH 1/4] Really make dwarf2_get_section_info public.
Date: Mon, 23 May 2011 10:29:00 -0000	[thread overview]
Message-ID: <1306146544-3925-2-git-send-email-gingold@adacore.com> (raw)
In-Reply-To: <1306146544-3925-1-git-send-email-gingold@adacore.com>

This patch is a preliminary clean-up.  Instead of using the section name
to get the section info, use an enum literal.

It might be worth going farther and using an array of dwarf2_section_info
in dwarf2_per_objfile (instead of record fields).  I let this decision to
maintainers.

gdb/
2011-05-23  Tristan Gingold  <gingold@adacore.com>

	* symfile.h (enum dwarf2_section_enum): New type.
	(dwarf2_get_section_info): New prototype.
	* dwarf2read.c (dwarf2_get_section_info): Replace parameter
	section_name by sect.  Use a switch to select the info.
	* dwarf2-frame.c (warf2_get_section_info): Remove prototype.
	(dwarf2_build_frame_info): Adjust calls to dwarf2_get_section_info.
---
 gdb/dwarf2-frame.c |   10 ++--------
 gdb/dwarf2read.c   |   20 +++++++++++++-------
 gdb/symfile.h      |   11 +++++++++++
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index fe48713..9c329f9 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -2183,12 +2183,6 @@ Corrupt data in %s:%s; align 8 workaround apparently succeeded"),
   return ret;
 }
 \f
-
-/* Imported from dwarf2read.c.  */
-extern void dwarf2_get_section_info (struct objfile *, const char *,
-				     asection **, gdb_byte **,
-				     bfd_size_type *);
-
 static int
 qsort_fde_cmp (const void *a, const void *b)
 {
@@ -2233,7 +2227,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
   unit->dbase = 0;
   unit->tbase = 0;
 
-  dwarf2_get_section_info (objfile, ".eh_frame",
+  dwarf2_get_section_info (objfile, dwarf2_eh_frame,
                            &unit->dwarf_frame_section,
                            &unit->dwarf_frame_buffer,
                            &unit->dwarf_frame_size);
@@ -2269,7 +2263,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
         }
     }
 
-  dwarf2_get_section_info (objfile, ".debug_frame",
+  dwarf2_get_section_info (objfile, dwarf2_debug_frame,
                            &unit->dwarf_frame_section,
                            &unit->dwarf_frame_buffer,
                            &unit->dwarf_frame_size);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 6558bfe..2003c46 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1636,7 +1636,8 @@ dwarf2_section_size (struct objfile *objfile,
    SECTION_NAME.  */
 
 void
-dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
+dwarf2_get_section_info (struct objfile *objfile,
+                         enum dwarf2_section_enum sect,
                          asection **sectp, gdb_byte **bufp,
                          bfd_size_type *sizep)
 {
@@ -1653,12 +1654,17 @@ dwarf2_get_section_info (struct objfile *objfile, const char *section_name,
       *sizep = 0;
       return;
     }
-  if (section_is_p (section_name, EH_FRAME_SECTION))
-    info = &data->eh_frame;
-  else if (section_is_p (section_name, FRAME_SECTION))
-    info = &data->frame;
-  else
-    gdb_assert_not_reached ("unexpected section");
+  switch (sect)
+    {
+    case dwarf2_debug_frame:
+      info = &data->frame;
+      break;
+    case dwarf2_eh_frame:
+      info = &data->eh_frame;
+      break;
+    default:
+      gdb_assert_not_reached ("unexpected section");
+    }
 
   dwarf2_read_section (objfile, info);
 
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 3544475..83e807c 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -555,6 +555,17 @@ extern struct cleanup *increment_reading_symtab (void);
 
 extern int dwarf2_has_info (struct objfile *);
 
+/* Dwarf2 sections that can be accessed by dwarf2_get_section_info.  */
+enum dwarf2_section_enum {
+  dwarf2_debug_frame,
+  dwarf2_eh_frame
+};
+
+extern void dwarf2_get_section_info (struct objfile *,
+                                     enum dwarf2_section_enum,
+				     asection **, gdb_byte **,
+				     bfd_size_type *);
+
 extern int dwarf2_initialize_objfile (struct objfile *);
 extern void dwarf2_build_psymtabs (struct objfile *);
 extern void dwarf2_build_frame_info (struct objfile *);
-- 
1.7.3.GIT


  parent reply	other threads:[~2011-05-23 10:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 10:29 [RFA] Add dwarf2 support to xcoff (aix) Tristan Gingold
2011-05-23 10:29 ` [PATCH 2/4] dwarf2read.c: handle alternate dwarf2 debug sections name Tristan Gingold
2011-05-23 15:22   ` Tom Tromey
2011-05-23 15:32     ` Tristan Gingold
2011-05-23 15:40   ` Tom Tromey
2011-05-26  7:48     ` Tristan Gingold
2011-05-23 10:29 ` Tristan Gingold [this message]
2011-05-23 15:15   ` [PATCH 1/4] Really make dwarf2_get_section_info public Tom Tromey
2011-05-24 12:41     ` Tristan Gingold
2011-05-23 10:29 ` [PATCH 4/4] bfd.c: hancle aixcoff in bfd_get_sign_extend_vma Tristan Gingold
2011-05-23 10:35 ` [PATCH 3/4] aix: add support for dwarf2 Tristan Gingold
2011-05-23 15:35   ` Tom Tromey
2011-05-23 15:42     ` Tom Tromey
2011-05-23 15:47       ` Tristan Gingold
2011-05-23 15:50   ` Tom Tromey
2011-05-24  7:20     ` Tristan Gingold
2011-05-24 13:37       ` Tom Tromey
2011-05-24 13:44         ` Tristan Gingold
2011-05-24 14:56           ` Tom Tromey
2011-05-24 15:11             ` Tristan Gingold
2011-06-01 15:37         ` Tristan Gingold
2011-06-02 19:11           ` Tom Tromey
2011-06-07 12:32             ` Tristan Gingold
2011-05-23 16:00 ` [RFA] Add dwarf2 support to xcoff (aix) Yao Qi
2011-05-24  7:06   ` Tristan Gingold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306146544-3925-2-git-send-email-gingold@adacore.com \
    --to=gingold@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox