/* The memory range data structure, and associated utilities.
- Copyright (C) 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2010-2022 Free Software Foundation, Inc.
This file is part of GDB.
#ifndef MEMRANGE_H
#define MEMRANGE_H
-#include "vec.h"
-
/* Defines a [START, START + LENGTH) memory range. */
struct mem_range
{
+ mem_range () = default;
+
+ mem_range (CORE_ADDR start_, int length_)
+ : start (start_), length (length_)
+ {}
+
+ bool operator< (const mem_range &other) const
+ {
+ return this->start < other.start;
+ }
+
+ bool operator== (const mem_range &other) const
+ {
+ return (this->start == other.start
+ && this->length == other.length);
+ }
+
/* Lowest address in the range. */
CORE_ADDR start;
int length;
};
-typedef struct mem_range mem_range_s;
-
-DEF_VEC_O(mem_range_s);
-
/* Returns true if the ranges defined by [start1, start1+len1) and
[start2, start2+len2) overlap. */
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. */
-extern void normalize_mem_ranges (VEC(mem_range_s) *memory);
+extern void normalize_mem_ranges (std::vector<mem_range> *memory);
#endif