ReactOS 0.4.15-dev-7711-g5627da4
dsdebug.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: dsdebug - Parser/Interpreter interface - debugging
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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 MERCHANTABILITY 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.
42 */
43
44#include "acpi.h"
45#include "accommon.h"
46#include "acdispat.h"
47#include "acnamesp.h"
48#include "acdisasm.h"
49#include "acinterp.h"
50
51
52#define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsdebug")
54
55
56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
57
58/* Local prototypes */
59
60static void
61AcpiDsPrintNodePathname (
63 const char *Message);
64
65
66/*******************************************************************************
67 *
68 * FUNCTION: AcpiDsPrintNodePathname
69 *
70 * PARAMETERS: Node - Object
71 * Message - Prefix message
72 *
73 * DESCRIPTION: Print an object's full namespace pathname
74 * Manages allocation/freeing of a pathname buffer
75 *
76 ******************************************************************************/
77
78static void
79AcpiDsPrintNodePathname (
81 const char *Message)
82{
85
86
87 ACPI_FUNCTION_TRACE (DsPrintNodePathname);
88
89 if (!Node)
90 {
91 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "[NULL NAME]"));
93 }
94
95 /* Convert handle to full pathname and print it (with supplied message) */
96
98
100 if (ACPI_SUCCESS (Status))
101 {
102 if (Message)
103 {
105 }
106
107 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "[%s] (Node %p)",
108 (char *) Buffer.Pointer, Node));
109 ACPI_FREE (Buffer.Pointer);
110 }
111
113}
114
115
116/*******************************************************************************
117 *
118 * FUNCTION: AcpiDsDumpMethodStack
119 *
120 * PARAMETERS: Status - Method execution status
121 * WalkState - Current state of the parse tree walk
122 * Op - Executing parse op
123 *
124 * RETURN: None
125 *
126 * DESCRIPTION: Called when a method has been aborted because of an error.
127 * Dumps the method execution stack.
128 *
129 ******************************************************************************/
130
131void
134 ACPI_WALK_STATE *WalkState,
136{
137 ACPI_PARSE_OBJECT *Next;
139 ACPI_WALK_STATE *NextWalkState;
140 ACPI_NAMESPACE_NODE *PreviousMethod = NULL;
141 ACPI_OPERAND_OBJECT *MethodDesc;
142
143
144 ACPI_FUNCTION_TRACE (DsDumpMethodStack);
145
146
147 /* Ignore control codes, they are not errors */
148
150 {
152 }
153
154 /* We may be executing a deferred opcode */
155
156 if (WalkState->DeferredNode)
157 {
159 "Executing subtree for Buffer/Package/Region\n"));
161 }
162
163 /*
164 * If there is no Thread, we are not actually executing a method.
165 * This can happen when the iASL compiler calls the interpreter
166 * to perform constant folding.
167 */
168 Thread = WalkState->Thread;
169 if (!Thread)
170 {
172 }
173
174 /* Display exception and method name */
175
177 "\n**** Exception %s during execution of method ",
179
180 AcpiDsPrintNodePathname (WalkState->MethodNode, NULL);
181
182 /* Display stack of executing methods */
183
185 "\n\nMethod Execution Stack:\n"));
186 NextWalkState = Thread->WalkStateList;
187
188 /* Walk list of linked walk states */
189
190 while (NextWalkState)
191 {
192 MethodDesc = NextWalkState->MethodDesc;
193 if (MethodDesc)
194 {
196 (ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
197 MethodDesc, WalkState);
198 }
199
201 " Method [%4.4s] executing: ",
202 AcpiUtGetNodeName (NextWalkState->MethodNode)));
203
204 /* First method is the currently executing method */
205
206 if (NextWalkState == WalkState)
207 {
208 if (Op)
209 {
210 /* Display currently executing ASL statement */
211
212 Next = Op->Common.Next;
213 Op->Common.Next = NULL;
214
215#ifdef ACPI_DISASSEMBLER
216 if (WalkState->MethodNode != AcpiGbl_RootNode)
217 {
218 /* More verbose if not module-level code */
219
220 AcpiOsPrintf ("Failed at ");
221 AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX);
222 }
223#endif
224 Op->Common.Next = Next;
225 }
226 }
227 else
228 {
229 /*
230 * This method has called another method
231 * NOTE: the method call parse subtree is already deleted at
232 * this point, so we cannot disassemble the method invocation.
233 */
234 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Call to method "));
235 AcpiDsPrintNodePathname (PreviousMethod, NULL);
236 }
237
238 PreviousMethod = NextWalkState->MethodNode;
239 NextWalkState = NextWalkState->Next;
241 }
242
244}
245
246#else
247
248void
251 ACPI_WALK_STATE *WalkState,
253{
254 return;
255}
256
257#endif
void AcpiDmDisassemble(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Origin, UINT32 NumOpcodes)
#define ACPI_CNTL_EXCEPTION(Status)
Definition: acexcep.h:103
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
ACPI_STATUS AcpiNsHandleToPathname(ACPI_HANDLE TargetHandle, ACPI_BUFFER *Buffer, BOOLEAN NoTrailing)
Definition: nsnames.c:187
#define ACPI_DB_DISPATCH
Definition: acoutput.h:163
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define return_VOID
Definition: acoutput.h:495
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
#define ACPI_FREE(a)
Definition: actypes.h:386
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_ALLOCATE_LOCAL_BUFFER
Definition: actypes.h:1047
#define ACPI_UINT32_MAX
Definition: actypes.h:66
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static const WCHAR Message[]
Definition: register.c:74
void AcpiDsDumpMethodStack(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsdebug.c:249
void AcpiExStopTraceMethod(ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: extrace.c:290
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:25
union acpi_operand_object * Node
Definition: acobject.h:220
union acpi_operand_object * MethodDesc
Definition: acstruct.h:115
struct acpi_namespace_node * MethodNode
Definition: acstruct.h:116
struct acpi_walk_state * Next
Definition: acstruct.h:75
struct acpi_namespace_node * DeferredNode
Definition: acstruct.h:111
ACPI_THREAD_STATE * Thread
Definition: acstruct.h:127
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
Definition: dlist.c:348
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70