Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 2012-2014 Chris Johns <chrisj@rtems.org>
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0025  * POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 /**
0028  * @file
0029  *
0030  * @ingroup rtems_rtl
0031  *
0032  * @brief RTEMS Run-Time Linker ELF Trace Support.
0033  */
0034 
0035 #if !defined (_RTEMS_RTL_TRACE_H_)
0036 #define _RTEMS_RTL_TRACE_H_
0037 
0038 #ifdef __cplusplus
0039 extern "C" {
0040 #endif /* __cplusplus */
0041 
0042 #include <stdbool.h>
0043 #include <stdint.h>
0044 
0045 #include <rtems/printer.h>
0046 
0047 /**
0048  * Set to 1 to build trace support in to the RTL code.
0049  */
0050 #define RTEMS_RTL_TRACE 1
0051 
0052 /**
0053  * The type of the mask.
0054  */
0055 typedef uint32_t rtems_rtl_trace_mask;
0056 
0057 /**
0058  * List of tracing bits for the various parts of the link editor.
0059  */
0060 #define RTEMS_RTL_TRACE_DETAIL                 (1UL << 0)
0061 #define RTEMS_RTL_TRACE_WARNING                (1UL << 1)
0062 #define RTEMS_RTL_TRACE_LOAD                   (1UL << 2)
0063 #define RTEMS_RTL_TRACE_UNLOAD                 (1UL << 3)
0064 #define RTEMS_RTL_TRACE_SECTION                (1UL << 4)
0065 #define RTEMS_RTL_TRACE_SYMBOL                 (1UL << 5)
0066 #define RTEMS_RTL_TRACE_RELOC                  (1UL << 6)
0067 #define RTEMS_RTL_TRACE_GLOBAL_SYM             (1UL << 7)
0068 #define RTEMS_RTL_TRACE_LOAD_SECT              (1UL << 8)
0069 #define RTEMS_RTL_TRACE_ALLOCATOR              (1UL << 9)
0070 #define RTEMS_RTL_TRACE_UNRESOLVED             (1UL << 10)
0071 #define RTEMS_RTL_TRACE_CACHE                  (1UL << 11)
0072 #define RTEMS_RTL_TRACE_ARCHIVES               (1UL << 12)
0073 #define RTEMS_RTL_TRACE_ARCHIVE_SYMS           (1UL << 13)
0074 #define RTEMS_RTL_TRACE_DEPENDENCY             (1UL << 14)
0075 #define RTEMS_RTL_TRACE_BIT_ALLOC              (1UL << 15)
0076 #define RTEMS_RTL_TRACE_COMP                   (1UL << 16)
0077 #define RTEMS_RTL_TRACE_ALL                    (0xffffffffUL & ~(RTEMS_RTL_TRACE_CACHE | \
0078                                                                  RTEMS_RTL_TRACE_COMP | \
0079                                                                  RTEMS_RTL_TRACE_GLOBAL_SYM | \
0080                                                                  RTEMS_RTL_TRACE_ARCHIVE_SYMS))
0081 
0082 /**
0083  * Call to check if this part is bring traced. If RTEMS_RTL_TRACE is defined to
0084  * 0 the code is dead code elminiated when built with -Os, -O2, or higher.
0085  *
0086  * @param mask The part of the API to trace.
0087  * @retval true Tracing is active for the mask.
0088  * @retval false Do not trace.
0089  */
0090 #if RTEMS_RTL_TRACE
0091 bool rtems_rtl_trace (rtems_rtl_trace_mask mask);
0092 #else
0093 #define rtems_rtl_trace(_m) (0)
0094 #endif
0095 
0096 /**
0097  * Set the mask.
0098  *
0099  * @param mask The mask bits to set.
0100  * @return The previous mask.
0101  */
0102 #if RTEMS_RTL_TRACE
0103 rtems_rtl_trace_mask rtems_rtl_trace_set_mask (rtems_rtl_trace_mask mask);
0104 #else
0105 #define rtems_rtl_trace_set_mask(_m)
0106 #endif
0107 
0108 /**
0109  * Clear the mask.
0110  *
0111  * @param mask The mask bits to clear.
0112  * @return The previous mask.
0113  */
0114 #if RTEMS_RTL_TRACE
0115 rtems_rtl_trace_mask rtems_rtl_trace_clear_mask (rtems_rtl_trace_mask mask);
0116 #else
0117 #define rtems_rtl_trace_clear_mask(_m)
0118 #endif
0119 
0120 /**
0121  * Add shell trace shell command.
0122  */
0123 #if RTEMS_RTL_TRACE
0124 int rtems_rtl_trace_shell_command (const rtems_printer* printer,
0125                    int                  argc,
0126                    char*                argv[]);
0127 #endif
0128 
0129 #ifdef __cplusplus
0130 }
0131 #endif /* __cplusplus */
0132 
0133 #endif