BOOLEAN AslIsExceptionDisabled ( UINT8 Level, UINT16 MessageId) { UINT32 EncodedMessageId; 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: /* * Ignore this warning/remark if it has been disabled by * the user (-vw option) */ EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId); for (i = 0; i < Gbl_DisabledMessagesIndex; i++) { /* Simple implementation via fixed array */ if (EncodedMessageId == Gbl_DisabledMessages[i]) { return (TRUE); } } break; default: break; } return (FALSE); }
void AePrintException ( UINT32 FileId, ASL_ERROR_MSG *Enode, char *Header) { UINT8 SourceByte; int Actual; size_t RActual; UINT32 MsgLength; const char *MainMessage; char *ExtraMessage; UINT32 SourceColumn; UINT32 ErrorColumn; FILE *OutputFile; FILE *SourceFile = NULL; long FileSize; BOOLEAN PrematureEOF = FALSE; UINT32 Total = 0; if (Gbl_NoErrors) { return; } /* * Only listing files have a header, and remarks/optimizations * are always output */ if (!Header) { /* Ignore remarks if requested */ switch (Enode->Level) { 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 */ OutputFile = Gbl_Files[FileId].Handle; if (!Enode->SourceLine) { /* Use the merged header/source file if present, otherwise use input file */ SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; if (!SourceFile) { SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle; } if (SourceFile) { /* Determine if the error occurred at source file EOF */ fseek (SourceFile, 0, SEEK_END); FileSize = ftell (SourceFile); if ((long) Enode->LogicalByteOffset >= FileSize) { PrematureEOF = TRUE; } } } if (Header) { fprintf (OutputFile, "%s", Header); } /* Print filename and line number if present and valid */ if (Enode->Filename) { if (Gbl_VerboseErrors) { fprintf (OutputFile, "%-8s", Enode->Filename); if (Enode->LineNumber) { if (Enode->SourceLine) { fprintf (OutputFile, " %6u: %s", Enode->LineNumber, Enode->SourceLine); } else { fprintf (OutputFile, " %6u: ", Enode->LineNumber); /* * 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. */ Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, (int) SEEK_SET); if (Actual) { fprintf (OutputFile, "[*** iASL: Seek error on source code temp file %s ***]", Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); } else { RActual = fread (&SourceByte, 1, 1, SourceFile); if (RActual != 1) { fprintf (OutputFile, "[*** iASL: Read error on source code temp file %s ***]", Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); } else { /* Read/write the source line, up to the maximum line length */ while (RActual && SourceByte && (SourceByte != '\n')) { if (Total < 256) { /* After the max line length, we will just read the line, no write */ if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) { printf ("[*** iASL: Write error on output file ***]\n"); return; } } else if (Total == 256) { fprintf (OutputFile, "\n[*** iASL: Very long input line, message below refers to column %u ***]", Enode->Column); } RActual = fread (&SourceByte, 1, 1, SourceFile); if (RActual != 1) { fprintf (OutputFile, "[*** iASL: Read error on source code temp file %s ***]", Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); return; } Total++; } } } } fprintf (OutputFile, "\n"); } } } else { /* * Less verbose version of the error message, enabled via the * -vi switch. The format is compatible with MS Visual Studio. */ fprintf (OutputFile, "%s", Enode->Filename); if (Enode->LineNumber) { fprintf (OutputFile, "(%u) : ", Enode->LineNumber); } } } /* If a NULL message ID, just print the raw message */ if (Enode->MessageId == 0) { fprintf (OutputFile, "%s\n", Enode->Message); return; } /* Decode the message ID */ fprintf (OutputFile, "%s %4.4d -", AeDecodeExceptionLevel (Enode->Level), AeBuildFullExceptionCode (Enode->Level, Enode->MessageId)); MainMessage = AeDecodeMessageId (Enode->MessageId); ExtraMessage = Enode->Message; /* If a NULL line number, just print the decoded message */ if (!Enode->LineNumber) { fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); return; } MsgLength = strlen (MainMessage); if (MsgLength == 0) { /* Use the secondary/extra message as main message */ MainMessage = Enode->Message; if (!MainMessage) { MainMessage = ""; } MsgLength = strlen (MainMessage); ExtraMessage = NULL; } if (Gbl_VerboseErrors && !PrematureEOF) { if (Total >= 256) { fprintf (OutputFile, " %s", MainMessage); } else { SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) { fprintf (OutputFile, "%*s%s", (int) ((SourceColumn - 1) - ErrorColumn), MainMessage, " ^ "); } else { fprintf (OutputFile, "%*s %s", (int) ((SourceColumn - ErrorColumn) + 1), "^", MainMessage); } } } else { fprintf (OutputFile, " %s", MainMessage); } /* Print the extra info message if present */ if (ExtraMessage) { fprintf (OutputFile, " (%s)", ExtraMessage); } if (PrematureEOF) { fprintf (OutputFile, " and premature End-Of-File"); } fprintf (OutputFile, "\n"); if (Gbl_VerboseErrors) { fprintf (OutputFile, "\n"); } }