Community
Participate
Working Groups
Created attachment 189885 [details] First part of fix It may be nice to allow a user to terminate a single process when doing a multi-process debug session. Currently, the DsfTerminateCommand (poorly named as it is GDB specific), immediately terminates GDB itself by using IGDBControl#terminate. Instead, we should find the process that is selected and call IProcesses#terminate. The attached patch does this. However, IProcesses#terminate still resorts to calling IGDBControl#terminate for now. This is because I still need to finalize the multi-inferior stuff to be able to kill a single process. I'm committing this patch, which does not change the behavior but that is a step towards the solution for this bug.
*** cdt cvs genie on behalf of mkhouzam *** Bug 338319: First step to allow terminating individual processes [*] GDBProcesses_7_0.java 1.37 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java?root=Tools_Project&r1=1.36&r2=1.37 [*] DsfTerminateCommand.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java?root=Tools_Project&r1=1.4&r2=1.5
Created attachment 190104 [details] Second part of fix Here is the second part of this change. Basically it has IProcesses#terminate actually send a CLI 'kill' for the process instead of killing GDB itself. I also cleaned up some things from IGDBControl that were process specific. There is a change in behavior after this patch. Previously, when the user had an element of the launch (container, thread or stack) selected and pressed terminate, we would terminate GDB, which would terminate both GDB and inferior. With this patch, when pressing terminate, we will kill the inferior only. But since we also have a user preference to kill GDB when the inferior dies, the result is the same. A more noticeable change is for an attach session. Before, by terminating GDB when pressing 'terminate', GDB would detach from the inferior and leave it running. Now, since we explicitly send a 'kill' for the inferior, pressing 'terminate' will not detach, but will kill the inferior. To balance this, I've enabled the 'detach' action from the Debug view which will give the user the ability to detach as before. I think this is good because it actually allows the user to do something (kill an attached process) he could not do before at all. Since an attach session does not show the inferior in the debug view, the user could not even select that entry to kill the inferior, it just was not something we provided. I am concerned that user may kill an attached process by mistake, when they actually only wanted to detach. I'm thinking that for this case, we may want to add a warning dialog asking for confirmation: "Are you sure you want to explicitly kill the process", or something of the sort. The other advantage of this change, of course, is that it will allow to terminate individual processes in a multi-process session. I just remembered that I didn't test this change when trying to terminate while the inferior is running. I will do that before committing the change.
Created attachment 190128 [details] Second part of fix take 2 (In reply to comment #2) > I just remembered that I didn't test this change when trying to terminate while > the inferior is running. I will do that before committing the change. Yep, I had to add a call to IGDBBackend#interrupt before sending 'kill', if the process is running. I committed this patch to HEAD. But we may want to discuss the fact that 'terminate' on an attach session, will actually kill the inferior. There are also some API changes that I will document.
Mikhail, I feel bad (almost) always asking you to review the patches, but you are the only active committer other than myself working on DSF-GDB at this time... Also, you have great experience with CDI. So, when you have some time, can you review?
I don't know what I'm doing wrong, but the tool won't allow me to set the review flag. It gives an error: "Mikhail Khodjaiants <mikhailkhod@googlemail.com> does not have permission to set the review flag. Please select a user who is a member of the editbugs group."
*** cdt cvs genie on behalf of mkhouzam *** Bug 338319: Allow terminating individual processes [+] MIInterpreterExecConsoleKill.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIInterpreterExecConsoleKill.java?root=Tools_Project&revision=1.1&view=markup [*] GDBControl_7_0.java 1.27 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java?root=Tools_Project&r1=1.26&r2=1.27 [*] GDBControl.java 1.23 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java?root=Tools_Project&r1=1.22&r2=1.23 [*] IGDBControl.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java?root=Tools_Project&r1=1.7&r2=1.8 [-] GDBInferiorProcess.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBInferiorProcess.java?root=Tools_Project&view=markup [*] StartOrRestartProcessSequence_7_0.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java?root=Tools_Project&r1=1.4&r2=1.5 [*] GDBProcesses.java 1.15 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java?root=Tools_Project&r1=1.14&r2=1.15 [*] GDBProcesses_7_0.java 1.38 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java?root=Tools_Project&r1=1.37&r2=1.38 [*] CommandFactory.java 1.22 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java?root=Tools_Project&r1=1.21&r2=1.22 [*] MIInferiorProcess.java 1.12 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIInferiorProcess.java?root=Tools_Project&r1=1.11&r2=1.12
Created attachment 190152 [details] Small enhancement to reduce visible changes to single process sessions It was bothering me that I was changing the behavior of single-process situations to accommodate multi-process. As I said, what the previous patch did was to kill the inferior instead of GDB, when any context was selected. A side effect of that is that the reliability of a terminate is reduced. This is because when we terminate GDB, we actually have a job monitoring the termination and if it does not work within 2 seconds, we forcibly kill GDB; for when we kill the inferior, we have no such job, and therefore if GDB does not properly kill the inferior, the terminate operation simply won't work. So, here is a little enhancement that makes things behave much closer to what was originally being done: - when the preference to kill GDB automatically when the last inferior dies is enabled, we kill GDB instead of killing the inferior. The result is the same, i.e., GDB and the inferior will die, but we get the robustness of the job that monitors killing GDB. - when the preference is off, meaning that the user wants GDB to keep running when the inferior completes, then we actually kill the inferior itself. If that operation fails, the user can still select the GDB process itself or the launch node, and forcibly kill things. - for an attach session, things behave in the same way as the two points above. This means that when the preference is on, terminating the session will detach from the process, as we did before. But when the preference is off, we will actually kill the attached process. If that is not what the user wants, they have the ability to use the 'detach' action instead of 'terminate'. One thing to note is that, unlike before, when selecting the inferior in the Debug View and pressing 'terminate' we will now kill GDB (if the preference is on) instead of killing the inferior. But since the preference is on, we would have killed GDB anyway. I committed this to HEAD.
*** cdt cvs genie on behalf of mkhouzam *** Bug 338319: Allow terminating individual processes [*] GDBProcesses.java 1.16 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses.java?root=Tools_Project&r1=1.15&r2=1.16 [*] GDBProcesses_7_0.java 1.39 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java?root=Tools_Project&r1=1.38&r2=1.39