Re: Debugging PJSIP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marc,

I made notes long ago on how to debug pjsua on Mac OS-X using XCode debugger, and how to debug the core dump files using lldb. It's not exactly what you want but may help, see below.

Regards,

Bill

===============================================================================
How to debug PJSUA on Mac

With XCode you can run pjsua in debugger even though pjsua is built using make. First, reconfigure pjsua to build in debug mode by running configure as:

./configure CXX="g++" CXXFLAGS="-g -arch i386" LDFLAGS="-arch i386" CFLAGS="-g -arch i386"

(Note this is a 32-bit build but you can do a x86_64 build too, or is it x64 on Mac?)
Then do make dep and make as usual to rebuild a debug version.

Then create a new Xcode project, set project type to "external build" and store it in pjsip tree (I call mine pjsip_xcode which creates a pjsip/pjsip_xcode directory and creates a pjsip_xcode.xcodeproj file within). Select the pjsip_xcode project in left pane and under "Info" in right pane the build tool should be "usr/bin/make" and then specify the root directory of pjsip. Then select menu option Product->Scheme->Edit Scheme and select Run Debug in left pane. Under Info tab on right pane set the Executable by navigating to the pjsua app in pjsip-apps/bin/pjsua. Then you can set up command line arguments in Arguments tab. Close the scheme and go back to project browser. Right click (CTRL click if you have a one button mouse) on pjsip_xcode and select Add Files to... and select the top level pjsip directory, unselect copy items, select create folder references, and unselect add to targets. This will add all the pjsip source to your project. After it scans for a while you will be able to click on any source file and open it up and set a breakpoint by clicking in left margin. Then click the run arrow button and it will do a "make" which should finish immediately (since it's already made) and then run pjsip in debugger and it will hit breakpoint. It's magic!

The first time I did this I went through the entire exercise with a very simple "hello, world" c++ app and makefile. If you get stuck I'd recommend that.

===============================================================================
Core dump debugging on Mac

Great page on Mac debugging techniques:

https://developer.apple.com/library/mac/technotes/tn2124

Follow the instructions for generating core dumps. I created /etc/launchd.conf with "limit core unlimited" and rebooted and still no core dumps. I then added world readability to /cores, which already existed on my machine. Still no core dumps. It was necessary to also do "ulimit -c unlimited" and then crashes from that shell produce core dumps. But unfortunately this only works for programs launched from that shell!

How to get it to work at all times:

http://unix.stackexchange.com/questions/176671/how-to-persist-ulimit-settings-in-osx-yosemite

Create the file "/System/Library/LaunchDaemons/enable core dumps.plist" with following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
<plist version="1.0">
<dict>
    <key>GroupName</key>
    <string>wheel</string>
    <key>InitGroups</key>
    <true/>
    <key>Label</key>
    <string>core dumps launchctl</string>
    <key>ProgramArguments</key>
    <array>
        <string>launchctl</string>
        <string>limit</string>
        <string>core</string>
        <string>unlimited</string>
        <string>unlimited</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>root</string>
</dict>
</plist>

Then after reboot, a shell should show:
Bills-MacBook-Pro:~ billg$ ulimit -c
unlimited
Bills-MacBook-Pro:~ billg$ launchctl limit core
    core        unlimited      unlimited


Note: gdb is no longer supported on Mac.

Using LLDB to read core file:

(lldb) target create --core /cores/core.1235

You can optionally give us the architecture and/or executable file if you know them:

(lldb) target create --core /cores/core.1235 --arch x86_64 /path/to/executable

After this command, you can then do a:

(lldb) thread list
(lldb) thread backtrace all

Core files only work for mach-o core files right now.

Core files are huge, so core dumps should probably be disabled when you don't need them.




On 8/15/2016 5:28 PM, Marc wrote:
Is there a guide to getting GDB or LLDB attached to PJSIP, especially if compiled as a static library (.a) for iOS?

Thanks
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux