简体   繁体   中英

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:

sudo startx app args 

I'm trying to debug the application and would like to use gdb. How do I start the application in 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:

$ 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.

What you probably want is to start the application normally, then attach GDB to it:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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