aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-08 13:40:54 -0700
committerTom Tromey <tom@tromey.com>2020-02-08 13:43:24 -0700
commit2c7d5afccfea519b7cb53d76673d5aca1a00bacc (patch)
treeeceda2f1e3d22ca4ba21c72475baf1d05f4ec1cc /gdb
parent4075cb26687ec6bbd5bab31b6b33f692a3ed3108 (diff)
downloadgdb-2c7d5afccfea519b7cb53d76673d5aca1a00bacc.zip
gdb-2c7d5afccfea519b7cb53d76673d5aca1a00bacc.tar.gz
gdb-2c7d5afccfea519b7cb53d76673d5aca1a00bacc.tar.bz2
Convert dwarf2_section_size to a method
This changes dwarf2_section_size to be a method on dwarf2_section_info. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_section_size): Remove. (error_check_comp_unit_head, dwarf2_symbol_mark_computed): Update. * dwarf2/section.h (struct dwarf2_section_info) <get_size>: New method. Change-Id: I12928fee5c84350ce98883e329357b86888d639b
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/dwarf2/read.c20
-rw-r--r--gdb/dwarf2/section.h13
3 files changed, 22 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b8d744e..10c8bf5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2020-02-08 Tom Tromey <tom@tromey.com>
+ * dwarf2/read.c (dwarf2_section_size): Remove.
+ (error_check_comp_unit_head, dwarf2_symbol_mark_computed):
+ Update.
+ * dwarf2/section.h (struct dwarf2_section_info) <get_size>: New method.
+
+2020-02-08 Tom Tromey <tom@tromey.com>
+
* dwarf2/read.c (read_initial_length): Move to leb.c.
* dwarf2/leb.h (read_initial_length): Declare.
* dwarf2/leb.c (read_initial_length): Move from read.c. Add
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4ff2a4c..2ba53a1 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2073,22 +2073,6 @@ dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp,
this->has_section_at_zero = true;
}
-/* A helper function that returns the size of a section in a safe way.
- If you are positive that the section has been read before using the
- size, then it is safe to refer to the dwarf2_section_info object's
- "size" field directly. In other cases, you must call this
- function, because for compressed sections the size field is not set
- correctly until the section has been read. */
-
-static bfd_size_type
-dwarf2_section_size (struct objfile *objfile,
- struct dwarf2_section_info *info)
-{
- if (!info->readin)
- info->read (objfile);
- return info->size;
-}
-
/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
SECTION_NAME. */
@@ -6092,7 +6076,7 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
const char *filename = section->get_file_name ();
if (to_underlying (header->abbrev_sect_off)
- >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section))
+ >= abbrev_section->get_size (dwarf2_per_objfile->objfile))
error (_("Dwarf Error: bad offset (%s) in compilation unit header "
"(offset %s + 6) [in module %s]"),
sect_offset_str (header->abbrev_sect_off),
@@ -24395,7 +24379,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
/* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
the section. If so, fall through to the complaint in the
other branch. */
- && DW_UNSND (attr) < dwarf2_section_size (objfile, section))
+ && DW_UNSND (attr) < section->get_size (objfile))
{
struct dwarf2_loclist_baton *baton;
diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h
index f76f1ef..8ddedca 100644
--- a/gdb/dwarf2/section.h
+++ b/gdb/dwarf2/section.h
@@ -81,6 +81,19 @@ struct dwarf2_section_info
If the section is compressed, uncompress it before returning. */
void read (struct objfile *objfile);
+ /* A helper function that returns the size of a section in a safe way.
+ If you are positive that the section has been read before using the
+ size, then it is safe to refer to the dwarf2_section_info object's
+ "size" field directly. In other cases, you must call this
+ function, because for compressed sections the size field is not set
+ correctly until the section has been read. */
+ bfd_size_type get_size (struct objfile *objfile)
+ {
+ if (!readin)
+ read (objfile);
+ return size;
+ }
+
union
{
/* If this is a real section, the bfd section. */