simulate debug breakpoints - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +--- Thread: simulate debug breakpoints (/Thread-simulate-debug-breakpoints) |
simulate debug breakpoints - gimpygirl - 03-03-2024 Hi Since it's not possible to debug a plugin on windows (maybe it can on linux?) I want to make a way to 'pause' execution of a plugin. Why I want to do that? I want to check in gimp if some code was executed correctly. For example: I add an alpha channel to a layer in the code, and I then want to 'pause' and check in gimp if it's added by right clicking the layer. And then continue my code. Is there a way I can pause the code by showing a message box (after the code line I want it to stop) or something that needs to be closed before the code continues? Or another way? Keyboard input is not possible I think? Please note I'm making a plugin WITHOUT GUI. RE: simulate debug breakpoints - Ofnuts - 03-03-2024 (03-03-2024, 01:56 AM)gimpygirl Wrote: Hi Typically I raise an exception where I want the code to stop: raise Exception("Stopping after adding mask"), but my script run inside a try/except block. But this isn't a breakpoint since the code will never restart afterwards. The closest you can be to a break point is to make the code sleep a bit: Code: import time RE: simulate debug breakpoints - gimpygirl - 03-03-2024 (03-03-2024, 05:13 PM)Ofnuts Wrote:(03-03-2024, 01:56 AM)gimpygirl Wrote: Hi IS there a true way to debug gimp plugins? Either on windows or linux? RE: simulate debug breakpoints - Ofnuts - 03-03-2024 (03-03-2024, 06:21 PM)gimpygirl Wrote:(03-03-2024, 05:13 PM)Ofnuts Wrote:(03-03-2024, 01:56 AM)gimpygirl Wrote: Hi No realistic way to run a debugger in a Gimp plugin. In theory, you could tweak either the Gimp configuration (windows) or the script shebang (Linux/OSX) to have the script be run by a debugger app, but I don't know anyone who tried that. From Brian Kernighan, the "inventor" of the C language and the guy who wrote a good deal of early Unix; Quote:The most effective debugging tool is still careful thought, coupled with judiciously placed print statements. Personally, as a professional software developer, I rarely use debuggers, and in practice the "careful thought" part of debugging seems to be the most important, people good with debuggers are also good with print statements. RE: simulate debug breakpoints - gimpygirl - 03-04-2024 (03-03-2024, 09:04 PM)Ofnuts Wrote:(03-03-2024, 06:21 PM)gimpygirl Wrote:(03-03-2024, 05:13 PM)Ofnuts Wrote: Typically I raise an exception where I want the code to stop: raise Exception("Stopping after adding mask"), but my script run inside a try/except block. But this isn't a breakpoint since the code will never restart afterwards. The closest you can be to a break point is to make the code sleep a bit: Will GIMP 3 have a debugger? I think it's useful Why shouldn't python be debugged? You can debug python without gimp RE: simulate debug breakpoints - Ofnuts - 03-04-2024 (03-04-2024, 02:40 AM)gimpygirl Wrote: Will GIMP 3 have a debugger? I think it's usefulIn Windows? Don't count on it. On Linux, that could possibly be jury-rigged. (03-04-2024, 02:40 AM)gimpygirl Wrote: Why shouldn't python be debugged? You can debug python without gimpBecause your Python code runs in an environment set up by Gimp, and you would need a combined Gimp+IDE environment. On the other hand we are talking about scripts, so just Python being the glue around API calls that do the real job and very little logic in Python. You can test these calls in the Python console and when they work move them to your code. And when you have complicated logic, you can factor it in Gimp-independent code, so test/debug it outside of Gimp, and when it works, just copy it to your script. I use debuggers in C and Java, much less in Python or Bash. |