Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 306552 - DSF Debugger "disconnect" button is inactive for non-attach sessions even if "detach" command is supported by GDB
Summary: DSF Debugger "disconnect" button is inactive for non-attach sessions even if ...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 13:06 EDT by cyberflex CLA
Modified: 2011-05-04 15:23 EDT (History)
2 users (show)

See Also:


Attachments
Potential fix (1.60 KB, patch)
2011-05-04 11:02 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cyberflex CLA 2010-03-19 13:06:26 EDT
Build Identifier: Build id: M20090917-0800

Version: 3.5.1 Build id: M20090917-0800


DSF Debugger "disconnect" button is inactive for none "attach-type" sessions even if "detach" command is supported by GDB.
This button may be usefull even if GDB is not regarded to be attached, yet it can make the remote gdbserver detach from the process.



In case of DEBUGGER_MODE_RUN "connect" and "disconnect" buttons are active,
this is for example when debugging local C/C++ application in DSF.
If DEBUGGER_MODE_REMOTE is used these buttons are inactive.

If for example DEBUGGER_MODE_REMOTE_ATTACH is used then "connect" and "disconnect" buttons are also active but "step-in","step-over"... are not
active till user pressed  "connect" and entered the process id.
But if gdbserver is already running and already connected to the process
then it also won't work



Reproducible: Always

Steps to Reproduce:
1.Run DSF GDB launch delegate (in custom plug-in for example) DEBUGGER_MODE_REMOTE
2. run gdbserver and make it start the process
3. setup claunch configuration for DSF launcher so that it connects to the gdbserver
Comment 1 cyberflex CLA 2010-03-19 13:08:44 EDT
org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate creates session basing on
the sessionType

        private void launchDebugSession( final ILaunchConfiguration config,
ILaunch l,
IProgressMonitor monitor ) throws CoreException {
                if ( monitor.isCanceled() ) {
                        return;
                }

                SessionType sessionType = LaunchUtils.getSessionType(config);
                boolean attach = LaunchUtils.getIsAttach(config);
                ...


org.eclipse.cdt.dsf.gdb.launching.LaunchUtils function getSessionType
returns if session "is attach" or not basing on this:

        public static boolean getIsAttach(ILaunchConfiguration config) {
                boolean ret = false;
                String debugMode = null;
        try {
                debugMode = config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
                if
(debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
                        ret = false;
                } else if
(debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
                        ret = true;
                } else if
(debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
                        ret = false;
                } else if
(debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
                        ret = false;
                        //ret =
true;System.out.println("org.eclipse.cdt.dfs.gdb.LaunchUtils.getIsAttach():
forcing ret="+ret);
                } else if
(debugMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE_ATTACH))
{
                    ret = true;
            }
        } catch (CoreException e) {   

        }
        (new Exception("org.eclipse.cdt.dfs.gdb.LaunchUtils.getIsAttach():
debugMode="+debugMode+" ret="+ret)).printStackTrace();
        return ret;
    }



org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getSessionType() is used in:

[1]org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launchDebugSession()

[2]org.eclipse.cdt.dsf.gdb.service.GDBBackend.getIsAttachSession()

Basing on return value of  [2]  commands/buttons org.eclipse.cdt.dsf.gdb and
org.eclipse.cdt.dsf.gdb.service are determining their enable/disable state.
So that if session is "attach-type" then at the very beginning only "connect"
and "disconnect" buttons are active (all other "step-in","step-over" buttons
are
inactive) and user have to use "connect" button and specify the number of
process to attach. And if our remote gdbserver is already attached to process
we
can do nothing with it.
If session is NOT "attach-type", then
"connect" and "disconnect" buttons are always inactive.
Comment 2 cyberflex CLA 2010-03-19 13:12:00 EDT
This feature may be enhancement ...
Comment 3 Marc Khouzam CLA 2011-05-04 11:02:49 EDT
Created attachment 194723 [details]
Potential fix

I think this patch would fix things.

I will need to do more testing though.
Comment 4 Marc Khouzam CLA 2011-05-04 15:12:42 EDT
GDB accepts the 'detach' command in every scenario that we use, even in post-mortem debugging.  Although it is a little weird to disconnect when in post-mortem mode, I left it since GDB supports it and people may find a use for it.

Committed to HEAD.

(In reply to comment #0)
> If for example DEBUGGER_MODE_REMOTE_ATTACH is used then "connect" and
> "disconnect" buttons are also active but "step-in","step-over"... are not
> active till user pressed  "connect" and entered the process id.
> But if gdbserver is already running and already connected to the process
> then it also won't work

It is not clear to me if this is another problem or not.
The fix that I did was mostly based on the title of the bug which states that the 'disconnect' button is not enabled when it should be.
Comment 5 CDT Genie CLA 2011-05-04 15:23:03 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 306552: DSF Debugger "disconnect" button is inactive for non-attach sessions even if "detach" command is supported by GDB.

[*] GDBProcesses.java 1.25 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.24&r2=1.25
[*] GDBProcesses_7_0.java 1.51 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.50&r2=1.51