public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Debug info issue with DW_TAG_lexical_block ?
@ 2012-06-08 11:24 Mohamed Shafi
  2012-06-27  8:42 ` Mohamed Shafi
  0 siblings, 1 reply; 2+ messages in thread
From: Mohamed Shafi @ 2012-06-08 11:24 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Debug info issue with DW_TAG_lexical_block ?
  2012-06-08 11:24 Debug info issue with DW_TAG_lexical_block ? Mohamed Shafi
@ 2012-06-27  8:42 ` Mohamed Shafi
  0 siblings, 0 replies; 2+ messages in thread
From: Mohamed Shafi @ 2012-06-27  8:42 UTC (permalink / raw)
  To: gcc-help; +Cc: Nick Clifton, richard.earnshaw, Paul Brook, ramana.radhakrishnan

Ping
http://gcc.gnu.org/ml/gcc-help/2012-06/msg00091.html



On 8 June 2012 16:53, Mohamed Shafi <shafitvm@gmail.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-06-27  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 11:24 Debug info issue with DW_TAG_lexical_block ? Mohamed Shafi
2012-06-27  8:42 ` Mohamed Shafi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).