aslerror.c revision 281075
1/******************************************************************************
2 *
3 * Module Name: aslerror - Error handling and statistics
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2015, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions, and the following disclaimer,
16 *    without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 *    substantially similar to the "NO WARRANTY" disclaimer below
19 *    ("Disclaimer") and any redistribution must be conditioned upon
20 *    including a substantially similar Disclaimer requirement for further
21 *    binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 *    of any contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <contrib/dev/acpica/compiler/aslcompiler.h>
45
46#define _COMPONENT          ACPI_COMPILER
47        ACPI_MODULE_NAME    ("aslerror")
48
49/* Local prototypes */
50
51static void
52AeAddToErrorLog (
53    ASL_ERROR_MSG           *Enode);
54
55
56/*******************************************************************************
57 *
58 * FUNCTION:    AslAbort
59 *
60 * PARAMETERS:  None
61 *
62 * RETURN:      None
63 *
64 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
65 *              I/O errors.
66 *
67 ******************************************************************************/
68
69void
70AslAbort (
71    void)
72{
73
74    AePrintErrorLog (ASL_FILE_STDERR);
75    if (Gbl_DebugFlag)
76    {
77        /* Print error summary to stdout also */
78
79        AePrintErrorLog (ASL_FILE_STDOUT);
80    }
81
82    exit (1);
83}
84
85
86/*******************************************************************************
87 *
88 * FUNCTION:    AeClearErrorLog
89 *
90 * PARAMETERS:  None
91 *
92 * RETURN:      None
93 *
94 * DESCRIPTION: Empty the error list
95 *
96 ******************************************************************************/
97
98void
99AeClearErrorLog (
100    void)
101{
102    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
103    ASL_ERROR_MSG           *Next;
104
105    /* Walk the error node list */
106
107    while (Enode)
108    {
109        Next = Enode->Next;
110        ACPI_FREE (Enode);
111        Enode = Next;
112    }
113
114    Gbl_ErrorLog = NULL;
115}
116
117
118/*******************************************************************************
119 *
120 * FUNCTION:    AeAddToErrorLog
121 *
122 * PARAMETERS:  Enode       - An error node to add to the log
123 *
124 * RETURN:      None
125 *
126 * DESCRIPTION: Add a new error node to the error log. The error log is
127 *              ordered by the "logical" line number (cumulative line number
128 *              including all include files.)
129 *
130 ******************************************************************************/
131
132static void
133AeAddToErrorLog (
134    ASL_ERROR_MSG           *Enode)
135{
136    ASL_ERROR_MSG           *Next;
137    ASL_ERROR_MSG           *Prev;
138
139
140    /* If Gbl_ErrorLog is null, this is the first error node */
141
142    if (!Gbl_ErrorLog)
143    {
144        Gbl_ErrorLog = Enode;
145        return;
146    }
147
148    /*
149     * Walk error list until we find a line number greater than ours.
150     * List is sorted according to line number.
151     */
152    Prev = NULL;
153    Next = Gbl_ErrorLog;
154
155    while ((Next) &&
156           (Next->LogicalLineNumber <= Enode->LogicalLineNumber))
157    {
158        Prev = Next;
159        Next = Next->Next;
160    }
161
162    /* Found our place in the list */
163
164    Enode->Next = Next;
165
166    if (Prev)
167    {
168        Prev->Next = Enode;
169    }
170    else
171    {
172        Gbl_ErrorLog = Enode;
173    }
174}
175
176
177/*******************************************************************************
178 *
179 * FUNCTION:    AePrintException
180 *
181 * PARAMETERS:  FileId          - ID of output file
182 *              Enode           - Error node to print
183 *              Header          - Additional text before each message
184 *
185 * RETURN:      None
186 *
187 * DESCRIPTION: Print the contents of an error node.
188 *
189 * NOTE:        We don't use the FlxxxFile I/O functions here because on error
190 *              they abort the compiler and call this function!  Since we
191 *              are reporting errors here, we ignore most output errors and
192 *              just try to get out as much as we can.
193 *
194 ******************************************************************************/
195
196void
197AePrintException (
198    UINT32                  FileId,
199    ASL_ERROR_MSG           *Enode,
200    char                    *Header)
201{
202    UINT8                   SourceByte;
203    int                     Actual;
204    size_t                  RActual;
205    UINT32                  MsgLength;
206    const char              *MainMessage;
207    char                    *ExtraMessage;
208    UINT32                  SourceColumn;
209    UINT32                  ErrorColumn;
210    FILE                    *OutputFile;
211    FILE                    *SourceFile = NULL;
212    long                    FileSize;
213    BOOLEAN                 PrematureEOF = FALSE;
214    UINT32                  Total = 0;
215
216
217    if (Gbl_NoErrors)
218    {
219        return;
220    }
221
222    /*
223     * Only listing files have a header, and remarks/optimizations
224     * are always output
225     */
226    if (!Header)
227    {
228        /* Ignore remarks if requested */
229
230        switch (Enode->Level)
231        {
232        case ASL_WARNING:
233        case ASL_WARNING2:
234        case ASL_WARNING3:
235
236            if (!Gbl_DisplayWarnings)
237            {
238                return;
239            }
240            break;
241
242        case ASL_REMARK:
243
244            if (!Gbl_DisplayRemarks)
245            {
246                return;
247            }
248            break;
249
250        case ASL_OPTIMIZATION:
251
252            if (!Gbl_DisplayOptimizations)
253            {
254                return;
255            }
256            break;
257
258        default:
259
260            break;
261        }
262    }
263
264    /* Get the various required file handles */
265
266    OutputFile = Gbl_Files[FileId].Handle;
267
268    if (!Enode->SourceLine)
269    {
270        /* Use the merged header/source file if present, otherwise use input file */
271
272        SourceFile = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
273        if (!SourceFile)
274        {
275            SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;
276        }
277
278        if (SourceFile)
279        {
280            /* Determine if the error occurred at source file EOF */
281
282            fseek (SourceFile, 0, SEEK_END);
283            FileSize = ftell (SourceFile);
284
285            if ((long) Enode->LogicalByteOffset >= FileSize)
286            {
287                PrematureEOF = TRUE;
288            }
289        }
290    }
291
292    if (Header)
293    {
294        fprintf (OutputFile, "%s", Header);
295    }
296
297    /* Print filename and line number if present and valid */
298
299    if (Enode->Filename)
300    {
301        if (Gbl_VerboseErrors)
302        {
303            fprintf (OutputFile, "%-8s", Enode->Filename);
304
305            if (Enode->LineNumber)
306            {
307                if (Enode->SourceLine)
308                {
309                    fprintf (OutputFile, " %6u: %s",
310                        Enode->LineNumber, Enode->SourceLine);
311                }
312                else
313                {
314                    fprintf (OutputFile, " %6u: ", Enode->LineNumber);
315
316                    /*
317                     * If not at EOF, get the corresponding source code line and
318                     * display it. Don't attempt this if we have a premature EOF
319                     * condition.
320                     */
321                    if (!PrematureEOF)
322                    {
323                        /*
324                         * Seek to the offset in the combined source file, read
325                         * the source line, and write it to the output.
326                         */
327                        Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset,
328                                    (int) SEEK_SET);
329                        if (Actual)
330                        {
331                            fprintf (OutputFile,
332                                "[*** iASL: Seek error on source code temp file %s ***]",
333                                Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
334                        }
335                        else
336                        {
337                            RActual = fread (&SourceByte, 1, 1, SourceFile);
338                            if (RActual != 1)
339                            {
340                                fprintf (OutputFile,
341                                    "[*** iASL: Read error on source code temp file %s ***]",
342                                    Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
343                            }
344                            else
345                            {
346                                /* Read/write the source line, up to the maximum line length */
347
348                                while (RActual && SourceByte && (SourceByte != '\n'))
349                                {
350                                    if (Total < 256)
351                                    {
352                                        /* After the max line length, we will just read the line, no write */
353
354                                        if (fwrite (&SourceByte, 1, 1, OutputFile) != 1)
355                                        {
356                                            printf ("[*** iASL: Write error on output file ***]\n");
357                                            return;
358                                        }
359                                    }
360                                    else if (Total == 256)
361                                    {
362                                        fprintf (OutputFile,
363                                            "\n[*** iASL: Very long input line, message below refers to column %u ***]",
364                                            Enode->Column);
365                                    }
366
367                                    RActual = fread (&SourceByte, 1, 1, SourceFile);
368                                    if (RActual != 1)
369                                    {
370                                        fprintf (OutputFile,
371                                            "[*** iASL: Read error on source code temp file %s ***]",
372                                            Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
373                                        return;
374                                    }
375                                    Total++;
376                                }
377                            }
378                        }
379                    }
380
381                    fprintf (OutputFile, "\n");
382                }
383            }
384        }
385        else
386        {
387            /*
388             * Less verbose version of the error message, enabled via the
389             * -vi switch. The format is compatible with MS Visual Studio.
390             */
391            fprintf (OutputFile, "%s", Enode->Filename);
392
393            if (Enode->LineNumber)
394            {
395                fprintf (OutputFile, "(%u) : ",
396                    Enode->LineNumber);
397            }
398        }
399    }
400
401    /* If a NULL message ID, just print the raw message */
402
403    if (Enode->MessageId == 0)
404    {
405        fprintf (OutputFile, "%s\n", Enode->Message);
406        return;
407    }
408
409    /* Decode the message ID */
410
411    fprintf (OutputFile, "%s %4.4d -",
412        AeDecodeExceptionLevel (Enode->Level),
413        AeBuildFullExceptionCode (Enode->Level, Enode->MessageId));
414
415    MainMessage = AeDecodeMessageId (Enode->MessageId);
416    ExtraMessage = Enode->Message;
417
418    /* If a NULL line number, just print the decoded message */
419
420    if (!Enode->LineNumber)
421    {
422        fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage);
423        return;
424    }
425
426    MsgLength = strlen (MainMessage);
427    if (MsgLength == 0)
428    {
429        /* Use the secondary/extra message as main message */
430
431        MainMessage = Enode->Message;
432        if (!MainMessage)
433        {
434            MainMessage = "";
435        }
436
437        MsgLength = strlen (MainMessage);
438        ExtraMessage = NULL;
439    }
440
441    if (Gbl_VerboseErrors && !PrematureEOF)
442    {
443        if (Total >= 256)
444        {
445            fprintf (OutputFile, "    %s",
446                MainMessage);
447        }
448        else
449        {
450            SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
451            ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
452
453            if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
454            {
455                fprintf (OutputFile, "%*s%s",
456                    (int) ((SourceColumn - 1) - ErrorColumn),
457                    MainMessage, " ^ ");
458            }
459            else
460            {
461                fprintf (OutputFile, "%*s %s",
462                    (int) ((SourceColumn - ErrorColumn) + 1), "^",
463                    MainMessage);
464            }
465        }
466    }
467    else
468    {
469        fprintf (OutputFile, " %s", MainMessage);
470    }
471
472    /* Print the extra info message if present */
473
474    if (ExtraMessage)
475    {
476        fprintf (OutputFile, " (%s)", ExtraMessage);
477    }
478
479    if (PrematureEOF)
480    {
481        fprintf (OutputFile, " and premature End-Of-File");
482    }
483
484    fprintf (OutputFile, "\n");
485    if (Gbl_VerboseErrors)
486    {
487        fprintf (OutputFile, "\n");
488    }
489}
490
491
492/*******************************************************************************
493 *
494 * FUNCTION:    AePrintErrorLog
495 *
496 * PARAMETERS:  FileId           - Where to output the error log
497 *
498 * RETURN:      None
499 *
500 * DESCRIPTION: Print the entire contents of the error log
501 *
502 ******************************************************************************/
503
504void
505AePrintErrorLog (
506    UINT32                  FileId)
507{
508    ASL_ERROR_MSG           *Enode = Gbl_ErrorLog;
509
510
511    /* Walk the error node list */
512
513    while (Enode)
514    {
515        AePrintException (FileId, Enode, NULL);
516        Enode = Enode->Next;
517    }
518}
519
520
521/*******************************************************************************
522 *
523 * FUNCTION:    AslCommonError2
524 *
525 * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
526 *              MessageId           - Index into global message buffer
527 *              LineNumber          - Actual file line number
528 *              Column              - Column in current line
529 *              SourceLine          - Actual source code line
530 *              Filename            - source filename
531 *              ExtraMessage        - additional error message
532 *
533 * RETURN:      None
534 *
535 * DESCRIPTION: Create a new error node and add it to the error log
536 *
537 ******************************************************************************/
538
539void
540AslCommonError2 (
541    UINT8                   Level,
542    UINT16                  MessageId,
543    UINT32                  LineNumber,
544    UINT32                  Column,
545    char                    *SourceLine,
546    char                    *Filename,
547    char                    *ExtraMessage)
548{
549    char                    *MessageBuffer = NULL;
550    char                    *LineBuffer;
551    ASL_ERROR_MSG           *Enode;
552
553
554    Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
555
556    if (ExtraMessage)
557    {
558        /* Allocate a buffer for the message and a new error node */
559
560        MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1);
561
562        /* Keep a copy of the extra message */
563
564        ACPI_STRCPY (MessageBuffer, ExtraMessage);
565    }
566
567    LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1);
568    ACPI_STRCPY (LineBuffer, SourceLine);
569
570    /* Initialize the error node */
571
572    if (Filename)
573    {
574        Enode->Filename = Filename;
575        Enode->FilenameLength = strlen (Filename);
576        if (Enode->FilenameLength < 6)
577        {
578            Enode->FilenameLength = 6;
579        }
580    }
581
582    Enode->MessageId            = MessageId;
583    Enode->Level                = Level;
584    Enode->LineNumber           = LineNumber;
585    Enode->LogicalLineNumber    = LineNumber;
586    Enode->LogicalByteOffset    = 0;
587    Enode->Column               = Column;
588    Enode->Message              = MessageBuffer;
589    Enode->SourceLine           = LineBuffer;
590
591    /* Add the new node to the error node list */
592
593    AeAddToErrorLog (Enode);
594
595    if (Gbl_DebugFlag)
596    {
597        /* stderr is a file, send error to it immediately */
598
599        AePrintException (ASL_FILE_STDERR, Enode, NULL);
600    }
601
602    Gbl_ExceptionCount[Level]++;
603}
604
605
606/*******************************************************************************
607 *
608 * FUNCTION:    AslCommonError
609 *
610 * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
611 *              MessageId           - Index into global message buffer
612 *              CurrentLineNumber   - Actual file line number
613 *              LogicalLineNumber   - Cumulative line number
614 *              LogicalByteOffset   - Byte offset in source file
615 *              Column              - Column in current line
616 *              Filename            - source filename
617 *              ExtraMessage        - additional error message
618 *
619 * RETURN:      None
620 *
621 * DESCRIPTION: Create a new error node and add it to the error log
622 *
623 ******************************************************************************/
624
625void
626AslCommonError (
627    UINT8                   Level,
628    UINT16                  MessageId,
629    UINT32                  CurrentLineNumber,
630    UINT32                  LogicalLineNumber,
631    UINT32                  LogicalByteOffset,
632    UINT32                  Column,
633    char                    *Filename,
634    char                    *ExtraMessage)
635{
636    char                    *MessageBuffer = NULL;
637    ASL_ERROR_MSG           *Enode;
638
639
640    Enode = UtLocalCalloc (sizeof (ASL_ERROR_MSG));
641
642    if (ExtraMessage)
643    {
644        /* Allocate a buffer for the message and a new error node */
645
646        MessageBuffer = UtStringCacheCalloc (strlen (ExtraMessage) + 1);
647
648        /* Keep a copy of the extra message */
649
650        ACPI_STRCPY (MessageBuffer, ExtraMessage);
651    }
652
653    /* Initialize the error node */
654
655    if (Filename)
656    {
657        Enode->Filename = Filename;
658        Enode->FilenameLength = strlen (Filename);
659        if (Enode->FilenameLength < 6)
660        {
661            Enode->FilenameLength = 6;
662        }
663    }
664
665    Enode->MessageId            = MessageId;
666    Enode->Level                = Level;
667    Enode->LineNumber           = CurrentLineNumber;
668    Enode->LogicalLineNumber    = LogicalLineNumber;
669    Enode->LogicalByteOffset    = LogicalByteOffset;
670    Enode->Column               = Column;
671    Enode->Message              = MessageBuffer;
672    Enode->SourceLine           = NULL;
673
674    /* Add the new node to the error node list */
675
676    AeAddToErrorLog (Enode);
677
678    if (Gbl_DebugFlag)
679    {
680        /* stderr is a file, send error to it immediately */
681
682        AePrintException (ASL_FILE_STDERR, Enode, NULL);
683    }
684
685    Gbl_ExceptionCount[Level]++;
686    if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
687    {
688        printf ("\nMaximum error count (%u) exceeded\n", ASL_MAX_ERROR_COUNT);
689
690        Gbl_SourceLine = 0;
691        Gbl_NextError = Gbl_ErrorLog;
692        CmCleanupAndExit ();
693        exit(1);
694    }
695
696    return;
697}
698
699
700/*******************************************************************************
701 *
702 * FUNCTION:    AslDisableException
703 *
704 * PARAMETERS:  MessageIdString     - ID to be disabled
705 *
706 * RETURN:      Status
707 *
708 * DESCRIPTION: Enter a message ID into the global disabled messages table
709 *
710 ******************************************************************************/
711
712ACPI_STATUS
713AslDisableException (
714    char                    *MessageIdString)
715{
716    UINT32                  MessageId;
717
718
719    /* Convert argument to an integer and validate it */
720
721    MessageId = (UINT32) strtoul (MessageIdString, NULL, 0);
722
723    if ((MessageId < 2000) || (MessageId > 5999))
724    {
725        printf ("\"%s\" is not a valid warning/remark ID\n",
726            MessageIdString);
727        return (AE_BAD_PARAMETER);
728    }
729
730    /* Insert value into the global disabled message array */
731
732    if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES)
733    {
734        printf ("Too many messages have been disabled (max %u)\n",
735            ASL_MAX_DISABLED_MESSAGES);
736        return (AE_LIMIT);
737    }
738
739    Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId;
740    Gbl_DisabledMessagesIndex++;
741    return (AE_OK);
742}
743
744
745/*******************************************************************************
746 *
747 * FUNCTION:    AslIsExceptionDisabled
748 *
749 * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
750 *              MessageId           - Index into global message buffer
751 *
752 * RETURN:      TRUE if exception/message should be ignored
753 *
754 * DESCRIPTION: Check if the user has specified options such that this
755 *              exception should be ignored
756 *
757 ******************************************************************************/
758
759BOOLEAN
760AslIsExceptionDisabled (
761    UINT8                   Level,
762    UINT16                  MessageId)
763{
764    UINT32                  EncodedMessageId;
765    UINT32                  i;
766
767
768    switch (Level)
769    {
770    case ASL_WARNING2:
771    case ASL_WARNING3:
772
773        /* Check for global disable via -w1/-w2/-w3 options */
774
775        if (Level > Gbl_WarningLevel)
776        {
777            return (TRUE);
778        }
779        /* Fall through */
780
781    case ASL_WARNING:
782    case ASL_REMARK:
783        /*
784         * Ignore this warning/remark if it has been disabled by
785         * the user (-vw option)
786         */
787        EncodedMessageId = AeBuildFullExceptionCode (Level, MessageId);
788        for (i = 0; i < Gbl_DisabledMessagesIndex; i++)
789        {
790            /* Simple implementation via fixed array */
791
792            if (EncodedMessageId == Gbl_DisabledMessages[i])
793            {
794                return (TRUE);
795            }
796        }
797        break;
798
799    default:
800        break;
801    }
802
803    return (FALSE);
804}
805
806
807/*******************************************************************************
808 *
809 * FUNCTION:    AslError
810 *
811 * PARAMETERS:  Level               - Seriousness (Warning/error, etc.)
812 *              MessageId           - Index into global message buffer
813 *              Op                  - Parse node where error happened
814 *              ExtraMessage        - additional error message
815 *
816 * RETURN:      None
817 *
818 * DESCRIPTION: Main error reporting routine for the ASL compiler (all code
819 *              except the parser.)
820 *
821 ******************************************************************************/
822
823void
824AslError (
825    UINT8                   Level,
826    UINT16                  MessageId,
827    ACPI_PARSE_OBJECT       *Op,
828    char                    *ExtraMessage)
829{
830
831    /* Check if user wants to ignore this exception */
832
833    if (Gbl_AllExceptionsDisabled ||
834        AslIsExceptionDisabled (Level, MessageId))
835    {
836        return;
837    }
838
839    if (Op)
840    {
841        AslCommonError (Level, MessageId, Op->Asl.LineNumber,
842            Op->Asl.LogicalLineNumber,
843            Op->Asl.LogicalByteOffset,
844            Op->Asl.Column,
845            Op->Asl.Filename, ExtraMessage);
846    }
847    else
848    {
849        AslCommonError (Level, MessageId, 0,
850            0, 0, 0, NULL, ExtraMessage);
851    }
852}
853
854
855/*******************************************************************************
856 *
857 * FUNCTION:    AslCoreSubsystemError
858 *
859 * PARAMETERS:  Op                  - Parse node where error happened
860 *              Status              - The ACPICA Exception
861 *              ExtraMessage        - additional error message
862 *              Abort               - TRUE -> Abort compilation
863 *
864 * RETURN:      None
865 *
866 * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA
867 *              core subsystem.
868 *
869 ******************************************************************************/
870
871void
872AslCoreSubsystemError (
873    ACPI_PARSE_OBJECT       *Op,
874    ACPI_STATUS             Status,
875    char                    *ExtraMessage,
876    BOOLEAN                 Abort)
877{
878
879    sprintf (MsgBuffer, "%s %s", AcpiFormatException (Status), ExtraMessage);
880
881    if (Op)
882    {
883        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Op->Asl.LineNumber,
884                        Op->Asl.LogicalLineNumber,
885                        Op->Asl.LogicalByteOffset,
886                        Op->Asl.Column,
887                        Op->Asl.Filename, MsgBuffer);
888    }
889    else
890    {
891        AslCommonError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, 0,
892                        0, 0, 0, NULL, MsgBuffer);
893    }
894
895    if (Abort)
896    {
897        AslAbort ();
898    }
899}
900
901
902/*******************************************************************************
903 *
904 * FUNCTION:    AslCompilererror
905 *
906 * PARAMETERS:  CompilerMessage         - Error message from the parser
907 *
908 * RETURN:      Status (0 for now)
909 *
910 * DESCRIPTION: Report an error situation discovered in a production
911 *              NOTE: don't change the name of this function, it is called
912 *              from the auto-generated parser.
913 *
914 ******************************************************************************/
915
916int
917AslCompilererror (
918    const char              *CompilerMessage)
919{
920
921    Gbl_SyntaxError++;
922
923    AslCommonError (ASL_ERROR, ASL_MSG_SYNTAX, Gbl_CurrentLineNumber,
924        Gbl_LogicalLineNumber, Gbl_CurrentLineOffset,
925        Gbl_CurrentColumn, Gbl_Files[ASL_FILE_INPUT].Filename,
926        ACPI_CAST_PTR (char, CompilerMessage));
927
928    return (0);
929}
930