diff options
author | Tom de Vries <tdevries@suse.de> | 2022-12-30 13:55:22 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-12-30 13:55:22 +0100 |
commit | d8f52a9a9ccbf7411cf4ae487d2756826f5d0bd5 (patch) | |
tree | 12ad9cf5e6bea0f74c5f0b7228aee9a3ffd5edfb /gdb/dwarf2/comp-unit-head.h | |
parent | a984f112b015b7d33c3c91230eb4c35695926539 (diff) | |
download | gdb-d8f52a9a9ccbf7411cf4ae487d2756826f5d0bd5.zip gdb-d8f52a9a9ccbf7411cf4ae487d2756826f5d0bd5.tar.gz gdb-d8f52a9a9ccbf7411cf4ae487d2756826f5d0bd5.tar.bz2 |
[gdb/symtab] Make comp_unit_head.length private
Make comp_unit_head.length private, to enforce using accessor functions.
Replace accessor function get_length with get_length_with_initial and
get_length_without_initial, to make it explicit which variant we're using.
Tested on x86_64-linux.
PR symtab/29343
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29343
Diffstat (limited to 'gdb/dwarf2/comp-unit-head.h')
-rw-r--r-- | gdb/dwarf2/comp-unit-head.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h index 7579fe7..45384fa 100644 --- a/gdb/dwarf2/comp-unit-head.h +++ b/gdb/dwarf2/comp-unit-head.h @@ -34,7 +34,9 @@ translation, looks like this. */ struct comp_unit_head { - unsigned int length = 0; +private: + unsigned int m_length = 0; +public: unsigned char version = 0; unsigned char addr_size = 0; unsigned char signed_addr_p = 0; @@ -65,17 +67,30 @@ struct comp_unit_head DW_UT_skeleton or DW_UT_split_compile. */ ULONGEST signature = 0; - /* Return the total length of the CU described by this header. */ - unsigned int get_length () const + void set_length (unsigned int length) { - return initial_length_size + length; + m_length = length; + } + + /* Return the total length of the CU described by this header, including the + initial length field. */ + unsigned int get_length_with_initial () const + { + return m_length + initial_length_size; + } + + /* Return the total length of the CU described by this header, excluding the + initial length field. */ + unsigned int get_length_without_initial () const + { + return m_length; } /* Return TRUE if OFF is within this CU. */ bool offset_in_cu_p (sect_offset off) const { sect_offset bottom = sect_off; - sect_offset top = sect_off + get_length (); + sect_offset top = sect_off + get_length_with_initial (); return off >= bottom && off < top; } |