aslerror.c revision 241973
1118611Snjl/****************************************************************************** 2118611Snjl * 3118611Snjl * Module Name: aslerror - Error handling and statistics 4118611Snjl * 5118611Snjl *****************************************************************************/ 6118611Snjl 7217365Sjkim/* 8229989Sjkim * Copyright (C) 2000 - 2012, Intel Corp. 9118611Snjl * All rights reserved. 10118611Snjl * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 25118611Snjl * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 29118611Snjl * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 43118611Snjl 44118611Snjl#define ASL_EXCEPTIONS 45151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h> 46118611Snjl 47118611Snjl#define _COMPONENT ACPI_COMPILER 48118611Snjl ACPI_MODULE_NAME ("aslerror") 49118611Snjl 50151937Sjkim/* Local prototypes */ 51118611Snjl 52151937Sjkimstatic void 53151937SjkimAeAddToErrorLog ( 54151937Sjkim ASL_ERROR_MSG *Enode); 55151937Sjkim 56151937Sjkim 57233250Sjkim/******************************************************************************* 58233250Sjkim * 59233250Sjkim * FUNCTION: AeClearErrorLog 60233250Sjkim * 61233250Sjkim * PARAMETERS: None 62233250Sjkim * 63233250Sjkim * RETURN: None 64233250Sjkim * 65233250Sjkim * DESCRIPTION: Empty the error list 66233250Sjkim * 67233250Sjkim ******************************************************************************/ 68233250Sjkim 69193529Sjkimvoid 70193529SjkimAeClearErrorLog ( 71193529Sjkim void) 72193529Sjkim{ 73193529Sjkim ASL_ERROR_MSG *Enode = Gbl_ErrorLog; 74193529Sjkim ASL_ERROR_MSG *Next; 75193529Sjkim 76193529Sjkim /* Walk the error node list */ 77193529Sjkim 78193529Sjkim while (Enode) 79193529Sjkim { 80193529Sjkim Next = Enode->Next; 81193529Sjkim ACPI_FREE (Enode); 82193529Sjkim Enode = Next; 83193529Sjkim } 84193529Sjkim 85193529Sjkim Gbl_ErrorLog = NULL; 86193529Sjkim} 87193529Sjkim 88193529Sjkim 89118611Snjl/******************************************************************************* 90118611Snjl * 91118611Snjl * FUNCTION: AeAddToErrorLog 92118611Snjl * 93118611Snjl * PARAMETERS: Enode - An error node to add to the log 94118611Snjl * 95118611Snjl * RETURN: None 96118611Snjl * 97241973Sjkim * DESCRIPTION: Add a new error node to the error log. The error log is 98118611Snjl * ordered by the "logical" line number (cumulative line number 99118611Snjl * including all include files.) 100118611Snjl * 101118611Snjl ******************************************************************************/ 102118611Snjl 103151937Sjkimstatic void 104118611SnjlAeAddToErrorLog ( 105118611Snjl ASL_ERROR_MSG *Enode) 106118611Snjl{ 107118611Snjl ASL_ERROR_MSG *Next; 108118611Snjl ASL_ERROR_MSG *Prev; 109118611Snjl 110118611Snjl 111202771Sjkim /* If Gbl_ErrorLog is null, this is the first error node */ 112118611Snjl 113118611Snjl if (!Gbl_ErrorLog) 114118611Snjl { 115118611Snjl Gbl_ErrorLog = Enode; 116118611Snjl return; 117118611Snjl } 118118611Snjl 119202771Sjkim /* 120202771Sjkim * Walk error list until we find a line number greater than ours. 121202771Sjkim * List is sorted according to line number. 122202771Sjkim */ 123118611Snjl Prev = NULL; 124118611Snjl Next = Gbl_ErrorLog; 125118611Snjl 126118611Snjl while ((Next) && 127118611Snjl (Next->LogicalLineNumber <= Enode->LogicalLineNumber)) 128118611Snjl { 129118611Snjl Prev = Next; 130118611Snjl Next = Next->Next; 131118611Snjl } 132118611Snjl 133118611Snjl /* Found our place in the list */ 134118611Snjl 135118611Snjl Enode->Next = Next; 136118611Snjl 137118611Snjl if (Prev) 138118611Snjl { 139118611Snjl Prev->Next = Enode; 140118611Snjl } 141118611Snjl else 142118611Snjl { 143118611Snjl Gbl_ErrorLog = Enode; 144118611Snjl } 145118611Snjl} 146118611Snjl 147118611Snjl 148118611Snjl/******************************************************************************* 149118611Snjl * 150118611Snjl * FUNCTION: AePrintException 151118611Snjl * 152151937Sjkim * PARAMETERS: FileId - ID of output file 153118611Snjl * Enode - Error node to print 154118611Snjl * Header - Additional text before each message 155118611Snjl * 156118611Snjl * RETURN: None 157118611Snjl * 158118611Snjl * DESCRIPTION: Print the contents of an error node. 159118611Snjl * 160118611Snjl * NOTE: We don't use the FlxxxFile I/O functions here because on error 161118611Snjl * they abort the compiler and call this function! Since we 162118611Snjl * are reporting errors here, we ignore most output errors and 163118611Snjl * just try to get out as much as we can. 164118611Snjl * 165118611Snjl ******************************************************************************/ 166118611Snjl 167118611Snjlvoid 168118611SnjlAePrintException ( 169118611Snjl UINT32 FileId, 170118611Snjl ASL_ERROR_MSG *Enode, 171118611Snjl char *Header) 172118611Snjl{ 173118611Snjl UINT8 SourceByte; 174151937Sjkim int Actual; 175151937Sjkim size_t RActual; 176118611Snjl UINT32 MsgLength; 177118611Snjl char *MainMessage; 178118611Snjl char *ExtraMessage; 179118611Snjl UINT32 SourceColumn; 180118611Snjl UINT32 ErrorColumn; 181118611Snjl FILE *OutputFile; 182233250Sjkim FILE *SourceFile = NULL; 183216471Sjkim long FileSize; 184216471Sjkim BOOLEAN PrematureEOF = FALSE; 185240716Sjkim UINT32 Total = 0; 186118611Snjl 187118611Snjl 188193529Sjkim if (Gbl_NoErrors) 189193529Sjkim { 190193529Sjkim return; 191193529Sjkim } 192193529Sjkim 193151937Sjkim /* 194151937Sjkim * Only listing files have a header, and remarks/optimizations 195151937Sjkim * are always output 196151937Sjkim */ 197118611Snjl if (!Header) 198118611Snjl { 199118611Snjl /* Ignore remarks if requested */ 200118611Snjl 201118611Snjl switch (Enode->Level) 202118611Snjl { 203118611Snjl case ASL_REMARK: 204118611Snjl if (!Gbl_DisplayRemarks) 205118611Snjl { 206118611Snjl return; 207118611Snjl } 208118611Snjl break; 209118611Snjl 210118611Snjl case ASL_OPTIMIZATION: 211118611Snjl if (!Gbl_DisplayOptimizations) 212118611Snjl { 213118611Snjl return; 214118611Snjl } 215118611Snjl break; 216118611Snjl 217118611Snjl default: 218118611Snjl break; 219118611Snjl } 220118611Snjl } 221118611Snjl 222118611Snjl /* Get the file handles */ 223118611Snjl 224118611Snjl OutputFile = Gbl_Files[FileId].Handle; 225209746Sjkim 226209746Sjkim 227233250Sjkim if (!Enode->SourceLine) 228209746Sjkim { 229233250Sjkim /* Use the merged header/source file if present, otherwise use input file */ 230118611Snjl 231233250Sjkim SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle; 232233250Sjkim if (!SourceFile) 233233250Sjkim { 234233250Sjkim SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle; 235233250Sjkim } 236216471Sjkim 237233250Sjkim if (SourceFile) 238233250Sjkim { 239233250Sjkim /* Determine if the error occurred at source file EOF */ 240216471Sjkim 241233250Sjkim fseek (SourceFile, 0, SEEK_END); 242233250Sjkim FileSize = ftell (SourceFile); 243233250Sjkim 244233250Sjkim if ((long) Enode->LogicalByteOffset >= FileSize) 245233250Sjkim { 246233250Sjkim PrematureEOF = TRUE; 247233250Sjkim } 248216471Sjkim } 249216471Sjkim } 250216471Sjkim 251118611Snjl if (Header) 252118611Snjl { 253118611Snjl fprintf (OutputFile, "%s", Header); 254118611Snjl } 255118611Snjl 256118611Snjl /* Print filename and line number if present and valid */ 257118611Snjl 258118611Snjl if (Enode->Filename) 259118611Snjl { 260118611Snjl if (Gbl_VerboseErrors) 261118611Snjl { 262234623Sjkim fprintf (OutputFile, "%-8s", Enode->Filename); 263118611Snjl 264118611Snjl if (Enode->LineNumber) 265118611Snjl { 266233250Sjkim if (Enode->SourceLine) 267233250Sjkim { 268233250Sjkim fprintf (OutputFile, " %6u: %s", 269233250Sjkim Enode->LineNumber, Enode->SourceLine); 270233250Sjkim } 271233250Sjkim else 272233250Sjkim { 273234623Sjkim fprintf (OutputFile, " %6u: ", Enode->LineNumber); 274118611Snjl 275216471Sjkim /* 276233250Sjkim * If not at EOF, get the corresponding source code line and 277233250Sjkim * display it. Don't attempt this if we have a premature EOF 278233250Sjkim * condition. 279216471Sjkim */ 280233250Sjkim if (!PrematureEOF) 281118611Snjl { 282233250Sjkim /* 283233250Sjkim * Seek to the offset in the combined source file, read 284233250Sjkim * the source line, and write it to the output. 285233250Sjkim */ 286233250Sjkim Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, 287233250Sjkim (int) SEEK_SET); 288233250Sjkim if (Actual) 289216471Sjkim { 290216471Sjkim fprintf (OutputFile, 291233250Sjkim "[*** iASL: Seek error on source code temp file %s ***]", 292216471Sjkim Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); 293216471Sjkim } 294233250Sjkim else 295216471Sjkim { 296216471Sjkim RActual = fread (&SourceByte, 1, 1, SourceFile); 297233250Sjkim if (!RActual) 298233250Sjkim { 299233250Sjkim fprintf (OutputFile, 300233250Sjkim "[*** iASL: Read error on source code temp file %s ***]", 301233250Sjkim Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); 302233250Sjkim } 303240716Sjkim else 304240716Sjkim { 305240716Sjkim while (RActual && SourceByte && (SourceByte != '\n') && (Total < 256)) 306240716Sjkim { 307240716Sjkim fwrite (&SourceByte, 1, 1, OutputFile); 308240716Sjkim RActual = fread (&SourceByte, 1, 1, SourceFile); 309240716Sjkim Total++; 310240716Sjkim } 311233250Sjkim 312240716Sjkim if (Total >= 256) 313240716Sjkim { 314240716Sjkim fprintf (OutputFile, 315240716Sjkim "\n[*** iASL: Long input line, an error occurred at column %u ***]", 316240716Sjkim Enode->Column); 317240716Sjkim } 318233250Sjkim } 319216471Sjkim } 320118611Snjl } 321233250Sjkim 322233250Sjkim fprintf (OutputFile, "\n"); 323118611Snjl } 324118611Snjl } 325118611Snjl } 326118611Snjl else 327118611Snjl { 328235945Sjkim /* 329235945Sjkim * Less verbose version of the error message, enabled via the 330235945Sjkim * -vi switch. The format is compatible with MS Visual Studio. 331235945Sjkim */ 332118611Snjl fprintf (OutputFile, "%s", Enode->Filename); 333118611Snjl 334118611Snjl if (Enode->LineNumber) 335118611Snjl { 336235945Sjkim fprintf (OutputFile, "(%u) : ", 337235945Sjkim Enode->LineNumber); 338118611Snjl } 339118611Snjl } 340118611Snjl } 341118611Snjl 342118611Snjl /* NULL message ID, just print the raw message */ 343118611Snjl 344118611Snjl if (Enode->MessageId == 0) 345118611Snjl { 346118611Snjl fprintf (OutputFile, "%s\n", Enode->Message); 347118611Snjl } 348118611Snjl else 349118611Snjl { 350118611Snjl /* Decode the message ID */ 351118611Snjl 352235945Sjkim if (Gbl_VerboseErrors) 353235945Sjkim { 354237412Sjkim fprintf (OutputFile, "%s %4.4d -", 355235945Sjkim AslErrorLevel[Enode->Level], 356235945Sjkim Enode->MessageId + ((Enode->Level+1) * 1000)); 357235945Sjkim } 358235945Sjkim else /* IDE case */ 359235945Sjkim { 360235945Sjkim fprintf (OutputFile, "%s %4.4d:", 361235945Sjkim AslErrorLevelIde[Enode->Level], 362235945Sjkim Enode->MessageId + ((Enode->Level+1) * 1000)); 363235945Sjkim } 364118611Snjl 365118611Snjl MainMessage = AslMessages[Enode->MessageId]; 366118611Snjl ExtraMessage = Enode->Message; 367118611Snjl 368118611Snjl if (Enode->LineNumber) 369118611Snjl { 370228110Sjkim /* Main message: try to use string from AslMessages first */ 371228110Sjkim 372228110Sjkim if (!MainMessage) 373228110Sjkim { 374228110Sjkim MainMessage = ""; 375228110Sjkim } 376228110Sjkim 377118611Snjl MsgLength = strlen (MainMessage); 378118611Snjl if (MsgLength == 0) 379118611Snjl { 380228110Sjkim /* Use the secondary/extra message as main message */ 381228110Sjkim 382118611Snjl MainMessage = Enode->Message; 383228110Sjkim if (!MainMessage) 384228110Sjkim { 385228110Sjkim MainMessage = ""; 386228110Sjkim } 387118611Snjl 388118611Snjl MsgLength = strlen (MainMessage); 389118611Snjl ExtraMessage = NULL; 390118611Snjl } 391118611Snjl 392216471Sjkim if (Gbl_VerboseErrors && !PrematureEOF) 393118611Snjl { 394240716Sjkim if (Total >= 256) 395118611Snjl { 396240716Sjkim fprintf (OutputFile, " %s", 397240716Sjkim MainMessage); 398118611Snjl } 399118611Snjl else 400118611Snjl { 401240716Sjkim SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; 402240716Sjkim ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; 403240716Sjkim 404240716Sjkim if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) 405240716Sjkim { 406240716Sjkim fprintf (OutputFile, "%*s%s", 407240716Sjkim (int) ((SourceColumn - 1) - ErrorColumn), 408240716Sjkim MainMessage, " ^ "); 409240716Sjkim } 410240716Sjkim else 411240716Sjkim { 412240716Sjkim fprintf (OutputFile, "%*s %s", 413240716Sjkim (int) ((SourceColumn - ErrorColumn) + 1), "^", 414240716Sjkim MainMessage); 415240716Sjkim } 416118611Snjl } 417118611Snjl } 418118611Snjl else 419118611Snjl { 420118611Snjl fprintf (OutputFile, " %s", MainMessage); 421118611Snjl } 422118611Snjl 423118611Snjl /* Print the extra info message if present */ 424118611Snjl 425118611Snjl if (ExtraMessage) 426118611Snjl { 427118611Snjl fprintf (OutputFile, " (%s)", ExtraMessage); 428118611Snjl } 429118611Snjl 430216471Sjkim if (PrematureEOF) 431216471Sjkim { 432216471Sjkim fprintf (OutputFile, " and premature End-Of-File"); 433216471Sjkim } 434216471Sjkim 435118611Snjl fprintf (OutputFile, "\n"); 436118611Snjl if (Gbl_VerboseErrors) 437118611Snjl { 438118611Snjl fprintf (OutputFile, "\n"); 439118611Snjl } 440118611Snjl } 441118611Snjl else 442118611Snjl { 443151937Sjkim fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); 444118611Snjl } 445118611Snjl } 446118611Snjl} 447118611Snjl 448118611Snjl 449118611Snjl/******************************************************************************* 450118611Snjl * 451118611Snjl * FUNCTION: AePrintErrorLog 452118611Snjl * 453118611Snjl * PARAMETERS: FileId - Where to output the error log 454118611Snjl * 455118611Snjl * RETURN: None 456118611Snjl * 457118611Snjl * DESCRIPTION: Print the entire contents of the error log 458118611Snjl * 459118611Snjl ******************************************************************************/ 460118611Snjl 461118611Snjlvoid 462118611SnjlAePrintErrorLog ( 463118611Snjl UINT32 FileId) 464118611Snjl{ 465118611Snjl ASL_ERROR_MSG *Enode = Gbl_ErrorLog; 466118611Snjl 467118611Snjl 468118611Snjl /* Walk the error node list */ 469118611Snjl 470118611Snjl while (Enode) 471118611Snjl { 472118611Snjl AePrintException (FileId, Enode, NULL); 473118611Snjl Enode = Enode->Next; 474118611Snjl } 475118611Snjl} 476118611Snjl 477118611Snjl 478118611Snjl/******************************************************************************* 479118611Snjl * 480233250Sjkim * FUNCTION: AslCommonError2 481233250Sjkim * 482233250Sjkim * PARAMETERS: Level - Seriousness (Warning/error, etc.) 483233250Sjkim * MessageId - Index into global message buffer 484233250Sjkim * LineNumber - Actual file line number 485233250Sjkim * Column - Column in current line 486233250Sjkim * SourceLine - Actual source code line 487233250Sjkim * Filename - source filename 488233250Sjkim * ExtraMessage - additional error message 489233250Sjkim * 490233250Sjkim * RETURN: None 491233250Sjkim * 492233250Sjkim * DESCRIPTION: Create a new error node and add it to the error log 493233250Sjkim * 494233250Sjkim ******************************************************************************/ 495233250Sjkim 496233250Sjkimvoid 497233250SjkimAslCommonError2 ( 498233250Sjkim UINT8 Level, 499233250Sjkim UINT8 MessageId, 500233250Sjkim UINT32 LineNumber, 501233250Sjkim UINT32 Column, 502233250Sjkim char *SourceLine, 503233250Sjkim char *Filename, 504233250Sjkim char *ExtraMessage) 505233250Sjkim{ 506233250Sjkim char *MessageBuffer = NULL; 507233250Sjkim char *LineBuffer; 508233250Sjkim ASL_ERROR_MSG *Enode; 509233250Sjkim 510233250Sjkim 511233250Sjkim Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG)); 512233250Sjkim 513233250Sjkim if (ExtraMessage) 514233250Sjkim { 515233250Sjkim /* Allocate a buffer for the message and a new error node */ 516233250Sjkim 517233250Sjkim MessageBuffer = UtLocalCalloc (strlen (ExtraMessage) + 1); 518233250Sjkim 519233250Sjkim /* Keep a copy of the extra message */ 520233250Sjkim 521233250Sjkim ACPI_STRCPY (MessageBuffer, ExtraMessage); 522233250Sjkim } 523233250Sjkim 524233250Sjkim LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1); 525233250Sjkim ACPI_STRCPY (LineBuffer, SourceLine); 526233250Sjkim 527233250Sjkim /* Initialize the error node */ 528233250Sjkim 529233250Sjkim if (Filename) 530233250Sjkim { 531233250Sjkim Enode->Filename = Filename; 532233250Sjkim Enode->FilenameLength = strlen (Filename); 533233250Sjkim if (Enode->FilenameLength < 6) 534233250Sjkim { 535233250Sjkim Enode->FilenameLength = 6; 536233250Sjkim } 537233250Sjkim } 538233250Sjkim 539233250Sjkim Enode->MessageId = MessageId; 540233250Sjkim Enode->Level = Level; 541233250Sjkim Enode->LineNumber = LineNumber; 542233250Sjkim Enode->LogicalLineNumber = LineNumber; 543233250Sjkim Enode->LogicalByteOffset = 0; 544233250Sjkim Enode->Column = Column; 545233250Sjkim Enode->Message = MessageBuffer; 546233250Sjkim Enode->SourceLine = LineBuffer; 547233250Sjkim 548233250Sjkim /* Add the new node to the error node list */ 549233250Sjkim 550233250Sjkim AeAddToErrorLog (Enode); 551233250Sjkim 552233250Sjkim if (Gbl_DebugFlag) 553233250Sjkim { 554233250Sjkim /* stderr is a file, send error to it immediately */ 555233250Sjkim 556233250Sjkim AePrintException (ASL_FILE_STDERR, Enode, NULL); 557233250Sjkim } 558233250Sjkim 559233250Sjkim Gbl_ExceptionCount[Level]++; 560233250Sjkim} 561233250Sjkim 562233250Sjkim 563233250Sjkim/******************************************************************************* 564233250Sjkim * 565118611Snjl * FUNCTION: AslCommonError 566118611Snjl * 567118611Snjl * PARAMETERS: Level - Seriousness (Warning/error, etc.) 568118611Snjl * MessageId - Index into global message buffer 569118611Snjl * CurrentLineNumber - Actual file line number 570118611Snjl * LogicalLineNumber - Cumulative line number 571118611Snjl * LogicalByteOffset - Byte offset in source file 572118611Snjl * Column - Column in current line 573118611Snjl * Filename - source filename 574118611Snjl * ExtraMessage - additional error message 575118611Snjl * 576151937Sjkim * RETURN: None 577118611Snjl * 578118611Snjl * DESCRIPTION: Create a new error node and add it to the error log 579118611Snjl * 580118611Snjl ******************************************************************************/ 581118611Snjl 582118611Snjlvoid 583118611SnjlAslCommonError ( 584118611Snjl UINT8 Level, 585118611Snjl UINT8 MessageId, 586118611Snjl UINT32 CurrentLineNumber, 587118611Snjl UINT32 LogicalLineNumber, 588118611Snjl UINT32 LogicalByteOffset, 589118611Snjl UINT32 Column, 590118611Snjl char *Filename, 591118611Snjl char *ExtraMessage) 592118611Snjl{ 593118611Snjl UINT32 MessageSize; 594118611Snjl char *MessageBuffer = NULL; 595118611Snjl ASL_ERROR_MSG *Enode; 596118611Snjl 597118611Snjl 598118611Snjl Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG)); 599118611Snjl 600118611Snjl if (ExtraMessage) 601118611Snjl { 602118611Snjl /* Allocate a buffer for the message and a new error node */ 603118611Snjl 604118611Snjl MessageSize = strlen (ExtraMessage) + 1; 605118611Snjl MessageBuffer = UtLocalCalloc (MessageSize); 606118611Snjl 607118611Snjl /* Keep a copy of the extra message */ 608118611Snjl 609118611Snjl ACPI_STRCPY (MessageBuffer, ExtraMessage); 610118611Snjl } 611118611Snjl 612118611Snjl /* Initialize the error node */ 613118611Snjl 614118611Snjl if (Filename) 615118611Snjl { 616118611Snjl Enode->Filename = Filename; 617118611Snjl Enode->FilenameLength = strlen (Filename); 618118611Snjl if (Enode->FilenameLength < 6) 619118611Snjl { 620118611Snjl Enode->FilenameLength = 6; 621118611Snjl } 622118611Snjl } 623118611Snjl 624118611Snjl Enode->MessageId = MessageId; 625118611Snjl Enode->Level = Level; 626118611Snjl Enode->LineNumber = CurrentLineNumber; 627118611Snjl Enode->LogicalLineNumber = LogicalLineNumber; 628118611Snjl Enode->LogicalByteOffset = LogicalByteOffset; 629118611Snjl Enode->Column = Column; 630118611Snjl Enode->Message = MessageBuffer; 631233250Sjkim Enode->SourceLine = NULL; 632118611Snjl 633118611Snjl /* Add the new node to the error node list */ 634118611Snjl 635118611Snjl AeAddToErrorLog (Enode); 636118611Snjl 637118611Snjl if (Gbl_DebugFlag) 638118611Snjl { 639118611Snjl /* stderr is a file, send error to it immediately */ 640118611Snjl 641118611Snjl AePrintException (ASL_FILE_STDERR, Enode, NULL); 642118611Snjl } 643118611Snjl 644118611Snjl Gbl_ExceptionCount[Level]++; 645118611Snjl if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) 646118611Snjl { 647209746Sjkim printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT); 648118611Snjl 649118611Snjl Gbl_SourceLine = 0; 650118611Snjl Gbl_NextError = Gbl_ErrorLog; 651118611Snjl CmDoOutputFiles (); 652118611Snjl CmCleanupAndExit (); 653199337Sjkim exit(1); 654118611Snjl } 655118611Snjl 656118611Snjl return; 657118611Snjl} 658118611Snjl 659118611Snjl 660118611Snjl/******************************************************************************* 661118611Snjl * 662118611Snjl * FUNCTION: AslError 663118611Snjl * 664118611Snjl * PARAMETERS: Level - Seriousness (Warning/error, etc.) 665118611Snjl * MessageId - Index into global message buffer 666118611Snjl * Op - Parse node where error happened 667118611Snjl * ExtraMessage - additional error message 668118611Snjl * 669118611Snjl * RETURN: None 670118611Snjl * 671118611Snjl * DESCRIPTION: Main error reporting routine for the ASL compiler (all code 672118611Snjl * except the parser.) 673118611Snjl * 674118611Snjl ******************************************************************************/ 675118611Snjl 676118611Snjlvoid 677118611SnjlAslError ( 678118611Snjl UINT8 Level, 679118611Snjl UINT8 MessageId, 680118611Snjl ACPI_PARSE_OBJECT *Op, 681118611Snjl char *ExtraMessage) 682118611Snjl{ 683118611Snjl 684167802Sjkim switch (Level) 685167802Sjkim { 686167802Sjkim case ASL_WARNING2: 687167802Sjkim case ASL_WARNING3: 688167802Sjkim if (Gbl_WarningLevel < Level) 689167802Sjkim { 690167802Sjkim return; 691167802Sjkim } 692167802Sjkim break; 693167802Sjkim 694167802Sjkim default: 695167802Sjkim break; 696167802Sjkim } 697167802Sjkim 698118611Snjl if (Op) 699118611Snjl { 700118611Snjl AslCommonError (Level, MessageId, Op->Asl.LineNumber, 701118611Snjl Op->Asl.LogicalLineNumber, 702118611Snjl Op->Asl.LogicalByteOffset, 703118611Snjl Op->Asl.Column, 704118611Snjl Op->Asl.Filename, ExtraMessage); 705118611Snjl } 706118611Snjl else 707118611Snjl { 708118611Snjl AslCommonError (Level, MessageId, 0, 709118611Snjl 0, 0, 0, NULL, ExtraMessage); 710118611Snjl } 711118611Snjl} 712118611Snjl 713118611Snjl 714118611Snjl/******************************************************************************* 715118611Snjl * 716118611Snjl * FUNCTION: AslCoreSubsystemError 717118611Snjl * 718118611Snjl * PARAMETERS: Op - Parse node where error happened 719118611Snjl * Status - The ACPI CA Exception 720118611Snjl * ExtraMessage - additional error message 721118611Snjl * Abort - TRUE -> Abort compilation 722118611Snjl * 723118611Snjl * RETURN: None 724118611Snjl * 725118611Snjl * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI 726118611Snjl * CA core subsystem. 727118611Snjl * 728118611Snjl ******************************************************************************/ 729118611Snjl 730118611Snjlvoid 731118611SnjlAslCoreSubsystemError ( 732118611Snjl ACPI_PARSE_OBJECT *Op, 733118611Snjl ACPI_STATUS Status, 734118611Snjl char *ExtraMessage, 735118611Snjl BOOLEAN Abort) 736118611Snjl{ 737118611Snjl 738118611Snjl sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage); 739118611Snjl 740118611Snjl if (Op) 741118611Snjl { 742118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber, 743118611Snjl Op->Asl.LogicalLineNumber, 744118611Snjl Op->Asl.LogicalByteOffset, 745118611Snjl Op->Asl.Column, 746118611Snjl Op->Asl.Filename, MsgBuffer); 747118611Snjl } 748118611Snjl else 749118611Snjl { 750118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0, 751118611Snjl 0, 0, 0, NULL, MsgBuffer); 752118611Snjl } 753118611Snjl 754118611Snjl if (Abort) 755118611Snjl { 756118611Snjl AslAbort (); 757118611Snjl } 758118611Snjl} 759118611Snjl 760118611Snjl 761118611Snjl/******************************************************************************* 762118611Snjl * 763118611Snjl * FUNCTION: AslCompilererror 764118611Snjl * 765118611Snjl * PARAMETERS: CompilerMessage - Error message from the parser 766118611Snjl * 767151937Sjkim * RETURN: Status (0 for now) 768118611Snjl * 769118611Snjl * DESCRIPTION: Report an error situation discovered in a production 770151937Sjkim * NOTE: don't change the name of this function, it is called 771151937Sjkim * from the auto-generated parser. 772118611Snjl * 773118611Snjl ******************************************************************************/ 774118611Snjl 775118611Snjlint 776118611SnjlAslCompilererror ( 777228110Sjkim const char *CompilerMessage) 778118611Snjl{ 779118611Snjl 780118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber, 781228110Sjkim Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, 782228110Sjkim Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename, 783228110Sjkim ACPI_CAST_PTR (char, CompilerMessage)); 784118611Snjl 785241973Sjkim return (0); 786118611Snjl} 787