Installing Gdb For Mac



NVIDIA® CUDA Toolkit 11.0 no longer supports development or running applications on macOS. While there are no tools which use macOS as a target environment, NVIDIA is making macOS host versions of these tools that you can launch profiling and debugging sessions on supported target platforms.

Instructions for installing cuda-gdb on the macOS This tar archive holds the distribution of the CUDA 11.0 cuda-gdb debugger front-end for macOS. Native macOS debugging is not supported in this release, only remote debugging to other CUDA enabled targets. Version 9.2 of GDB, the GNU Debugger, is now available for download. See the ANNOUNCEMENT for details including changes in this release. An errata list and documentation are also available. News September 13th, 2020: GDB 10 branch created. The GDB 10 branch (gdb-10-branch) has been created. To check out a copy of the branch use. GDB: The GNU Project Debugger GDB Maintainers contributing current git documentation mailing lists Download GDB The most recent.

You may download all these tools here. Note that the Nsight tools provide the ability to download these macOS host versions on their respective product pages.

Install gdb via Homebrew: brew install gdb Restart taskgated: sudo killall taskgated && exit Reopen a Terminal window and type sudo codesign -vfs gdb.cert /usr/local/bin/gdb. This videos explains the step by step process to insall gdb debugger and gcc in windows 10. First of all you need to go to download page of minGW by clicking.

Please visit each tool's overview page for more information about the tool and its supported target platforms.

The macOS host tools provided are:

  • Nsight Systems - a system profiler and timeline trace tool supporting Pascal and newer GPUs
  • Nsight Compute - a CUDA kernel profiler supporting Volta and new GPUs
  • Visual Profiler - a CUDA kernel and system profiler and timeline trace tool supporting older GPUs (see installation instructions, below)
  • cuda-gdb - a GPU and CPU CUDA application debugger (see installation instructions, below)

Download
NVIDIA® development tools are freely offered through the NVIDIA Registered Developer Program

