1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: dsdebug - Parser/Interpreter interface - debugging
6 * Copyright (C) 2000 - 2019, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
14 #ifdef ACPI_DISASSEMBLER
19 #define _COMPONENT ACPI_DISPATCHER
20 ACPI_MODULE_NAME("dsdebug")
22 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
23 /* Local prototypes */
25 acpi_ds_print_node_pathname(struct acpi_namespace_node
*node
,
28 /*******************************************************************************
30 * FUNCTION: acpi_ds_print_node_pathname
32 * PARAMETERS: node - Object
33 * message - Prefix message
35 * DESCRIPTION: Print an object's full namespace pathname
36 * Manages allocation/freeing of a pathname buffer
38 ******************************************************************************/
41 acpi_ds_print_node_pathname(struct acpi_namespace_node
*node
,
44 struct acpi_buffer buffer
;
47 ACPI_FUNCTION_TRACE(ds_print_node_pathname
);
50 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
, "[NULL NAME]"));
54 /* Convert handle to full pathname and print it (with supplied message) */
56 buffer
.length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
58 status
= acpi_ns_handle_to_pathname(node
, &buffer
, TRUE
);
59 if (ACPI_SUCCESS(status
)) {
61 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
, "%s ",
65 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
, "[%s] (Node %p)",
66 (char *)buffer
.pointer
, node
));
67 ACPI_FREE(buffer
.pointer
);
73 /*******************************************************************************
75 * FUNCTION: acpi_ds_dump_method_stack
77 * PARAMETERS: status - Method execution status
78 * walk_state - Current state of the parse tree walk
79 * op - Executing parse op
83 * DESCRIPTION: Called when a method has been aborted because of an error.
84 * Dumps the method execution stack.
86 ******************************************************************************/
89 acpi_ds_dump_method_stack(acpi_status status
,
90 struct acpi_walk_state
*walk_state
,
91 union acpi_parse_object
*op
)
93 union acpi_parse_object
*next
;
94 struct acpi_thread_state
*thread
;
95 struct acpi_walk_state
*next_walk_state
;
96 struct acpi_namespace_node
*previous_method
= NULL
;
97 union acpi_operand_object
*method_desc
;
99 ACPI_FUNCTION_TRACE(ds_dump_method_stack
);
101 /* Ignore control codes, they are not errors */
103 if ((status
& AE_CODE_MASK
) == AE_CODE_CONTROL
) {
107 /* We may be executing a deferred opcode */
109 if (walk_state
->deferred_node
) {
110 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH
,
111 "Executing subtree for Buffer/Package/Region\n"));
116 * If there is no Thread, we are not actually executing a method.
117 * This can happen when the iASL compiler calls the interpreter
118 * to perform constant folding.
120 thread
= walk_state
->thread
;
125 /* Display exception and method name */
127 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH
,
128 "\n**** Exception %s during execution of method ",
129 acpi_format_exception(status
)));
131 acpi_ds_print_node_pathname(walk_state
->method_node
, NULL
);
133 /* Display stack of executing methods */
135 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
,
136 "\n\nMethod Execution Stack:\n"));
137 next_walk_state
= thread
->walk_state_list
;
139 /* Walk list of linked walk states */
141 while (next_walk_state
) {
142 method_desc
= next_walk_state
->method_desc
;
144 acpi_ex_stop_trace_method((struct acpi_namespace_node
*)
145 method_desc
->method
.node
,
146 method_desc
, walk_state
);
149 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH
,
150 " Method [%4.4s] executing: ",
151 acpi_ut_get_node_name(next_walk_state
->
154 /* First method is the currently executing method */
156 if (next_walk_state
== walk_state
) {
159 /* Display currently executing ASL statement */
161 next
= op
->common
.next
;
162 op
->common
.next
= NULL
;
164 #ifdef ACPI_DISASSEMBLER
165 if (walk_state
->method_node
!=
166 acpi_gbl_root_node
) {
168 /* More verbose if not module-level code */
170 acpi_os_printf("Failed at ");
171 acpi_dm_disassemble(next_walk_state
, op
,
175 op
->common
.next
= next
;
179 * This method has called another method
180 * NOTE: the method call parse subtree is already deleted at
181 * this point, so we cannot disassemble the method invocation.
183 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
,
185 acpi_ds_print_node_pathname(previous_method
, NULL
);
188 previous_method
= next_walk_state
->method_node
;
189 next_walk_state
= next_walk_state
->next
;
190 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DISPATCH
, "\n"));
198 acpi_ds_dump_method_stack(acpi_status status
,
199 struct acpi_walk_state
*walk_state
,
200 union acpi_parse_object
*op
)