xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/print-utils.h (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
18dffb485Schristos /* Cell-based print utility routines for GDB, the GNU debugger.
28dffb485Schristos 
3*5ba1f45fSchristos    Copyright (C) 1986-2024 Free Software Foundation, Inc.
48dffb485Schristos 
58dffb485Schristos    This file is part of GDB.
68dffb485Schristos 
78dffb485Schristos    This program is free software; you can redistribute it and/or modify
88dffb485Schristos    it under the terms of the GNU General Public License as published by
98dffb485Schristos    the Free Software Foundation; either version 3 of the License, or
108dffb485Schristos    (at your option) any later version.
118dffb485Schristos 
128dffb485Schristos    This program is distributed in the hope that it will be useful,
138dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
148dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158dffb485Schristos    GNU General Public License for more details.
168dffb485Schristos 
178dffb485Schristos    You should have received a copy of the GNU General Public License
188dffb485Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
198dffb485Schristos 
208dffb485Schristos #ifndef COMMON_PRINT_UTILS_H
218dffb485Schristos #define COMMON_PRINT_UTILS_H
228dffb485Schristos 
238dffb485Schristos /* How many characters (including the terminating null byte) fit in a
248dffb485Schristos    cell.  */
258dffb485Schristos #define PRINT_CELL_SIZE 50
268dffb485Schristos 
278dffb485Schristos /* %u for ULONGEST.  The result is stored in a circular static buffer,
288dffb485Schristos    NUMCELLS deep.  */
298dffb485Schristos 
30*5ba1f45fSchristos extern const char *pulongest (ULONGEST u);
318dffb485Schristos 
328dffb485Schristos /* %d for LONGEST.  The result is stored in a circular static buffer,
338dffb485Schristos    NUMCELLS deep.  */
348dffb485Schristos 
35*5ba1f45fSchristos extern const char *plongest (LONGEST l);
368dffb485Schristos 
378dffb485Schristos /* Convert a ULONGEST into a HEX string, like %lx, with leading zeros.
388dffb485Schristos    The result is stored in a circular static buffer, NUMCELLS deep.  */
398dffb485Schristos 
40*5ba1f45fSchristos extern const char *phex (ULONGEST l, int sizeof_l);
418dffb485Schristos 
428dffb485Schristos /* Convert a ULONGEST into a HEX string, like %lx, without leading zeros.
438dffb485Schristos    The result is  stored in a circular static buffer, NUMCELLS deep.  */
448dffb485Schristos 
45*5ba1f45fSchristos extern const char *phex_nz (ULONGEST l, int sizeof_l);
468dffb485Schristos 
478dffb485Schristos /* Converts a LONGEST to a C-format hexadecimal literal and stores it
488dffb485Schristos    in a static string.  Returns a pointer to this string.  */
498dffb485Schristos 
50*5ba1f45fSchristos extern const char *hex_string (LONGEST num);
518dffb485Schristos 
528dffb485Schristos /* Converts a LONGEST number to a C-format hexadecimal literal and
538dffb485Schristos    stores it in a static string.  Returns a pointer to this string
548dffb485Schristos    that is valid until the next call.  The number is padded on the
558dffb485Schristos    left with 0s to at least WIDTH characters.  */
568dffb485Schristos 
57*5ba1f45fSchristos extern const char *hex_string_custom (LONGEST num, int width);
588dffb485Schristos 
598dffb485Schristos /* Convert VAL to a numeral in the given radix.  For
608dffb485Schristos  * radix 10, IS_SIGNED may be true, indicating a signed quantity;
618dffb485Schristos  * otherwise VAL is interpreted as unsigned.  If WIDTH is supplied,
628dffb485Schristos  * it is the minimum width (0-padded if needed).  USE_C_FORMAT means
638dffb485Schristos  * to use C format in all cases.  If it is false, then 'x'
648dffb485Schristos  * and 'o' formats do not include a prefix (0x or leading 0).  */
658dffb485Schristos 
66*5ba1f45fSchristos extern const char *int_string (LONGEST val, int radix, int is_signed, int width,
678dffb485Schristos 			       int use_c_format);
688dffb485Schristos 
698dffb485Schristos /* Convert a CORE_ADDR into a string.  */
708dffb485Schristos 
718dffb485Schristos extern const char *core_addr_to_string (const CORE_ADDR addr);
728dffb485Schristos 
738dffb485Schristos extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
748dffb485Schristos 
758dffb485Schristos extern const char *host_address_to_string_1 (const void *addr);
768dffb485Schristos 
778dffb485Schristos /* Wrapper that avoids adding a pointless cast to all callers.  */
788dffb485Schristos #define host_address_to_string(ADDR) \
798dffb485Schristos   host_address_to_string_1 ((const void *) (ADDR))
808dffb485Schristos 
818dffb485Schristos /* Return the next entry in the circular print buffer.  */
828dffb485Schristos 
838dffb485Schristos extern char *get_print_cell (void);
848dffb485Schristos 
858dffb485Schristos #endif /* COMMON_PRINT_UTILS_H */
86