[英]Change the working directory when debug in emacs gdb?
As I open emacs and enter :当我打开 emacs 并输入:
M+x gdb
M+x 数据库
Run gdb (like this): gdb im=mi /home/qinchen/major/caffe/caffe_gdb/build/tools/caffe
运行gdb(像这样):gdb im=mi /home/qinchen/major/caffe/caffe_gdb/build/tools/caffe
And then input:然后输入:
run train --solver=examples/mnist/lenet_solver.prototxt
运行 train --solver=examples/mnist/lenet_solver.prototxt
But it reports : i但它报告:我
o.cpp Check failed: fd!=-1.
o.cpp 检查失败:fd!=-1。 file not found:examples/mnist/lenet_solver.prototxt
文件未找到:examples/mnist/lenet_solver.prototxt
I guess if the error is triggered by emacs' current working directory is not in CAFFE_ROOT.我想如果错误是由 emacs 的当前工作目录触发的,则不在 CAFFE_ROOT 中。 Since as I debug in linux terminal in CAFFE_ROOT directory with
由于我在 CAFFE_ROOT 目录中的 linux 终端中调试
gdb --args build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
gdb --args build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
I can successfully debug this demo.So can anyone help me to set emacs working directory to CAFFE_ROOT when debug in gdb to eliminate the error reported above?我可以成功调试这个demo。那么有没有人能帮我在gdb中调试时将emacs工作目录设置为CAFFE_ROOT以消除上面报告的错误?
simple:简单:
M+x gdb
gdb -i=mi -cd /home/qinchen/major/caffe/caffe_gdb --args build/tools/caffe train --solver=examples/mnist/lenet_solver.prototx
I personally find it pretty annoying copying and pasting the absolute path to my executable so I normally just run it this way:我个人觉得将绝对路径复制并粘贴到我的可执行文件非常烦人,所以我通常只是这样运行它:
M+x
then gdb
and run with the default command: gdb -i=mi
M+x
然后gdb
并使用默认命令运行: gdb -i=mi
Better yet, if you use Projectile, you can do projectile-run-gdb
(or Cc pxg
) to run gdb with the project root as the CWD.更好的是,如果您使用 Projectile,您可以执行
projectile-run-gdb
(或Cc pxg
)以项目根目录作为 CWD 运行 gdb。 This way you can just pass: gdb -i=mi build/tools/caffe
.这样你就可以通过:
gdb -i=mi build/tools/caffe
。 This is pretty handy for me since my build
directory is normally in my project root.这对我来说非常方便,因为我的
build
目录通常在我的项目根目录中。
If you don't use projectile, when in the gdb interface, doing pwd
tells you where you are.如果你不使用projectile,在gdb界面的时候,做
pwd
告诉你你在哪里。 I just usually have to cd
once or twice to get to the working directory I'd like to be in. Then just doing file build/tools/caffe
opens the file for debugging and you're ready to go.我通常只需要
cd
一两次才能进入我想要进入的工作目录。然后只需执行file build/tools/caffe
打开文件进行调试,您就可以开始了。
Pasting or editing paths/args into the mini-buffer can be infuriating for me.将路径/参数粘贴或编辑到迷你缓冲区中可能让我很恼火。 This way I just run it, change a directory or two, and work with a relative path as I would in the console.
这样我只需运行它,更改一两个目录,然后像在控制台中一样使用相对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.