[PATCHv4,2/7] gdb/dwarf: remove m_line_header from lnp_state_machine class
Commit Message
Following on from the previous commit, this commit remove
m_line_header from the lnp_state_machine class. The lnp_state_machine
class already holds m_cu, a dwarf2_cu, and the m_line_header was
always just m_cu->line_header, so instead of holding both of these
separately, lets just hold m_cu, and access the line header through
that.
There should be no user visible changes after this commit.
---
gdb/dwarf2/line-program.c | 46 ++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 25 deletions(-)
Comments
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> Following on from the previous commit, this commit remove
Andrew> m_line_header from the lnp_state_machine class. The lnp_state_machine
Andrew> class already holds m_cu, a dwarf2_cu, and the m_line_header was
Andrew> always just m_cu->line_header, so instead of holding both of these
Andrew> separately, lets just hold m_cu, and access the line header through
Andrew> that.
Thanks, this looks reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
@@ -46,13 +46,13 @@ class lnp_state_machine
public:
/* Initialize a machine state for the start of a line number
program. */
- lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, line_header *lh);
+ lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch);
file_entry *current_file ()
{
/* lh->file_names is 0-based, but the file name numbers in the
statement program are 1-based. */
- return m_line_header->file_name_at (m_file);
+ return m_cu->line_header->file_name_at (m_file);
}
/* Record the line in the state machine. END_SEQUENCE is true if
@@ -161,9 +161,6 @@ class lnp_state_machine
gdbarch *m_gdbarch;
- /* The line number header. */
- line_header *m_line_header;
-
/* These are part of the standard DWARF line number state machine,
and initialized according to the DWARF spec. */
@@ -206,29 +203,29 @@ void
lnp_state_machine::handle_advance_pc (CORE_ADDR adjust)
{
CORE_ADDR addr_adj = (((m_op_index + adjust)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
+ / m_cu->line_header->maximum_ops_per_instruction)
+ * m_cu->line_header->minimum_instruction_length);
addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
m_op_index = ((m_op_index + adjust)
- % m_line_header->maximum_ops_per_instruction);
+ % m_cu->line_header->maximum_ops_per_instruction);
}
void
lnp_state_machine::handle_special_opcode (unsigned char op_code)
{
- unsigned char adj_opcode = op_code - m_line_header->opcode_base;
- unsigned char adj_opcode_d = adj_opcode / m_line_header->line_range;
- unsigned char adj_opcode_r = adj_opcode % m_line_header->line_range;
+ unsigned char adj_opcode = op_code - m_cu->line_header->opcode_base;
+ unsigned char adj_opcode_d = adj_opcode / m_cu->line_header->line_range;
+ unsigned char adj_opcode_r = adj_opcode % m_cu->line_header->line_range;
CORE_ADDR addr_adj = (((m_op_index + adj_opcode_d)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
+ / m_cu->line_header->maximum_ops_per_instruction)
+ * m_cu->line_header->minimum_instruction_length);
addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
m_op_index = ((m_op_index + adj_opcode_d)
- % m_line_header->maximum_ops_per_instruction);
+ % m_cu->line_header->maximum_ops_per_instruction);
- int line_delta = m_line_header->line_base + adj_opcode_r;
+ int line_delta = m_cu->line_header->line_base + adj_opcode_r;
advance_line (line_delta);
record_line (false);
m_discriminator = 0;
@@ -247,7 +244,7 @@ lnp_state_machine::handle_set_file (file_name_index file)
else
{
m_line_has_non_zero_discriminator = m_discriminator != 0;
- dwarf2_start_subfile (m_cu, *fe, *m_line_header);
+ dwarf2_start_subfile (m_cu, *fe, *m_cu->line_header);
}
}
@@ -255,17 +252,17 @@ void
lnp_state_machine::handle_const_add_pc ()
{
CORE_ADDR adjust
- = (255 - m_line_header->opcode_base) / m_line_header->line_range;
+ = (255 - m_cu->line_header->opcode_base) / m_cu->line_header->line_range;
CORE_ADDR addr_adj
= (((m_op_index + adjust)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
+ / m_cu->line_header->maximum_ops_per_instruction)
+ * m_cu->line_header->minimum_instruction_length);
addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
m_op_index = ((m_op_index + adjust)
- % m_line_header->maximum_ops_per_instruction);
+ % m_cu->line_header->maximum_ops_per_instruction);
}
/* Return true if we should add LINE to the line number table.
@@ -432,19 +429,18 @@ lnp_state_machine::record_line (bool end_sequence)
m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0;
}
-lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch,
- line_header *lh)
+lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch)
: m_cu (cu),
m_builder (cu->get_builder ()),
m_gdbarch (arch),
- m_line_header (lh),
/* Call `gdbarch_adjust_dwarf2_line' on the initial 0 address as
if there was a line entry for it so that the backend has a
chance to adjust it and also record it in case it needs it.
This is currently used by MIPS code,
cf. `mips_adjust_dwarf2_line'. */
m_address ((unrelocated_addr) gdbarch_adjust_dwarf2_line (arch, 0, 0)),
- m_flags (lh->default_is_stmt ? LEF_IS_STMT : (linetable_entry_flags) 0),
+ m_flags (m_cu->line_header->default_is_stmt
+ ? LEF_IS_STMT : (linetable_entry_flags) 0),
m_last_address (m_address)
{
}
@@ -503,7 +499,7 @@ dwarf_decode_lines_1 (struct dwarf2_cu *cu, unrelocated_addr lowpc)
{
/* The DWARF line number program state machine. Reset the state
machine at the start of each sequence. */
- lnp_state_machine state_machine (cu, gdbarch, lh);
+ lnp_state_machine state_machine (cu, gdbarch);
bool end_sequence = false;
/* Start a subfile for the current file of the state