* [PATCH] gdb: convert address_in_mem_range to mem_range::contains
@ 2024-05-08 15:05 Andrew Burgess
2024-05-08 17:04 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2024-05-08 15:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
Replace the global function address_in_mem_range with the member
function mem_range::contains. The implementation of the function
doesn't change.
There should be no user visible changes after this commit.
---
gdb/corelow.c | 4 ++--
gdb/memrange.c | 8 ++++----
gdb/memrange.h | 8 +++-----
gdb/solib-svr4.c | 2 +-
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/gdb/corelow.c b/gdb/corelow.c
index a710b07f968..462a05591c1 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -994,9 +994,9 @@ core_target::xfer_memory_via_mappings (gdb_byte *readbuf,
for (const auto &mr : m_core_unavailable_mappings)
{
- if (address_in_mem_range (memaddr, &mr))
+ if (mr.contains (memaddr))
{
- if (!address_in_mem_range (memend, &mr))
+ if (!mr.contains (memend))
len = mr.start + mr.length - memaddr;
xfer_status = this->beneath ()->xfer_partial (TARGET_OBJECT_MEMORY,
diff --git a/gdb/memrange.c b/gdb/memrange.c
index 11687b808b8..58749b757ca 100644
--- a/gdb/memrange.c
+++ b/gdb/memrange.c
@@ -33,11 +33,11 @@ mem_ranges_overlap (CORE_ADDR start1, int len1,
/* See memrange.h. */
-int
-address_in_mem_range (CORE_ADDR address, const struct mem_range *r)
+bool
+mem_range::contains (CORE_ADDR address) const
{
- return (r->start <= address
- && (address - r->start) < r->length);
+ return (this->start <= address
+ && (address - this->start) < this->length);
}
void
diff --git a/gdb/memrange.h b/gdb/memrange.h
index 74df82588f4..d83fcbd57a6 100644
--- a/gdb/memrange.h
+++ b/gdb/memrange.h
@@ -41,6 +41,9 @@ struct mem_range
&& this->length == other.length);
}
+ /* Returns true if ADDR is in this mem_range. */
+ bool contains (CORE_ADDR addr) const;
+
/* Lowest address in the range. */
CORE_ADDR start;
@@ -54,11 +57,6 @@ struct mem_range
extern int mem_ranges_overlap (CORE_ADDR start1, int len1,
CORE_ADDR start2, int len2);
-/* Returns true if ADDR is in RANGE. */
-
-extern int address_in_mem_range (CORE_ADDR addr,
- const struct mem_range *range);
-
/* Sort ranges by start address, then coalesce contiguous or
overlapping ranges. */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 1dd04c29c98..1d4a50568d7 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1475,7 +1475,7 @@ svr4_current_sos ()
auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info.get ());
- if (address_in_mem_range (li->l_ld, &vsyscall_range))
+ if (vsyscall_range.contains (li->l_ld))
{
auto next = sos.erase (so);
delete &*so;
base-commit: 868883583e7520ff1bd99fcb224d2b33a990edff
--
2.25.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: convert address_in_mem_range to mem_range::contains
2024-05-08 15:05 [PATCH] gdb: convert address_in_mem_range to mem_range::contains Andrew Burgess
@ 2024-05-08 17:04 ` Tom Tromey
2024-05-09 9:12 ` Andrew Burgess
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2024-05-08 17:04 UTC (permalink / raw)
To: Andrew Burgess; +Cc: gdb-patches
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> Replace the global function address_in_mem_range with the member
Andrew> function mem_range::contains. The implementation of the function
Andrew> doesn't change.
Andrew> There should be no user visible changes after this commit.
Looks reasonable to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: convert address_in_mem_range to mem_range::contains
2024-05-08 17:04 ` Tom Tromey
@ 2024-05-09 9:12 ` Andrew Burgess
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2024-05-09 9:12 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> Replace the global function address_in_mem_range with the member
> Andrew> function mem_range::contains. The implementation of the function
> Andrew> doesn't change.
>
> Andrew> There should be no user visible changes after this commit.
>
> Looks reasonable to me.
> Approved-By: Tom Tromey <tom@tromey.com>
Pushed.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-09 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 15:05 [PATCH] gdb: convert address_in_mem_range to mem_range::contains Andrew Burgess
2024-05-08 17:04 ` Tom Tromey
2024-05-09 9:12 ` Andrew Burgess
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).