Home » Language IDEs » C / C++ IDE (CDT) » Debugging ncurses application in Eclipse CDT (Linux)
| | | | |
Re: Debugging ncurses application in Eclipse CDT (Linux) [message #1821753 is a reply to message #1821257] |
Wed, 19 February 2020 09:55   |
Eclipse User |
|
|
|
Thanks for your message and apologies for the late reply. I'm still trying to solve the gdb issue, with some progress.
I'm able to run my application with gdb directly - it responds to some basic commands, such as start, run, break and continue (i'm a complete beginner when it comes to command line gdb). However, the terminal window quickly becomes cluttered as both the ncurses app and gdb attempt to print to the terminal window.
As the next possible solution I tried to redirect the output of gdb to another terminal window using the tty command. That ended up printing both the gdb and the ncurses outputs to the second terminal, but the ncurses stopped responding to user input. This issue was raised in the forum post that you suggested:
https://stackoverflow.com/questions/11965328/debugging-ncurses-application-with-gdb
Finally, I tried to run the ncurses application separately from a terminal window and attach gdb to the running process, using gdb -p [pid]. Initially I ran into the same gdb error as seen in Eclipse, related to "ptrace operation not permitted". Apparently, this issue is caused by "Linux kernel hardening". The suggested solutions were to run the gdb command as root (and that's why I could attach the Eclipse debugger when running Eclipse as root), or to change the kernel.yama.ptrace_scope variable in /etc/sysctl.d/10-ptrace.conf from 1 to 0.
After changing the suggested variable, I'm able to attach gdb to the process, either from a terminal or from Eclipse. However, gdb behaves in an unexpected manner, printing the following output after attaching to the process:
[New LWP 23653]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f5c4c59e384 in __libc_read (fd=0, buf=0x7fff83008fdf, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:27
27 ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
I'm assuming it's becuase I'm using multithreading in my application, and debugging a multithreaded application in gdb is a bit more complicated:
https://www.cs.swarthmore.edu/~newhall/unixhelp/gdb_pthreads.php
I'm also not sure what the ../sysdeps/unix/sysv/linux/read.c: No such file or directory. error means.
When I type the continue command, the application works, and gdb prints out information related to stopping/starting threads (as I navigate through my application). I'm sure there's a way I can debug the application from the terminal (I haven't read through the tutorial yet).
(gdb) continue
Continuing.
[New Thread 0x7ff70e934700 (LWP 23784)]
[Thread 0x7ff70e934700 (LWP 23784) exited]
[New Thread 0x7ff70e934700 (LWP 23787)]
[Thread 0x7ff70e934700 (LWP 23787) exited]
[New Thread 0x7ff70e934700 (LWP 23788)]
[Thread 0x7ff70e934700 (LWP 23788) exited]
[New Thread 0x7ff70e934700 (LWP 23789)]
Unfortunately, Eclipse still behaves erratically after attaching to the process (unresponsive, flashing windows etc). Is there any way to configure Eclipse to support debugging the multithreaded ncurses application? I've previously been successful in debugging a multithreaded wxWidgets application in Eclipse. The debugger worked without any issues (however I didn't have to attach to a separate process then).
Many thanks,
Ksawery
[Updated on: Wed, 19 February 2020 10:09] by Moderator
|
|
| |
Goto Forum:
Current Time: Fri Jun 13 22:37:21 EDT 2025
Powered by FUDForum. Page generated in 0.04593 seconds
|