Gdbserver(1)

来源:互联网 发布:光纤网络发射器 编辑:程序博客网 时间:2024/06/05 10:42

Gdbserver

 

 gdb之间的通信可以是串口,也可以是tcp连接。 在目标设备上运行的程序可以使strip过的,因为符号分析在gdb这端。

 启动方式

如果是串口方式

Gdbserver /dev/com1 emacs foo.txt

如果是tcp的方式

命令的输入格式为

Gdbserver host:port emacs foo.txt

注意 host gdbipportlocal port

使用—attach 来指明程序附加

gdbserver原理

 

gdb事件

struct gdb_event

  {

    /* Procedure to call to service this event.  */

    event_handler_func *proc;

 

    /* File descriptor that is ready.  */

    int fd;

 

    /* Next in list of events or NULL.  */

    struct gdb_event *next_event;

  };

就一个文件描述符和一个事件处理函数及一个指向下一个gdb_event的指针。

 

static struct

  {

    /* The first pending event.  */

    gdb_event *first_event;

 

    /* The last pending event.  */

    gdb_event *last_event;

  }

event_queue;

process_event 处理事件,也就是从event_queue中去取出事件,先从链表中移除,然后再调用相应的处理函数,如果处理成功返回1,失败返回-1,如果链表为空,则返回0

将相应的gdb_event处理完后,然后处理回调事件

最后使用select 模型来监听所有的文件描述符

原创粉丝点击