如何在CLION中自动为GDB加载漂亮的打印机

发布于 2025-02-07 20:45:20 字数 278 浏览 0 评论 0原文

我为用户定义的C ++类编写了一些GDB漂亮打印机,它们可以按预期工作。

我的IDE是CLION,问题是我必须在第一个调试会话中从GDB内手动运行“ source predtyprinters.py”。

如何使Clion自动加载这些文件?

我知道有一个名为.gdbinit的文件。我试图将我的python脚本放在这个文件中。我还试图将“ source prettyprinters.py”放在此文件中,但是这些尝试都没有成功。

请注意,我使用的是捆绑的GDB版本,该版本带有Clion。

I have written some GDB pretty-printers for my user-defined c++ classes, and they work as expected.

My IDE is CLion, and the problem is I have to manually run 'source PrettyPrinters.py' from within gdb at the first debugging session.

How can I make CLion load these files automatically?

I understand there is a file called .gdbinit. I have tried to put my python script in this file. I have also tried to put 'source PrettyPrinters.py' in this file, but none of these attempts have been successful.

Note, I am using the bundled version of GDB, that comes with CLion.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国粹 2025-02-14 20:45:20

要回答我自己的问题:

  1. 在Clion项目的根目录中添加一个“ .gdbinit”文件。
  2. 将包含漂亮打印机定义的Python脚本放入适当的目录中。 (我使用了此路径和文件名:'Project-root/gdb-pretty-rinters/prettyprinters.py')
  3. 添加命令'源project-root/gdb-pretty-printers/prettyprinters.py.py' (1)。

打开文件'〜/.config/gdb/gdbinit',或创建它,如果尚不存在。将命令的“ add-auto-load-saf-path project-root/.gdbinit”添加到此文件中。

现在,GDB应该在下一次调试会话时自动加载漂亮的打印机(您无需重新启动CLION)。

To answer my own question:

  1. Add a '.gdbinit'-file to the root directory of the clion project.
  2. Place the python script containing the pretty-printers definition in an appropriate directory. (I used this path and filename: 'project-root/gdb-pretty-printers/PrettyPrinters.py')
  3. Add the command 'source project-root/gdb-pretty-printers/PrettyPrinters.py' to the .gdbinit file mentioned in (1).

Open the file '~/.config/gdb/gdbinit', or create it, if it does not already exist. Add the command 'add-auto-load-safe-path project-root/.gdbinit' to this file.

GDB should now load the pretty-printers automatically upon next debugging session (you do not need to restart clion).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文