Create dwarf2/leb.[ch]
[deliverable/binutils-gdb.git] / gdb / dwarf2 / leb.h
CommitLineData
f4382c45
TT
1/* Low-level DWARF 2 reading code
2
3 Copyright (C) 1994-2020 Free Software Foundation, Inc.
4
5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
6 Inc. with support from Florida State University (under contract
7 with the Ada Joint Program Office), and Silicon Graphics, Inc.
8 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
10 support.
11
12 This file is part of GDB.
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26
27#ifndef GDB_DWARF2_LEB_H
28#define GDB_DWARF2_LEB_H
29
30/* Read dwarf information from a buffer. */
31
32static inline unsigned int
33read_1_byte (bfd *abfd, const gdb_byte *buf)
34{
35 return bfd_get_8 (abfd, buf);
36}
37
38static inline int
39read_1_signed_byte (bfd *abfd, const gdb_byte *buf)
40{
41 return bfd_get_signed_8 (abfd, buf);
42}
43
44static inline unsigned int
45read_2_bytes (bfd *abfd, const gdb_byte *buf)
46{
47 return bfd_get_16 (abfd, buf);
48}
49
50static inline int
51read_2_signed_bytes (bfd *abfd, const gdb_byte *buf)
52{
53 return bfd_get_signed_16 (abfd, buf);
54}
55
56/* Read the next three bytes (little-endian order) as an unsigned integer. */
57static inline unsigned int
58read_3_bytes (bfd *abfd, const gdb_byte *buf)
59{
60 unsigned int result = 0;
61 for (int i = 0; i < 3; ++i)
62 {
63 unsigned char byte = bfd_get_8 (abfd, buf);
64 buf++;
65 result |= ((unsigned int) byte << (i * 8));
66 }
67 return result;
68}
69
70static inline unsigned int
71read_4_bytes (bfd *abfd, const gdb_byte *buf)
72{
73 return bfd_get_32 (abfd, buf);
74}
75
76static inline int
77read_4_signed_bytes (bfd *abfd, const gdb_byte *buf)
78{
79 return bfd_get_signed_32 (abfd, buf);
80}
81
82static inline ULONGEST
83read_8_bytes (bfd *abfd, const gdb_byte *buf)
84{
85 return bfd_get_64 (abfd, buf);
86}
87
88extern LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
89
90extern ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
91
92#endif /* GDB_DWARF2_LEB_H */
This page took 0.025737 seconds and 4 git commands to generate.