diff options
author | Tom de Vries <tdevries@suse.de> | 2018-11-22 00:06:27 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2018-11-22 00:06:27 +0000 |
commit | 292592c5da637e07eb0fe18850363e65018315ba (patch) | |
tree | 46acc06968a10835162ced045cfada51746440df /libbacktrace | |
parent | 208a53290430fc17e801c7cc8f0f0289184a2d86 (diff) | |
download | gcc-292592c5da637e07eb0fe18850363e65018315ba.zip gcc-292592c5da637e07eb0fe18850363e65018315ba.tar.gz gcc-292592c5da637e07eb0fe18850363e65018315ba.tar.bz2 |
[libbacktrace] Factor out read_initial_length
Factor out new function read_initial_length in dwarf.c.
Bootstrapped and reg-tested on x86_64.
2018-11-22 Tom de Vries <tdevries@suse.de>
* dwarf.c (read_initial_length): Factor out of ...
(build_address_map, read_line_info): ... here.
From-SVN: r266361
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 5 | ||||
-rw-r--r-- | libbacktrace/dwarf.c | 36 |
2 files changed, 26 insertions, 15 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index c2963f5..cbd80a3 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,8 @@ +2018-11-22 Tom de Vries <tdevries@suse.de> + + * dwarf.c (read_initial_length): Factor out of ... + (build_address_map, read_line_info): ... here. + 2018-11-21 Tom de Vries <tdevries@suse.de> * dwarf.c (read_string): Factor out of ... diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index c4f8732..4e93f12 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -651,6 +651,25 @@ leb128_len (const unsigned char *p) return ret; } +/* Read initial_length from BUF and advance the appropriate number of bytes. */ + +static uint64_t +read_initial_length (struct dwarf_buf *buf, int *is_dwarf64) +{ + uint64_t len; + + len = read_uint32 (buf); + if (len == 0xffffffff) + { + len = read_uint64 (buf); + *is_dwarf64 = 1; + } + else + *is_dwarf64 = 0; + + return len; +} + /* Free an abbreviations structure. */ static void @@ -1463,14 +1482,7 @@ build_address_map (struct backtrace_state *state, uintptr_t base_address, unit_data_start = info.buf; - is_dwarf64 = 0; - len = read_uint32 (&info); - if (len == 0xffffffff) - { - len = read_uint64 (&info); - is_dwarf64 = 1; - } - + len = read_initial_length (&info, &is_dwarf64); unit_buf = info; unit_buf.left = len; @@ -2002,13 +2014,7 @@ read_line_info (struct backtrace_state *state, struct dwarf_data *ddata, line_buf.data = data; line_buf.reported_underflow = 0; - is_dwarf64 = 0; - len = read_uint32 (&line_buf); - if (len == 0xffffffff) - { - len = read_uint64 (&line_buf); - is_dwarf64 = 1; - } + len = read_initial_length (&line_buf, &is_dwarf64); line_buf.left = len; if (!read_line_header (state, u, is_dwarf64, &line_buf, hdr)) |