简体   繁体   English

使用gdb调试使用startx启动的应用程序

[英]using gdb to debug application started using startx

I have an application with a GUI which I run on the command line, directly in the X server, without using a windows manager: 我有一个带有GUI的应用程序,它直接在X服务器中在命令行上运行,而无需使用Windows管理器:

sudo startx app args 

I'm trying to debug the application and would like to use gdb. 我正在尝试调试应用程序,并想使用gdb。 How do I start the application in gdb? 如何在gdb中启动应用程序? I've tried this but it doesn't work: 我已经尝试过了,但是没有用:

sudo gdb --args startx app args 

I've tried this but it doesn't work 我已经尝试过了,但是没有用

It doesn't work because startx is a shell script: 它不起作用,因为startx是一个Shell脚本:

$ file /usr/bin/startx
/usr/bin/startx: POSIX shell script, ASCII text executable

You almost certainly don't want to debug a shell script with GDB. 几乎可以肯定,您不想使用GDB调试Shell脚本。

What you probably want is to start the application normally, then attach GDB to it: 您可能想要的是正常启动应用程序,然后 GDB 附加到该应用程序:

sudo startx app args
sudo gdb -p $(pgrep app)

Note also that debugging applications from the same display on which the application runs is ill-advised: if you set a breakpoint in a context where the application has grabbed the X server, then all your keystrokes will go to the application, and there would be no way to continue the application. 还请注意,从运行应用程序的同一显示器调试应用程序是不明智的:如果在应用程序已捕获 X服务器的环境中设置断点,则所有击键都将进入该应用程序,并且无法继续申请。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM