Skip to content

Commit

Permalink
Executer: Add interpreter tracing mode for method tracing facility.
Browse files Browse the repository at this point in the history
The AcpiDebugTrace() is the mechanism known as ACPI method tracing that is
used by Linux as ACPICA debugging message reducer. This facility can be
controlled through Linux ACPI subsystem - /sys/module/acpi/parameters.
This facility requires CONFIG_ACPI_DEBUG to be enabled to see ACPICA trace
logs in the kernel dmesg output.

This patch enhances AcpiDebugTrace() to make it not only a message reducer,
but a real tracer to trace AML interpreter execution. Note that in addition
to the AML tracer enabling, this patch also updates the facility with the
following enhancements:
1. Allow a full path to be specified by the AcpiDebugTrace() API.
2. Allow any method rather than just the entrance of AcpiEvaluateObject()
   to be traced.
3. All interpreter ACPI_LV_TRACE_POINT messages are collected for
   ACPI_EXECUTER layer.

This patch also updates "trace" command to allow it to perform all Linux
method tracing functionalities:
   1. "trace aml" to always enable AML execution trace messages
      (level=TRACE_POINT, layer=EXECUTER) for all control methods.
   2. "trace aml \MTHD" to always enable AML execution trace messages for
      only \MTHD method.
   3. "trace aml \MTHD once" to enable AML execution trace messages only
      once for only \MTHD method.
   4. "trace enable" to always enable all trace messsages (level=ALL,
      layer=ALL) for all control methods.
   5. "trace enable \MTHD" to always enable all trace messages for only
      \MTHD method.
   6. "trace enable \MTHD once" to enable all trace messages only once for
      only \MTHD method.
   7. "trace disable" to disable trace facility.

The Makefiles of acpinames/iasl are also updated to include exdebug.o and
the duplicated stubs are removed after that.

Note that since this patch has enhanced the method tracing facility, Linux
need also be updated after applying this patch. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jun 10, 2015
1 parent 71299ec commit 07fffd0
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 226 deletions.
1 change: 1 addition & 0 deletions generate/unix/acpinames/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ OBJECTS = \
$(OBJDIR)/dswscope.o\
$(OBJDIR)/dswstate.o\
$(OBJDIR)/excreate.o\
$(OBJDIR)/exdebug.o\
$(OBJDIR)/exdump.o\
$(OBJDIR)/exmutex.o\
$(OBJDIR)/exnames.o\
Expand Down
1 change: 1 addition & 0 deletions generate/unix/iasl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ OBJECTS = \
$(OBJDIR)/dtutils.o\
$(OBJDIR)/exconvrt.o\
$(OBJDIR)/excreate.o\
$(OBJDIR)/exdebug.o\
$(OBJDIR)/exdump.o\
$(OBJDIR)/exmisc.o\
$(OBJDIR)/exmutex.o\
Expand Down
9 changes: 0 additions & 9 deletions source/compiler/aslstubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,6 @@ AcpiEvInitializeRegion (
return (AE_OK);
}

void
AcpiExDoDebugObject (
ACPI_OPERAND_OBJECT *SourceDesc,
UINT32 Level,
UINT32 Index)
{
return;
}

