/* Parts of target interface that deal with accessing memory and memory-like
objects.
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 2006-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "target.h"
#include "memory-map.h"
-#include "gdb_assert.h"
-
-#include <stdio.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
+#include <algorithm>
static int
compare_block_starting_address (const void *a, const void *b)
{
- const struct memory_write_request *a_req = a;
- const struct memory_write_request *b_req = b;
+ const struct memory_write_request *a_req
+ = (const struct memory_write_request *) a;
+ const struct memory_write_request *b_req
+ = (const struct memory_write_request *) b;
if (a_req->begin < b_req->begin)
return -1;
if (end != 0 && end <= r->begin)
continue;
- claimed_begin = max (begin, r->begin);
+ claimed_begin = std::max (begin, r->begin);
if (end == 0)
claimed_end = r->end;
else
- claimed_end = min (end, r->end);
+ claimed_end = std::min (end, r->end);
if (claimed_begin == r->begin && claimed_end == r->end)
VEC_safe_push (memory_write_request_s, *result, r);
{
struct mem_region *region;
unsigned blocksize;
+ CORE_ADDR offset_in_region;
region = lookup_mem_region (address);
gdb_assert (region->attrib.mode == MEM_FLASH);
blocksize = region->attrib.blocksize;
+
+ offset_in_region = address - region->lo;
+
if (begin)
- *begin = address / blocksize * blocksize;
+ *begin = region->lo + offset_in_region / blocksize * blocksize;
if (end)
- *end = (address + blocksize - 1) / blocksize * blocksize;
+ *end = region->lo + (offset_in_region + blocksize - 1) / blocksize * blocksize;
}
/* Given the list of memory requests to be WRITTEN, this function
static void
cleanup_request_data (void *p)
{
- VEC(memory_write_request_s) **v = p;
+ VEC(memory_write_request_s) **v = (VEC(memory_write_request_s) **) p;
struct memory_write_request *r;
int i;
static void
cleanup_write_requests_vector (void *p)
{
- VEC(memory_write_request_s) **v = p;
+ VEC(memory_write_request_s) **v = (VEC(memory_write_request_s) **) p;
VEC_free (memory_write_request_s, *v);
}
for (i = 0; VEC_iterate (memory_write_request_s, garbled, i, r); ++i)
{
gdb_assert (r->data == NULL);
- r->data = xmalloc (r->end - r->begin);
+ r->data = (gdb_byte *) xmalloc (r->end - r->begin);
err = target_read_memory (r->begin, r->data, r->end - r->begin);
if (err != 0)
goto out;