1 /* This test script is part of GDB, the GNU debugger.
3 Copyright 1999-2023 Free Software Foundation, Inc.
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 /* Test long long expression; test printing in general.
20 * /CLO/BUILD_ENV/Exports/cc -g +e -o long_long long_long.c
24 * cc +e +DA2.0 -g -o long_long long_long.c
29 enum { MAX_BYTES
= 16 };
32 pack (unsigned char b
[MAX_BYTES
], int size
, int nr
)
34 static long long val
[] = { 0x123456789abcdefLL
, 01234567123456701234567LL, 12345678901234567890ULL};
35 volatile static int e
= 1;
37 for (i
= 0; i
< nr
; i
++)
42 offset
= sizeof (long long) - size
;
44 /* Big endian endian. */
46 memcpy (b
+ size
* i
, (char *) val
+ sizeof (long long) * i
+ offset
, size
);
50 unsigned char b
[MAX_BYTES
];
51 unsigned char h
[MAX_BYTES
];
52 unsigned char w
[MAX_BYTES
];
53 unsigned char g
[MAX_BYTES
];
55 unsigned char c
[MAX_BYTES
];
56 unsigned char s
[MAX_BYTES
];
57 unsigned char i
[MAX_BYTES
];
58 unsigned char l
[MAX_BYTES
];
59 unsigned char ll
[MAX_BYTES
];
63 /* A union is used here as, hopefully it has well defined packing
66 long long bin
, oct
, dec
, hex
;
68 memset (&val
, 0, sizeof val
);
70 /* Known values, filling the full 64 bits. */
71 val
.bin
= 0x123456789abcdefLL
; /* 64 bits = 16 hex digits */
72 val
.oct
= 01234567123456701234567LL; /* = 21+ octal digits */
73 val
.dec
= 12345678901234567890ULL; /* = 19+ decimal digits */
75 /* Stop here and look! */
76 val
.hex
= val
.bin
- val
.dec
| val
.oct
;
83 /* Pack Byte, Half, Word and Giant arrays with byte-ordered values.
84 That way "(gdb) x" gives the same output on different
90 pack (c
, sizeof (char), 2);
91 pack (s
, sizeof (short), 2);
92 pack (i
, sizeof (int), 2);
93 pack (l
, sizeof (long), 2);
94 pack (ll
, sizeof (long long), 2);