Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 535143

Summary: GDB Remote target Generic serial assumes 'target remote', cannot do 'target extended-remote'
Product: [Tools] CDT Reporter: Ian Shillingford <eons>
Component: cdt-debug-hardwareAssignee: John Dallaway <john>
Status: RESOLVED FIXED QA Contact: John Dallaway <john>
Severity: normal    
Priority: P3 CC: cdtdoug, john, jonah, torbjorn.svensson
Version: 9.4.3   
Target Milestone: 10.7.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/123392
https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192863
https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=90627bfa830f27f12646637bb30865d8a9f2ed13
https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192874
https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=38ff9d67eaca40b91a7a9631ba4a3311e7271de8
https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192882
https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e16e7ea5cb30f725027f71de641f61371688115c
Whiteboard:
Attachments:
Description Flags
extended remote screenshot
none
Target protocol selection screenshot none

Description Ian Shillingford CLA 2018-05-26 04:03:08 EDT
Trying to debug 1Bitsy with a BlackMagic probe (built-in GDB server via serial-over-USB) which requires connection with 'target extended-remote' command.
Eclipse Oxygen with CDT 9.4.3 assumes 'target remote' which fails with error message
"Error in final launch sequence
Failed to execute MI command:
-target-select remote com4

Error message from debugger back end:
The target is not running (try extended-remote?)
The target is not running (try extended-remote?)"

but there is no way to set extended-remote; anything in the text box is simply appended to 'target remote'.

I suggest either a tick-box for 'extended-remote' or perhaps a fall-through where if 'target remote' fails it tries 'target extended-remote'.
Comment 1 Eclipse Genie CLA 2018-05-26 16:59:12 EDT
New Gerrit change created: https://git.eclipse.org/r/123392
Comment 2 Jonah Graham CLA 2018-05-26 17:01:35 EDT
I don't know if we can get this in in time for 9.5 as we are already in the release candidate phase. If not it will be available in the nightly build for 9.6 soon (in a week or so, once 9.6 nightly builds start).
Comment 3 Jonah Graham CLA 2018-05-26 17:10:34 EDT
Created attachment 274215 [details]
extended remote screenshot

I have submitted a possible implementation.

There is some new API. So for the N&N into whichever version it goes:

Feature change:

extended-remote mode for GDB Hardware Debugging - When debugging with the GDB Hardware Debugging launch configuration users can now specify whether to use "extended-remote" mode when connecting to the target. <screenshot> See Bug 535143.

API change:

Extensions of the org.eclipse.cdt.debug.gdbjtag.core.JTagDevice extension point can now optionally implement the IGDBJtagConnection2 interface to provide commands to do a GDB extended-remote mode connection and control how the "Use extended-remote mode" checkbox is presented to the user in the Launch Configuration.
Comment 4 Jonah Graham CLA 2018-05-27 05:59:22 EDT
Too late for 9.5.
Comment 5 John Dallaway CLA 2018-05-27 12:40:54 EDT
Relates to bug 535163.
Comment 6 Jonah Graham CLA 2018-12-19 14:51:45 EST
I will revisit this bug in the coming week to make an appropriate update to target milestone.
Comment 7 Jonah Graham CLA 2019-12-30 17:05:44 EST
This bug was assigned and targeted at a now released milestone. As that milestone has now passed, the milestone field has been cleared. If this bug has been fixed, please set the milestone to the version it was fixed in and marked the bug as resolved.
Comment 8 John Dallaway CLA 2022-04-19 12:39:42 EDT
Jonah and all, looking at this with fresh eyes. I think it might be preferable to generalize for any remote connection type (protocol). That way, an extender could support exotic/legacy protocols such as "rdi", "kvm", something in-house, or some future mainline GDB protocol.

We could add a new method to the existing IGDBJtagConnection interface:

  default void doTarget(String protocol, String connection, Collection<String> commands) {
    if ("remote".equals(protocol)) {
      doRemote(connection, commands);
    } // else not supported
  }

The DefaultGDBJtagConnectionImpl.doTarget() implementation would support any protocol. Some of the existing "JTAG device" implementations would support both "remote" and "extended-remote" protocols.

The UI would allow selection of the protocol from a drop-down list. The content of that list would be updated on "JTAG device" selection change. The default protocol would be be the zeroth item in the protocol list.

We could describe the ordered list of supported protocols in XML by extending the JtagDevice schema in a compatible manner (default to "remote" only if not specified):

  <device protocols="remote,extended-remote" ... >

This seems a bit more elegant than using another new IGDBJtagConnection interface method:

  default Collection<String> getProtocols() {
    return List.of("remote");
  }

because the list of supported protocols has some affinity with the default connection string that is also provided by XML.

In the case of the BlackMagic probe, only the "extended-remote" protocol would be listed in the JtagDevice XML and so the correct protocol would be selected when the BlackMagic probe is selected.

Comments?
Comment 9 Jonah Graham CLA 2022-04-19 12:57:00 EDT
(In reply to John Dallaway from comment #8)
> Comments?

@John - your idea seems sounds.
Comment 10 Torbjörn Svensson CLA 2022-04-19 13:02:29 EDT
(In reply to Jonah Graham from comment #9)
> (In reply to John Dallaway from comment #8)
> > Comments?
> 
> @John - your idea seems sounds.

@John, I 2nd what Jonah wrote.
Comment 11 John Dallaway CLA 2022-04-21 03:50:31 EDT
Created attachment 288463 [details]
Target protocol selection screenshot
Comment 12 Eclipse Genie CLA 2022-04-21 17:32:20 EDT
New Gerrit change created: https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192863
Comment 14 Eclipse Genie CLA 2022-04-22 11:44:53 EDT
New Gerrit change created: https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192874
Comment 16 Eclipse Genie CLA 2022-04-24 12:46:21 EDT
New Gerrit change created: https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/192882
Comment 18 Jonah Graham CLA 2022-05-02 09:33:10 EDT
Thanks John! On behalf of the hardware debug community I am grateful for your ongoing maintenance of this part of the code base!