public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove BLOCK_NRANGES macro Date: Thu, 28 Apr 2022 02:39:43 +0000 (GMT) [thread overview] Message-ID: <20220428023943.4F7463858405@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f73b4922a06f5455c1f0173d3b2026dba957d1b7 commit f73b4922a06f5455c1f0173d3b2026dba957d1b7 Author: Simon Marchi <simon.marchi@efficios.com> Date: Sun Feb 6 22:30:06 2022 -0500 gdb: remove BLOCK_NRANGES macro Replace with range for loops. Change-Id: Icbe04f9b6f9e6ddae2e15b2409c61f7a336bc3e3 Diff: --- gdb/block.h | 4 ---- gdb/blockframe.c | 23 +++++++++++------------ gdb/cli/cli-cmds.c | 7 ++++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/gdb/block.h b/gdb/block.h index daaaecdd501..3782327c155 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -215,10 +215,6 @@ struct global_block struct compunit_symtab *compunit_symtab; }; -/* Number of ranges within a block. */ - -#define BLOCK_NRANGES(bl) (bl)->ranges ().size () - /* Access range array for block BL. */ #define BLOCK_RANGE(bl) (bl)->ranges ().data () diff --git a/gdb/blockframe.c b/gdb/blockframe.c index e91faaa98b1..78c9daabf23 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -283,19 +283,19 @@ find_pc_partial_function_sym (CORE_ADDR pc, } else { - int i; - for (i = 0; i < BLOCK_NRANGES (b); i++) + bool found = false; + for (const blockrange &range : b->ranges ()) { - if (BLOCK_RANGE (b)[i].start () <= mapped_pc - && mapped_pc < BLOCK_RANGE (b)[i].end ()) + if (range.start () <= mapped_pc && mapped_pc < range.end ()) { - cache_pc_function_low = BLOCK_RANGE (b)[i].start (); - cache_pc_function_high = BLOCK_RANGE (b)[i].end (); + cache_pc_function_low = range.start (); + cache_pc_function_high = range.end (); + found = true; break; } } /* Above loop should exit via the break. */ - gdb_assert (i < BLOCK_NRANGES (b)); + gdb_assert (found); } @@ -394,16 +394,15 @@ find_function_entry_range_from_pc (CORE_ADDR pc, const char **name, { CORE_ADDR entry_pc = BLOCK_ENTRY_PC (block); - for (int i = 0; i < BLOCK_NRANGES (block); i++) + for (const blockrange &range : block->ranges ()) { - if (BLOCK_RANGE (block)[i].start () <= entry_pc - && entry_pc < BLOCK_RANGE (block)[i].end ()) + if (range.start () <= entry_pc && entry_pc < range.end ()) { if (address != nullptr) - *address = BLOCK_RANGE (block)[i].start (); + *address = range.start (); if (endaddr != nullptr) - *endaddr = BLOCK_RANGE (block)[i].end (); + *endaddr = range.end (); return status; } diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index f7c556a4e0c..7a6a8ea20a1 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1442,10 +1442,11 @@ print_disassembly (struct gdbarch *gdbarch, const char *name, } else { - for (int i = 0; i < BLOCK_NRANGES (block); i++) + for (const blockrange &range : block->ranges ()) { - CORE_ADDR range_low = BLOCK_RANGE (block)[i].start (); - CORE_ADDR range_high = BLOCK_RANGE (block)[i].end (); + CORE_ADDR range_low = range.start (); + CORE_ADDR range_high = range.end (); + gdb_printf (_("Address range %ps to %ps:\n"), styled_string (address_style.style (), paddress (gdbarch, range_low)),
reply other threads:[~2022-04-28 2:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220428023943.4F7463858405@sourceware.org \ --to=simark@sourceware.org \ --cc=gdb-cvs@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: linkBe 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).