KDevelop调试警告:无法设置控制终端:不允许操作

发布于 2024-12-04 13:02:25 字数 233 浏览 0 评论 0 原文

前段时间我把个人操作系统换成了linux,开发环境换成了KDevelop。

然而,调试 C++ 项目仍然无法正常工作。 我的 KDevelop 版本是 4.2.2(我通过包管理安装了它)

每次我点击“调试按钮”时,应用程序都会以控制台消息启动 警告:GDB:无法设置控制终端:不允许操作并且调试功能不可用。

欢迎任何想法。

(如果您需要更多信息,请随时询问)

A while ago I changed my personal operating system to linux and my development enviroment to KDevelop.

However debugging c++ projects is still not working as it should.
My KDevelop version is 4.2.2 (I installed it through package management)

Every time I hit the "debug button" the application is starting with the console message
warning: GDB: Failed to set controlling terminal: Operation not permitted and debugging functionality is not available.

Any ideas welcome.

(If you need additional information don't hesitate to ask)

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

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

发布评论

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

评论(3

绻影浮沉 2024-12-11 13:02:25

我也遇到了这个问题,但我在 KDevelop 中很少使用 gdb,这还没有困扰我。这是我尝试修复它的日志:

Grepping 通过 GDB 7.3.1 源代码显示,当 GDB 尝试将其主 TTY 设置为新创建的伪 tty 时,会打印此消息(请参阅 gdb/inflow.c,第 683 行) -740)。特别是,使用请求 TIOCSCTTY 调用 ioctl 失败并出现权限错误。

考虑到这一点,我查看了 Linux 内核源代码,看看是什么导致了失败。一些搜索表明它最终会退化为对 tiocsctty() 的调用。 tiocsctty 的评论在这里很重要:

/*
 * The process must be a session leader and
 * not have a controlling tty already.
 */

由于 EPERM 失败的唯一原因是 GDB 创建的 tty 实际上是另一个进程的控制 tty(这似乎不太可能),我认为可以合理地假设 GDB 不是会话领导者。公平地说,它毕竟是 KDevelop 推出的!

所以:我尝试在外部终端中启动 GDB 会话,并且它有效。问题范围缩小了。

最初,外部终端行设置为 konsole --noclose --workdir %workdir -e %exe 。将其更改为 terminator -e %exe 会产生轻微的差异:KDevelop 警告我

GDB cannot use the tty* or pty* devices.
Check the settings on /dev/tty* and /dev/pty*
As root you may need to "chmod ug+rw" tty* and pty* devices and/or add the user to the tty group using "usermod -G tty username".

检查了我的权限;我的用户是 tty 组的一部分,所有相关文件都是可读可写的。

通过 Grep 浏览 KDevelop 源代码可以了解 KDevelop 实际如何设置终端。它运行 shell 脚本

tty > FIFO_PATH ; trap "" INT QUIT TSTP ; exec<&-; exec>&-; while :; do sleep 3600;done

,然后设置 GDB 以使用它从 FIFO_PATH 读取的终端设备。 (顺便说一句,我的名字不是 KDevelop 使用的名字。)问题(据我所知)是 gdb 不是作为 shell 脚本的子脚本启动的,因此不能将其用作其主 tty。

到目前为止,我还不想修补 KDevelop 以使其正常工作(或者首先找到实际上导致其停止工作的原因......),所以我目前能建议的最好的办法就是不要使用用于调试目的的外部终端。

祝你好运!如果我发现任何有用的东西,我会更新。

I also had this problem, but I use gdb in KDevelop sparsely enough that hadn't bothered me yet. Here's my log of trying to fix it:

Grepping through the GDB 7.3.1 source code reveals that this message is printed when GDB tries to set its master TTY to a newly-created pseudo-tty (see gdb/inflow.c, lines 683-740). In particular, a call to ioctl with request TIOCSCTTY fails with a permissions error.

With this in mind, I took a look at the Linux kernel source code to see what could cause a failure. A bit of searching shows that it will eventually degenerate into a call to tiocsctty(). The comment from tiocsctty that is important here:

/*
 * The process must be a session leader and
 * not have a controlling tty already.
 */

Since the only other reason it can fail with EPERM is if the tty that GDB creates is actually a controlling tty for another process (which seems highly unlikely), I thought it reasonable to assume that GDB is not a session leader. Fair enough, it's launched by KDevelop after all!

So: I tried not launching the GDB session in an external terminal, and it works. Problem narrowed down.

Originally, the external terminal line was set to konsole --noclose --workdir %workdir -e %exe. Changing this to terminator -e %exe made a slight difference: KDevelop warned me that

GDB cannot use the tty* or pty* devices.
Check the settings on /dev/tty* and /dev/pty*
As root you may need to "chmod ug+rw" tty* and pty* devices and/or add the user to the tty group using "usermod -G tty username".

I checked my permissions; my user was part of the tty group and all relevant files were readable and writable.

Grepping through the KDevelop source code reveals how KDevelop actually sets up the terminal. It runs the shell script

tty > FIFO_PATH ; trap "" INT QUIT TSTP ; exec<&-; exec>&-; while :; do sleep 3600;done

and then sets up GDB to use the terminal device it reads from FIFO_PATH. (My name, by the way, not the one that KDevelop uses.) The problem (as best I can tell) is that gdb is not launched as a child of the shell script, and thus cannot use it as its main tty.

I'm not feeling up to patching KDevelop to make this work properly as of yet (or finding what actually caused this to stop working in the first place . . .), so the best I can suggest at the moment is to simply not use an external terminal for debugging purposes.

Good luck! I'll update if I find anything useful.

◇流星雨 2024-12-11 13:02:25

正如 Arthur Zennig 所说,要了解更多信息,您需要做一些事情

  1. 首先,您需要创建终端配置文件

< img src="https://i.sstatic.net/9gPbM.jpg" alt="在此处输入图像描述">

  1. 其次,打开 Launch Configurations,填写如下图所示的信息

在此处输入图像描述

祝你好运!

As Arthur Zennig said, for more information, you need to do something

  1. Firstly, you need to create the Terminal profile

enter image description here

  1. Secondly, open Launch Configurations, fill info such as the image below

enter image description here

Good luck!

彻夜缠绵 2024-12-11 13:02:25

如果您遇到错误:

“无法接收 konsole tty/pty。检查 konsole 实际上是
终端并接受这些参数”

RUN > CONFIGURE LAUCHERS >(参见下图。我的项目名称是“loops”)
对我有用的是取消选中“使用外部终端”复选框。在“编译的二进制文件”选项卡中找到了。

运行 > 配置启动器

In case you got the error:

"Can't receive konsole tty/pty. Check that konsole is actually a
terminal and that it accepts these arguments"

RUN > CONFIGURE LAUCHERS > (See picture below. My project name was "loops")
What worked for me was to uncheck checkbox "Use External Terminal". Found the in the "Compiled Binaries" Tab.

RUN > Configure Laucher

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