1 /******************************************************************************
3 * Module Name: asldebug -- Debug output support
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2017, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <contrib/dev/acpica/compiler/aslcompiler.h>
45 #include "aslcompiler.y.h"
48 #define _COMPONENT ACPI_COMPILER
49 ACPI_MODULE_NAME ("asldebug")
52 /* Local prototypes */
56 ACPI_PARSE_OBJECT *Op,
61 /*******************************************************************************
63 * FUNCTION: UtDumpIntegerOp
65 * PARAMETERS: Op - Current parse op
66 * Level - Current output indentation level
67 * IntegerLength - Output length of the integer (2/4/8/16)
71 * DESCRIPTION: Emit formatted debug output for "integer" ops.
72 * Note: IntegerLength must be one of 2,4,8,16.
74 ******************************************************************************/
78 ACPI_PARSE_OBJECT *Op,
83 /* Emit the ParseOp name, leaving room for the integer */
85 UtDumpParseOpName (Op, Level, IntegerLength);
87 /* Emit the integer based upon length */
89 switch (IntegerLength)
95 DbgPrint (ASL_TREE_OUTPUT,
96 "%*.*X", IntegerLength, IntegerLength, Op->Asl.Value.Integer);
99 case 16: /* Qword and Integer */
101 DbgPrint (ASL_TREE_OUTPUT,
102 "%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
111 /*******************************************************************************
113 * FUNCTION: UtDumpStringOp
115 * PARAMETERS: Op - Current parse op
116 * Level - Current output indentation level
120 * DESCRIPTION: Emit formatted debug output for String/Pathname ops.
122 ******************************************************************************/
126 ACPI_PARSE_OBJECT *Op,
132 String = Op->Asl.Value.String;
134 if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)
137 * For the "path" ops NAMEPATH, NAMESEG, METHODCALL -- if the
138 * ExternalName is valid, it takes precedence. In these cases the
139 * Value.String is the raw "internal" name from the AML code, which
140 * we don't want to use, because it contains non-ascii characters.
142 if (Op->Asl.ExternalName)
144 String = Op->Asl.ExternalName;
150 DbgPrint (ASL_TREE_OUTPUT,
151 " ERROR: Could not find a valid String/Path pointer\n");
155 /* Emit the ParseOp name, leaving room for the string */
157 UtDumpParseOpName (Op, Level, strlen (String));
158 DbgPrint (ASL_TREE_OUTPUT, "%s", String);
162 /*******************************************************************************
164 * FUNCTION: UtDumpBasicOp
166 * PARAMETERS: Op - Current parse op
167 * Level - Current output indentation level
171 * DESCRIPTION: Generic formatted debug output for "basic" ops that have no
172 * associated strings or integer values.
174 ******************************************************************************/
178 ACPI_PARSE_OBJECT *Op,
182 /* Just print out the ParseOp name, there is no extra data */
184 UtDumpParseOpName (Op, Level, 0);
188 /*******************************************************************************
190 * FUNCTION: UtDumpParseOpName
192 * PARAMETERS: Op - Current parse op
193 * Level - Current output indentation level
194 * DataLength - Length of data to appear after the name
198 * DESCRIPTION: Indent and emit the ascii ParseOp name for the op
200 ******************************************************************************/
204 ACPI_PARSE_OBJECT *Op,
212 UINT32 PaddingLength;
215 /* Emit the LineNumber/IndentLevel prefix on each output line */
217 DbgPrint (ASL_TREE_OUTPUT,
218 "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
220 ParseOpName = UtGetOpName (Op->Asl.ParseOpcode);
222 /* Calculate various lengths for output alignment */
224 IndentLength = Level * DEBUG_SPACES_PER_INDENT;
225 NameLength = strlen (ParseOpName);
226 LineLength = IndentLength + 1 + NameLength + 1 + DataLength;
227 PaddingLength = (DEBUG_MAX_LINE_LENGTH + 1) - LineLength;
229 /* Parse tree indentation is based upon the nesting/indent level */
233 DbgPrint (ASL_TREE_OUTPUT, "%*s", IndentLength, " ");
236 /* Emit the actual name here */
238 DbgPrint (ASL_TREE_OUTPUT, " %s", ParseOpName);
240 /* Emit extra padding blanks for alignment of later data items */
242 if (LineLength > DEBUG_MAX_LINE_LENGTH)
244 /* Split a long line immediately after the ParseOpName string */
246 DbgPrint (ASL_TREE_OUTPUT, "\n%*s",
247 (DEBUG_FULL_LINE_LENGTH - DataLength), " ");
251 DbgPrint (ASL_TREE_OUTPUT, "%*s", PaddingLength, " ");