arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / extract-store-integer.h
bloba51ef3d09429de6e15c3186bcf43471f9ff33a0d
1 /* Copyright (C) 1986-2024 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef GDB_EXTRACT_STORE_INTEGER_H
19 #define GDB_EXTRACT_STORE_INTEGER_H
21 #include <type_traits>
23 template<typename T, typename = std::is_integral<T>>
24 T extract_integer (gdb::array_view<const gdb_byte>, enum bfd_endian byte_order);
26 static inline LONGEST
27 extract_signed_integer (gdb::array_view<const gdb_byte> buf,
28 enum bfd_endian byte_order)
30 return extract_integer<LONGEST> (buf, byte_order);
33 static inline LONGEST
34 extract_signed_integer (const gdb_byte *addr, int len,
35 enum bfd_endian byte_order)
37 return extract_signed_integer (gdb::array_view<const gdb_byte> (addr, len),
38 byte_order);
41 static inline ULONGEST
42 extract_unsigned_integer (gdb::array_view<const gdb_byte> buf,
43 enum bfd_endian byte_order)
45 return extract_integer<ULONGEST> (buf, byte_order);
48 static inline ULONGEST
49 extract_unsigned_integer (const gdb_byte *addr, int len,
50 enum bfd_endian byte_order)
52 return extract_unsigned_integer (gdb::array_view<const gdb_byte> (addr, len),
53 byte_order);
56 extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
57 struct type *type);
59 /* All 'store' functions accept a host-format integer and store a
60 target-format integer at ADDR which is LEN bytes long. */
62 template<typename T, typename = RequireLongest<T>>
63 extern void store_integer (gdb::array_view<gdb_byte> dst,
64 bfd_endian byte_order, T val);
66 template<typename T>
67 static inline void
68 store_integer (gdb_byte *addr, int len, bfd_endian byte_order, T val)
70 return store_integer (gdb::make_array_view (addr, len), byte_order, val);
73 static inline void
74 store_signed_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
75 LONGEST val)
77 return store_integer (dst, byte_order, val);
80 static inline void
81 store_signed_integer (gdb_byte *addr, int len, bfd_endian byte_order,
82 LONGEST val)
84 return store_signed_integer (gdb::make_array_view (addr, len), byte_order,
85 val);
88 static inline void
89 store_unsigned_integer (gdb::array_view<gdb_byte> dst, bfd_endian byte_order,
90 ULONGEST val)
92 return store_integer (dst, byte_order, val);
95 static inline void
96 store_unsigned_integer (gdb_byte *addr, int len, bfd_endian byte_order,
97 ULONGEST val)
99 return store_unsigned_integer (gdb::make_array_view (addr, len), byte_order,
100 val);
103 extern void store_typed_address (gdb_byte *buf, struct type *type,
104 CORE_ADDR addr);
106 extern void copy_integer_to_size (gdb_byte *dest, int dest_size,
107 const gdb_byte *source, int source_size,
108 bool is_signed, enum bfd_endian byte_order);
110 #endif /* GDB_EXTRACT_STORE_INTEGER_H */