Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 15, 2013, 11:52 PM   #1
ArtOfWarfare
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Log Every 10000th time breakpoint is hit?

I just discovered the "Edit Breakpoint..." options that appear when you right click a breakpoint. It's occurred to me that this allows me to easily insert debug messages without modifying my source files at all.

I have a loop that I'm expecting will be run approximately 8.1 B times... I don't want it to a log every iteration through the loop, but every 10 Kth iteration through the loop.

I figured that simply setting the "Ignore x Times Before Stopping" option would do this for me, but that causes it to stop on iteration 10,000, 10,001, 10,002, and so on... not terribly helpful.

I realize that I could probably utilize the condition field some how, but it's not very easy (I have no iteration counting variable right now... and the whole point here is to avoid modifying code for the sole point of debugging.)

So... what am I missing? What's the simplest thing I can do here without modifying my code to make it so that it logs every 10Kth iteration only?
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.

Last edited by ArtOfWarfare; Feb 16, 2013 at 12:11 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 16, 2013, 10:49 AM   #2
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
Here you go. This doesn't break at all. It just logs the value every 5th iteration.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-02-16 at 11.45.41 AM.png
Views:	4
Size:	65.3 KB
ID:	397308  
Attached Images
 
PhoneyDeveloper is offline   0 Reply With Quote
Old Feb 16, 2013, 11:33 AM   #3
ArtOfWarfare
Thread Starter
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I don't have an iteration variable in my code right now (it's a while loop & I'm trying to do this without modifying my code to include a variable just for debugging.)

Last edited by ArtOfWarfare; Feb 16, 2013 at 11:39 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 16, 2013, 01:20 PM   #4
firewood
macrumors 603
 
Join Date: Jul 2003
Location: Silicon Valley
Quote:
Originally Posted by ArtOfWarfare View Post
What's the simplest thing I can do here without modifying my code to make it so that it logs every 10Kth iteration only?
Modify your code. This will have less impact on performance than a conditional breakpoint. If your code is checked into source control, then just revert after debugging to get rid of all the temporary debug modifications.
firewood is offline   0 Reply With Quote
Old Feb 16, 2013, 02:30 PM   #5
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
OP, you miss the point. Whatever the condition is that you want to have a log use that. Also, you can add a counter that increments each time through the loop.

The concepts are "conditional breakpoint" and "breakpoint action." You set a condition and it breaks. The action can print or run an applescript or several other possibilities.

int count = 0;
while (!done)
{
// do whatever
count++; // set your conditional breakpoint here
}
PhoneyDeveloper is offline   0 Reply With Quote
Old Feb 16, 2013, 11:26 PM   #6
ArtOfWarfare
Thread Starter
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I'm wondering if maybe it was my goal that was wrong...

Trying to break less often didn't help me fix my bugs... instead what I had to do was scale back my problem.

I was trying to read in a list of 90 K words and sort them alphabetically (school assignment - I had to roll my own sorting method,) but I couldn't figure out why some words weren't sorting properly. I ultimately fixed my issue by scaling my list down to just 12 words, following my own procedure on a white board, and then stepping through my code and modifying it to do the same thing as I did on the white board when it strayed.
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 17, 2013, 02:10 AM   #7
xArtx
macrumors 6502a
 
Join Date: Mar 2012
Quote:
Originally Posted by ArtOfWarfare View Post
I'm wondering if maybe it was my goal that was wrong...

Trying to break less often didn't help me fix my bugs... instead what I had to do was scale back my problem.

I was trying to read in a list of 90 K words and sort them alphabetically (school assignment - I had to roll my own sorting method,) but I couldn't figure out why some words weren't sorting properly. I ultimately fixed my issue by scaling my list down to just 12 words, following my own procedure on a white board, and then stepping through my code and modifying it to do the same thing as I did on the white board when it strayed.
you can use qsort in Xcode.
xArtx is offline   0 Reply With Quote
Old Feb 17, 2013, 02:51 AM   #8
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Lost in Minneapolis
Quote:
Originally Posted by xArtx View Post
you can use qsort in Xcode.
The assignment required writing the sort algorithm.
xStep is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:43 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC