WSL2下不能使用gdb.attach的解决方案

发布时间 2023-08-05 11:30:55作者: lmarch2

安装tmux

用root权限安装

sudo apt-get install tmux

进入根目录

cd ~

编辑配置

使用root权限打开tmux,方便保存配置文件

sudo tmux

新建.tmux.conf文件

vim .tmux.conf

在文件中输入

#输入
bind-key c new-window -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"
bind-key '"' split-window -c "#{pane_current_path}"
set -g mouse on

关闭所有tmux窗口并输入

tmux source-file ~/.tmux.conf

重新启动tmux则完成更改、

使用

接下来可以在exp中下断点了 gdb.attach(p)

同时要在exp中加上指定terminal

context.terminal = ['tmux', 'splitw', '-h']

-h代表横向分屏

之后就可以在运行exp时debug

注意要在tmux终端下运行