(root)/
strace-6.5/
src/
xlat.h
       1  /*
       2   * Copyright (c) 2016-2021 The strace developers.
       3   * All rights reserved.
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   */
       7  
       8  #ifndef STRACE_XLAT_H
       9  # define STRACE_XLAT_H
      10  
      11  # include <stdint.h>
      12  
      13  enum xlat_type {
      14  	XT_NORMAL,
      15  	XT_SORTED,
      16  	XT_INDEXED,
      17  };
      18  
      19  enum xlat_style {
      20  	/**
      21  	 * Special value that is used for passing to *print{xval,flags}*_ex
      22  	 * routines that indicates that no overriding of user-supplied xlat
      23  	 * verbosity/formatting configuration is intended.
      24  	 */
      25  	XLAT_STYLE_DEFAULT = 0,
      26  
      27  	/** Print xlat value as is without xlat processing */
      28  	XLAT_STYLE_RAW     = 1 << 0,
      29  	/**
      30  	 * Historic strace style, process xlat and print the result (xlat
      31  	 * constant name/combination of flags), raw number only if nothing is
      32  	 * found.
      33  	 */
      34  	XLAT_STYLE_ABBREV  = 1 << 1,
      35  	/** Always print both raw number and xlat processing result. */
      36  	XLAT_STYLE_VERBOSE = XLAT_STYLE_RAW | XLAT_STYLE_ABBREV,
      37  
      38  # define XLAT_STYLE_FORMAT_SHIFT   2
      39  # define XLAT_STYLE_VERBOSITY_MASK ((1 << XLAT_STYLE_FORMAT_SHIFT) - 1)
      40  
      41  	XLAT_STYLE_FMT_X   = 0 << XLAT_STYLE_FORMAT_SHIFT,
      42  	XLAT_STYLE_FMT_U   = 1 << XLAT_STYLE_FORMAT_SHIFT,
      43  	XLAT_STYLE_FMT_D   = 2 << XLAT_STYLE_FORMAT_SHIFT,
      44  
      45  # define XLAT_STYLE_FORMAT_MASK    (3 << XLAT_STYLE_FORMAT_SHIFT)
      46  
      47  # define XLAT_STYLE_SPEC_BITS (XLAT_STYLE_FORMAT_SHIFT + 2)
      48  # define XLAT_STYLE_MASK ((1 << XLAT_STYLE_SPEC_BITS) - 1)
      49  };
      50  
      51  struct xlat_data {
      52  	uint64_t val;
      53  	const char *str;
      54  };
      55  
      56  struct xlat {
      57  	const struct xlat_data *data;
      58  	size_t flags_strsz;
      59  	uint32_t size;
      60  	enum xlat_type type;
      61  	uint64_t flags_mask;
      62  };
      63  
      64  # define XLAT(val)			{ (unsigned)(val), #val }
      65  # define XLAT_PAIR(val, str)		{ (unsigned)(val), str  }
      66  # define XLAT_TYPE(type, val)		{     (type)(val), #val }
      67  # define XLAT_TYPE_PAIR(type, val, str)	{     (type)(val), str  }
      68  
      69  #endif /* !STRACE_XLAT_H */