diff options
author | Pedro Alves <palves@redhat.com> | 2011-02-14 19:19:18 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-02-14 19:19:18 +0000 |
commit | c0f61f9c377a278ce83259cbf2251e178bbc0e85 (patch) | |
tree | 56db943ad02a10835fa57dfc44a20eb98b66eb88 /gdb/memrange.c | |
parent | 602427c4af6c2c0946c40a38541d9a5243860744 (diff) | |
download | gdb-c0f61f9c377a278ce83259cbf2251e178bbc0e85.zip gdb-c0f61f9c377a278ce83259cbf2251e178bbc0e85.tar.gz gdb-c0f61f9c377a278ce83259cbf2251e178bbc0e85.tar.bz2 |
gdb/
* memrange.c (compare_mem_ranges): Mention sort order in
describing comment.
(normalize_mem_ranges): Add comment. Fix ra->length calculation.
* tracepoint.c (traceframe_available_memory): Extend comment to
mention what happens to RESULT when the target does not support
the query.
Diffstat (limited to 'gdb/memrange.c')
-rw-r--r-- | gdb/memrange.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gdb/memrange.c b/gdb/memrange.c index 4ffe6bd..dcacff6 100644 --- a/gdb/memrange.c +++ b/gdb/memrange.c @@ -31,7 +31,8 @@ mem_ranges_overlap (CORE_ADDR start1, int len1, return (l < h); } -/* qsort comparison function, that compares mem_ranges. */ +/* qsort comparison function, that compares mem_ranges. Ranges are + sorted in ascending START order. */ static int compare_mem_ranges (const void *ap, const void *bp) @@ -50,6 +51,10 @@ compare_mem_ranges (const void *ap, const void *bp) void normalize_mem_ranges (VEC(mem_range_s) *ranges) { + /* This function must not use any VEC operation on RANGES that + reallocates the memory block as that invalidates the RANGES + pointer, which callers expect to remain valid. */ + if (!VEC_empty (mem_range_s, ranges)) { struct mem_range *ra, *rb; @@ -68,7 +73,8 @@ normalize_mem_ranges (VEC(mem_range_s) *ranges) merge them. */ if (rb->start <= ra->start + ra->length) { - ra->length = (rb->start + rb->length) - ra->start; + ra->length = max (ra->length, + (rb->start - ra->start) + rb->length); continue; /* next b, same a */ } a++; /* next a */ |