使用 gdbserver 远程调试

使用 gdbserver 可以对目标设备上的程序进行远程调试。

安装 GDBSERVER

在 ICE-EVB 开发板上,通过下面命令来安装 GDBSEVER。

apt install gdbserver

gdbserver 用法

Usage:  gdbserver [OPTIONS] COMM PROG [ARGS ...]
        gdbserver [OPTIONS] --attach COMM PID
        gdbserver [OPTIONS] --multi COMM

COMM may either be a tty device (for serial debugging),
HOST:PORT to listen for a TCP connection, or '-' or 'stdio' to use
stdin/stdout of gdbserver.
PROG is the executable program.  ARGS are arguments passed to inferior.
PID is the process ID to attach to, when --attach is specified.

Operating modes:

  --attach              Attach to running process PID.
  --multi               Start server without a specific program, and
                        only quit when explicitly commanded.
  --once                Exit after the first connection has closed.
  --help                Print this message and then exit.
  --version             Display version information and exit.

第一步:在目标机上启动 gdbserver 服务

要进行gdb调试,首先要在目标系统上启动gdbserver服务。在gdbserver所在目录下输入命令:

gdbserver :12345 helloworld

此时gdbserver监听端口号1234,并等待客户端连接。

第二步:在宿主机上运行 GDB:

riscv64-linux-gnu-gdb helloworld

(gdb) target remote 192.168.1.4:12345

GDB 的调用的使用方法,可以参考: GDB调试入门

results matching ""

    No results matching ""