I tried this in VSCode+PHP extension and NetBeans, and both seem to not offer a function like that.
Basically what I want is to keep debugger session for next run but terminate the current PHP execution. I'm debugging a cron job that modifies the DB many times and just don't want the script to complete after I reach a certain point in debugger.
The only function I can see in both IDE's is stop debugging which may or may not abort execution but definitely ends the debugging session.
Related
So i'm debugging a very rare case that SEGSEV occurs, I do not know when it will happen, but i know that when it happens, one local var is -1, so I did this in gdb
break file.c:100 if t1 == -1
the problem is i have to go back many steps to find out what happened, is it possible to record all execution information, so that I can replay the execution?
there is currently the rr project for linux which record the execution of your program and help you replay the execution in GDB.
Windows also seem to have some replay debugging capabilities with winDbg preview
I have a batch script that calls a bunch of programs written in C that do a lot of data processing. It works fine when run manually but when Jenkins calls the batch, one of the programs fails with a useless error message.
Before I litter the program with printf()s, I tried to use DebugBreak() to attach the debugger to see what difference Jenkins is making but the program just ends without invoking the debugger.
Is there a way to invoke the debugger from within the failing program that'll work with Jenkins?
EDIT: I tried calling MessageBox() but nothing appears and Jenkins sits there waiting for console output.
I'm trying to debug for the first time a gtk code and actually, I want to debug a callback function for key-press-event so I set a breakpoint with gdb and when it hits the breakpoint, the whole desktop evirement is freezing (I'm running under gnome-shell) it seems that the graphic envirement is waiting for the event to finish.
I got some idea that didn't worked :
The first attempts was to assign some gdb commands to the breakpoint :
(gdb) break on_key_press_callback
(gdb) commands
> back trace
> next
> next
> next
> continue
> end
but I don't know why, only the back trace command is executed, and then freeze.
The second attempt was to debug remotely using gdbserver and gdb on tty1 (no graphigs to freeze :) ) I was able to send commands like next and step after the breakpoint but there was nothing to see (can't list code, inspect the stack, ect ...)
So any good tips to be able to debug in such situations ?
Thanks
It's typical to have lockups when debugging an X program running on the same server that you're using to debug. For example, if the inferior (gdb terminology for the program being debugged) does a server grab -- whoops, the gdb GUI (or terminal or emacs etc) is locked out.
Your idea of doing more programmatic debugging is a good one, but it's hard to make it all work nicely. As you found, some gdb commands (basically those related to inferior control) don't work in commands. Also, it just isn't nearly as convenient.
You can go further that direction. For example you could use SystemTap to probe the program instead.
However there are also nicer approaches.
One way is to run the inferior using a virtual X server -- a nested one, or one running in a VM. Then you can escape to the "outer" X server for debugging. This will be much nicer.
Another way is to have two computers, and run the debugger on one and the inferior on the other. In a way this is really the same answer, just using a real machine rather than a virtual one.
The question is old, but for anyone that may be struggling with this issue, there is a way to stop the freezing behaviour from happening by disabling the X server grab.
You have to change the config in your IDE to run the program with the following system property:
-Dsun.awt.disablegrab=true
If you are using javaws (Java Web Start) to run the application use:
-J-Dsun.awt.disablegrab=true
instead.
I'd like to know if anybody had success with debugging postgres through an IDE (NetBeans or Eclipse) by attaching the debugger to the process and still perform step debugging (stop at breakpoints and watch variables).
For most cases, debugging PostgreSQL isn't significantly different to any other server in this regard.
You determine the process ID of the process you wish to examine, then attach the debugger to it and set breakpoints/watchpoints and continue execution. When you hit the break/watch, examine, step, etc as required.
You can SELECT pg_backend_pid() to get the process ID of the current session.
I usually start psql, SELECT pg_backend_pid(), attach gdb, set my breaks/watches, cont, and in my psql session run whatever I expect to trigger my breakpoint/watchpoint. The same principle applies with IDE debuggers (Visual Studio, Eclipse, NetBeans, whatever).
See: the PostgreSQL wiki for some instructions.
I'm trying to debug an issue that happens on service startup. Trying to attach while things are running is failing, windbg times out with an error about a link lock. I think that the error occurs before I have a chance to attach. A sleep might let me attach, but is there a more elegant solution?
I'd like to start up the debugger first thing as the service starts. C# has a Debugger.Launch() method to start a debugger at runtime. Is there an equivalent C call that can be used without .net? Something I could just drop in the start routine.
I can't call DebugBreak because at the time the service has started I'm not under a debugger.
Sleep is certainly a viable approach. It's crude yet effective. Somewhat less crude is to use a good logging framework to output diagnostics. With a sufficiently capable logging framework this can be very effective.