Community
Participate
Working Groups
When doing a local attach, we could allow the user to detach from the current process and attach to it again or to another process. The detach action does not behave very well in that use-case. This applies to all GDB versions (except maybe 7.2 where it may already be fixed because we handle multi-process)
The detaching seems to work properly. However, attaching to a different process after a detah does not seem to work properly. When we do a local attach, we don't specify the binary but instead let GDB figure it out itself. However, after a detach, if we attach again, GDB seems to re-use the same binary as for the first attach, even though it is attached to another process altogether. I think we would need to explicitly set the binary in this case, like we do for non-attach session. Note that this problem only happen for GDB < 7.2. There is no problem for 7.2 probably because when we do an attach, we use a brand new inferior, which allows GDB to choose a new binary.
(In reply to comment #1) > I think we would need to explicitly set the binary in this case, like we do for > non-attach session. Setting the binary would require us to ask the user which binary to use. A better solution would be to 'unset' the current GDB binary, which would allow GDB to automatically choose the new one. To do this, we can simply set the binary to nothing. Just to make sure things are clear, this is how to reproduce the problem: - start an attach session with GDB <= 7.1 - attach to any process - detach from the process with the disconnect button - press the connect button and choose a process with a _different_ binary => notice that the stack frame shows the old binary code, although the values of variables are from the new binary executing (with names from the old binary)
Besides resetting the binary in GDB, we also need to stopTrackingBreakpoints because on the re-attach we will try to startTracking them again.
Since this problem is only for GDB versions before 7.2, I won't spend more time on it. With GDB 7.2 it works properly.