• 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: Break on ivar value change
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Break on ivar value change


  • Subject: Re: Break on ivar value change
  • From: Jim Ingham <email@hidden>
  • Date: Tue, 25 May 2010 09:52:48 -0700

Note, we did add one little aid to setting watchpoints on the location of a variable (rather than on the variable's expression.)

If you want to watch the ivar of an object you have a pointer to, you're tempted to try:

(gdb) watch self->ivar

But that doesn't work because "watch" is watching this as an expression, and self is a local variable, so the expression becomes invalid when you leave the scope of the method.

The old solution to this was to do:

rather than having to do:

(gdb) print &(self->ivar)
(gdb) watch *(int*)<address from print>

which watches the final location of the expression, but it is a pain in the neck to do.  So we added:

(gdb) watch -location self->ivar

which does the same thing and is more convenient.

Also keep in mind that there are only 4 hardware watchpoint registers on Intel, after that you fall back on single-step & check the value as a watchpoint implementation which is hideously slow...

Jim

On May 25, 2010, at 2:23 AM, Paul Sanders wrote:

> Try it!  It works for me, although I have only used it on Intel.  I don't notice any performance problems so I think there must be kernel support for the Pentium's hardware debug registers.  Interesting post you dug up.
>
> A couple of other useful console commands are:
>     i b - displays current break and watchpoints
>     d b <n> - deletes a breakpoint or watchpoint
>     disable b <n>  /  enable b <n> - disable or enable a breakpoint or watchpoint
>
> Paul Sanders.
>
> ----- Original Message -----
> From: <email@hidden>
> To: <email@hidden>
> Sent: Monday, May 24, 2010 11:21 PM
> Subject: Break on ivar value change
>
> One of my ObjC class ivars is getting overwritten.
>
> This posting suggests issuing a GDB watch on the offender:
>
> http://www.mailinglistarchive.com/html/email@hidden/2007-07/msg00058.html
>
> Is this still the best way to proceed?
>
> Regards
>
> Jonathan Mitchell
>
> Developer
> Mugginsoft LLP
> http://www.mugginsoft.com
> _______________________________________________
> 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

  • Follow-Ups:
    • Re: Break on ivar value change
      • From: "Paul Sanders" <email@hidden>
References: 
 >Break on ivar value change (From: "email@hidden" <email@hidden>)
 >Re: Break on ivar value change (From: "Paul Sanders" <email@hidden>)

  • Prev by Date: Re: Memory Browser Font
  • Next by Date: Re: Break on ivar value change
  • Previous by thread: Re: Break on ivar value change
  • Next by thread: Re: Break on ivar value change
  • Index(es):
    • Date
    • Thread