print-utils.h 3.0 KB

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