Debug posix build in Qt?

Is it possible to debug a posix_sitl build in Qt?

I get the following error when attempting debug:

Debugging starts
the debug information found in “/lib64/ld-2.23.so” does not match “/lib64/ld-linux-x86-64.so.2” (CRC mismatch).
ERROR [Unknown] Error expected 1 or 2 position arguments, got 0
./px4 [-d] [data_directory] startup_config [-h]
-d - Optional flag to run the app in daemon mode and does not listen for user input.
This is needed if px4 is intended to be run as a upstart job on linux
<data_directory> - directory where ROMFS and posix-configs are located (if not given, CWD is used)
<startup_config> - config file for starting/stopping px4 modules
-h - help/usage information
Restoring terminal
Debugging has finished

Yes definitely, it’s just a bit convoluted to start because there are quite a few options for specifying the model and simulation.

The easiest way is to launch it externally (run make posix_sitl_default gazebo_plane), and then use Qtcreator, or whichever debugger you prefer to attach to the px4 process. You’ll see it then builds gazebo for you, and launches both gazebo and px4 via the ./Tools/sitl_run.sh script.

We should find a better way to make it trivial to launch this under a debugger from an IDE.

Thanks Daniel.
It would be great to have debugger from the IDE so breakpoints can be placed in initialization.

This doesn’t work for me on latest upstream/master:
make posix_sitl_default gazebo_plane

Has error output:

[  6%] Performing configure step for 'sitl_gazebo'
-- install-prefix: /usr
CMake Error at CMakeLists.txt:26 (find_package):
  By not providing "Findgazebo.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "gazebo", but
  CMake did not find one.

  Could not find a package configuration file provided by "gazebo" with any
  of the following names:

    gazeboConfig.cmake
    gazebo-config.cmake

  Add the installation prefix of "gazebo" to CMAKE_PREFIX_PATH or set
  "gazebo_DIR" to a directory containing one of the above files.  If "gazebo"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/matt/src/Firmware_original/build_posix_sitl_default/build_gazebo/CMakeFiles/CMakeOutput.log".
src/firmware/posix/CMakeFiles/sitl_gazebo.dir/build.make:107: recipe for target 'external/Stamp/sitl_gazebo/sitl_gazebo-configure' failed
make[4]: *** [external/Stamp/sitl_gazebo/sitl_gazebo-configure] Error 1
CMakeFiles/Makefile2:8711: recipe for target 'src/firmware/posix/CMakeFiles/sitl_gazebo.dir/all' failed
make[3]: *** [src/firmware/posix/CMakeFiles/sitl_gazebo.dir/all] Error 2
make[3]: *** Waiting for unfinished jobs....
[ 25%] Built target msg_gen
CMakeFiles/Makefile2:13581: recipe for target 'src/firmware/posix/CMakeFiles/gazebo_plane.dir/rule' failed
make[2]: *** [src/firmware/posix/CMakeFiles/gazebo_plane.dir/rule] Error 2
Makefile:4680: recipe for target 'gazebo_plane' failed
make[1]: *** [gazebo_plane] Error 2
Makefile:139: recipe for target 'posix_sitl_default' failed
make: *** [posix_sitl_default] Error 2

Daniel,
Please can you help me get Qt attached to the right process. If I try attaching to any of the processes when running:

make posix_sitl_default jmavsim

it returns with:

ptrace: Operation not permitted.

Could not attach to the process. Make sure no other debugger traces this process.
If your uid matches the uid
of the target process, check the settings of
/proc/sys/kernel/yama/ptrace_scope
For more details, see /etc/sysctl.d/10-ptrace.conf

I tried attaching to unstarted by watching the PX4 executable but that does the same thing

It’s a default security setting, but easy to change - http://askubuntu.com/a/41656

If you want to use the gazebo simulation it’s just the default gazebo install instructions - http://gazebosim.org/tutorials?tut=install_ubuntu&ver=7.0&cat=install
You’ll need to have gazebo7 and libgazebo7-dev installed.

@dagar
Maybe one step closer…
make posix_sitl_default jmavsim___gdb

which gets the same error as before:
warning: the debug information found in "/lib64/ld-2.23.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).

I don’t know the gdb port number. Tried the default tcp of 2159 which didn’t work.

Thanks again for the hints. I am slowly following the cookie trail of error messages but have no idea if I am on the right path.

The linked instruction installed gazebo v8.0. I get all sorts of errors buildign the gazebo plugin. Will look for a way to get to V7.0

I got around that gdb security problem by editing the .gdbinit with:
add-auto-load-safe-path /home/user/src/Firmware_dev/build_posix_sitl_default/tmp/.gdbinit

@dagar I am on Ubuntu 16.04 xenial so gazebo 7 doesn’t install.

Matthew.I have exactly the same problem in Qt,have you solved it now?

I solved it by not hardware debugging. This is not as awful as it sounds. Solution is to print debug messages to terminal. This doesn’t work for some modules so you have to get creative about how you do it.
Good luck
/Matt