aboutsummaryrefslogtreecommitdiff
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 8117531..18f3c7f 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -50,6 +50,7 @@
#include "source.h"
#include "ax.h"
#include "ax-gdb.h"
+#include "memrange.h"
/* readline include files */
#include "readline/readline.h"
@@ -130,21 +131,6 @@ extern void output_command (char *, int);
typedef struct trace_state_variable tsv_s;
DEF_VEC_O(tsv_s);
-/* Defines a [START, START + LENGTH) memory range. */
-
-struct mem_range
-{
- /* Lowest address in the range. */
- CORE_ADDR start;
-
- /* Length of the range. */
- int length;
-};
-
-typedef struct mem_range mem_range_s;
-
-DEF_VEC_O(mem_range_s);
-
/* An object describing the contents of a traceframe. */
struct traceframe_info
@@ -4597,6 +4583,49 @@ get_traceframe_info (void)
return traceframe_info;
}
+/* Return in RESULT, the set of collected memory in the current
+ traceframe, found within the LEN bytes range starting at MEMADDR.
+ Returns true if the target supports the query, otherwise returns
+ false. */
+
+int
+traceframe_available_memory (VEC(mem_range_s) **result,
+ CORE_ADDR memaddr, ULONGEST len)
+{
+ struct traceframe_info *info = get_traceframe_info ();
+
+ if (info != NULL)
+ {
+ struct mem_range *r;
+ int i;
+
+ *result = NULL;
+
+ for (i = 0; VEC_iterate (mem_range_s, info->memory, i, r); i++)
+ if (mem_ranges_overlap (r->start, r->length, memaddr, len))
+ {
+ ULONGEST lo1, hi1, lo2, hi2;
+ struct mem_range *nr;
+
+ lo1 = memaddr;
+ hi1 = memaddr + len;
+
+ lo2 = r->start;
+ hi2 = r->start + r->length;
+
+ nr = VEC_safe_push (mem_range_s, *result, NULL);
+
+ nr->start = max (lo1, lo2);
+ nr->length = min (hi1, hi2) - nr->start;
+ }
+
+ normalize_mem_ranges (*result);
+ return 1;
+ }
+
+ return 0;
+}
+
/* module initialization */
void
_initialize_tracepoint (void)