In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to use pdb in python. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Pdb starts.
The current frame binding tracking function trace_dispatch.
Def trace_dispatch (self, frame, event, arg): if self.quitting: return # None if event = = 'line': return self.dispatch_line (frame) if event =' call': return self.dispatch_call (frame, arg) if event = = 'return': return self.dispatch_return (frame, arg) if event = =' exception':...
2. The handling of different events in each frame will go through the interrupt control logic.
It is mainly the stop_here (line events also pass through the break_here) function that determines whether the code is interrupted and which line it needs to interrupt.
If an interrupt is needed, trigger the subclass method user_#event.
The subclass can update the stack frame information through interaction, print the corresponding information on the console, and then execute cmdloop to make the console wait for interactive input.
Def interaction (self, frame, traceback): self.setup (frame, traceback) # current stack, frame, local vars self.print_stack_entry (self.stack [self.curindex]) self.cmdloop () self.forget ()
3. The user inputs debugging commands.
For example, when next returns to the car, they will first call the set_# command to set up stopframe, returnframe, and stoplineno, which will affect the logic of interrupt control and determine the interrupt result of running to the next frame.
4. debug the commands of the process control class.
Generally, the do_# command returns 1, so the runloop ends immediately, and the next time you run to a certain frame to trigger an interrupt, the runloop will be started again (see step 3). For commands of the information acquisition class, the do_# command does not return a value to maintain the current interrupted state.
5. Run the code to the next frame and repeat step 3.
Thank you for reading! This is the end of the article on "how to use pdb in python". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.