仿真调试

    As the simulation is running on the host machine, all the desktop development tools are available.

    The Clang address sanitizer can help to find alignment (bus) errors and other memory faults like segmentation fauls. The command below sets the right compile options.

    shbrew install valgrind

    or

    shsudo apt-get install valgrind

    where the last parameter is the <viewer_model_debugger> triplet (using three underscores implies the default 'iris' model).This will start the debugger and launch the SITL application. In order to break into the debugger shell and halt the execution, hit CTRL-C:

    1. Process 16529 stopped* thread #1: tid = 0x114e6d, 0x00007fff90f4430a libsystem_kernel.dylib`__read_nocancel + 10, name = 'px4', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x00007fff90f4430a libsystem_kernel.dylib`__read_nocancel + 10libsystem_kernel.dylib`__read_nocancel:-> 0x7fff90f4430a <+10>: jae 0x7fff90f44314 ; <+20> 0x7fff90f4430c <+12>: movq %rax, %rdi 0x7fff90f4430f <+15>: jmp 0x7fff90f3fc53 ; cerror_nocancel 0x7fff90f44314 <+20>: retq(lldb)

    In order to not have the DriverFrameworks scheduling interfere with the debugging session should be masked in LLDB and GDB:

      Or in the case of GDB:

      After that the The lldb or gdb shells behave like normal sessions, please refer to the LLDB / GDB documentation.

      The last parameter, the <viewer_model_debugger> triplet, is actually passed to make in the build directory, so

      1. make posix_sitl_lpe jmavsim___gdb

      is equivalent with

      1. make posix_sitl_lpe # Configure with cmakemake -C build_posix_sitl_lpe jmavsim___gdb

      but for your convenience, a list with just the <viewer_model_debugger> tripletsis printed with the command

        It is possible to suppress compiler optimization for given executables and/ormodules (as added by cmake with or add_library) when configuringfor posix_sitl_*. This can be handy when it is necessary to step through codewith a debugger or print variables that would otherwise be optimized out.

        To do so, set the environment variable PX4_NO_OPTIMIZATION to be a semi-colonseparated list of regular expressions that match the targets that needto be compiled without optimization. This environment variable is ignoredwhen the configuration isn't posix_sitl_*.

        For example,

        would suppress optimization of the targets: platforms__posix__px4_layer, modules__systemlib, modules__uORB, examples__px4_simple_app, modules__uORB__uORB_tests and px4.

        The targets that can be matched with these regular expressions can beprinted with the command: