Skip to content

Commit

Permalink
Debugger: Fix runtime stub issues of ACPI_DEBUGGER_EXEC using differe…
Browse files Browse the repository at this point in the history
…nt stub mechanism

The ACPI_DEBUGGER_EXEC is a problem now when the debugger code is compiled
but runtime disabled. They actually will get executed in this situation.
Although such executions are harmless if we can correctly make
AcpiDbSingleStep() a runtime stub, users may still do not want to see the
debugger print messages logged into OSPMs' kernel logs when a debugger
driver is not loaded to enable the debugger during runtime.

This patch fixes this issue by introducing new stub mechanism instead of
ACPI_DEBUGGER_EXEC. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Nov 20, 2015
1 parent 859e448 commit 11522d6
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 36 deletions.
14 changes: 14 additions & 0 deletions source/components/debugger/dbdisply.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,13 @@ AcpiDbDisplayResultObject (
ACPI_WALK_STATE *WalkState)
{

#ifndef ACPI_APPLICATION
if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
{
return;
}
#endif

/* Only display if single stepping */

if (!AcpiGbl_CmSingleStep)
Expand Down Expand Up @@ -847,6 +854,13 @@ AcpiDbDisplayArgumentObject (
ACPI_WALK_STATE *WalkState)
{

#ifndef ACPI_APPLICATION
if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
{
return;
}
#endif

if (!AcpiGbl_CmSingleStep)
{
return;
Expand Down
34 changes: 34 additions & 0 deletions source/components/debugger/dbxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,40 @@ AcpiDbStartCommand (
}


/*******************************************************************************
*
* FUNCTION: AcpiDbSignalBreakPoint
*
* PARAMETERS: WalkState - Current walk
*
* RETURN: Status
*
* DESCRIPTION: Called for AML_BREAK_POINT_OP
*
******************************************************************************/

void
AcpiDbSignalBreakPoint (
ACPI_WALK_STATE *WalkState)
{

#ifndef ACPI_APPLICATION
if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ())
{
return;
}
#endif

/*
* Set the single-step flag. This will cause the debugger (if present)
* to break to the console within the AML debugger at the start of the
* next AML instruction.
*/
AcpiGbl_CmSingleStep = TRUE;
AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n");
}


/*******************************************************************************
*
* FUNCTION: AcpiDbSingleStep
Expand Down
10 changes: 2 additions & 8 deletions source/components/dispatcher/dscontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acdebug.h"

#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dscontrol")
Expand Down Expand Up @@ -431,14 +432,7 @@ AcpiDsExecEndControlOp (

case AML_BREAK_POINT_OP:

/*
* Set the single-step flag. This will cause the debugger (if present)
* to break to the console within the AML debugger at the start of the
* next AML instruction.
*/
ACPI_DEBUGGER_EXEC (AcpiGbl_CmSingleStep = TRUE);
ACPI_DEBUGGER_EXEC (
AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
AcpiDbSignalBreakPoint (WalkState);

/* Call to the OSL in case OS wants a piece of the action */

Expand Down
10 changes: 4 additions & 6 deletions source/components/dispatcher/dsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,7 @@ AcpiDsCreateOperand (
return_ACPI_STATUS (Status);
}

ACPI_DEBUGGER_EXEC (
AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
AcpiDbDisplayArgumentObject (ObjDesc, WalkState);
}
else
{
Expand Down Expand Up @@ -757,8 +756,8 @@ AcpiDsCreateOperand (
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Argument previously created, already stacked\n"));

ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (
WalkState->Operands [WalkState->NumOperands - 1], WalkState));
AcpiDbDisplayArgumentObject (
WalkState->Operands [WalkState->NumOperands - 1], WalkState);

/*
* Use value that was already previously returned
Expand Down Expand Up @@ -805,8 +804,7 @@ AcpiDsCreateOperand (
return_ACPI_STATUS (Status);
}

ACPI_DEBUGGER_EXEC (
AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
AcpiDbDisplayArgumentObject (ObjDesc, WalkState);
}

return_ACPI_STATUS (AE_OK);
Expand Down
15 changes: 8 additions & 7 deletions source/components/dispatcher/dswexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,9 @@ AcpiDsGetPredicateValue (
"Completed a predicate eval=%X Op=%p\n",
WalkState->ControlState->Common.Value, WalkState->Op));

/* Break to debugger to display result */
/* Break to debugger to display result */

ACPI_DEBUGGER_EXEC (
AcpiDbDisplayResultObject (LocalObjDesc, WalkState));
AcpiDbDisplayResultObject (LocalObjDesc, WalkState);

/*
* Delete the predicate result object (we know that
Expand Down Expand Up @@ -494,8 +493,11 @@ AcpiDsExecEndOp (

/* Call debugger for single step support (DEBUG build only) */

ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass));
ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);});
Status = AcpiDbSingleStep (WalkState, Op, OpClass);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}

