Move two more functions to dwarf2/leb.h
This moves read_n_bytes and read_direct_string to be with the the low-level value-reading code. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_n_bytes, read_direct_string): Move to read.c. * dwarf2/leb.h (read_n_bytes, read_direct_string): Move from read.c. Change-Id: Id07bfa13d93c0ac1f47a385749a8f01f4755b818
This commit is contained in:
parent
c8a7a66fb7
commit
9f66ff1c8c
@ -1,3 +1,10 @@
|
|||||||
|
2020-02-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* dwarf2/read.c (read_n_bytes, read_direct_string): Move to
|
||||||
|
read.c.
|
||||||
|
* dwarf2/leb.h (read_n_bytes, read_direct_string): Move from
|
||||||
|
read.c.
|
||||||
|
|
||||||
2020-02-08 Tom Tromey <tom@tromey.com>
|
2020-02-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* dwarf2/read.c (read_address): Move to comp-unit.c.
|
* dwarf2/read.c (read_address): Move to comp-unit.c.
|
||||||
|
@ -134,4 +134,31 @@ extern LONGEST read_initial_length (bfd *abfd, const gdb_byte *buf,
|
|||||||
extern LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
|
extern LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
|
||||||
unsigned int offset_size);
|
unsigned int offset_size);
|
||||||
|
|
||||||
|
static inline const gdb_byte *
|
||||||
|
read_n_bytes (bfd *abfd, const gdb_byte *buf, unsigned int size)
|
||||||
|
{
|
||||||
|
/* If the size of a host char is 8 bits, we can return a pointer
|
||||||
|
to the buffer, otherwise we have to copy the data to a buffer
|
||||||
|
allocated on the temporary obstack. */
|
||||||
|
gdb_assert (HOST_CHAR_BIT == 8);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline const char *
|
||||||
|
read_direct_string (bfd *abfd, const gdb_byte *buf,
|
||||||
|
unsigned int *bytes_read_ptr)
|
||||||
|
{
|
||||||
|
/* If the size of a host char is 8 bits, we can return a pointer
|
||||||
|
to the string, otherwise we have to copy the string to a buffer
|
||||||
|
allocated on the temporary obstack. */
|
||||||
|
gdb_assert (HOST_CHAR_BIT == 8);
|
||||||
|
if (*buf == '\0')
|
||||||
|
{
|
||||||
|
*bytes_read_ptr = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
*bytes_read_ptr = strlen ((const char *) buf) + 1;
|
||||||
|
return (const char *) buf;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GDB_DWARF2_LEB_H */
|
#endif /* GDB_DWARF2_LEB_H */
|
||||||
|
@ -1246,10 +1246,6 @@ static sect_offset read_abbrev_offset
|
|||||||
(struct dwarf2_per_objfile *dwarf2_per_objfile,
|
(struct dwarf2_per_objfile *dwarf2_per_objfile,
|
||||||
struct dwarf2_section_info *, sect_offset);
|
struct dwarf2_section_info *, sect_offset);
|
||||||
|
|
||||||
static const gdb_byte *read_n_bytes (bfd *, const gdb_byte *, unsigned int);
|
|
||||||
|
|
||||||
static const char *read_direct_string (bfd *, const gdb_byte *, unsigned int *);
|
|
||||||
|
|
||||||
static const char *read_indirect_string
|
static const char *read_indirect_string
|
||||||
(struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *,
|
(struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *,
|
||||||
const struct comp_unit_head *, unsigned int *);
|
const struct comp_unit_head *, unsigned int *);
|
||||||
@ -18731,33 +18727,6 @@ read_checked_initial_length_and_offset (bfd *abfd, const gdb_byte *buf,
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gdb_byte *
|
|
||||||
read_n_bytes (bfd *abfd, const gdb_byte *buf, unsigned int size)
|
|
||||||
{
|
|
||||||
/* If the size of a host char is 8 bits, we can return a pointer
|
|
||||||
to the buffer, otherwise we have to copy the data to a buffer
|
|
||||||
allocated on the temporary obstack. */
|
|
||||||
gdb_assert (HOST_CHAR_BIT == 8);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
read_direct_string (bfd *abfd, const gdb_byte *buf,
|
|
||||||
unsigned int *bytes_read_ptr)
|
|
||||||
{
|
|
||||||
/* If the size of a host char is 8 bits, we can return a pointer
|
|
||||||
to the string, otherwise we have to copy the string to a buffer
|
|
||||||
allocated on the temporary obstack. */
|
|
||||||
gdb_assert (HOST_CHAR_BIT == 8);
|
|
||||||
if (*buf == '\0')
|
|
||||||
{
|
|
||||||
*bytes_read_ptr = 1;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*bytes_read_ptr = strlen ((const char *) buf) + 1;
|
|
||||||
return (const char *) buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return pointer to string at section SECT offset STR_OFFSET with error
|
/* Return pointer to string at section SECT offset STR_OFFSET with error
|
||||||
reporting strings FORM_NAME and SECT_NAME. */
|
reporting strings FORM_NAME and SECT_NAME. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user