Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support gdb extended remote connection for launch? #363

Open
8 tasks
fbs2016 opened this issue Jun 22, 2022 · 6 comments
Open
8 tasks

Does it support gdb extended remote connection for launch? #363

fbs2016 opened this issue Jun 22, 2022 · 6 comments
Labels
more info needed Waiting for author to provide more information

Comments

@fbs2016
Copy link

fbs2016 commented Jun 22, 2022

If submitting a bug please make sure

  • If you are using gdb
    • gdb --version >= 7.7.1
    • it works on the command line with gdb
    • cwd and target are properly set
  • If you are using lldb
    • lldb --version >= 3.7.1
    • it works on the command line with lldb-mi
    • cwd and target are properly set

Screenshots are helpful but not required

Does it support gdb extended remote connection for launch/attach? Thanks, I try to debug applicaiton with "gdbserver --multi", but it can't work.

@GitMensch
Copy link
Collaborator

Yes, that's supported, see #330 for the issue that currently documents how this is done (feel free to send a PR to add this to the README) and about how it likely will be adjusted.

@fbs2016
Copy link
Author

fbs2016 commented Jun 27, 2022

@GitMensch Thanks a lot. I try it between 2 linux host, it works well.
And I try to debug our embedded os from my linux host, it can't work.

    {
        "type": "gdb",
        "request": "attach",
        "name": "Attach to gdbserver",
        "executable": "myexe",
        "target": "extended-remote 127.0.0.1:37303",
        "showDevDebugOutput": true,
        "remote": false,
        "cwd": "${workspaceRoot}",
        "gdbpath": "gdb",
        "autorun": [
            "b 11",
	"attach 2"
	],
        "printCalls": true,
    },

The log in debug console:

6-interpreter-exec console "b 11"
7-interpreter-exec console "attach 2"
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Breakpoint 1 at 0x2005b0: file myexe, line 11.\n"}]}
Breakpoint 1 at 0x2005b0: file myexe, line 11.
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-created","output":[["bkpt",[["number","1"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x00000000002005b0"],["func","main"],["file","myexe"],["fullname","myexe"],["line","11"],["thread-groups",["i1"]],["times","0"],["original-location","myexe:11"]]]]}]}
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Attaching to process 2\n"}]}
Attaching to process 2
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"Attaching to process 2 failed\n"}]}
Attaching to process 2 failed
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Attaching to process 2 failed"]]}}

@brownts
Copy link
Collaborator

brownts commented Jun 27, 2022

Hi @fbs2016:

Can you also post the logs and configuration from the scenario that did work? Also, I'm curious about your configuration. You mentioned your host is running Linux and you're attempting to debug your embedded OS. I assume your embedded OS is running on a different machine. With that expectation, I'd think that your IP address wouldn't be the loopback IP for the Linux host, but maybe I don't fully understand your configuration.

The response "Attaching to process 2 failed" is coming from GDB. Are you able to perform the same functionality from the GDB command line? If so, could you post the set of commands you use from the command line to accomplish this? That might help us understand if commands are being sent in different orders or something else that might be different between the command line and this extension.

If it's possible, can you post the complete logs for both setups?

@brownts brownts added the more info needed Waiting for author to provide more information label Jan 1, 2023
@fbs2016
Copy link
Author

fbs2016 commented Jan 11, 2023

@brownts
Thanks.
I try my embedded os on QEMU, so the the ip is localhost. The attach can work well if I define the command in "autorun".
And the launch can't work for remote debug I can't configure the remote address of launch, I see that the launch just support local debug, right?

I can launch the exe from customized gdb cmd in "autorun" of attach configuration, but I can't kill the process as attach just support disconnect.

@fbs2016
Copy link
Author

fbs2016 commented Jan 11, 2023

#195

@fbs2016 fbs2016 changed the title Does it support gdb extended remote connection for launch/attach? Does it support gdb extended remote connection for launch? Jan 11, 2023
@brownts
Copy link
Collaborator

brownts commented Jan 15, 2023

This extension doesn't support a "launch" configuration for the extended-remote, at least not at this time, however I'm pretty sure you can get what you want using the "attach" configuration.

I'm still a bit unclear on exactly how you are using this. Are you specifying the application to load on the command line as an option to gdbserver or are you expecting to load the file via the extension? I assume you want to specify the application to load in the extension configuration. If so, you can do this by specifying it in the autorun list and disabling the default "continue" behavior (i.e., by setting stopAtConnect to true) and adding in the "run" command:

stopAtConnect: true,
autorun: [
   "set remote exec-file /path/to/filename",
   "run"
]

You also mentioned that the default "disconnect" doesn't kill the process. Is it possible that using the --once option with your gdbserver command would address this? Again, it's not clear exactly what your debugging workflow looks like, so I'm not sure if this meets your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Waiting for author to provide more information
Projects
None yet
Development

No branches or pull requests

3 participants