After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750807 - G_BREAKPOINT doesn't work as intended on Darwin
G_BREAKPOINT doesn't work as intended on Darwin
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.44.x
Other Mac OS
: Normal normal
: ---
Assigned To: Ilya Konstantinov
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-06-11 18:37 UTC by Ilya Konstantinov
Modified: 2015-07-09 14:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gbacktrace: support for Darwin (OSX, iOS) (1.20 KB, patch)
2015-06-11 18:44 UTC, Ilya Konstantinov
none Details | Review
gbacktrace: fix G_BREAKPOINT on Darwin (OSX, iOS) (1.21 KB, patch)
2015-06-11 18:45 UTC, Ilya Konstantinov
committed Details | Review

Description Ilya Konstantinov 2015-06-11 18:37:52 UTC
G_BREAKPOINT currently raises SIGTRAP on Apple platforms. However, SIGTRAP seems to be redirected (somehow) to the main thread, which is not very useful.

Apple documentation indicates we should use __builtin_trap:
https://developer.apple.com/library/mac/technotes/tn2124/_index.html#//apple_ref/doc/uid/DTS10003391-CH1-SECCONTROLLEDCRASH
Comment 1 Ilya Konstantinov 2015-06-11 18:44:04 UTC
Created attachment 305094 [details] [review]
gbacktrace: support for Darwin (OSX, iOS)

Please commit and push, since I don't have permission.
Comment 2 Ilya Konstantinov 2015-06-11 18:45:46 UTC
Created attachment 305095 [details] [review]
gbacktrace: fix G_BREAKPOINT on Darwin (OSX, iOS)

Improved commit message.
Comment 3 Ilya Konstantinov 2015-06-12 09:14:46 UTC
__builtin_trap() has apparently two drawbacks:

 1) clang assumes all code after __builtin_trap() is dead, which might cause unwanted optimizations

 2) naive attempts to resume in Xcode return to the __builtin_trap(). For that purpose, replacing __builtin_trap() with __asm__("brk #0x1") (on arm64) has the same result.

Someone on Stack Overflow proposes using __asm__("svc 0"):
http://stackoverflow.com/a/20713868/130066
With Xcode 6 and arm64 iOS target, this works as expected -- the breakpoint stops on the *following* instruction -- but it's a rather ugly workaround, so I'm not keen on using it.
Comment 4 Ilya Konstantinov 2015-06-13 14:00:00 UTC
Just to clarify, the patch is still way better than the current situation, so it should be applied.
Comment 5 Ilya Konstantinov 2015-07-09 14:45:32 UTC
Reviewed and committed by Patrick Griffis:
https://git.gnome.org/browse/glib/commit/?id=27fae8390946e73e8343a7fd7505796f3599ee23