Instructions for installing cuda-gdb on the macOS

    This tar archive holds the distribution of the CUDA 11.0 cuda-gdb debugger front-end for macOS.
    Native macOS debugging is not supported in this release. Remote debugging from a macOS host to other CUDA enabled targets, however, is supported.
    To install:
    1. Create an installation directory
        INSTALL_DIR=$HOME/cuda-gdb-darwin-11.0
        mkdir $INSTALL_DIR
        cd $INSTALL_DIR
    2. Download the cuda-gdb-darwin-11.0.tar.gz tar archive into $INSTALL_DIR above
    3. Unpack the tar archive
        tar fxvz cuda-gdb-darwin-11.0.tar.gz
    4. Add the bin directory to your path
        PATH=$INSTALL_DIR/bin:$PATH
    5. Run cuda-gdb --version to confirm you're picking up the correct binaries
        cuda-gdb --version
    6. You should see the following output:

        NVIDIA (R) CUDA Debugger
        11.0 release
        Portions Copyright (C) 2007-2020 NVIDIA Corporation
        GNU gdb (GDB) 8.2
        Copyright (C) 2018 Free Software Foundation, Inc.
        License GPLv3+: GNU GPL version 3 or later Installing Gdb On Mac
          Native macOS profiling is not supported in this release. Remote profiling from a macOS host to other CUDA enabled targets, however, is supported.
          Supported Mac platforms: Mac OS X 10.13
          Steps to install:
          1. Double click .dmg file to mount it and access it in finder.
          2. Drag nvvp folder and drop it to any location you want (say <nvvp_mac>).
            Directory Structure:
              |--nvvp
              |--bin/
              |--lib64/
              |--libnvvp/
          3. Download and install the required version of JDK.
            (Refer to the Notes about JRE Requirements when using Visual Profiler on the macOS section, below)
          Steps to run:
          1. Open terminal.
          2. Change to the bin folder
              > cd <nvvp_mac>/nvvp/bin
          3. Run nvvp script file in command line
              > ./nvvp -vm <path_to_java>
            <path_to_java> should point to the JRE update 151 version of Java (See Notes about JRE Requirements, below).
              For example:
              > ./nvvp -vm /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/bin/java
          Summary of supported features:
          1. Remote profiling
          2. Import nvprof output files
          Refer the 'Visual Profiler' section in the 'Profiler User's Guide'
          for more information:
            https://docs.nvidia.com/cuda/profiler-users-guide/index.html#visual

        Notes about JRE Requirements when using Visual Profiler on the macOS

          OpenJDK provides an open-source (and standards compliant) implementation of a Java compliant JVM.
          Binaries are provided by various vendors such as Oracle, Azul Systems (Zulu), Amazon, Red Hat, IBM, etc.
          Visual Profiler needs to use an older version of Java, specifically JRE update 151, to work correctly.
          This is currently not offered by Oracle JDK but is provided by Azul Systems (Zulu).
          The Bazel Build project also uses the Zulu builds of OpenJDK.
          Download JDK 8.0.144 to get JRE update 151:
            • Download version: 8u144-b01 (Zulu: 8.23.0.3) .dmg.zip.tar.gz
            • Download version: Zulu 8.23.0.3 (build 1.8.0_144-b01 .zip

        There comes a time when you want to step through your code, and breakpoints become useful. If you’re a PHP developer you reach out for Xdebug for example or it’s even built into some languages like recent versions of Python.

        For many languages, the tool to reach to is gdb (GNU Project Debugger) it supports a wide range of languages including C++ and in my case Rust.

        Indeed its as close to “official” debugger as you can get for Rust to the point the official install of rust has a rust-gdb wrapper to prettify the output. So installing it will be easy right?

        it’s surely just

        Install gdb for mac

        Well that certainly gets you a binary… not a working binary at least not today (Late April 2019)

        Compiling from (the right) source

        Hopefully, this will get fixed, but installing from Homebrew and even after code signing it (more on that later) resulted in the error:

        When trying to actually run within gdb, lot’s of Googling and much head scratching it appears, that the version of source that Homebrew is using has a couple of bugs in it. This isn’t Homebrew fault, rather an issue with upstream.

        Mac

        So compiling from source using the latest 8.2.1 which at the time was the most recent release was my next step, and like Homebrew it also failed (which makes sense as that’s the same source they would be using).

        Next up was to go bleeding edge… yep no dice, that didn’t even compile

        So after looking through issues, it appears the issue was patched a little bit after 8.2.1 was released which was December 2018. Looking to early 2019 there was a series of 8.2.50 commits, before moving to 8.3 so in the end, I took a punt on the Feb 26th Snapshot the actual snapshot I used was.

        From there it was pretty simple:

        Important (I think) I have GCC 8 setup by default via Homebrew

        Several folks have mentioned in various threads about compiler failures. As I already use GCC I have no idea if those are historic issues or not.

        By default we now end up with gdb installed into:

        So that’s the end of the story right….

        Mac

        Creating a code signing certificate

        Regardless of how you get a binary, before you can get it working you need to get a certificate and associate it with the binary to allow code signing otherwise you get

        Creating a new certificate isn’t particularly complicated:

        • Open up Keychain Access
        • Select Certificate Assistant -> Create a Certificate
        • give it a name gdb-cert, type is self-signed root and Certificate Type is Code Signing. Finally, tick the Let me override defaults (this is important)
        • It will warn you, you are about to create a certificate (because this might have been a shock) click continue
        • For serial number and validity length, you can leave as, or change. then click continue
        • The other certificate information can be left blank and just click continue
        • 2048 Key size and Algorithm RSA which should be defaults just click continue
        • Next 3 you can just click Continue
        • Specify a Location, make sure you choose the Keychain option of System

        With a certificate created, restart the machine. Yes there are other ways to do this, but trust me its just easier to restart and be sure everything is working.

        Right with a certificate we need to apply it to the binary, first of create an entitlements file, this is an XML file that shows associated permissions you want to grant the binary.

        With the file saved (in my case as gdb.xml) then the final setup is:

        Ok surprisingly at this stage it’s working and you can start using gdb on MacOS congrats.

        Few Gotchas

        Gdb For Mac

        Ok assuming you found this after some Googling, you might reach the end of the above steps and run gdb think everything is going fine and it hangs with a message something like:

        Gdb Install Windows

        If this is you, then edit your ~/.gdbinit file to not include the line:

        Chances are like me you added this early on in your trying to get things working, as it was announced in several places as a potential fix. I’m not actually sure why it doesn’t work and it may work for you. I’m slightly suspicious that it might be due to using ZSH but removing the line solved the issue for me, so I dug no further.

        While trying to get things working at some point you might have runin which case I would recommendas there is no reason to enable it.

        Couple of other things to consider, if you haven’t already make sure you uninstalled gdb via Homebrew if you installed that way, or it’s likely to relink at some point causing chaos.

        How To Install Gdb

        Also, that certificate you generated, will expire…
        So you might want to make a note on how you made it and put in your diary to renew or it’s going to confuse the hell out of you next year.

        The last gotcha is more of a comment and specific to Rust, when debugging something built from cargo it leaves an almighty mess, with lots of references to missing files and being unable to read symbols. This doesn’t seem to affect anything other than adding to any warnings your code might actually have. Using rustc -g didn’t come with such gumph but also is way less convenient so for now, I’m just going to live with it.

        Osx Gdb

        So there we have it, how to install a 30-year-old workhorse tool that has probably been installed on thousands if not millions of machines. Yet due to a combination of MacOS tightened security, some weird rabbit holes caused back with High Sierra and a couple of bugs in the 8.2.1 source has caused more than a little headache for me.