• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GDB & static const variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GDB & static const variables


  • Subject: Re: GDB & static const variables
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 16 Jul 2009 11:29:32 -0500

On 16 Jul 2009, at 10:25 AM, Eric Gorr wrote:

Boolean TestFunction( void )
{
	static const int doubleByteDegreeMark = 42;
	static int anotherVar = 12;

	return ( doubleByteDegreeMark == 42 && anotherVar == 12 );
}

from GDB, if I do 'info locals' it prints out:

(gdb) info locals
anotherVar = 12

if I try to print out the value of doubleByteDegreeMark, it gives me the error message:

(gdb) print doubleByteDegreeMark
No symbol "doubleByteDegreeMark" in current context.

So, my (probably really simple) question is how can I print out the value of doubleByteDegreeMark from GDB?

Given that doubleByteDegreeMark is a constant, and referred to only within the function, gcc optimized by doing away with the storage, and substituted the literal value 42; and then it saw "42 == 42," and optimized that to true; and then saw "true && anotherVar == 12," and optimized that to "anotherVar == 12." I don't know why it didn't optimize that to simply "true." Maybe at the optimization level you chose, it didn't do the analysis to get that far.


There being no storage for doubleByteDegreeMark, gdb didn't have any stored value to display. I don't know the details of why it didn't know about it just as a constant; I've seen it display enum constants.

	— F


--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/ >


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: GDB & static const variables
      • From: Eric Gorr <email@hidden>
References: 
 >GDB & static const variables (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: GDB & static const variables
  • Next by Date: Re: GDB & static const variables
  • Previous by thread: Re: GDB & static const variables
  • Next by thread: Re: GDB & static const variables
  • Index(es):
    • Date
    • Thread