Tagged debugbreak MacOS macos-carbon macos-catalina macos-high-sierra.Menu Mac OS X Sierra and Ruby debugging: An unhappy marriage 21 December 2016Gdb mac software, free downloads and reviews at WinSite Free Mac Gdb Shareware and Freeware. Cpp -link -subsystem:console -debugcl. MacOS High Sierra 10.13.6 or Mojave 10.14.4 installed Xcode 8 or aboveCS3411 Debugging 9 Using gdb (ave. This guide will show you how to prepare a development environment for Qt with cross compiling for RPi3 on macOS Mojave or High Sierra. Cross compiling Qt 5.11 for RPi3 on macOS 10.14 Mojave or macOS 10.13 High Sierra.Debugging C code is normally a pretty mundane task involving lots of poking around with gdb, and one I've done many times before in a previous life. Docker Toolbox to understand the impact of this installation on your existing setup, how to set your environment for Docker Desktop on Mac, and how the two products can coexist.In my new role I've found myself having to debug Ruby native gems again. When you follow it, ignore I'm using macOS 10 13 6 and I was having the same issue that ' (please check gdb is codesigned - see taskgated(8))'.Gdb Download And Install Mac If you are already running Docker on your machine, first read Docker Desktop for Mac vs.
![]() Gdb Sierra Mac OS XAfter some poking around for a readelf equivalent for Mac OS' Mach-O format I came upon otool and borrowed another laptop running Mac OS X 10.11.6 (El Capitan) for comparison purposes:Mac OS X 10.11.6 (El Capitan): otool -l /usr/lib/dyldMagic cputype cpusubtype caps filetype ncmds sizeofcmds flags0xfeedfacf 16777223 3 0x00 7 14 1696 0x00000085Mac OS X 10.12.2 (Sierra): otool -l /usr/lib/dyldIt became apparent that vmaddr has changed and that gdb is now attempting to set breakpoints at a raw offset instead of the final relocated value. Both lldb and gdb transparently set a breakpoint on this function in order to intercept dynamic libraries being loaded. /configure -enable-debug -disable-build-warnings -prefix=/Users/Stefan/Desktop/gdb-patched-binThis time I got a bit further: Cannot insert breakpoint -1Investigation showed that 0xe85d is the offset of the gdb_image_notifier function in /usr/lib/dyld. I bumped the DYLD_VERSION_MAX as had been done for version 14 and built my own gdb from the latest source: CXXFLAGS="-Wno-c++11-narrowing -O0 -g3" CFLAGS="-Wno-c++11-narrowing -O0 -g3". Some investigation showed that Apple has updated dyld to version 15, which is not yet supported by gdb. I was then met with: warning: unhandled dyld version (15)The usual info shared command did not work and my gem was not being picked up. You will never know imany zippy florin(In fact worse, since the rip for gdb is 0x0 and Ruby's own signal handler would attempt to walk backwards to find a stack trace and would proceed to SIGSEGV - I'm still not sure why that happened, but gdb seemed to die in the same place and with the same SIGSTOP as lldb).A bit of searching came upon an interesting post:Lldb sets a breakpoint on gdb_image_notifier() in order to catch libraries being loaded. I enabled core dumps with ulimit -c unlimited and found the the following: lldb `which ruby` -c /cores/core.83458(lldb) target create "/Users/Stefan/bin/ruby/bin/ruby" -core "/cores/core.83458"* thread #1: tid = 0x0000, 0x000000010040885e dyld`gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) + 1, stop reason = signal SIGSTOP* frame #0: 0x000000010040885e dyld`gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) + 1Rax = 0x0000000100438000 dyld`dyld_all_image_infosRip = 0x000000010040885e dyld`gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) + 1I tried gdb as well (with the semi-broken patch I made) and got a similar core dump. I decided to give lldb a try and found that all my forked children in the test would fail instantly. Error in re-setting breakpoint 1: Cannot access memory at address 0x3fe0I added some more debug printf lines to my gdb and found that some object files seem to have the wrong memory addresses embedded in their DWARF2 debug info at DW_AT_low_pc:Good example: Base addr 0x100001060 for object file: /Users/Stefan/src/ruby/main.oBad example: Base addr 0x3fe0 for object file: /Users/Stefan/src/my_gem/tmp/x86_64-darwin16/my_gem/2.3.3/my_gem.oThis finding indicates that there may be something more fundamentally wrong about relocations on Sierra and gdb 7.12. While gdb now starts up properly and info shared behaves as expected I was still unable to set breakpoints in my gem. ![]() To my knowledge no native debugger supports follow-fork-mode child and set detach-on-fork on on Mac OS and the alternatives are pretty lacklustre. For reasons I do not understand at this time the DWARF2 debug info for some objects also contains offsets which gdb does not relocate appropriately, so even with the patch you may not be able to debug shared libraries properly unless you do more hacks to offset the bad locations appropriately. This is a huge problem that I partially overcame with a shitty patch. dyld 15 and Mac OS 10.12+ have modified their relocation behaviour and gdb in its current state cannot debug shared libraries on it anymore. Fork is an integral part of any reasonably complex Ruby program, and not being able to debug forked children easily on Mac OS disqualifies it as a serious development platform for Ruby users.I believe there are currently multiple compounding issues: I'll be monitoring the upstream bug report for any comments from gdb maintainers.Should you have any ideas please do leave a comment below. I do not yet have a minimal test case, and a trivial "Hello World" style fork + require program did not exhibit this behaviour.At this point I've gone way too far down the tooling rabbit hole and will instead set up a Virtualbox VM with Linux so I can use the tooling I know and expect to work. I do not recall this behaviour happening in El Capitan (though I don't have easy access to a machine running it to check).
0 Comments
Leave a Reply. |
AuthorTom ArchivesCategories |