aslerror.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: aslerror - Error handling and statistics
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslerror")
/* Local prototypes */
static void
/*******************************************************************************
*
* FUNCTION: AslAbort
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Dump the error log and abort the compiler. Used for serious
* I/O errors.
*
******************************************************************************/
void
AslAbort (
void)
{
if (Gbl_DebugFlag)
{
/* Print error summary to stdout also */
}
exit (1);
}
/*******************************************************************************
*
* FUNCTION: AeClearErrorLog
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Empty the error list
*
******************************************************************************/
void
void)
{
/* Walk the error node list */
while (Enode)
{
}
Gbl_ErrorLog = NULL;
}
/*******************************************************************************
*
* FUNCTION: AeAddToErrorLog
*
* PARAMETERS: Enode - An error node to add to the log
*
* RETURN: None
*
* DESCRIPTION: Add a new error node to the error log. The error log is
* ordered by the "logical" line number (cumulative line number
* including all include files.)
*
******************************************************************************/
static void
{
/* If Gbl_ErrorLog is null, this is the first error node */
if (!Gbl_ErrorLog)
{
return;
}
/*
* Walk error list until we find a line number greater than ours.
* List is sorted according to line number.
*/
Next = Gbl_ErrorLog;
while ((Next) &&
{
}
/* Found our place in the list */
if (Prev)
{
}
else
{
}
}
/*******************************************************************************
*
* FUNCTION: AePrintException
*
* PARAMETERS: FileId - ID of output file
* Enode - Error node to print
* Header - Additional text before each message
*
* RETURN: None
*
* DESCRIPTION: Print the contents of an error node.
*
* NOTE: We don't use the FlxxxFile I/O functions here because on error
* they abort the compiler and call this function! Since we
* are reporting errors here, we ignore most output errors and
* just try to get out as much as we can.
*
******************************************************************************/
void
char *Header)
{
int Actual;
const char *MainMessage;
char *ExtraMessage;
long FileSize;
if (Gbl_NoErrors)
{
return;
}
/*
* Only listing files have a header, and remarks/optimizations
* are always output
*/
if (!Header)
{
/* Ignore remarks if requested */
{
case ASL_WARNING:
case ASL_WARNING2:
case ASL_WARNING3:
if (!Gbl_DisplayWarnings)
{
return;
}
break;
case ASL_REMARK:
if (!Gbl_DisplayRemarks)
{
return;
}
break;
case ASL_OPTIMIZATION:
if (!Gbl_DisplayOptimizations)
{
return;
}
break;
default:
break;
}
}
/* Get the various required file handles */
if (!Enode->SourceLine)
{
if (!SourceFile)
{
}
if (SourceFile)
{
/* Determine if the error occurred at source file EOF */
{
PrematureEOF = TRUE;
}
}
}
if (Header)
{
}
/* Print filename and line number if present and valid */
{
if (Gbl_VerboseErrors)
{
if (Enode->LineNumber)
{
if (Enode->SourceLine)
{
}
else
{
/*
* If not at EOF, get the corresponding source code line and
* display it. Don't attempt this if we have a premature EOF
* condition.
*/
if (!PrematureEOF)
{
/*
* Seek to the offset in the combined source file, read
* the source line, and write it to the output.
*/
(int) SEEK_SET);
if (Actual)
{
"[*** iASL: Seek error on source code temp file %s ***]",
}
else
{
if (RActual != 1)
{
"[*** iASL: Read error on source code temp file %s ***]",
}
else
{
{
if (Total < 256)
{
/* After the max line length, we will just read the line, no write */
{
printf ("[*** iASL: Write error on output file ***]\n");
return;
}
}
else if (Total == 256)
{
"\n[*** iASL: Very long input line, message below refers to column %u ***]",
}
if (RActual != 1)
{
"[*** iASL: Read error on source code temp file %s ***]",
return;
}
Total++;
}
}
}
}
}
}
}
else
{
/*
* Less verbose version of the error message, enabled via the
* -vi switch. The format is compatible with MS Visual Studio.
*/
if (Enode->LineNumber)
{
Enode->LineNumber);
}
}
}
/* If a NULL message ID, just print the raw message */
{
return;
}
/* Decode the message ID */
/* If a NULL line number, just print the decoded message */
if (!Enode->LineNumber)
{
return;
}
if (MsgLength == 0)
{
if (!MainMessage)
{
MainMessage = "";
}
ExtraMessage = NULL;
}
if (Gbl_VerboseErrors && !PrematureEOF)
{
if (Total >= 256)
{
}
else
{
{
MainMessage, " ^ ");
}
else
{
}
}
}
else
{
}
/* Print the extra info message if present */
if (ExtraMessage)
{
}
if (PrematureEOF)
{
}
if (Gbl_VerboseErrors)
{
}
}
/*******************************************************************************
*
* FUNCTION: AePrintErrorLog
*
* PARAMETERS: FileId - Where to output the error log
*
* RETURN: None
*
* DESCRIPTION: Print the entire contents of the error log
*
******************************************************************************/
void
{
/* Walk the error node list */
while (Enode)
{
}
}
/*******************************************************************************
*
* FUNCTION: AslCommonError2
*
* MessageId - Index into global message buffer
* LineNumber - Actual file line number
* Column - Column in current line
* SourceLine - Actual source code line
* Filename - source filename
* ExtraMessage - additional error message
*
* RETURN: None
*
* DESCRIPTION: Create a new error node and add it to the error log
*
******************************************************************************/
void
char *SourceLine,
char *Filename,
char *ExtraMessage)
{
char *MessageBuffer = NULL;
char *LineBuffer;
if (ExtraMessage)
{
/* Allocate a buffer for the message and a new error node */
/* Keep a copy of the extra message */
}
/* Initialize the error node */
if (Filename)
{
{
}
}
Enode->LogicalByteOffset = 0;
/* Add the new node to the error node list */
if (Gbl_DebugFlag)
{
/* stderr is a file, send error to it immediately */
}
}
/*******************************************************************************
*
* FUNCTION: AslCommonError
*
* MessageId - Index into global message buffer
* CurrentLineNumber - Actual file line number
* LogicalLineNumber - Cumulative line number
* LogicalByteOffset - Byte offset in source file
* Column - Column in current line
* Filename - source filename
* ExtraMessage - additional error message
*
* RETURN: None
*
* DESCRIPTION: Create a new error node and add it to the error log
*
******************************************************************************/
void
char *Filename,
char *ExtraMessage)
{
char *MessageBuffer = NULL;
if (ExtraMessage)
{
/* Allocate a buffer for the message and a new error node */
/* Keep a copy of the extra message */
}
/* Initialize the error node */
if (Filename)
{
{
}
}
/* Add the new node to the error node list */
if (Gbl_DebugFlag)
{
/* stderr is a file, send error to it immediately */
}
{
Gbl_SourceLine = 0;
CmCleanupAndExit ();
exit(1);
}
return;
}
/*******************************************************************************
*
* FUNCTION: AslDisableException
*
* PARAMETERS: MessageIdString - ID to be disabled
*
* RETURN: Status
*
* DESCRIPTION: Enter a message ID into the global disabled messages table
*
******************************************************************************/
char *MessageIdString)
{
/* Convert argument to an integer and validate it */
{
return (AE_BAD_PARAMETER);
}
/* Insert value into the global disabled message array */
{
printf ("Too many messages have been disabled (max %u)\n",
return (AE_LIMIT);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AslIsExceptionDisabled
*
* MessageId - Index into global message buffer
*
*
* DESCRIPTION: Check if the user has specified options such that this
* exception should be ignored
*
******************************************************************************/
{
UINT32 i;
switch (Level)
{
case ASL_WARNING2:
case ASL_WARNING3:
/* Check for global disable via -w1/-w2/-w3 options */
if (Level > Gbl_WarningLevel)
{
return (TRUE);
}
/* Fall through */
case ASL_WARNING:
case ASL_REMARK:
/*
* the user (-vw option)
*/
for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
{
/* Simple implementation via fixed array */
if (EncodedMessageId == Gbl_DisabledMessages[i])
{
return (TRUE);
}
}
break;
default:
break;
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: AslError
*
* MessageId - Index into global message buffer
* Op - Parse node where error happened
* ExtraMessage - additional error message
*
* RETURN: None
*
* DESCRIPTION: Main error reporting routine for the ASL compiler (all code
* except the parser.)
*
******************************************************************************/
void
AslError (
char *ExtraMessage)
{
/* Check if user wants to ignore this exception */
if (Gbl_AllExceptionsDisabled ||
{
return;
}
if (Op)
{
}
else
{
0, 0, 0, NULL, ExtraMessage);
}
}
/*******************************************************************************
*
* FUNCTION: AslCoreSubsystemError
*
* PARAMETERS: Op - Parse node where error happened
* Status - The ACPICA Exception
* ExtraMessage - additional error message
* Abort - TRUE -> Abort compilation
*
* RETURN: None
*
* DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
* core subsystem.
*
******************************************************************************/
void
char *ExtraMessage,
{
if (Op)
{
}
else
{
}
if (Abort)
{
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: AslCompilererror
*
* PARAMETERS: CompilerMessage - Error message from the parser
*
* RETURN: Status (0 for now)
*
* DESCRIPTION: Report an error situation discovered in a production
* NOTE: don't change the name of this function, it is called
* from the auto-generated parser.
*
******************************************************************************/
int
const char *CompilerMessage)
{
ACPI_CAST_PTR (char, CompilerMessage));
return (0);
}