diff options
author | Bob Moore <robert.moore@intel.com> | 2015-12-29 00:54:44 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-12-31 21:47:34 -0500 |
commit | 5df2e3ed04862d9e6465b3b2748ef747d31c4bbc (patch) | |
tree | c088cf8d3cb0728a079b9c200219ca92fabe6659 | |
parent | 1fad87385e7e82f656fb661aef0f841e42991974 (diff) |
ACPICA: Split interpreter tracing functions to a new file
ACPICA commit a3f85a7d26a52ee0d9103feb4fbec8d7b6ba4c11
Split out functions from exdebug.c to extrace.c
Link: https://github.com/acpica/acpica/commit/a3f85a7d
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/Makefile | 3 | ||||
-rw-r--r-- | drivers/acpi/acpica/exdebug.c | 325 | ||||
-rw-r--r-- | drivers/acpi/acpica/extrace.c | 377 |
3 files changed, 379 insertions, 326 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 885936f79542..e75f40164258 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -50,6 +50,7 @@ acpi-y += \ | |||
50 | exdump.o \ | 50 | exdump.o \ |
51 | exfield.o \ | 51 | exfield.o \ |
52 | exfldio.o \ | 52 | exfldio.o \ |
53 | exmisc.o \ | ||
53 | exmutex.o \ | 54 | exmutex.o \ |
54 | exnames.o \ | 55 | exnames.o \ |
55 | exoparg1.o \ | 56 | exoparg1.o \ |
@@ -57,7 +58,6 @@ acpi-y += \ | |||
57 | exoparg3.o \ | 58 | exoparg3.o \ |
58 | exoparg6.o \ | 59 | exoparg6.o \ |
59 | exprep.o \ | 60 | exprep.o \ |
60 | exmisc.o \ | ||
61 | exregion.o \ | 61 | exregion.o \ |
62 | exresnte.o \ | 62 | exresnte.o \ |
63 | exresolv.o \ | 63 | exresolv.o \ |
@@ -66,6 +66,7 @@ acpi-y += \ | |||
66 | exstoren.o \ | 66 | exstoren.o \ |
67 | exstorob.o \ | 67 | exstorob.o \ |
68 | exsystem.o \ | 68 | exsystem.o \ |
69 | extrace.o \ | ||
69 | exutils.o | 70 | exutils.o |
70 | 71 | ||
71 | acpi-y += \ | 72 | acpi-y += \ |
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c index 665a4b9556e2..815442bbd051 100644 --- a/drivers/acpi/acpica/exdebug.c +++ b/drivers/acpi/acpica/exdebug.c | |||
@@ -43,21 +43,11 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acnamesp.h" | ||
47 | #include "acinterp.h" | 46 | #include "acinterp.h" |
48 | #include "acparser.h" | ||
49 | 47 | ||
50 | #define _COMPONENT ACPI_EXECUTER | 48 | #define _COMPONENT ACPI_EXECUTER |
51 | ACPI_MODULE_NAME("exdebug") | 49 | ACPI_MODULE_NAME("exdebug") |
52 | 50 | ||
53 | static union acpi_operand_object *acpi_gbl_trace_method_object = NULL; | ||
54 | |||
55 | /* Local prototypes */ | ||
56 | |||
57 | #ifdef ACPI_DEBUG_OUTPUT | ||
58 | static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type); | ||
59 | #endif | ||
60 | |||
61 | #ifndef ACPI_NO_ERROR_MESSAGES | 51 | #ifndef ACPI_NO_ERROR_MESSAGES |
62 | /******************************************************************************* | 52 | /******************************************************************************* |
63 | * | 53 | * |
@@ -80,7 +70,6 @@ static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type); | |||
80 | * enabled if necessary. | 70 | * enabled if necessary. |
81 | * | 71 | * |
82 | ******************************************************************************/ | 72 | ******************************************************************************/ |
83 | |||
84 | void | 73 | void |
85 | acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | 74 | acpi_ex_do_debug_object(union acpi_operand_object *source_desc, |
86 | u32 level, u32 index) | 75 | u32 level, u32 index) |
@@ -319,317 +308,3 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
319 | return_VOID; | 308 | return_VOID; |
320 | } | 309 | } |
321 | #endif | 310 | #endif |
322 | |||
323 | /******************************************************************************* | ||
324 | * | ||
325 | * FUNCTION: acpi_ex_interpreter_trace_enabled | ||
326 | * | ||
327 | * PARAMETERS: name - Whether method name should be matched, | ||
328 | * this should be checked before starting | ||
329 | * the tracer | ||
330 | * | ||
331 | * RETURN: TRUE if interpreter trace is enabled. | ||
332 | * | ||
333 | * DESCRIPTION: Check whether interpreter trace is enabled | ||
334 | * | ||
335 | ******************************************************************************/ | ||
336 | |||
337 | static u8 acpi_ex_interpreter_trace_enabled(char *name) | ||
338 | { | ||
339 | |||
340 | /* Check if tracing is enabled */ | ||
341 | |||
342 | if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED)) { | ||
343 | return (FALSE); | ||
344 | } | ||
345 | |||
346 | /* | ||
347 | * Check if tracing is filtered: | ||
348 | * | ||
349 | * 1. If the tracer is started, acpi_gbl_trace_method_object should have | ||
350 | * been filled by the trace starter | ||
351 | * 2. If the tracer is not started, acpi_gbl_trace_method_name should be | ||
352 | * matched if it is specified | ||
353 | * 3. If the tracer is oneshot style, acpi_gbl_trace_method_name should | ||
354 | * not be cleared by the trace stopper during the first match | ||
355 | */ | ||
356 | if (acpi_gbl_trace_method_object) { | ||
357 | return (TRUE); | ||
358 | } | ||
359 | if (name && | ||
360 | (acpi_gbl_trace_method_name && | ||
361 | strcmp(acpi_gbl_trace_method_name, name))) { | ||
362 | return (FALSE); | ||
363 | } | ||
364 | if ((acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT) && | ||
365 | !acpi_gbl_trace_method_name) { | ||
366 | return (FALSE); | ||
367 | } | ||
368 | |||
369 | return (TRUE); | ||
370 | } | ||
371 | |||
372 | /******************************************************************************* | ||
373 | * | ||
374 | * FUNCTION: acpi_ex_get_trace_event_name | ||
375 | * | ||
376 | * PARAMETERS: type - Trace event type | ||
377 | * | ||
378 | * RETURN: Trace event name. | ||
379 | * | ||
380 | * DESCRIPTION: Used to obtain the full trace event name. | ||
381 | * | ||
382 | ******************************************************************************/ | ||
383 | |||
384 | #ifdef ACPI_DEBUG_OUTPUT | ||
385 | |||
386 | static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type) | ||
387 | { | ||
388 | switch (type) { | ||
389 | case ACPI_TRACE_AML_METHOD: | ||
390 | |||
391 | return "Method"; | ||
392 | |||
393 | case ACPI_TRACE_AML_OPCODE: | ||
394 | |||
395 | return "Opcode"; | ||
396 | |||
397 | case ACPI_TRACE_AML_REGION: | ||
398 | |||
399 | return "Region"; | ||
400 | |||
401 | default: | ||
402 | |||
403 | return ""; | ||
404 | } | ||
405 | } | ||
406 | |||
407 | #endif | ||
408 | |||
409 | /******************************************************************************* | ||
410 | * | ||
411 | * FUNCTION: acpi_ex_trace_point | ||
412 | * | ||
413 | * PARAMETERS: type - Trace event type | ||
414 | * begin - TRUE if before execution | ||
415 | * aml - Executed AML address | ||
416 | * pathname - Object path | ||
417 | * | ||
418 | * RETURN: None | ||
419 | * | ||
420 | * DESCRIPTION: Internal interpreter execution trace. | ||
421 | * | ||
422 | ******************************************************************************/ | ||
423 | |||
424 | void | ||
425 | acpi_ex_trace_point(acpi_trace_event_type type, | ||
426 | u8 begin, u8 *aml, char *pathname) | ||
427 | { | ||
428 | |||
429 | ACPI_FUNCTION_NAME(ex_trace_point); | ||
430 | |||
431 | if (pathname) { | ||
432 | ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, | ||
433 | "%s %s [0x%p:%s] execution.\n", | ||
434 | acpi_ex_get_trace_event_name(type), | ||
435 | begin ? "Begin" : "End", aml, pathname)); | ||
436 | } else { | ||
437 | ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, | ||
438 | "%s %s [0x%p] execution.\n", | ||
439 | acpi_ex_get_trace_event_name(type), | ||
440 | begin ? "Begin" : "End", aml)); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /******************************************************************************* | ||
445 | * | ||
446 | * FUNCTION: acpi_ex_start_trace_method | ||
447 | * | ||
448 | * PARAMETERS: method_node - Node of the method | ||
449 | * obj_desc - The method object | ||
450 | * walk_state - current state, NULL if not yet executing | ||
451 | * a method. | ||
452 | * | ||
453 | * RETURN: None | ||
454 | * | ||
455 | * DESCRIPTION: Start control method execution trace | ||
456 | * | ||
457 | ******************************************************************************/ | ||
458 | |||
459 | void | ||
460 | acpi_ex_start_trace_method(struct acpi_namespace_node *method_node, | ||
461 | union acpi_operand_object *obj_desc, | ||
462 | struct acpi_walk_state *walk_state) | ||
463 | { | ||
464 | acpi_status status; | ||
465 | char *pathname = NULL; | ||
466 | u8 enabled = FALSE; | ||
467 | |||
468 | ACPI_FUNCTION_NAME(ex_start_trace_method); | ||
469 | |||
470 | if (method_node) { | ||
471 | pathname = acpi_ns_get_normalized_pathname(method_node, TRUE); | ||
472 | } | ||
473 | |||
474 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
475 | if (ACPI_FAILURE(status)) { | ||
476 | goto exit; | ||
477 | } | ||
478 | |||
479 | enabled = acpi_ex_interpreter_trace_enabled(pathname); | ||
480 | if (enabled && !acpi_gbl_trace_method_object) { | ||
481 | acpi_gbl_trace_method_object = obj_desc; | ||
482 | acpi_gbl_original_dbg_level = acpi_dbg_level; | ||
483 | acpi_gbl_original_dbg_layer = acpi_dbg_layer; | ||
484 | acpi_dbg_level = ACPI_TRACE_LEVEL_ALL; | ||
485 | acpi_dbg_layer = ACPI_TRACE_LAYER_ALL; | ||
486 | |||
487 | if (acpi_gbl_trace_dbg_level) { | ||
488 | acpi_dbg_level = acpi_gbl_trace_dbg_level; | ||
489 | } | ||
490 | if (acpi_gbl_trace_dbg_layer) { | ||
491 | acpi_dbg_layer = acpi_gbl_trace_dbg_layer; | ||
492 | } | ||
493 | } | ||
494 | |||
495 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
496 | |||
497 | exit: | ||
498 | if (enabled) { | ||
499 | ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, TRUE, | ||
500 | obj_desc ? obj_desc->method.aml_start : NULL, | ||
501 | pathname); | ||
502 | } | ||
503 | if (pathname) { | ||
504 | ACPI_FREE(pathname); | ||
505 | } | ||
506 | } | ||
507 | |||
508 | /******************************************************************************* | ||
509 | * | ||
510 | * FUNCTION: acpi_ex_stop_trace_method | ||
511 | * | ||
512 | * PARAMETERS: method_node - Node of the method | ||
513 | * obj_desc - The method object | ||
514 | * walk_state - current state, NULL if not yet executing | ||
515 | * a method. | ||
516 | * | ||
517 | * RETURN: None | ||
518 | * | ||
519 | * DESCRIPTION: Stop control method execution trace | ||
520 | * | ||
521 | ******************************************************************************/ | ||
522 | |||
523 | void | ||
524 | acpi_ex_stop_trace_method(struct acpi_namespace_node *method_node, | ||
525 | union acpi_operand_object *obj_desc, | ||
526 | struct acpi_walk_state *walk_state) | ||
527 | { | ||
528 | acpi_status status; | ||
529 | char *pathname = NULL; | ||
530 | u8 enabled; | ||
531 | |||
532 | ACPI_FUNCTION_NAME(ex_stop_trace_method); | ||
533 | |||
534 | if (method_node) { | ||
535 | pathname = acpi_ns_get_normalized_pathname(method_node, TRUE); | ||
536 | } | ||
537 | |||
538 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
539 | if (ACPI_FAILURE(status)) { | ||
540 | goto exit_path; | ||
541 | } | ||
542 | |||
543 | enabled = acpi_ex_interpreter_trace_enabled(NULL); | ||
544 | |||
545 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
546 | |||
547 | if (enabled) { | ||
548 | ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, FALSE, | ||
549 | obj_desc ? obj_desc->method.aml_start : NULL, | ||
550 | pathname); | ||
551 | } | ||
552 | |||
553 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
554 | if (ACPI_FAILURE(status)) { | ||
555 | goto exit_path; | ||
556 | } | ||
557 | |||
558 | /* Check whether the tracer should be stopped */ | ||
559 | |||
560 | if (acpi_gbl_trace_method_object == obj_desc) { | ||
561 | |||
562 | /* Disable further tracing if type is one-shot */ | ||
563 | |||
564 | if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT) { | ||
565 | acpi_gbl_trace_method_name = NULL; | ||
566 | } | ||
567 | |||
568 | acpi_dbg_level = acpi_gbl_original_dbg_level; | ||
569 | acpi_dbg_layer = acpi_gbl_original_dbg_layer; | ||
570 | acpi_gbl_trace_method_object = NULL; | ||
571 | } | ||
572 | |||
573 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
574 | |||
575 | exit_path: | ||
576 | if (pathname) { | ||
577 | ACPI_FREE(pathname); | ||
578 | } | ||
579 | } | ||
580 | |||
581 | /******************************************************************************* | ||
582 | * | ||
583 | * FUNCTION: acpi_ex_start_trace_opcode | ||
584 | * | ||
585 | * PARAMETERS: op - The parser opcode object | ||
586 | * walk_state - current state, NULL if not yet executing | ||
587 | * a method. | ||
588 | * | ||
589 | * RETURN: None | ||
590 | * | ||
591 | * DESCRIPTION: Start opcode execution trace | ||
592 | * | ||
593 | ******************************************************************************/ | ||
594 | |||
595 | void | ||
596 | acpi_ex_start_trace_opcode(union acpi_parse_object *op, | ||
597 | struct acpi_walk_state *walk_state) | ||
598 | { | ||
599 | |||
600 | ACPI_FUNCTION_NAME(ex_start_trace_opcode); | ||
601 | |||
602 | if (acpi_ex_interpreter_trace_enabled(NULL) && | ||
603 | (acpi_gbl_trace_flags & ACPI_TRACE_OPCODE)) { | ||
604 | ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, TRUE, | ||
605 | op->common.aml, op->common.aml_op_name); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | /******************************************************************************* | ||
610 | * | ||
611 | * FUNCTION: acpi_ex_stop_trace_opcode | ||
612 | * | ||
613 | * PARAMETERS: op - The parser opcode object | ||
614 | * walk_state - current state, NULL if not yet executing | ||
615 | * a method. | ||
616 | * | ||
617 | * RETURN: None | ||
618 | * | ||
619 | * DESCRIPTION: Stop opcode execution trace | ||
620 | * | ||
621 | ******************************************************************************/ | ||
622 | |||
623 | void | ||
624 | acpi_ex_stop_trace_opcode(union acpi_parse_object *op, | ||
625 | struct acpi_walk_state *walk_state) | ||
626 | { | ||
627 | |||
628 | ACPI_FUNCTION_NAME(ex_stop_trace_opcode); | ||
629 | |||
630 | if (acpi_ex_interpreter_trace_enabled(NULL) && | ||
631 | (acpi_gbl_trace_flags & ACPI_TRACE_OPCODE)) { | ||
632 | ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, FALSE, | ||
633 | op->common.aml, op->common.aml_op_name); | ||
634 | } | ||
635 | } | ||
diff --git a/drivers/acpi/acpica/extrace.c b/drivers/acpi/acpica/extrace.c new file mode 100644 index 000000000000..e4a185eece8a --- /dev/null +++ b/drivers/acpi/acpica/extrace.c | |||
@@ -0,0 +1,377 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: extrace - Support for interpreter execution tracing | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2015, 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 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. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "acnamesp.h" | ||
47 | #include "acinterp.h" | ||
48 | |||
49 | #define _COMPONENT ACPI_EXECUTER | ||
50 | ACPI_MODULE_NAME("extrace") | ||
51 | |||
52 | static union acpi_operand_object *acpi_gbl_trace_method_object = NULL; | ||
53 | |||
54 | /* Local prototypes */ | ||
55 | |||
56 | #ifdef ACPI_DEBUG_OUTPUT | ||
57 | static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type); | ||
58 | #endif | ||
59 | |||
60 | /******************************************************************************* | ||
61 | * | ||
62 | * FUNCTION: acpi_ex_interpreter_trace_enabled | ||
63 | * | ||
64 | * PARAMETERS: name - Whether method name should be matched, | ||
65 | * this should be checked before starting | ||
66 | * the tracer | ||
67 | * | ||
68 | * RETURN: TRUE if interpreter trace is enabled. | ||
69 | * | ||
70 | * DESCRIPTION: Check whether interpreter trace is enabled | ||
71 | * | ||
72 | ******************************************************************************/ | ||
73 | |||
74 | static u8 acpi_ex_interpreter_trace_enabled(char *name) | ||
75 | { | ||
76 | |||
77 | /* Check if tracing is enabled */ | ||
78 | |||
79 | if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED)) { | ||
80 | return (FALSE); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Check if tracing is filtered: | ||
85 | * | ||
86 | * 1. If the tracer is started, acpi_gbl_trace_method_object should have | ||
87 | * been filled by the trace starter | ||
88 | * 2. If the tracer is not started, acpi_gbl_trace_method_name should be | ||
89 | * matched if it is specified | ||
90 | * 3. If the tracer is oneshot style, acpi_gbl_trace_method_name should | ||
91 | * not be cleared by the trace stopper during the first match | ||
92 | */ | ||
93 | if (acpi_gbl_trace_method_object) { | ||
94 | return (TRUE); | ||
95 | } | ||
96 | |||
97 | if (name && | ||
98 | (acpi_gbl_trace_method_name && | ||
99 | strcmp(acpi_gbl_trace_method_name, name))) { | ||
100 | return (FALSE); | ||
101 | } | ||
102 | |||
103 | if ((acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT) && | ||
104 | !acpi_gbl_trace_method_name) { | ||
105 | return (FALSE); | ||
106 | } | ||
107 | |||
108 | return (TRUE); | ||
109 | } | ||
110 | |||
111 | /******************************************************************************* | ||
112 | * | ||
113 | * FUNCTION: acpi_ex_get_trace_event_name | ||
114 | * | ||
115 | * PARAMETERS: type - Trace event type | ||
116 | * | ||
117 | * RETURN: Trace event name. | ||
118 | * | ||
119 | * DESCRIPTION: Used to obtain the full trace event name. | ||
120 | * | ||
121 | ******************************************************************************/ | ||
122 | |||
123 | #ifdef ACPI_DEBUG_OUTPUT | ||
124 | |||
125 | static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type) | ||
126 | { | ||
127 | |||
128 | switch (type) { | ||
129 | case ACPI_TRACE_AML_METHOD: | ||
130 | |||
131 | return "Method"; | ||
132 | |||
133 | case ACPI_TRACE_AML_OPCODE: | ||
134 | |||
135 | return "Opcode"; | ||
136 | |||
137 | case ACPI_TRACE_AML_REGION: | ||
138 | |||
139 | return "Region"; | ||
140 | |||
141 | default: | ||
142 | |||
143 | return ""; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | #endif | ||
148 | |||
149 | /******************************************************************************* | ||
150 | * | ||
151 | * FUNCTION: acpi_ex_trace_point | ||
152 | * | ||
153 | * PARAMETERS: type - Trace event type | ||
154 | * begin - TRUE if before execution | ||
155 | * aml - Executed AML address | ||
156 | * pathname - Object path | ||
157 | * | ||
158 | * RETURN: None | ||
159 | * | ||
160 | * DESCRIPTION: Internal interpreter execution trace. | ||
161 | * | ||
162 | ******************************************************************************/ | ||
163 | |||
164 | void | ||
165 | acpi_ex_trace_point(acpi_trace_event_type type, | ||
166 | u8 begin, u8 *aml, char *pathname) | ||
167 | { | ||
168 | |||
169 | ACPI_FUNCTION_NAME(ex_trace_point); | ||
170 | |||
171 | if (pathname) { | ||
172 | ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, | ||
173 | "%s %s [0x%p:%s] execution.\n", | ||
174 | acpi_ex_get_trace_event_name(type), | ||
175 | begin ? "Begin" : "End", aml, pathname)); | ||
176 | } else { | ||
177 | ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, | ||
178 | "%s %s [0x%p] execution.\n", | ||
179 | acpi_ex_get_trace_event_name(type), | ||
180 | begin ? "Begin" : "End", aml)); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | /******************************************************************************* | ||
185 | * | ||
186 | * FUNCTION: acpi_ex_start_trace_method | ||
187 | * | ||
188 | * PARAMETERS: method_node - Node of the method | ||
189 | * obj_desc - The method object | ||
190 | * walk_state - current state, NULL if not yet executing | ||
191 | * a method. | ||
192 | * | ||
193 | * RETURN: None | ||
194 | * | ||
195 | * DESCRIPTION: Start control method execution trace | ||
196 | * | ||
197 | ******************************************************************************/ | ||
198 | |||
199 | void | ||
200 | acpi_ex_start_trace_method(struct acpi_namespace_node *method_node, | ||
201 | union acpi_operand_object *obj_desc, | ||
202 | struct acpi_walk_state *walk_state) | ||
203 | { | ||
204 | acpi_status status; | ||
205 | char *pathname = NULL; | ||
206 | u8 enabled = FALSE; | ||
207 | |||
208 | ACPI_FUNCTION_NAME(ex_start_trace_method); | ||
209 | |||
210 | if (method_node) { | ||
211 | pathname = acpi_ns_get_normalized_pathname(method_node, TRUE); | ||
212 | } | ||
213 | |||
214 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
215 | if (ACPI_FAILURE(status)) { | ||
216 | goto exit; | ||
217 | } | ||
218 | |||
219 | enabled = acpi_ex_interpreter_trace_enabled(pathname); | ||
220 | if (enabled && !acpi_gbl_trace_method_object) { | ||
221 | acpi_gbl_trace_method_object = obj_desc; | ||
222 | acpi_gbl_original_dbg_level = acpi_dbg_level; | ||
223 | acpi_gbl_original_dbg_layer = acpi_dbg_layer; | ||
224 | acpi_dbg_level = ACPI_TRACE_LEVEL_ALL; | ||
225 | acpi_dbg_layer = ACPI_TRACE_LAYER_ALL; | ||
226 | |||
227 | if (acpi_gbl_trace_dbg_level) { | ||
228 | acpi_dbg_level = acpi_gbl_trace_dbg_level; | ||
229 | } | ||
230 | |||
231 | if (acpi_gbl_trace_dbg_layer) { | ||
232 | acpi_dbg_layer = acpi_gbl_trace_dbg_layer; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
237 | |||
238 | exit: | ||
239 | if (enabled) { | ||
240 | ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, TRUE, | ||
241 | obj_desc ? obj_desc->method.aml_start : NULL, | ||
242 | pathname); | ||
243 | } | ||
244 | |||
245 | if (pathname) { | ||
246 | ACPI_FREE(pathname); | ||
247 | } | ||
248 | } | ||
249 | |||
250 | /******************************************************************************* | ||
251 | * | ||
252 | * FUNCTION: acpi_ex_stop_trace_method | ||
253 | * | ||
254 | * PARAMETERS: method_node - Node of the method | ||
255 | * obj_desc - The method object | ||
256 | * walk_state - current state, NULL if not yet executing | ||
257 | * a method. | ||
258 | * | ||
259 | * RETURN: None | ||
260 | * | ||
261 | * DESCRIPTION: Stop control method execution trace | ||
262 | * | ||
263 | ******************************************************************************/ | ||
264 | |||
265 | void | ||
266 | acpi_ex_stop_trace_method(struct acpi_namespace_node *method_node, | ||
267 | union acpi_operand_object *obj_desc, | ||
268 | struct acpi_walk_state *walk_state) | ||
269 | { | ||
270 | acpi_status status; | ||
271 | char *pathname = NULL; | ||
272 | u8 enabled; | ||
273 | |||
274 | ACPI_FUNCTION_NAME(ex_stop_trace_method); | ||
275 | |||
276 | if (method_node) { | ||
277 | pathname = acpi_ns_get_normalized_pathname(method_node, TRUE); | ||
278 | } | ||
279 | |||
280 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
281 | if (ACPI_FAILURE(status)) { | ||
282 | goto exit_path; | ||
283 | } | ||
284 | |||
285 | enabled = acpi_ex_interpreter_trace_enabled(NULL); | ||
286 | |||
287 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
288 | |||
289 | if (enabled) { | ||
290 | ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, FALSE, | ||
291 | obj_desc ? obj_desc->method.aml_start : NULL, | ||
292 | pathname); | ||
293 | } | ||
294 | |||
295 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
296 | if (ACPI_FAILURE(status)) { | ||
297 | goto exit_path; | ||
298 | } | ||
299 | |||
300 | /* Check whether the tracer should be stopped */ | ||
301 | |||
302 | if (acpi_gbl_trace_method_object == obj_desc) { | ||
303 | |||
304 | /* Disable further tracing if type is one-shot */ | ||
305 | |||
306 | if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT) { | ||
307 | acpi_gbl_trace_method_name = NULL; | ||
308 | } | ||
309 | |||
310 | acpi_dbg_level = acpi_gbl_original_dbg_level; | ||
311 | acpi_dbg_layer = acpi_gbl_original_dbg_layer; | ||
312 | acpi_gbl_trace_method_object = NULL; | ||
313 | } | ||
314 | |||
315 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
316 | |||
317 | exit_path: | ||
318 | if (pathname) { | ||
319 | ACPI_FREE(pathname); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | /******************************************************************************* | ||
324 | * | ||
325 | * FUNCTION: acpi_ex_start_trace_opcode | ||
326 | * | ||
327 | * PARAMETERS: op - The parser opcode object | ||
328 | * walk_state - current state, NULL if not yet executing | ||
329 | * a method. | ||
330 | * | ||
331 | * RETURN: None | ||
332 | * | ||
333 | * DESCRIPTION: Start opcode execution trace | ||
334 | * | ||
335 | ******************************************************************************/ | ||
336 | |||
337 | void | ||
338 | acpi_ex_start_trace_opcode(union acpi_parse_object *op, | ||
339 | struct acpi_walk_state *walk_state) | ||
340 | { | ||
341 | |||
342 | ACPI_FUNCTION_NAME(ex_start_trace_opcode); | ||
343 | |||
344 | if (acpi_ex_interpreter_trace_enabled(NULL) && | ||
345 | (acpi_gbl_trace_flags & ACPI_TRACE_OPCODE)) { | ||
346 | ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, TRUE, | ||
347 | op->common.aml, op->common.aml_op_name); | ||
348 | } | ||
349 | } | ||
350 | |||
351 | /******************************************************************************* | ||
352 | * | ||
353 | * FUNCTION: acpi_ex_stop_trace_opcode | ||
354 | * | ||
355 | * PARAMETERS: op - The parser opcode object | ||
356 | * walk_state - current state, NULL if not yet executing | ||
357 | * a method. | ||
358 | * | ||
359 | * RETURN: None | ||
360 | * | ||
361 | * DESCRIPTION: Stop opcode execution trace | ||
362 | * | ||
363 | ******************************************************************************/ | ||
364 | |||
365 | void | ||
366 | acpi_ex_stop_trace_opcode(union acpi_parse_object *op, | ||
367 | struct acpi_walk_state *walk_state) | ||
368 | { | ||
369 | |||
370 | ACPI_FUNCTION_NAME(ex_stop_trace_opcode); | ||
371 | |||
372 | if (acpi_ex_interpreter_trace_enabled(NULL) && | ||
373 | (acpi_gbl_trace_flags & ACPI_TRACE_OPCODE)) { | ||
374 | ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, FALSE, | ||
375 | op->common.aml, op->common.aml_op_name); | ||
376 | } | ||
377 | } | ||