gdb/common/format.h - gdb

Data types defined

Macros defined

Source code

  1. /* Parse a printf-style format string.

  2.    Copyright (C) 1986-2015 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. #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
  15. # define USE_PRINTF_I64 1
  16. # define PRINTF_HAS_LONG_LONG
  17. #else
  18. # define USE_PRINTF_I64 0
  19. #endif

  20. /* The argclass represents the general type of data that goes with a
  21.    format directive; int_arg for %d, long_arg for %l, and so forth.
  22.    Note that these primarily distinguish types by size and need for
  23.    special handling, so for instance %u and %x are (at present) also
  24.    classed as int_arg.  */

  25. enum argclass
  26.   {
  27.     literal_piece,
  28.     int_arg, long_arg, long_long_arg, ptr_arg,
  29.     string_arg, wide_string_arg, wide_char_arg,
  30.     double_arg, long_double_arg, decfloat_arg
  31.   };

  32. /* A format piece is a section of the format string that may include a
  33.    single print directive somewhere in it, and the associated class
  34.    for the argument.  */

  35. struct format_piece
  36. {
  37.   char *string;
  38.   enum argclass argclass;
  39. };

  40. /* Return an array of printf fragments found at the given string, and
  41.    rewrite ARG with a pointer to the end of the format string.  */

  42. extern struct format_piece *parse_format_string (const char **arg);

  43. /* Given a pointer to an array of format pieces, free any memory that
  44.    would have been allocated by parse_format_string.  */

  45. extern void free_format_pieces (struct format_piece *frags);

  46. /* Freeing, cast as a cleanup.  */

  47. extern void free_format_pieces_cleanup (void *);