xref: /netbsd-src/external/gpl3/gdb.old/dist/gdbsupport/print-utils.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* Cell-based print utility routines for GDB, the GNU debugger.
27d62b00eSchristos 
3*6881a400Schristos    Copyright (C) 1986-2023 Free Software Foundation, Inc.
47d62b00eSchristos 
57d62b00eSchristos    This file is part of GDB.
67d62b00eSchristos 
77d62b00eSchristos    This program is free software; you can redistribute it and/or modify
87d62b00eSchristos    it under the terms of the GNU General Public License as published by
97d62b00eSchristos    the Free Software Foundation; either version 3 of the License, or
107d62b00eSchristos    (at your option) any later version.
117d62b00eSchristos 
127d62b00eSchristos    This program is distributed in the hope that it will be useful,
137d62b00eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
147d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
157d62b00eSchristos    GNU General Public License for more details.
167d62b00eSchristos 
177d62b00eSchristos    You should have received a copy of the GNU General Public License
187d62b00eSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
197d62b00eSchristos 
207d62b00eSchristos #ifndef COMMON_PRINT_UTILS_H
217d62b00eSchristos #define COMMON_PRINT_UTILS_H
227d62b00eSchristos 
237d62b00eSchristos /* How many characters (including the terminating null byte) fit in a
247d62b00eSchristos    cell.  */
257d62b00eSchristos #define PRINT_CELL_SIZE 50
267d62b00eSchristos 
277d62b00eSchristos /* %u for ULONGEST.  The result is stored in a circular static buffer,
287d62b00eSchristos    NUMCELLS deep.  */
297d62b00eSchristos 
307d62b00eSchristos extern char *pulongest (ULONGEST u);
317d62b00eSchristos 
327d62b00eSchristos /* %d for LONGEST.  The result is stored in a circular static buffer,
337d62b00eSchristos    NUMCELLS deep.  */
347d62b00eSchristos 
357d62b00eSchristos extern char *plongest (LONGEST l);
367d62b00eSchristos 
377d62b00eSchristos /* Convert a ULONGEST into a HEX string, like %lx, with leading zeros.
387d62b00eSchristos    The result is stored in a circular static buffer, NUMCELLS deep.  */
397d62b00eSchristos 
407d62b00eSchristos extern char *phex (ULONGEST l, int sizeof_l);
417d62b00eSchristos 
427d62b00eSchristos /* Convert a ULONGEST into a HEX string, like %lx, without leading zeros.
437d62b00eSchristos    The result is  stored in a circular static buffer, NUMCELLS deep.  */
447d62b00eSchristos 
457d62b00eSchristos extern char *phex_nz (ULONGEST l, int sizeof_l);
467d62b00eSchristos 
477d62b00eSchristos /* Converts a LONGEST to a C-format hexadecimal literal and stores it
487d62b00eSchristos    in a static string.  Returns a pointer to this string.  */
497d62b00eSchristos 
507d62b00eSchristos extern char *hex_string (LONGEST num);
517d62b00eSchristos 
527d62b00eSchristos /* Converts a LONGEST number to a C-format hexadecimal literal and
537d62b00eSchristos    stores it in a static string.  Returns a pointer to this string
547d62b00eSchristos    that is valid until the next call.  The number is padded on the
557d62b00eSchristos    left with 0s to at least WIDTH characters.  */
567d62b00eSchristos 
577d62b00eSchristos extern char *hex_string_custom (LONGEST num, int width);
587d62b00eSchristos 
597d62b00eSchristos /* Convert VAL to a numeral in the given radix.  For
607d62b00eSchristos  * radix 10, IS_SIGNED may be true, indicating a signed quantity;
617d62b00eSchristos  * otherwise VAL is interpreted as unsigned.  If WIDTH is supplied,
627d62b00eSchristos  * it is the minimum width (0-padded if needed).  USE_C_FORMAT means
637d62b00eSchristos  * to use C format in all cases.  If it is false, then 'x'
647d62b00eSchristos  * and 'o' formats do not include a prefix (0x or leading 0).  */
657d62b00eSchristos 
667d62b00eSchristos extern char *int_string (LONGEST val, int radix, int is_signed, int width,
677d62b00eSchristos 			 int use_c_format);
687d62b00eSchristos 
697d62b00eSchristos /* Convert a CORE_ADDR into a string.  */
707d62b00eSchristos 
717d62b00eSchristos extern const char *core_addr_to_string (const CORE_ADDR addr);
727d62b00eSchristos 
737d62b00eSchristos extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
747d62b00eSchristos 
757d62b00eSchristos extern const char *host_address_to_string_1 (const void *addr);
767d62b00eSchristos 
777d62b00eSchristos /* Wrapper that avoids adding a pointless cast to all callers.  */
787d62b00eSchristos #define host_address_to_string(ADDR) \
797d62b00eSchristos   host_address_to_string_1 ((const void *) (ADDR))
807d62b00eSchristos 
817d62b00eSchristos /* Return the next entry in the circular print buffer.  */
827d62b00eSchristos 
837d62b00eSchristos extern char *get_print_cell (void);
847d62b00eSchristos 
857d62b00eSchristos #endif /* COMMON_PRINT_UTILS_H */
86