From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7833) id 902F93858C52; Mon, 4 Apr 2022 22:07:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 902F93858C52 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Lancelot SIX To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/buildsym: Line record use a record flag X-Act-Checkin: binutils-gdb X-Git-Author: Lancelot SIX X-Git-Refname: refs/heads/master X-Git-Oldrev: 962937b15dd570e44109f3c8196a392b788837ba X-Git-Newrev: 6cacd78ba5bb705e127d60478c71955b37914c53 Message-Id: <20220404220706.902F93858C52@sourceware.org> Date: Mon, 4 Apr 2022 22:07:06 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2022 22:07:06 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6cacd78ba5bb= 705e127d60478c71955b37914c53 commit 6cacd78ba5bb705e127d60478c71955b37914c53 Author: Lancelot SIX Date: Mon Mar 7 17:36:53 2022 +0000 gdb/buildsym: Line record use a record flag =20 Currently when recording a line entry (with buildsym_compunit::record_line), a boolean argument argument is used to indicate that the is_stmt flag should be set for this particular record. As a later commit will add support for new flags, instead of adding a parameter to record_line for each possible flag, transform the current is_stmt parameter into a enum flag. This flags parameter will allow greater flexibility in future commits. =20 This enum flags type is not propagated into the linetable_entry type as this would require a lot of changes across the codebase for no practical gain (it currently uses a bitfield where each interesting flag only occupy 1 bit in the structure). =20 Tested on x86_64-linux, no regression observed. =20 Change-Id: I5d061fa67bdb34918742505ff983d37453839d6a Diff: --- gdb/buildsym-legacy.c | 2 +- gdb/buildsym.c | 4 ++-- gdb/buildsym.h | 12 +++++++++++- gdb/dwarf2/read.c | 37 ++++++++++++++++++++++--------------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c index b16c97807ac..490eef965d0 100644 --- a/gdb/buildsym-legacy.c +++ b/gdb/buildsym-legacy.c @@ -210,7 +210,7 @@ record_line (struct subfile *subfile, int line, CORE_AD= DR pc) gdb_assert (buildsym_compunit !=3D nullptr); /* Assume every line entry is a statement start, that is a good place to put a breakpoint for that line number. */ - buildsym_compunit->record_line (subfile, line, pc, true); + buildsym_compunit->record_line (subfile, line, pc, LEF_IS_STMT); } =20 /* Start a new compunit_symtab for a new source file in OBJFILE. Called, = for diff --git a/gdb/buildsym.c b/gdb/buildsym.c index c970762badb..08e4062fe17 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -667,7 +667,7 @@ buildsym_compunit::pop_subfile () =20 void buildsym_compunit::record_line (struct subfile *subfile, int line, - CORE_ADDR pc, bool is_stmt) + CORE_ADDR pc, linetable_entry_flags flags) { struct linetable_entry *e; =20 @@ -723,7 +723,7 @@ buildsym_compunit::record_line (struct subfile *subfile= , int line, =20 e =3D subfile->line_vector->item + subfile->line_vector->nitems++; e->line =3D line; - e->is_stmt =3D is_stmt ? 1 : 0; + e->is_stmt =3D (flags & LEF_IS_STMT) !=3D 0; e->pc =3D pc; } =20 diff --git a/gdb/buildsym.h b/gdb/buildsym.h index fa774dbd6fb..00e57787897 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -110,6 +110,16 @@ struct context_stack =20 }; =20 +/* Flags associated with a linetable entry. */ + +enum linetable_entry_flag : unsigned +{ + /* Indicates this PC is a good location to place a breakpoint at LINE. = */ + LEF_IS_STMT =3D 1 << 1, +}; +DEF_ENUM_FLAGS_TYPE (enum linetable_entry_flag, linetable_entry_flags); + + /* Buildsym's counterpart to struct compunit_symtab. */ =20 struct buildsym_compunit @@ -188,7 +198,7 @@ struct buildsym_compunit const char *pop_subfile (); =20 void record_line (struct subfile *subfile, int line, CORE_ADDR pc, - bool is_stmt); + linetable_entry_flags flags); =20 struct compunit_symtab *get_compunit_symtab () { diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index cb33171b1a9..d1c0ec2be2d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20925,7 +20925,7 @@ public: /* Handle DW_LNS_negate_stmt. */ void handle_negate_stmt () { - m_is_stmt =3D !m_is_stmt; + m_flags ^=3D LEF_IS_STMT; } =20 /* Handle DW_LNS_const_add_pc. */ @@ -20984,7 +20984,7 @@ private: /* These are initialized in the constructor. */ =20 CORE_ADDR m_address; - bool m_is_stmt; + linetable_entry_flags m_flags; unsigned int m_discriminator; =20 /* Additional bits of state we need to track. */ @@ -20999,9 +20999,9 @@ private: CORE_ADDR m_last_address; =20 /* Set to true when a previous line at the same address (using - m_last_address) had m_is_stmt true. This is reset to false when a - line entry at a new address (m_address different to m_last_address) is - processed. */ + m_last_address) had LEF_IS_STMT set in m_flags. This is reset to fal= se + when a line entry at a new address (m_address different to + m_last_address) is processed. */ bool m_stmt_at_address =3D false; =20 /* When true, record the lines we decode. */ @@ -21131,7 +21131,8 @@ dwarf_record_line_p (struct dwarf2_cu *cu, =20 static void dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile, - unsigned int line, CORE_ADDR address, bool is_stmt, + unsigned int line, CORE_ADDR address, + linetable_entry_flags flags, struct dwarf2_cu *cu) { CORE_ADDR addr =3D gdbarch_addr_bits_remove (gdbarch, address); @@ -21145,7 +21146,7 @@ dwarf_record_line_1 (struct gdbarch *gdbarch, struc= t subfile *subfile, } =20 if (cu !=3D nullptr) - cu->get_builder ()->record_line (subfile, line, addr, is_stmt); + cu->get_builder ()->record_line (subfile, line, addr, flags); } =20 /* Subroutine of dwarf_decode_lines_1 to simplify it. @@ -21168,7 +21169,7 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct = subfile *subfile, paddress (gdbarch, address)); } =20 - dwarf_record_line_1 (gdbarch, subfile, 0, address, true, cu); + dwarf_record_line_1 (gdbarch, subfile, 0, address, LEF_IS_STMT, cu); } =20 void @@ -21181,7 +21182,8 @@ lnp_state_machine::record_line (bool end_sequence) " address %s, is_stmt %u, discrim %u%s\n", m_line, m_file, paddress (m_gdbarch, m_address), - m_is_stmt, m_discriminator, + (m_flags & LEF_IS_STMT) !=3D 0, + m_discriminator, (end_sequence ? "\t(end sequence)" : "")); } =20 @@ -21216,7 +21218,8 @@ lnp_state_machine::record_line (bool end_sequence) =3D m_last_subfile !=3D m_cu->get_builder ()->get_current_subfile (); bool ignore_this_line =3D ((file_changed && !end_sequence && m_last_address =3D=3D m_address - && !m_is_stmt && m_stmt_at_address) + && ((m_flags & LEF_IS_STMT) =3D=3D 0) + && m_stmt_at_address) || (!end_sequence && m_line =3D=3D 0)); =20 if ((file_changed && !ignore_this_line) || end_sequence) @@ -21227,7 +21230,9 @@ lnp_state_machine::record_line (bool end_sequence) =20 if (!end_sequence && !ignore_this_line) { - bool is_stmt =3D producer_is_codewarrior (m_cu) || m_is_stmt; + linetable_entry_flags lte_flags =3D m_flags; + if (producer_is_codewarrior (m_cu)) + lte_flags |=3D LEF_IS_STMT; =20 if (dwarf_record_line_p (m_cu, m_line, m_last_line, m_line_has_non_zero_discriminator, @@ -21236,7 +21241,7 @@ lnp_state_machine::record_line (bool end_sequence) buildsym_compunit *builder =3D m_cu->get_builder (); dwarf_record_line_1 (m_gdbarch, builder->get_current_subfile (), - m_line, m_address, is_stmt, + m_line, m_address, lte_flags, m_currently_recording_lines ? m_cu : nullptr); } m_last_subfile =3D m_cu->get_builder ()->get_current_subfile (); @@ -21245,14 +21250,14 @@ lnp_state_machine::record_line (bool end_sequence) } } =20 - /* Track whether we have seen any m_is_stmt true at m_address in case we + /* Track whether we have seen any IS_STMT true at m_address in case we have multiple line table entries all at m_address. */ if (m_last_address !=3D m_address) { m_stmt_at_address =3D false; m_last_address =3D m_address; } - m_stmt_at_address |=3D m_is_stmt; + m_stmt_at_address |=3D (m_flags & LEF_IS_STMT) !=3D 0; } =20 lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, @@ -21270,7 +21275,9 @@ lnp_state_machine::lnp_state_machine (struct dwarf2= _cu *cu, gdbarch *arch, and also record it in case it needs it. This is currently used by MI= PS code, cf. `mips_adjust_dwarf2_line'. */ m_address =3D gdbarch_adjust_dwarf2_line (arch, 0, 0); - m_is_stmt =3D lh->default_is_stmt; + m_flags =3D 0; + if (lh->default_is_stmt) + m_flags |=3D LEF_IS_STMT; m_discriminator =3D 0; =20 m_last_address =3D m_address;