diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:54 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:54 -0700 |
commit | f4382c45a4de31b654c063d1ae70d932bde1c2f2 (patch) | |
tree | 914254afcd1620342bac6ac4f5603a635a946f35 /gdb/dwarf2read.c | |
parent | 01840b7a09722330ff36038001ea72dd7525c67e (diff) | |
download | binutils-f4382c45a4de31b654c063d1ae70d932bde1c2f2.zip binutils-f4382c45a4de31b654c063d1ae70d932bde1c2f2.tar.gz binutils-f4382c45a4de31b654c063d1ae70d932bde1c2f2.tar.bz2 |
Create dwarf2/leb.[ch]
This moves some scalar-unpacking code into a couple of new files,
dwarf2/leb.h and dwarf2/leb.c.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.h (read_unsigned_leb128): Don't declare.
* dwarf2read.c (read_1_byte, read_1_signed_byte, read_2_bytes)
(read_2_signed_bytes, read_3_bytes, read_4_bytes)
(read_4_signed_bytes, read_8_bytes): Move to dwarf2/leb.h.
(read_unsigned_leb128, read_signed_leb128): Move to dwarf2/leb.c.
* dwarf2/leb.h: New file, from dwarf2read.c.
* dwarf2/leb.c: New file, from dwarf2read.c.
* dwarf2-frame.c (read_1_byte, read_4_bytes, read_8_bytes):
Remove.
* Makefile.in (CONFIG_SRC_SUBDIR): Add dwarf2.
(COMMON_SFILES): Add dwarf2/leb.c.
Change-Id: Idd19647686c8f959d226a95fdfca4db47c6e96d0
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 130 |
1 files changed, 1 insertions, 129 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index dafe01d..fe26fc3 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -32,6 +32,7 @@ #include "dwarf2read.h" #include "dwarf-index-cache.h" #include "dwarf-index-common.h" +#include "dwarf2/leb.h" #include "bfd.h" #include "elf-bfd.h" #include "symtab.h" @@ -1551,19 +1552,6 @@ static void read_attribute_reprocess (const struct die_reader_specs *reader, static CORE_ADDR read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index); -static unsigned int read_1_byte (bfd *, const gdb_byte *); - -static int read_1_signed_byte (bfd *, const gdb_byte *); - -static unsigned int read_2_bytes (bfd *, const gdb_byte *); - -/* Read the next three bytes (little-endian order) as an unsigned integer. */ -static unsigned int read_3_bytes (bfd *, const gdb_byte *); - -static unsigned int read_4_bytes (bfd *, const gdb_byte *); - -static ULONGEST read_8_bytes (bfd *, const gdb_byte *); - static CORE_ADDR read_address (bfd *, const gdb_byte *ptr, struct dwarf2_cu *, unsigned int *); @@ -1602,8 +1590,6 @@ static const char *read_indirect_string_at_offset static const char *read_indirect_string_from_dwz (struct objfile *objfile, struct dwz_file *, LONGEST); -static LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *); - static CORE_ADDR read_addr_index_from_leb128 (struct dwarf2_cu *, const gdb_byte *, unsigned int *); @@ -19685,63 +19671,6 @@ read_attribute (const struct die_reader_specs *reader, need_reprocess); } -/* Read dwarf information from a buffer. */ - -static unsigned int -read_1_byte (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_8 (abfd, buf); -} - -static int -read_1_signed_byte (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_signed_8 (abfd, buf); -} - -static unsigned int -read_2_bytes (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_16 (abfd, buf); -} - -static int -read_2_signed_bytes (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_signed_16 (abfd, buf); -} - -static unsigned int -read_3_bytes (bfd *abfd, const gdb_byte *buf) -{ - unsigned int result = 0; - for (int i = 0; i < 3; ++i) - { - unsigned char byte = bfd_get_8 (abfd, buf); - buf++; - result |= ((unsigned int) byte << (i * 8)); - } - return result; -} - -static unsigned int -read_4_bytes (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_32 (abfd, buf); -} - -static int -read_4_signed_bytes (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_signed_32 (abfd, buf); -} - -static ULONGEST -read_8_bytes (bfd *abfd, const gdb_byte *buf) -{ - return bfd_get_64 (abfd, buf); -} - static CORE_ADDR read_address (bfd *abfd, const gdb_byte *buf, struct dwarf2_cu *cu, unsigned int *bytes_read) @@ -20051,63 +19980,6 @@ read_indirect_line_string (struct dwarf2_per_objfile *dwarf2_per_objfile, str_offset); } -ULONGEST -read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf, - unsigned int *bytes_read_ptr) -{ - ULONGEST result; - unsigned int num_read; - int shift; - unsigned char byte; - - result = 0; - shift = 0; - num_read = 0; - while (1) - { - byte = bfd_get_8 (abfd, buf); - buf++; - num_read++; - result |= ((ULONGEST) (byte & 127) << shift); - if ((byte & 128) == 0) - { - break; - } - shift += 7; - } - *bytes_read_ptr = num_read; - return result; -} - -static LONGEST -read_signed_leb128 (bfd *abfd, const gdb_byte *buf, - unsigned int *bytes_read_ptr) -{ - ULONGEST result; - int shift, num_read; - unsigned char byte; - - result = 0; - shift = 0; - num_read = 0; - while (1) - { - byte = bfd_get_8 (abfd, buf); - buf++; - num_read++; - result |= ((ULONGEST) (byte & 127) << shift); - shift += 7; - if ((byte & 128) == 0) - { - break; - } - } - if ((shift < 8 * sizeof (result)) && (byte & 0x40)) - result |= -(((ULONGEST) 1) << shift); - *bytes_read_ptr = num_read; - return result; -} - /* Given index ADDR_INDEX in .debug_addr, fetch the value. ADDR_BASE is the DW_AT_addr_base (DW_AT_GNU_addr_base) attribute or zero. ADDR_SIZE is the size of addresses from the CU header. */ |