Add comp_unit_head to dwarf2_per_cu_data
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 27 May 2020 15:14:10 +0000 (11:14 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 27 May 2020 15:19:40 +0000 (11:19 -0400)
commit2e6a9f7959dca5af9a7e6e5cea8c5dccd2e510f0
tree2e1f95c2ef8db3b38a6f71f02e3ff2dc5b1573cc
parent1b555f17476d99f97f33fb4c648d94f7767bcbd7
Add comp_unit_head to dwarf2_per_cu_data

The per_cu_header_read_in function allows obtaining a filled
comp_unit_head object for a given dwarf2_per_cu_data object.  If a
dwarf2_cu object exists for this dwarf2_per_cu_data, then it just
returns a pointer to the comp_unit_head from that dwarf2_cu.  Otherwise,
it reads the header into a temporary buffer provided by the caller, and
returns a pointer to that.

Since the dwarf2_per_cu_data::cu link is going to be removed
(dwarf2_per_cu_data will become objfile-independent while dwarf2_cu
stays objfile-dependent), we cannot rely anymore on returning the header
from the dwarf2_cu object.

The not too complex solution implemented by this patch is to keep a copy
of the header in the dwarf2_per_cu_data object, independent from the
copy in dwarf2_cu.  The new copy is only used in the addr_size,
offset_size and ref_addr_size methods of dwarf2_per_cu_data.

There's nothing intrinsic to the comp_unit_head object that prevents it
to be shared between two dwarf2_cu objects (belonging to different
objfiles) representing the same CU.  In other words, I think we could
eventually get rid of the copy in dwarf2_cu to only keep the one in
dwarf2_per_cu_data.  It is not trivial, however, so I have decided not
to do it for the moment.

gdb/ChangeLog:

* dwarf2/read.h (struct dwarf2_per_cu_data) <m_header,
m_header_read_in>: New fields.
<get_header>: New method.
* dwarf2/read.c (per_cu_header_read_in): Remove.
(dwarf2_per_cu_data::get_header): New.
(dwarf2_per_cu_data::addr_size): Update.
(dwarf2_per_cu_data::offset_size): Update.
(dwarf2_per_cu_data::ref_addr_size): Update.

Change-Id: Id7541fca7562843eba110ece21c4df38d45fca23
gdb/ChangeLog
gdb/dwarf2/read.c
gdb/dwarf2/read.h
This page took 0.025171 seconds and 4 git commands to generate.