/* Decode the Opcode Class */

Expand Down Expand Up @@ -827,8 +829,7 @@ AcpiDsExecEndOp (
{
/* Break to debugger to display result */

ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (
WalkState->ResultObj,WalkState));
AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState);

/*
* Delete the result op if and only if:
Expand Down
14 changes: 11 additions & 3 deletions source/include/acdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,17 @@ typedef struct acpi_db_execute_walk
/*
* dbxface - external debugger interfaces
*/
ACPI_DBR_DEPENDENT_RETURN_OK (
ACPI_STATUS
AcpiDbSingleStep (
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op,
UINT32 OpType);
UINT32 OpType))

ACPI_DBR_DEPENDENT_RETURN_VOID (
void
AcpiDbSignalBreakPoint (
ACPI_WALK_STATE *WalkState))


/*
Expand Down Expand Up @@ -362,10 +368,11 @@ AcpiDbDecodeAndDisplayObject (
char *Target,
char *OutputType);

ACPI_DBR_DEPENDENT_RETURN_VOID (
void
AcpiDbDisplayResultObject (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState);
ACPI_WALK_STATE *WalkState))

ACPI_STATUS
AcpiDbDisplayAllMethods (
Expand All @@ -391,10 +398,11 @@ void
AcpiDbDisplayObjectType (
char *ObjectArg);

ACPI_DBR_DEPENDENT_RETURN_VOID (
void
AcpiDbDisplayArgumentObject (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState);
ACPI_WALK_STATE *WalkState))


/*
Expand Down
12 changes: 0 additions & 12 deletions source/include/acmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,18 +477,6 @@
#endif


/*
* Some code only gets executed when the debugger is built in.
* Note that this is entirely independent of whether the
* DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
*/
#ifdef ACPI_DEBUGGER
#define ACPI_DEBUGGER_EXEC(a) a
#else
#define ACPI_DEBUGGER_EXEC(a)
#endif


/*
* Macros used for ACPICA utilities only
*/
Expand Down
24 changes: 24 additions & 0 deletions source/include/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,30 @@ ACPI_GLOBAL (BOOLEAN, AcpiGbl_SystemAwakeAndRunning);
#endif /* ACPI_APPLICATION */


/*
* Debugger prototypes
*
* All interfaces used by debugger will be configured
* out of the ACPICA build unless the ACPI_DEBUGGER
* flag is defined.
*/
#ifdef ACPI_DEBUGGER
#define ACPI_DBR_DEPENDENT_RETURN_OK(Prototype) \
ACPI_EXTERNAL_RETURN_OK(Prototype)

#define ACPI_DBR_DEPENDENT_RETURN_VOID(Prototype) \
ACPI_EXTERNAL_RETURN_VOID(Prototype)

#else
#define ACPI_DBR_DEPENDENT_RETURN_OK(Prototype) \
static ACPI_INLINE Prototype {return(AE_OK);}

#define ACPI_DBR_DEPENDENT_RETURN_VOID(Prototype) \
static ACPI_INLINE Prototype {return;}

#endif /* ACPI_DEBUGGER */


/*****************************************************************************
*
* ACPICA public interface prototypes
Expand Down

0 comments on commit 11522d6

Please sign in to comment.