]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdbsupport/print-utils.h
gdbsupport: constify some return values in print-utils.{h,cc}
[thirdparty/binutils-gdb.git] / gdbsupport / print-utils.h
CommitLineData
01fd3ea5
TT
1/* Cell-based print utility routines for GDB, the GNU debugger.
2
1d506c26 3 Copyright (C) 1986-2024 Free Software Foundation, Inc.
01fd3ea5
TT
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
1a5c2598
TT
20#ifndef COMMON_PRINT_UTILS_H
21#define COMMON_PRINT_UTILS_H
01fd3ea5 22
43792cf0
PA
23/* How many characters (including the terminating null byte) fit in a
24 cell. */
25#define PRINT_CELL_SIZE 50
26
5f93c5a6 27/* %u for ULONGEST. The result is stored in a circular static buffer,
01fd3ea5
TT
28 NUMCELLS deep. */
29
523e454f 30extern const char *pulongest (ULONGEST u);
01fd3ea5 31
5f93c5a6 32/* %d for LONGEST. The result is stored in a circular static buffer,
01fd3ea5
TT
33 NUMCELLS deep. */
34
523e454f 35extern const char *plongest (LONGEST l);
01fd3ea5 36
5f93c5a6
JW
37/* Convert a ULONGEST into a HEX string, like %lx, with leading zeros.
38 The result is stored in a circular static buffer, NUMCELLS deep. */
39
523e454f 40extern const char *phex (ULONGEST l, int sizeof_l);
01fd3ea5 41
5f93c5a6
JW
42/* Convert a ULONGEST into a HEX string, like %lx, without leading zeros.
43 The result is stored in a circular static buffer, NUMCELLS deep. */
01fd3ea5 44
523e454f 45extern const char *phex_nz (ULONGEST l, int sizeof_l);
01fd3ea5
TT
46
47/* Converts a LONGEST to a C-format hexadecimal literal and stores it
48 in a static string. Returns a pointer to this string. */
49
523e454f 50extern const char *hex_string (LONGEST num);
01fd3ea5
TT
51
52/* Converts a LONGEST number to a C-format hexadecimal literal and
53 stores it in a static string. Returns a pointer to this string
54 that is valid until the next call. The number is padded on the
55 left with 0s to at least WIDTH characters. */
56
523e454f 57extern const char *hex_string_custom (LONGEST num, int width);
01fd3ea5
TT
58
59/* Convert VAL to a numeral in the given radix. For
60 * radix 10, IS_SIGNED may be true, indicating a signed quantity;
61 * otherwise VAL is interpreted as unsigned. If WIDTH is supplied,
62 * it is the minimum width (0-padded if needed). USE_C_FORMAT means
63 * to use C format in all cases. If it is false, then 'x'
64 * and 'o' formats do not include a prefix (0x or leading 0). */
65
523e454f
SM
66extern const char *int_string (LONGEST val, int radix, int is_signed, int width,
67 int use_c_format);
01fd3ea5
TT
68
69/* Convert a CORE_ADDR into a string. */
70
71extern const char *core_addr_to_string (const CORE_ADDR addr);
72
73extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
74
b80c3053
PA
75extern const char *host_address_to_string_1 (const void *addr);
76
77/* Wrapper that avoids adding a pointless cast to all callers. */
78#define host_address_to_string(ADDR) \
79 host_address_to_string_1 ((const void *) (ADDR))
01fd3ea5 80
43792cf0
PA
81/* Return the next entry in the circular print buffer. */
82
83extern char *get_print_cell (void);
84
1a5c2598 85#endif /* COMMON_PRINT_UTILS_H */