It is believed that most programmers are interested in using python Language or in linux Conduct C The common debugging method for language program programming is printf, This is a method that everyone can reach , The first problem is to add printing information , see log Record . For products deployed outside , Is not a good way . However, compared with the method of online debugging, this method can obtain less information , Analyzing problems is not so fast .
python It supports online debugging , Perhaps the relevant books do not introduce this too much , It makes me think that it can't be debugged online . Just last week I met a QT After the interface program runs for a long time, the interface is stuck , To find the cause of the problem , I just thought of online debugging , A check found that QT It really supports online debugging . So how to use online debugging ,python The native IDE It supports online debugging , The code compiler I use vscode Software ,vscode Software based on python The debugger provides friendly interface support , The experience is better . I'll just use vscode Online debugging has been carried out . Here's the picture , Open the program and select the upper right corner Debug Python File It's ready to run .
After entering the debugging interface , The left window shows the variables that the program runs , call Stack , The breakpoint , If you need to stop observing data at a specific code location , Click before the line number , Just make a red dot .
Use the method of online debugging , Running software 4 Hours , Found out QT Software interface stuck , The program is in a while You can't get out of the loop , Here's the picture . When pos = -1 when ,while The loop cannot exit , Find the problem , It's easy to solve the problem .