From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 07/14] gdb: remove BLOCK_RANGES macro
Date: Thu, 21 Apr 2022 10:59:03 -0400 [thread overview]
Message-ID: <20220421145910.15335-7-simon.marchi@efficios.com> (raw)
In-Reply-To: <20220421145910.15335-1-simon.marchi@efficios.com>
Replace with an equivalent method on struct block.
Change-Id: I6dcf13e9464ba8a08ade85c89e7329c300fd6c2a
---
gdb/block.h | 28 +++++++++++++++++++---------
gdb/dwarf2/read.c | 2 +-
gdb/objfiles.c | 12 +++++-------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/gdb/block.h b/gdb/block.h
index 473abde5b3d9..3935e263f929 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -21,6 +21,7 @@
#define BLOCK_H
#include "dictionary.h"
+#include "gdbsupport/array-view.h"
/* Opaque declarations. */
@@ -162,6 +163,19 @@ struct block
m_namespace_info = namespace_info;
}
+ gdb::array_view<blockrange> ranges () const
+ {
+ if (m_ranges != nullptr)
+ return gdb::make_array_view (m_ranges->range, m_ranges->nranges);
+ else
+ return {};
+ }
+
+ void set_ranges (blockranges *ranges)
+ {
+ m_ranges = ranges;
+ }
+
/* Addresses in the executable code that are in this block. */
CORE_ADDR m_start;
@@ -193,7 +207,7 @@ struct block
is NULL, then there is only one range which is specified by
startaddr and endaddr above. */
- struct blockranges *ranges;
+ struct blockranges *m_ranges;
};
/* The global block is singled out so that we can provide a back-link
@@ -210,22 +224,18 @@ struct global_block
struct compunit_symtab *compunit_symtab;
};
-/* Accessor for ranges field within block BL. */
-
-#define BLOCK_RANGES(bl) (bl)->ranges
-
/* Number of ranges within a block. */
-#define BLOCK_NRANGES(bl) (bl)->ranges->nranges
+#define BLOCK_NRANGES(bl) (bl)->ranges ().size ()
/* Access range array for block BL. */
-#define BLOCK_RANGE(bl) (bl)->ranges->range
+#define BLOCK_RANGE(bl) (bl)->ranges ().data ()
/* Are all addresses within a block contiguous? */
-#define BLOCK_CONTIGUOUS_P(bl) (BLOCK_RANGES (bl) == nullptr \
- || BLOCK_NRANGES (bl) <= 1)
+#define BLOCK_CONTIGUOUS_P(bl) ((bl)->ranges ().size () == 0 \
+ || (bl)->ranges ().size () == 1)
/* 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 bb72e0e4791b..c62d4be72a12 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13198,7 +13198,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
blockvec.emplace_back (start, end);
});
- BLOCK_RANGES(block) = make_blockranges (objfile, blockvec);
+ block->set_ranges (make_blockranges (objfile, blockvec));
}
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 9c7a30d9a60d..c4b054a70d57 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]);
- if (BLOCK_RANGES (b) != nullptr)
- for (int j = 0; j < BLOCK_NRANGES (b); j++)
- {
- blockrange &r = 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]);
+ }
/* We only want to iterate over the local symbols, not any
symbols in included symtabs. */
--
2.26.2
next prev parent reply other threads:[~2022-04-21 14:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 14:58 [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
2022-04-21 14:58 ` [PATCH 02/14] gdb: remove BLOCK_FUNCTION macro Simon Marchi
2022-04-21 14:58 ` [PATCH 03/14] gdb: remove BLOCK_SUPERBLOCK macro Simon Marchi
2022-04-21 14:59 ` [PATCH 04/14] gdb: remove BLOCK_MULTIDICT macro Simon Marchi
2022-04-21 17:33 ` Lancelot SIX
2022-04-21 17:49 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 05/14] gdb: remove BLOCK_NAMESPACE macro Simon Marchi
2022-04-21 14:59 ` [PATCH 06/14] gdb: remove BLOCK_RANGE_{START,END} macros Simon Marchi
2022-04-21 14:59 ` Simon Marchi [this message]
2022-04-21 18:16 ` [PATCH 07/14] gdb: remove BLOCK_RANGES macro Pedro Alves
2022-04-21 18:57 ` Simon Marchi
2022-04-28 10:47 ` Andrew Burgess
2022-04-21 14:59 ` [PATCH 08/14] gdb: remove BLOCK_NRANGES macro Simon Marchi
2022-04-21 17:38 ` Lancelot SIX
2022-04-21 17:52 ` Simon Marchi
2022-04-21 14:59 ` [PATCH 09/14] gdb: remove BLOCK_RANGE macro Simon Marchi
2022-04-21 14:59 ` [PATCH 10/14] gdb: remove BLOCK_CONTIGUOUS_P macro Simon Marchi
2022-04-21 18:16 ` Lancelot SIX
2022-04-21 18:59 ` Simon Marchi
2022-04-28 2:39 ` [PATCH 01/14] gdb: remove BLOCK_{START,END} macros Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220421145910.15335-7-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).