ARM Technical Support Knowledge Articles

ERROR MESSAGES POINT TO THE WRONG SOURCE LINE

Applies to: uVision IDE

Answer


Information in this article applies to:


SYMPTOM

When compiling programs using uVision, error messages may indicate incorrect line numbers.

CAUSE

This problem may occur when executable code is included in #include or header files. Consider the following...

--File Header.h--

int Singlestep(int x)
{
x++;
return x;
}

int Doublestep(int y)
{
y++;
return ++y;
}

--File Code.c--

#include "Header.h"


void main(void)
{
int Step1, Step2;

Step1 = Singlestep(5);
Step2 = Doublestep(7);

}

--Compiler Output--

             ; FUNCTION _Singlestep (BEGIN)
                                           ; SOURCE LINE # 1
;---- Variable 'x' assigned to Register 'R6/R7' ----
                                           ; SOURCE LINE # 2
                                           ; SOURCE LINE # 3
0000 0F                INC     R7
0001 BF0001            CJNE    R7,#00H,?C0004
0004 0E                INC     R6
0005         ?C0004:
                                           ; SOURCE LINE # 4
                                           ; SOURCE LINE # 5
0005         ?C0001:
0005 22                RET
             ; FUNCTION _Singlestep (END)

             ; FUNCTION _Doublestep (BEGIN)
                                           ; SOURCE LINE # 7
;---- Variable 'y' assigned to Register 'R6/R7' ----
                                           ; SOURCE LINE # 8
                                           ; SOURCE LINE # 9
0000 0F                INC     R7
0001 BF0001            CJNE    R7,#00H,?C0005
0004 0E                INC     R6
0005         ?C0005:
                                           ; SOURCE LINE # 10
0005 0F                INC     R7
0006 EF                MOV     A,R7
0007 7001              JNZ     ?C0006
0009 0E                INC     R6
000A         ?C0006:
                                           ; SOURCE LINE # 11
000A         ?C0002:
000A 22                RET
             ; FUNCTION _Doublestep (END)

             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 4
                                           ; SOURCE LINE # 5
                                           ; SOURCE LINE # 8
0000 7F05              MOV     R7,#05H
0002 7E00              MOV     R6,#00H
0004 120000      R     LCALL   _Singlestep
0007 8E00        R     MOV     Step1,R6
0009 8F00        R     MOV     Step1+01H,R7
                                           ; SOURCE LINE # 9
000B 7F07              MOV     R7,#07H
000D 7E00              MOV     R6,#00H
000F 120000      R     LCALL   _Doublestep
0012 8E00        R     MOV     Step2,R6
0014 8F00        R     MOV     Step2+01H,R7
                                           ; SOURCE LINE # 11
0016 22                RET
             ; FUNCTION main (END)

Note that some source line numbers are not unique. The reason for this is that line numbers are reset for each file that includes source code.

Line numbers are reset for each file that contains source code (code that generates object code) because of the way the 8051 object module format handles source-level debug information. Basically, each line of object code may reference a source file (by filename) and a line number (from the top of the file starting at 1). When a debugger synchronizes the object code with the source code, it requires the name of the file and the line number.

The problem with all of this is that the line number may have been reset due to include files with source code. Any subsequent error or warning messages will use the reset line number and make it more difficult to locate the exact location of the error.

This is NOT a problem when using include files that generate no object code.

RESOLUTION

There is no compiler-based resolution to this problem at this time. However, it is our recommendation (and good engineering practice) to avoid putting source code into include files.

Article last edited on: 2004-05-01 11:12:07

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential