Skip to content

target extended-remote with restart support #183

Open
@DeadRabbits307

Description

@DeadRabbits307

Setup:
gdbserver version: 7.11.1 ("gdbserver was configured as "aarch64-buildroot-linux-uclibc"")
aarch64-linux-gdb version: 7.11.1
VS Code version: 1.34.0
native debug version: 0.23.1

On the target (embedded Linux OS build with buildroot) I start gdbserver as following:
$ gdbserver --multi :2345

My launch.json:

{   
            "type": "gdb",
            "request": "attach",
            "name": "myprogdebug via gdbserver",
            "executable": "./myprog",
            "target": "extended-remote xx.xx.xx.xx:2345",
            "remote": false,
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText",
            "gdbpath": "aarch64-linux-gdb",
            "env": {
                "PATH": "/path/to/cross-compiler:${env:PATH}"
             },
            "printCalls": true,
            "autorun": ["b 27", "set remote exec-file myprog", "run"]
}

With this launch.json debugging with VS code is possible, but without the "restart" and "stop" functionality.
Activating a "Start Debugging" following outputs are produced:

target:

Listening on port 2345
Remote debugging from host xx.xx.xx.207
Process myprog created; pid = 1654
Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on port 2345

host:

1-gdb-set target-async on
2-environment-directory "/home/xy/xy/"
3-target-select extended-remote xx.xx.xx.227:2345
4-file-symbol-file "/some/path/myprog"
5-break-delete
6-interpreter-exec console "b 27"
7-interpreter-exec console "set remote exec-file myprog"
8-interpreter-exec console "run"
9-break-insert -f "/some/path/myprog.c:25"
Breakpoint 1 at 0x400960: file myprog.c, line 27.
Starting program:  
Reading /root/mountp_tmp/myprog from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /root/mountp_tmp/myprog from remote target...
Load new symbol table from "target:/root/mountp_tmp/myprog"? (y or n) [answered Y; input not from terminal]
Reading symbols from target:/root/mountp_tmp/myprog...
done.
thread.c:982: internal-error: is_thread_state: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? 
(y or n) [answered Y; input not from terminal]

This is a bug, please report it.
  For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.

Without the "run" autorun-option, following host output is printed:

1-gdb-set target-async on
2-environment-directory "/home/xy/xy/"
3-target-select extended-remote xx.xx.xx.xx:2345
4-file-symbol-file "/some/path/myprog"
5-break-delete
6-interpreter-exec console "b 27"
7-interpreter-exec console "set remote exec-file myprog"
Breakpoint 1 at 0x400960: file myprog.c, line 27.
8-break-insert -f "/some/path/myprog.c:25"
9-exec-continue
-target-detach
10-thread-info
The program is not being run.

On the other hand, running gdb in the terminal (without VS code/native debug) using gdb's command r/restart everything works fine:

target:

$ gdbserver --multi :2345 my_prog
Listening on port 2345
Remote debugging from host xx.xx.xx.207
Process myprog created; pid = 1658
usage: myprog <poll-device>
Process myprog created; pid = 1659

host:

$ aarch64-linux-gdb -q ./my_prog
Reading symbols from ./myprog...done.
(gdb) target extended-remote xx.xx.xx.227:2345
Remote debugging using xx.xx.xx.227:2345
(gdb) set remote exec-file myprog
(gdb) b 25
Breakpoint 1 at 0x400928: file myprog.c, line 25.
(gdb) c
The program is not being run.
(gdb) r
Starting program: /some/path/myprog 
Reading /lib/ld-uClibc.so.0 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-uClibc.so.0 from remote target...
Reading /lib//libc.so.0 from remote target...

Breakpoint 1, main (argc=1, argv=0x7ffffffc68) at myprog.c:25
25          if (argc < 2) {
(gdb) n
26              fprintf(stderr, "usage: %s <poll-device>\n", argv[0]);
(gdb) n
27              exit(EXIT_FAILURE);
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /some/path/myprog 
Reading /lib/ld-uClibc.so.0 from remote target...
Reading /lib/ld-uClibc.so.0 from remote target...
Reading /lib//libc.so.0 from remote target...

Breakpoint 1, main (argc=1, argv=0x7ffffffc68) at myprog.c:25
25          if (argc < 2) {
(gdb) 

Therefore: Do I have a wrong launch.json file or are modifications to native debug necessary?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions