50 const gdb_byte *source,
unsigned int source_offset,
51 unsigned int nbits,
int msb0)
53 size_t len = align_up (dest_offset + nbits, 8);
54 char *expected = (
char *) alloca (len + 1);
55 char *actual = (
char *) alloca (len + 1);
56 gdb_byte *buf = (gdb_byte *) alloca (len / 8);
76 bits_to_str (expected + dest_offset, source, source_offset, nbits, msb0);
80 memcpy (buf, dest, len / 8);
81 copy_bitwise (buf, dest_offset, source, source_offset, nbits, msb0);
85 expected[len] = actual[len] =
'\0';
86 if (strcmp (expected, actual) != 0)
87 error (_(
"copy_bitwise %s != %s (%u+%u -> %u)"),
88 expected, actual, source_offset, nbits, dest_offset);
105 static const gdb_byte data_lsb0[] = {
106 0x00, 0xf8, 0xff, 0x12, 0xa5, 0x4f
108 static const gdb_byte data_msb0[] = {
109 0x00, 0x1f, 0xff, 0x48, 0xa5, 0xf2
112 constexpr size_t data_nbits = 8 *
sizeof (data_lsb0);
113 constexpr unsigned max_nbits = 24;
121 for (
int msb0 = 0; msb0 < 2; msb0++)
123 const gdb_byte *data = msb0 ? data_msb0 : data_lsb0;
125 for (
unsigned int nbits = 1; nbits <= max_nbits; nbits++)
127 const unsigned int max_offset = data_nbits - nbits;
129 for (
unsigned source_offset = 0;
130 source_offset <= max_offset;
133 for (
unsigned dest_offset = 0;
134 dest_offset <= max_offset;
139 data + source_offset / 8,
static void check_copy_bitwise(const gdb_byte *dest, unsigned int dest_offset, const gdb_byte *source, unsigned int source_offset, unsigned int nbits, int msb0)
void copy_bitwise(gdb_byte *dest, ULONGEST dest_offset, const gdb_byte *source, ULONGEST source_offset, ULONGEST nbits, int bits_big_endian)