diff options
Diffstat (limited to 'source/include/acoutput.h')
| -rw-r--r-- | source/include/acoutput.h | 154 | 
1 files changed, 151 insertions, 3 deletions
| diff --git a/source/include/acoutput.h b/source/include/acoutput.h index 193d0acc4c81..236124dda278 100644 --- a/source/include/acoutput.h +++ b/source/include/acoutput.h @@ -267,18 +267,140 @@   * Common parameters used for debug output functions:   * line number, function name, module(file) name, component ID   */ -#define ACPI_DEBUG_PARAMETERS           __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT +#define ACPI_DEBUG_PARAMETERS \ +    __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* Check if debug output is currently dynamically enabled */ + +#define ACPI_IS_DEBUG_ENABLED(Level, Component) \ +    ((Level & AcpiDbgLevel) && (Component & AcpiDbgLayer))  /*   * Master debug print macros   * Print message if and only if:   *    1) Debug print for the current component is enabled   *    2) Debug error level or trace level for the print statement is enabled + * + * November 2012: Moved the runtime check for whether to actually emit the + * debug message outside of the print function itself. This improves overall + * performance at a relatively small code cost. Implementation involves the + * use of variadic macros supported by C99. + */ + +/* DEBUG_PRINT functions */ + +#define ACPI_DEBUG_PRINT(plist)         ACPI_ACTUAL_DEBUG plist +#define ACPI_DEBUG_PRINT_RAW(plist)     ACPI_ACTUAL_DEBUG_RAW plist + +/* Helper macros for DEBUG_PRINT */ + +#define ACPI_DEBUG(Function, Level, Line, Filename, Modulename, Component, ...) \ +    if (ACPI_IS_DEBUG_ENABLED (Level, Component)) \ +    { \ +        Function (Level, Line, Filename, Modulename, Component, __VA_ARGS__); \ +    } + +#define ACPI_ACTUAL_DEBUG(Level, Line, Filename, Modulename, Component, ...) \ +    ACPI_DEBUG (AcpiDebugPrint, Level, Line, Filename, Modulename, Component, __VA_ARGS__) + +#define ACPI_ACTUAL_DEBUG_RAW(Level, Line, Filename, Modulename, Component, ...) \ +    ACPI_DEBUG (AcpiDebugPrintRaw, Level, Line, Filename, Modulename, Component, __VA_ARGS__) + + +/* + * Function entry tracing + * + * The name of the function is emitted as a local variable that is + * intended to be used by both the entry trace and the exit trace.   */ -#define ACPI_DEBUG_PRINT(plist)         AcpiDebugPrint plist -#define ACPI_DEBUG_PRINT_RAW(plist)     AcpiDebugPrintRaw plist +/* Helper macro */ + +#define ACPI_TRACE_ENTRY(Name, Function, Cast, Param) \ +    ACPI_FUNCTION_NAME (Name) \ +    Function (ACPI_DEBUG_PARAMETERS, Cast (Param)) + +/* The actual entry trace macros */ + +#define ACPI_FUNCTION_TRACE(Name) \ +    ACPI_FUNCTION_NAME(Name) \ +    AcpiUtTrace (ACPI_DEBUG_PARAMETERS) + +#define ACPI_FUNCTION_TRACE_PTR(Name, Pointer) \ +    ACPI_TRACE_ENTRY (Name, AcpiUtTracePtr, (void *), Pointer) + +#define ACPI_FUNCTION_TRACE_U32(Name, Value) \ +    ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, (UINT32), Value) + +#define ACPI_FUNCTION_TRACE_STR(Name, String) \ +    ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, (char *), String) + +#define ACPI_FUNCTION_ENTRY() \ +    AcpiUtTrackStackPtr() + + +/* + * Function exit tracing + * + * These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro before the actual return + * is very ugly and difficult to maintain. + * + * One of the FUNCTION_TRACE macros above must be used in conjunction + * with these macros so that "_AcpiFunctionName" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from + * complaining about these constructs. On other compilers the do...while + * adds some extra code, so this feature is optional. + */ +#ifdef ACPI_USE_DO_WHILE_0 +#define ACPI_DO_WHILE0(a)               do a while(0)  #else +#define ACPI_DO_WHILE0(a)               a +#endif + +/* Exit trace helper macro */ + +#define ACPI_TRACE_EXIT(Function, Cast, Param) \ +    ACPI_DO_WHILE0 ({ \ +        Function (ACPI_DEBUG_PARAMETERS, Cast (Param)); \ +        return ((Param)); \ +    }) + +/* The actual exit macros */ + +#define return_VOID \ +    ACPI_DO_WHILE0 ({ \ +        AcpiUtExit (ACPI_DEBUG_PARAMETERS); \ +        return; \ +    }) + +#define return_ACPI_STATUS(Status) \ +    ACPI_TRACE_EXIT (AcpiUtStatusExit, (ACPI_STATUS), Status) + +#define return_PTR(Pointer) \ +    ACPI_TRACE_EXIT (AcpiUtPtrExit, (UINT8 *), Pointer) + +#define return_VALUE(Value) \ +    ACPI_TRACE_EXIT (AcpiUtValueExit, (UINT64), Value) + + +/* Conditional execution */ + +#define ACPI_DEBUG_EXEC(a)              a +#define ACPI_DEBUG_ONLY_MEMBERS(a)      a; +#define _VERBOSE_STRUCTURES + + +/* Various object display routines for debug */ + +#define ACPI_DUMP_STACK_ENTRY(a)        AcpiExDumpOperand((a), 0) +#define ACPI_DUMP_OPERANDS(a, b ,c)     AcpiExDumpOperands(a, b, c) +#define ACPI_DUMP_ENTRY(a, b)           AcpiNsDumpEntry (a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d)  AcpiNsDumpPathname(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b)          AcpiUtDebugDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) + +#else /* ACPI_DEBUG_OUTPUT */  /*   * This is the non-debug case -- make everything go away,   * leaving no executable debug code! @@ -286,6 +408,32 @@  #define ACPI_FUNCTION_NAME(a)  #define ACPI_DEBUG_PRINT(pl)  #define ACPI_DEBUG_PRINT_RAW(pl) +#define ACPI_DEBUG_EXEC(a) +#define ACPI_DEBUG_ONLY_MEMBERS(a) +#define ACPI_FUNCTION_TRACE(a) +#define ACPI_FUNCTION_TRACE_PTR(a, b) +#define ACPI_FUNCTION_TRACE_U32(a, b) +#define ACPI_FUNCTION_TRACE_STR(a, b) +#define ACPI_FUNCTION_EXIT +#define ACPI_FUNCTION_STATUS_EXIT(s) +#define ACPI_FUNCTION_VALUE_EXIT(s) +#define ACPI_FUNCTION_ENTRY() +#define ACPI_DUMP_STACK_ENTRY(a) +#define ACPI_DUMP_OPERANDS(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) +#define ACPI_DUMP_TABLES(a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) +#define ACPI_IS_DEBUG_ENABLED(Level, Component) 0 + +/* Return macros must have a return statement at the minimum */ + +#define return_VOID                     return +#define return_ACPI_STATUS(s)           return(s) +#define return_VALUE(s)                 return(s) +#define return_PTR(s)                   return(s)  #endif /* ACPI_DEBUG_OUTPUT */ | 
