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.
This commit is contained in:
Pedro Alves
2011-02-14 11:20:27 +00:00
parent 4d1f5c790b
commit 2a7498d819
6 changed files with 197 additions and 18 deletions

View File

@@ -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)