This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Debug info issue with DW_TAG_lexical_block ?


Hi,

I tried debugging the following function with arm and native C and C++ compiler.

void func(int in)
{
     int a;
     in++;
     {
          int k, j;
    	  k = 10;
    	  j = k + 44;
    	  in = j + 1;
    	  a = in;
     }                  <------      Line 1
     a = in;
     a++;
}           <--------- Line 2

When i try to print the value of 'a' when the execution reaches "line
2" i get the message "No symbol "a" in current context.". Here is the
gdb output:

(gdb) l
15                j = k + 44;
16                in = j + 1;
17                a = in;
18           }
19           a = in;
20           a++;
21      }
22
23      int main()
24      {
(gdb) s
21      }
(gdb) p a
No symbol "a" in current context.
(gdb) p in
$1 = 55
(gdb)

For the same program i am able to view the value of 'a' if i compile
this as a C program. This happens because DW_TAG_lexical_block which
is generated only for in C++ debug info marks the scope of variable
'a' between prologue and epilogue of the code. Since the epilogue is
not present in the scope, the variable cannot be viewed when the
control reaches the closing brace of the function.

Is this an expected behavior?
Since in C i can view the variable at the end of the function is not
logical to have the same behavior for C++ code also?

Regards,
Shafi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]