diff options
author | Martin Sebor <msebor@redhat.com> | 2015-06-12 00:01:50 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2015-06-11 18:01:50 -0600 |
commit | d99a7b4d6b75dc1f933631f6e598c5850a1a6502 (patch) | |
tree | 8234309683396aed832fe1af93e6800de74b44b7 /libbacktrace | |
parent | 39e150e85f8059df69b1cc4fff2567d682b6da9f (diff) | |
download | gcc-d99a7b4d6b75dc1f933631f6e598c5850a1a6502.tar.gz |
re PR sanitizer/65479 (sanitizer stack trace missing frames past #0 on powerpc64)
2015-06-11 Martin Sebor <msebor@redhat.com>
PR sanitizer/65479
* dwarf.c (struct line): Add new field idx.
(line_compare): Use it.
(add_line): Set it.
(read_line_info): Reset it.
From-SVN: r224402
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 8 | ||||
-rw-r--r-- | libbacktrace/dwarf.c | 17 |
2 files changed, 20 insertions, 5 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index e105e38ee95..d043761bbe7 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,11 @@ +2015-06-11 Martin Sebor <msebor@redhat.com> + + PR sanitizer/65479 + * dwarf.c (struct line): Add new field idx. + (line_compare): Use it. + (add_line): Set it. + (read_line_info): Reset it. + 2015-05-29 Tristan Gingold <gingold@adacore.com> * pecoff.c: New file. diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index 919b568c786..e32c4688573 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -211,6 +211,10 @@ struct line const char *filename; /* Line number. */ int lineno; + /* Index of the object in the original array read from the DWARF + section, before it has been sorted. The index makes it possible + to use Quicksort and maintain stability. */ + int idx; }; /* A growable vector of line number information. This is used while @@ -940,9 +944,10 @@ unit_addrs_search (const void *vkey, const void *ventry) return 0; } -/* Sort the line vector by PC. We want a stable sort here. We know - that the pointers are into the same array, so it is safe to compare - them directly. */ +/* Sort the line vector by PC. We want a stable sort here to maintain + the order of lines for the same PC values. Since the sequence is + being sorted in place, their addresses cannot be relied on to + maintain stability. That is the purpose of the index member. */ static int line_compare (const void *v1, const void *v2) @@ -954,9 +959,9 @@ line_compare (const void *v1, const void *v2) return -1; else if (ln1->pc > ln2->pc) return 1; - else if (ln1 < ln2) + else if (ln1->idx < ln2->idx) return -1; - else if (ln1 > ln2) + else if (ln1->idx > ln2->idx) return 1; else return 0; @@ -1551,6 +1556,7 @@ add_line (struct backtrace_state *state, struct dwarf_data *ddata, ln->filename = filename; ln->lineno = lineno; + ln->idx = vec->count; ++vec->count; @@ -2011,6 +2017,7 @@ read_line_info (struct backtrace_state *state, struct dwarf_data *ddata, ln->pc = (uintptr_t) -1; ln->filename = NULL; ln->lineno = 0; + ln->idx = 0; if (!backtrace_vector_release (state, &vec.vec, error_callback, data)) goto fail; |