Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
wiki1874: DebuggerFAQ (Version 10)

Qnx Momentics IDE Debugger FAQ#

Q: Why debugger does not stop on breakpoints in my shared library code (or does not "step in" in the function from library)?#

Usually because gdb cannot load symbols for this library. To check this open Modules view and if you see your library there without a bug icon - symbols are not loaded

Q: Why debugger would not load symbols for my shared library?#

First, it needs to find this library in your shared library path on a host side. You usually have to explicitly specify this in the Shared Libraries tab in the Debug tab of the launch configuration. Second, library file name must be the same as soname with "lib" prefix. You can check soname if you open Properties view on library (.so file) or open it in Binary editor. If you have soname as aaa.so.1 and library called libaaa.so gdb cannot match it (because of extra version number). To avoid this problem for debugging purposes do not use so version number when you generate so name for your library. Third, the library has to be compiled with debug information.

Q: I tried to launch debug session from IDE and I get an error "Target is not responding (time out)". Why I cannot debug?#

Most likely when you created an image for the target board you did not include pdebug program in /usr/bin. This binary is required to be on target for remote debugging. Also make sure qconn process has permissions to run it.

Q: If IDE does not provide some of functionality that gdb has, can I use gdb command line console?#

Yes, gdb console is provided and will redirect user input to gdb command interpreter during debugging session. To access console open Console view from Windows->Show View... and click on "gdb target" of current debugging session in Debug view. Or click on Display Selected Console button (looks like a blue monitor) on a Console view and pick gdb console from the drop down list. When just type command in console, like show version. Example of such functionality would be setting address breakpoints and catchpoints.

Q: How can I attach debugger to a running process?#

First you need to create launch configuration, select Run->Debug..., then select Attach to Process and click New button (top left). Fill configuration with project and binary, select target and press Debug. It will prompt you to pick a process running on selected target, pick a process and click Ok. Debug session will be created, now you can use regular debugger commands: resume, suspend, step, etc... You can re-use same launch configuration for future runs, just re-select process id (of cause binary has to match too).

Q: Why debugger shows different value for my variable than printed on console???#

Most likely you trying to debug optimized code. This variable is been optimized as register and actual memory region never changes. To fix this use option -O0 for gcc compiler.

Q: Why console output of my program does not match when I step through the code with debugger#

Console is buffered. If you using stderr or stdout and you want to see your output immediately you have to add "\n" or flush the output. Input is always buffered, you have to press enter from console for application to get any of the data, even if you are reading one byte.

Q: Why my program output looks different when I am debugging vs running on windows?#

When you debug on windows IDE cannot allocate another console for your program output, so it gets mixed in with debugger data, and since it using specific debugger protocol, some lines of your program output can be parser as debugger command and won't be printed back. You can mitigate this by enabling verbose console for gdb in Debug tab of launch configuration.

Q: How to debug child process after fork?#

By default, when a program forks, GDB will continue to debug the parent process and the child process will run unimpeded.

If you want to follow the child process instead of the parent process, use the command set follow-fork-mode child from gdb console .

If you want to follow both you can use the following workaround: put a call to sleep (of send SIGSTOP to itself) in the code which the child process executes after the fork. It may be useful to sleep only if a certain environment variable is set, or a certain file exists, so that the delay need not occur when you don't want to run GDB on the child. While the child is sleeping, launch another debugger session that attaches to a running process a pick a child process from the list.

Q: Why debugger shows garbage in backtrace or stepping does not seems to match with my source code?#

When using remote debugging it is often happens that binary and libraries on the host side does not match with libraries and binary on the target side. GDB > 6.7 would print a warning on console if it thinks that some libraries do not match. If you don't use IDE to upload your binaries and libraries on every lunch you have to take care yourself about keeping them in sink. You can check what exact files gdb is using on the host side by exploring your libraries in the Modules view,

Q: I am trying to debug simple program and it SIGSEGV before entering main, it runs fine without debugger. What can I do?#

This is usual symptom of library host/target mismatch. For example when you running Momentics 6.3.2 on target and 6.4.0 on host side. If you using gdb 6.7 (which is btw available from foundry independent from Momenitcs) it will print a warning about library mismatch on a console. Also can happened if you applied libc patch on host and not on target or visa versa.

In rare cases C++ program can crash before entering main in static initializers of your own code or library code. In this case you can actually use debugger stack trace to examine the problem.