Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging loops

For some current projects, I'm working with several data structures that are pretty large (in the area of 10K elements). To be able to access this data in lists, I need to use loops and iterators, which can be a pain when the problem area is in the latter half of the list.

So I find myself spending alot of time with my finger on the F8 button in Eclipse's debugger to loop through each element of an iterating loop. This gets worse when have to step through that particular section several times to get an idea why the code is reacting a particular way.

If one has a general idea how many times a loop is to execute before a problem area is hit, is there a way to set a loop breakpoint to execute up to that point then pause?

like image 834
Jason Avatar asked Nov 01 '10 22:11

Jason


People also ask

How do you debug an infinite loop?

The best first step for debugging an infinite loop is to comment out different sections or lines of code, then running the program to see where the infinite loop is occurring. Start by testing any sections that contain for or while loops, then if/else statements, then other blocks of code.

What are debugging in Python?

A debugger is a program that can help you find out what is going on in a computer program. You can stop the execution at any prescribed line number, print out variables, continue execution, stop again, execute statements one by one, and repeat such actions until you have tracked down abnormal behavior and found bugs.

Is Python good for debugging?

Python has a few basic functions that can help with debugging (see the print() process below).


1 Answers

Use conditional breakpoints.

http://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F

like image 74
thejh Avatar answered Nov 15 '22 18:11

thejh