• 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: Filling variables in the debugger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filling variables in the debugger


  • Subject: Re: Filling variables in the debugger
  • From: Jim Ingham <email@hidden>
  • Date: Fri, 4 Nov 2005 09:32:39 -0800


On Nov 4, 2005, at 5:45 AM, Karan, Cem (Civ, ARL/CISD) wrote:

I'm trying to figure out when and where one of my arrays gets hosed.
The easiest way for me to do this is to fill the array with a known
pattern, and then see who stomps on the pattern. Ideally, I would be
able to open up the array in the debugger, select all of the variable
positions, and copy one value into every position (kind of like how you
might do it in a spreadsheet program). Is there a way of doing this, or
am I being dense? Note that I would like to avoid modifying my code,
and copying into each position one at a time is also really annoying.


In the console, you can do something like:

(gdb) set $i = 0
(gdb) while $i < <ARRAY_SIZE>
set array[$i] = 0xdeadbeef
set $i += 1
end

Dunno if there is an easy cut & paste way to do this in the Variables View, if not please file a bug, that sounds like a useful enhancement.


Also, how do I get XCode to treat a pointer as an array of something?
For example, I have a void pointer, and a size variable being passed
into a function. Because of the size variable, I know how big the array
is going to be; I'd like to cast the expression to an array type of a
particular size so that it updates continuously as I step thru my code.
Is there an easy way of doing this?

The debugger has a kind of funny cast expression for turning a pointer into an array of a given size. Look at the "artificial arrays" section in the gdb manual:


file:///Developer/ADC Reference Library/documentation/ DeveloperTools/gdb/gdb/gdb_9.html#SEC58

for the full skinny. To use this, if you have an pointer "foo" which you know points to an array whose length is given by a variable "len", open the Expressions window, and enter the expression:

*foo@len

and that will be rendered as an array of length len that you can turn down and watch in the expressions window.

Hope that helps,

Jim



Thanks, Cem Karan _______________________________________________ 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


_______________________________________________ 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
References: 
 >Filling variables in the debugger (From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>)

  • Prev by Date: Re: "Flattening" a static library
  • Next by Date: Re: xcode 2.2 editor problem
  • Previous by thread: Filling variables in the debugger
  • Next by thread: OpenSceneGraph and Xcode 2.1
  • Index(es):
    • Date
    • Thread