Need help for modifying the format of debug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

  I met one problem when I tried to modify the debug format from gcc.

Supposing there is a program :

1:void main()
2:{
3: int i=1;
4: if (i>1)
5: {
6:  i=2;
7:  if(i == 2)
8:  {
9:   i=i+1;
10:   i=3;
11:  }
12:  i=i-1;
13: }
14: i=i+1;
15:}

Using gcc-avr, part of the assembler code (statement 6,7 and 9) will be:

.stabn 68,0,6,.LM3-.LFBB1   --
.LM3:                                   |
MOV A,2                              |
MOV Y+1,A                          |- for statement 6
 MOV A,2                             |
MOV Y+1,A                        --
.stabn 68,0,7,.LM4-.LFBB1  --
.LM4:                                   |- for statement 7
       ....                              --
.stabn 68,0,9,.LM5-.LFBB1  --
.LM5:                                  |
INC Y+1                              |- for statement 9
SZ [0AH].2                          |
INC Y+1                            --


we want to set a scope id for each statement, for example,

void main()
{
int i=1;         ------------------->  scope = 1;
if (i>1)
{
 i=2;            --------------------> scope =2; because it is inside a brace;
 if(i == 2)
 {
  i=i+1;         --------------------> scope =3; because it is inside two brace;
  i=3;           --------------------> scope =3; because it is inside two brace;
 }
 i=i-1;          --------------------> scope =2; because it is inside a brace;
}
i=i+1;           --------------------> scope =1;
}

And we want to add this scope information in the assembler code, like
this. (As soon as it reaches a "{", the scope will add "1" and the
scope will remove "1" when it reaches a "}" )

       scope 2  ------------------------ we want to add this "scope" information
.stabn 68,0,6,.LM3-.LFBB1   --
.LM3:                                   |
MOV A,2                              |
MOV Y+1,A                          |- for statement 6
 MOV A,2                             |
MOV Y+1,A                        --
.stabn 68,0,7,.LM4-.LFBB1  --
.LM4:                                   |- for statement 7
       ....                              --
       scope 3   ----------------------   we want to add this "scope"
information
.stabn 68,0,9,.LM5-.LFBB1  --
.LM5:                                   |
INC Y+1                               |- for statement 9
SZ [0AH].2                           |
INC Y+1                             --


Gcc generates the assembler code from the RTL tree. There is not any
information for "{" and "}" in the RTL.
But I also found basic block struct has a variable "loop_depth", can I use it?
What is the easiest way to implement this.
Thank you very much.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux