From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 3B1E7385842B; Thu, 28 Apr 2022 02:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B1E7385842B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove BLOCK_RANGES macro X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 6dd5a4bd44b7b7d2daf195dd5e48faeaf7231c17 X-Git-Newrev: f5cb8afdd297dd68273d98a10fbfd350dff918d8 Message-Id: <20220428023938.3B1E7385842B@sourceware.org> Date: Thu, 28 Apr 2022 02:39:38 +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: Thu, 28 Apr 2022 02:39:38 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df5cb8afdd297= dd68273d98a10fbfd350dff918d8 commit f5cb8afdd297dd68273d98a10fbfd350dff918d8 Author: Simon Marchi Date: Sun Feb 6 22:27:53 2022 -0500 gdb: remove BLOCK_RANGES macro =20 Replace with an equivalent method on struct block. =20 Change-Id: I6dcf13e9464ba8a08ade85c89e7329c300fd6c2a Diff: --- gdb/block.h | 27 ++++++++++++++++++--------- gdb/dwarf2/read.c | 2 +- gdb/objfiles.c | 12 +++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/gdb/block.h b/gdb/block.h index 60e53c641a2..daaaecdd501 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -21,6 +21,7 @@ #define BLOCK_H =20 #include "dictionary.h" +#include "gdbsupport/array-view.h" =20 /* Opaque declarations. */ =20 @@ -154,6 +155,18 @@ struct block void set_namespace_info (block_namespace_info *namespace_info) { m_namespace_info =3D namespace_info; } =20 + /* Return a view on this block's ranges. */ + gdb::array_view ranges () + { return gdb::make_array_view (m_ranges->range, m_ranges->nranges); } + + /* Const version of the above. */ + gdb::array_view ranges () const + { return gdb::make_array_view (m_ranges->range, m_ranges->nranges); } + + /* Set this block's ranges array. */ + void set_ranges (blockranges *ranges) + { m_ranges =3D ranges; } + /* Addresses in the executable code that are in this block. */ =20 CORE_ADDR m_start; @@ -185,7 +198,7 @@ struct block is NULL, then there is only one range which is specified by startaddr and endaddr above. */ =20 - struct blockranges *ranges; + struct blockranges *m_ranges; }; =20 /* The global block is singled out so that we can provide a back-link @@ -202,22 +215,18 @@ struct global_block struct compunit_symtab *compunit_symtab; }; =20 -/* Accessor for ranges field within block BL. */ - -#define BLOCK_RANGES(bl) (bl)->ranges - /* Number of ranges within a block. */ =20 -#define BLOCK_NRANGES(bl) (bl)->ranges->nranges +#define BLOCK_NRANGES(bl) (bl)->ranges ().size () =20 /* Access range array for block BL. */ =20 -#define BLOCK_RANGE(bl) (bl)->ranges->range +#define BLOCK_RANGE(bl) (bl)->ranges ().data () =20 /* Are all addresses within a block contiguous? */ =20 -#define BLOCK_CONTIGUOUS_P(bl) (BLOCK_RANGES (bl) =3D=3D nullptr \ - || BLOCK_NRANGES (bl) <=3D 1) +#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () =3D=3D 0 \ + || (bl)->ranges ().size () =3D=3D 1) =20 /* Define the "entry pc" for a block BL to be the lowest (start) address for the block when all addresses within the block are contiguous. If diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 37e9587e43e..d146d525066 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13192,7 +13192,7 @@ dwarf2_record_block_ranges (struct die_info *die, s= truct block *block, blockvec.emplace_back (start, end); }); =20 - BLOCK_RANGES(block) =3D make_blockranges (objfile, blockvec); + block->set_ranges (make_blockranges (objfile, blockvec)); } } =20 diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 9c7a30d9a60..c4b054a70d5 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -680,13 +680,11 @@ objfile_relocate1 (struct objfile *objfile, b->set_start (b->start () + delta[block_line_section]); b->set_end (b->end () + delta[block_line_section]); =20 - if (BLOCK_RANGES (b) !=3D nullptr) - for (int j =3D 0; j < BLOCK_NRANGES (b); j++) - { - blockrange &r =3D BLOCK_RANGE (b)[j]; - r.set_start (r.start () + delta[block_line_section]); - r.set_end (r.end () + delta[block_line_section]); - } + for (blockrange &r : b->ranges ()) + { + r.set_start (r.start () + delta[block_line_section]); + r.set_end (r.end () + delta[block_line_section]); + } =20 /* We only want to iterate over the local symbols, not any symbols in included symtabs. */