diff options
author | Pedro Alves <palves@redhat.com> | 2011-02-14 11:20:27 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-02-14 11:20:27 +0000 |
commit | 2a7498d819aef97a9abf94dc20899affe68080fe (patch) | |
tree | 97fcf43c8f7bcb84fe060973daa35695160d8820 /gdb/tracepoint.c | |
parent | 4d1f5c790bbbc9c638b130fca24a9483c700e8d9 (diff) | |
download | gdb-2a7498d819aef97a9abf94dc20899affe68080fe.zip gdb-2a7498d819aef97a9abf94dc20899affe68080fe.tar.gz gdb-2a7498d819aef97a9abf94dc20899affe68080fe.tar.bz2 |
2011-02-14 Pedro Alves <pedro@codesourcery.com>
gdb/
* Makefile.in (SFILES): Add memrange.c.
(HFILES_NO_SRCDIR): Add memrange.h.
(COMMON_OBS): Add memrange.o.
* memrange.c: New file.
* memrange.h: New file.
* tracepoint.c: Include memrange.h.
(struct mem_range): Delete.
(mem_range_s): Delete.
(traceframe_available_memory): New function.
* tracepoint.h (traceframe_available_memory): Declare.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 59 |
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) |