ACPI_STATUS
AcpiExReadDataFromField (
ACPI_WALK_STATE *WalkState,
Expand Down
72 changes: 72 additions & 0 deletions source/components/debugger/dbcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ AcpiDbDoOneSleepState (
UINT8 SleepState);


static char *AcpiDbTraceMethodName = NULL;

/*******************************************************************************
*
* FUNCTION: AcpiDbConvertToNode
Expand Down Expand Up @@ -1298,4 +1300,74 @@ AcpiDbGenerateSci (

#endif /* !ACPI_REDUCED_HARDWARE */


/*******************************************************************************
*
* FUNCTION: AcpiDbTrace
*
* PARAMETERS: EnableArg - ENABLE/AML to enable tracer
* DISABLE to disable tracer
* MethodArg - Method to trace
* OnceArg - Whether trace once
*
* RETURN: None
*
* DESCRIPTION: Control method tracing facility
*
******************************************************************************/

void
AcpiDbTrace (
char *EnableArg,
char *MethodArg,
char *OnceArg)
{
UINT32 DebugLevel = 0;
UINT32 DebugLayer = 0;
UINT32 Flags = 0;


if (EnableArg)
{
AcpiUtStrupr (EnableArg);
}
if (OnceArg)
{
AcpiUtStrupr (OnceArg);
}
if (MethodArg)
{
if (AcpiDbTraceMethodName)
{
ACPI_FREE (AcpiDbTraceMethodName);
AcpiDbTraceMethodName = NULL;
}
AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
if (!AcpiDbTraceMethodName)
{
AcpiOsPrintf ("Failed to allocate method name (%s)\n", MethodArg);
return;
}
strcpy (AcpiDbTraceMethodName, MethodArg);
}
if (!strcmp (EnableArg, "ENABLE") ||
!strcmp (EnableArg, "AML"))
{
if (!strcmp (EnableArg, "AML"))
{
DebugLevel = ACPI_LV_TRACE_POINT;
DebugLayer = ACPI_EXECUTER;
}

Flags = ACPI_TRACE_ENABLED;
if (OnceArg && !strcmp (OnceArg, "ONCE"))
{
Flags |= ACPI_TRACE_ONESHOT;
}
}

(void) AcpiDebugTrace (AcpiDbTraceMethodName,
DebugLevel, DebugLayer, Flags);
}

#endif /* ACPI_DEBUGGER */
7 changes: 5 additions & 2 deletions source/components/debugger/dbinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
{1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
{1, " Stop", "Terminate control method\n"},
{1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
{1, " Trace <method name>", "Trace method execution\n"},
{4, " Trace <State> [<Method>] [Once]", "Trace method execution\n"},
{1, " Enable", "Enable all messages\n"},
{1, " Disable", "Disable traer\n"},
{1, " AML", "Enable AML execution messages\n"},
{1, " Tree", "Display control method calling tree\n"},
{1, " <Enter>", "Single step next AML opcode (over calls)\n"},

Expand Down Expand Up @@ -1182,7 +1185,7 @@ AcpiDbCommandDispatch (

case CMD_TRACE:

(void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
break;

case CMD_TREE:
Expand Down
24 changes: 5 additions & 19 deletions source/components/dispatcher/dsdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
#include "acdispat.h"
#include "acnamesp.h"
#include "acdisasm.h"
#include "acinterp.h"


#define _COMPONENT ACPI_DISPATCHER
Expand Down Expand Up @@ -210,7 +211,6 @@ AcpiDsDumpMethodStack (
ACPI_WALK_STATE *NextWalkState;
ACPI_NAMESPACE_NODE *PreviousMethod = NULL;
ACPI_OPERAND_OBJECT *MethodDesc;
char *Pathname = NULL;


ACPI_FUNCTION_TRACE (DsDumpMethodStack);
Expand Down Expand Up @@ -260,25 +260,11 @@ AcpiDsDumpMethodStack (
while (NextWalkState)
{
MethodDesc = NextWalkState->MethodDesc;
if (MethodDesc && MethodDesc->Method.Node)
if (MethodDesc)
{
Pathname = AcpiNsGetNormalizedPathname (
(ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
TRUE);
}
if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p:%s] execution.\n",
MethodDesc->Method.AmlStart, Pathname));
ACPI_FREE (Pathname);
Pathname = NULL;
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p] execution.\n",
MethodDesc->Method.AmlStart));
AcpiExStopTraceMethod (
(ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
MethodDesc, WalkState);
}

ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
Expand Down
39 changes: 3 additions & 36 deletions source/components/dispatcher/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ AcpiDsBeginMethodExecution (
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
char *Pathname = NULL;


ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
Expand All @@ -430,20 +429,7 @@ AcpiDsBeginMethodExecution (
return_ACPI_STATUS (AE_NULL_ENTRY);
}

Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin method [0x%p:%s] execution.\n",
ObjDesc->Method.AmlStart, Pathname));
ACPI_FREE (Pathname);
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin method [0x%p] execution.\n",
ObjDesc->Method.AmlStart));
}
AcpiExStartTraceMethod (MethodNode, ObjDesc, WalkState);

/* Prevent wraparound of thread count */

Expand Down Expand Up @@ -828,8 +814,6 @@ AcpiDsTerminateControlMethod (
ACPI_OPERAND_OBJECT *MethodDesc,
ACPI_WALK_STATE *WalkState)
{
char *Pathname = NULL;


ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);

Expand Down Expand Up @@ -968,25 +952,8 @@ AcpiDsTerminateControlMethod (
}
}

if (MethodDesc->Method.Node)
{
Pathname = AcpiNsGetNormalizedPathname (
(ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
TRUE);
}
if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p:%s] execution.\n",
MethodDesc->Method.AmlStart, Pathname));
ACPI_FREE (Pathname);
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p] execution.\n",
MethodDesc->Method.AmlStart));
}
AcpiExStopTraceMethod ((ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
MethodDesc, WalkState);

return_VOID;
}
Loading

0 comments on commit 07fffd0

Please sign in to comment.