diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-12-05 18:32:02 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-12-05 18:32:02 +0000 |
commit | 583d5f6b1f6f0b63439649c6a0bc3dd8cdeb67d4 (patch) | |
tree | a21a16be4ac9b12fe22e13697ded7ead64c31b02 /libbacktrace | |
parent | 178e1d9947431e09eee09a3ef8a0f1fe545313ef (diff) | |
download | gcc-583d5f6b1f6f0b63439649c6a0bc3dd8cdeb67d4.tar.gz |
* alloc.c (backtrace_vector_finish): Add error_callback and data
parameters. Call backtrace_vector_release. Return address base.
* mmap.c (backtrace_vector_finish): Add error_callback and data
parameters. Return address base.
* dwarf.c (read_function_info): Get new address base from
backtrace_vector_finish.
* internal.h (backtrace_vector_finish): Update declaration.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205716 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 10 | ||||
-rw-r--r-- | libbacktrace/alloc.c | 20 | ||||
-rw-r--r-- | libbacktrace/dwarf.c | 8 | ||||
-rw-r--r-- | libbacktrace/internal.h | 14 | ||||
-rw-r--r-- | libbacktrace/mmap.c | 13 |
5 files changed, 51 insertions, 14 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 3b86043fbfb..43ad82a55db 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,13 @@ +2013-12-05 Ian Lance Taylor <iant@google.com> + + * alloc.c (backtrace_vector_finish): Add error_callback and data + parameters. Call backtrace_vector_release. Return address base. + * mmap.c (backtrace_vector_finish): Add error_callback and data + parameters. Return address base. + * dwarf.c (read_function_info): Get new address base from + backtrace_vector_finish. + * internal.h (backtrace_vector_finish): Update declaration. + 2013-11-27 Ian Lance Taylor <iant@google.com> * dwarf.c (find_address_ranges): New static function, broken out diff --git a/libbacktrace/alloc.c b/libbacktrace/alloc.c index d0796737786..b2c31fabcbc 100644 --- a/libbacktrace/alloc.c +++ b/libbacktrace/alloc.c @@ -113,12 +113,24 @@ backtrace_vector_grow (struct backtrace_state *state ATTRIBUTE_UNUSED, /* Finish the current allocation on VEC. */ -void -backtrace_vector_finish (struct backtrace_state *state ATTRIBUTE_UNUSED, - struct backtrace_vector *vec) +void * +backtrace_vector_finish (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data) { - vec->base = (char *) vec->base + vec->size; + void *ret; + + /* With this allocator we call realloc in backtrace_vector_grow, + which means we can't easily reuse the memory here. So just + release it. */ + if (!backtrace_vector_release (state, vec, error_callback, data)) + return NULL; + ret = vec->base; + vec->base = NULL; vec->size = 0; + vec->alc = 0; + return ret; } /* Release any extra space allocated for VEC. */ diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index f9c3b3723e7..fa9b9904322 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -2535,19 +2535,23 @@ read_function_info (struct backtrace_state *state, struct dwarf_data *ddata, if (pfvec->count == 0) return; - addrs = (struct function_addrs *) pfvec->vec.base; addrs_count = pfvec->count; if (fvec == NULL) { if (!backtrace_vector_release (state, &lvec.vec, error_callback, data)) return; + addrs = (struct function_addrs *) pfvec->vec.base; } else { /* Finish this list of addresses, but leave the remaining space in the vector available for the next function unit. */ - backtrace_vector_finish (state, &fvec->vec); + addrs = ((struct function_addrs *) + backtrace_vector_finish (state, &fvec->vec, + error_callback, data)); + if (addrs == NULL) + return; fvec->count = 0; } diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h index c93e89f36f4..9bec33cf993 100644 --- a/libbacktrace/internal.h +++ b/libbacktrace/internal.h @@ -233,13 +233,17 @@ extern void *backtrace_vector_grow (struct backtrace_state *state, size_t size, struct backtrace_vector *vec); /* Finish the current allocation on VEC. Prepare to start a new - allocation. The finished allocation will never be freed. */ + allocation. The finished allocation will never be freed. Returns + a pointer to the base of the finished entries, or NULL on + failure. */ -extern void backtrace_vector_finish (struct backtrace_state *state, - struct backtrace_vector *vec); +extern void* backtrace_vector_finish (struct backtrace_state *state, + struct backtrace_vector *vec, + backtrace_error_callback error_callback, + void *data); -/* Release any extra space allocated for VEC. Returns 1 on success, 0 - on failure. */ +/* Release any extra space allocated for VEC. This may change + VEC->base. Returns 1 on success, 0 on failure. */ extern int backtrace_vector_release (struct backtrace_state *state, struct backtrace_vector *vec, diff --git a/libbacktrace/mmap.c b/libbacktrace/mmap.c index 04aae85e586..dc94b29a3f7 100644 --- a/libbacktrace/mmap.c +++ b/libbacktrace/mmap.c @@ -230,12 +230,19 @@ backtrace_vector_grow (struct backtrace_state *state,size_t size, /* Finish the current allocation on VEC. */ -void -backtrace_vector_finish (struct backtrace_state *state ATTRIBUTE_UNUSED, - struct backtrace_vector *vec) +void * +backtrace_vector_finish ( + struct backtrace_state *state ATTRIBUTE_UNUSED, + struct backtrace_vector *vec, + backtrace_error_callback error_callback ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) { + void *ret; + + ret = vec->base; vec->base = (char *) vec->base + vec->size; vec->size = 0; + return ret; } /* Release any extra space allocated for VEC. */ |