Vscode lldb debugging "PAUSED ON EXCEPTION"

I’m attempting to debug 1.9.2 in vscode using jmavsim (or gazebo) in OS X Catalina. I’m using the default targets and am getting an issue where it never seems to fully start the px4 process. Specifically, I see “PAUSED ON EXCEPTION” in the call stack and no matter how many times I continue the debug session it keeps stopping. I’ve also tried running the lldb session manually and get:

Process 2603 launched: 'firmware/build/px4_sitl_default/bin/px4' (x86_64)
INFO  [px4] Creating symlink firmware/ROMFS/px4fmu_common -> firmware/build/px4_sitl_default/tmp/rootfs/etc

______  __   __    ___
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to connect on TCP port 4560
INFO  [simulator] Simulator connected on TCP port 4560.
Init MAVLink
Process 2603 stopped
* thread #2, name = 'hpwork', stop reason = signal SIGCONT
    frame #0: 0x00007fff721a18f6 libsystem_kernel.dylib`__psynch_cvwait + 10
libsystem_kernel.dylib`__psynch_cvwait:
->  0x7fff721a18f6 <+10>: jae    0x7fff721a1900            ; <+20>
    0x7fff721a18f8 <+12>: movq   %rax, %rdi
    0x7fff721a18fb <+15>: jmp    0x7fff7219e397            ; cerror_nocancel
    0x7fff721a1900 <+20>: retq
Target 0: (px4) stopped.

Has anyone been able to debug 1.9.2 in OS X Catalina?

1 Like

It looks like it’s just stoping on the SIGCONT signal but you should be able to ignore that signal.

Have a look at: https://stackoverflow.com/questions/11984051/how-to-tell-lldb-debugger-not-to-handle-sigbus

What you need is something like:

pro hand -p true -s false SIGCONT

I can’t reproduce what you get yet. I’m on Mojave though.

I get this:

Unable to find GDB in default search path and /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lldb.

How did you install llvm?

Hi Julian-

Thanks very much for your help with this. Unfortunately the pro hand -p true -s false SIGCONT doesn’t seem to make a difference, and actually doesn’t do much because I need to kill the process to instantiate it, which appears to break the px4<->gazebo/jmavsim connection.

RE lldb: I didn’t do anything special; in fact I’ve now started with a clean install of Catalina, followed the developer guide (https://dev.px4.io/v1.9.0/en/setup/dev_env_mac.html) and lldb is already there.

I should mention I actually saw this same problem on Mojave.

Are you able to run the debugger (in VSCode or otherwise) with gazebo/jmavsim successfully in Mojave at all?

-Allan

A quick follow-up: I was able to get process handle SIGCONT -p true -s false -n false to fix the issue, but it took a bit of work, namely I had to:

1.) run the sim in debug mode (make px4_sitl jmavsim___lldb)
2.) set a breakpoint at the entrypoint of main() (b main.cpp:123 worked for me)
3.) set the signal handling flags (process handle SIGCONT -p true -s false -n false)
4.) continue (c)

From then on it appears to work properly. I’m trying to figure out how to have this happen on all runs of lldb but setting it in the ~/.lldbinit doesn’t seem to work. Additionally it seems like this is something that should be set in the fimrware repo so it doesn’t affect debugging other code.

EDIT: After a bit more searching, it looks like someone else already ran into this and put this in the launch.json:

            "osx": {
                "MIMode": "lldb",
                "setupCommands": [
                    {
                        "text": "pro hand -p true -s false -n false SIGCONT",
                    }
                ]
            }

But clearly its not working.

-Allan

Hey, @dagar, have you seen this issue before on your adventures in Visual Studio land? is this something you can help @almatthew with?

I can now actually launch the debugging with lldb. (All I did was restarted VSCode after the weekend :smile:.)

I’m not seeing the SIGCONT problem but I do get a “PAUSED ON EXCEPTION”, and it also looks a bit like this issue: https://github.com/PX4/Firmware/issues/12661

Hi @JulianOes @rroche @dagar, any insight into this? I am able to run the debugger manually (see above) but its quite cumbersome to work with. Any suggestions to get vscode/lldb debugging working (or suggested alternatives) would be extremely helpful.

Thanks!

Hey, I have this issue when working in a mac I was follow the track to change the miDebuggerPath to really point to the lldb-mi library but I didn’t have the time to really make it work :frowning:, by now I’m working in and old and trusty(bionic, this line worked better with 14.14) ubuntu.

@almatthew I usually work on Linux, so I’m not too experienced with macOS and lldb. It would be awesome if someone from the community who is using macOS day by day could figure it out.

As a workaround you can enter this in the “DEBUG CONSOLE” tab when lldb pauses the first time:

-exec pro hand -p true -s false -n false SIGCONT

From then on it should ignore the SIGCONT signals.

2 Likes

I actually tried that, but it doesn’t break in that main() method like it does if I invoke lldb from the command line, so I’m unable to set the SIGCONT handler

I’m not sure what exception you’re seeing then. Not the same as me?

I’m seeing the same “PAUSED ON EXCEPTION” as in my original post

I see PAUSED ON EXCEPTION too but it’s actually due to SIGCONT. And once I add the

-exec pro hand -p true -s false -n false SIGCONT

and then hit resume (not restart) it works.

Alternatively, you can try if it works with this pull request where I got rid of the SIGCONT stuff:

1 Like