Gdb For Mac Install

Download Gdb Mac Software. Thread-GDB v.b.2.2.0 Extend the multi-thread capabilities of the gdb debugger. This targets POSIX threads implementations, although attempts to remain neutral with respect to the threads implementation. Creating a robust environment for thread debugging is the.

  1. I've recently formatted my Mac and when I reinstalled the command line tools, I installed the new Command Line Tools (OS X Mountain Lion) for Xcode - September 2013. I've just typed gdb in my terminal to debug one of my programs and it told me -bash: gdb: command not found.
  2. 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.

Mac Os Gdb

THIS PAGE HAS BEEN DEPRECATED. SEE THE SPRING 2015 SITE.

Installing G++ on a Mac

This section is intended to get you quickly started with C++ programming on your Mac. We'll be installing GCC 4.8.1 and GDB through a tool called Homebrew. If you want an additional guide on all of the following steps (except for installing GCC), the one by Moncef Belyamani is quite helpful. When you follow it, ignore anything about installing Ruby; that is, stop after setting up git.

Homebrew

Homebrew 'installs the stuff that you need that Apple don't'. It's like Ubuntu's apt-get, where one can install packages easily from repositories. Instead of having to download, configure, and install something yourself, all you need to do is run one command, and Homebrew will take care of the rest for you.

Pre-requisites

Homebrew requires that you have either Xcode or the Xcode command line tools installed on your Mac. Xcode is a free integrated development environment similar to Eclipse designed by Apple and mainly intended for iOS development or targeting the clang compiler. In this class, we will focus on gcc.

Xcode is quite a big install, so if you do not want to install it, you can get away with just installing the Xcode command line tools. See a Stackoverflow discussion for instructions on how to install the command line tools regardless of whether you have Xcode installed.

Installing Homebrew

You need xcode command line tools to install Homebrew. It is very easy to install Homebrew. Open your terminal, and run the following command:

For

If this doesn't seem to do anything, try killing it (CTRL C) and running it again. Or checkout homebrew website.

How to install gdb

GCC and GDB

Installing GCC

Osx Gdb

First of all, you should make sure that your Homebrew is up-to-date. Check to see if it is so with the following:

As mentioned before, installing packages with Homebrew is very easy. First, we will add the repository from which the GCC package is available, so that Homebrew knows where to find the package we want. The repository is at https://github.com/Homebrew/homebrew-versions.

We do this by using the brew-tap command. Keep your terminal open, and run the following command. (For more information on how brew-tap works, visit the Homebrew docs):

Next, we will actually install the GCC package. Run the following command:

It might take long time before the installation is complete. If you run into any issues, you can debug with:

When done, run the following:

The result should look like this:

USC Wireless Warning

Many people have had issues running the brew install commands while connected to USC Wireless. If you are having trouble, you can either try using a wired connection, a different wireless connection, or do the following:

Gdb For Mac Installer

  1. Download a homebrew cache
  2. Open Finder, press CMD (command) + SHIFT + G and type /Library/Caches/Homebrew
  3. Extract the contents of the .zip you downloaded inside of the folder you opened in the previous step. Do not extract any of the .tar.bz2 or .tar.gz inside of the .zip folder.This should look as follows:

  4. Run brew install gcc48 in the Terminal as instructed above.

Using G++

To compile with the newly installed G++ compiler, use g++-4.8.

(Advanced) Aliasing g++

Gdb

If you prefer calling g++ directly, you can also create a bash alias, as follows:

Put these two lines at the end of the file ~/.bashrc, and run:source ~/.bashrc

For more information on bash alias, take a look at the GNU Docs.

Installing GDB

Here also we use Homebrew. The following instruction has been taken from GDB on OS X Mavericks and Xcode 5 guide. To install, run the following brew command.

Check if it's installed:

The result should be gdb version 7 or higher.

Codesigning gdb

gdb is not going to debug yet. You'll get an error message like 'please check gdb is codesigned'. You need to create a certificate and sign gdb. By doing so you're telling the operating system that gdb is authorized to attach to other processes for debugging purposes. The following instructions have been taken from this Code Signing guide.

Gdb For Mac InstallGdb For Mac Install
  1. Open application 'Keychain Access' (/Applications/Utilities/Keychain Access.app)
  2. In Keychain Access, select the 'login' keychain in the 'Keychains' list in the upper left hand corner of the window.

  3. Open the menu item in /Keychain Access/Certificate Assistant/Create a Certificate...

  4. Choose a name ('lldb_codesign' in the example, but you can use anything you want), set 'Identity Type' to 'Self Signed Root', and set 'Certificate Type' to 'Code Signing'. Click 'Create'.

  5. Click continue, continue and done.

  6. Click on the “My Certificates” category on the left side and double click on the new “lldb_codesign” certificate.

  7. Open the context menu for 'Trust' (click the triangle) and change the following:When using this certificate: Always Trust

  8. Now close this window, and enter your login password to confirm this change.

  9. Option-drag (this meaning holding the option key down and dragging) the new 'lldb_codesign' certificate from the login keychain to the System keychain in the Keychains pane of the main Keychain Access window to make a copy of this certificate in the System keychain. You'll have to authorize a few more times, set it to be 'Always trusted' when asked.

  10. Switch to the 'System' keychain and drag a copy of the 'lldb_codesign' you just made onto the Desktop.

  11. Switch to Terminal and then run the following command (copy paste it!): sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer

  12. Then right click on the 'lldb_codesign' certificate in the 'System' keychain (not 'Login') and select 'delete' to delete it from the 'System' keychain.

  13. Then reboot your system/computer.

  14. Finally you can sign gdb:codesign -s lldb_codesign /usr/local/bin/gdb

  15. If this command doesn't work...then panic! Just kidding, be sure that you have gdb installed and that gdb is actually installed in /usr/local/bin. You may want to try 'which gdb' in your Terminal to figure out where it is.

  16. Finally, remove the lldb_codesign.cer file that's sitting on your desktop, and gdb should be working at this point. :)

Home » Language IDEs » C / C++ IDE (CDT) » GDB under High Sierra - no joy!
Show:Today's Messages::Show Polls::Message Navigator
GDB under High Sierra - no joy![message #1793946]Tue, 21 August 2018 01:20
Andrew Voelkel
Messages: 17
Registered: September 2016
I have a C++ only Mac project and I'm sick of dealing with the poor C++ environment in Xcode. So I'd like to use Eclipse Photon.
I've tried various recipes on Stack Overflow etc. to get native gdb to work with Mac OS High Sierra and Eclipse. After spending a couple hours still no joy. The variety of error messages is too great to enumerate. From the looks of the comments to the recipes I've found, this is far from a slam dunk.
The problems seem to be:
a) gdb 8.1 compatibility with Eclipse Photon.
b) Big time code signing crapola with gdb and High Sierra.
Should I just give up on this? I'm pretty damn frustrated at this point.
It sure would be nice if I could just get a code signed version of gdb.
I guess that most folks doing this sort of thing just use Xcode?
Re: GDB under High Sierra - no joy![message #1795142 is a reply to message #1793946]Sun, 16 September 2018 22:19
Marc-André Laperle
Messages: 256
Registered: July 2009
I was able to make GDB 8.0.1 work OK on High Sierra, compiling it from source and following the instructions here https://sourceware.org/gdb/wiki/BuildingOnDarwin. There is some discussion here:
https://sourceware.org/bugzilla/show_bug.cgi?id=20266
Otherwise, you could also try the integration with LLDB, which I have been looking at improving, see https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3F and following sections. It might not be a good solution for you yet but any feedback and bug reports are appreciated.
Re: GDB under High Sierra - no joy![message #1795147 is a reply to message #1795142]Mon, 17 September 2018 05:26
Andrew Voelkel
Messages: 17
Registered: September 2016
I tried lldb-mi. It seemed to work, but then I tried debugging some stuff which uses the STL container library, and it was pretty useless.
I don't actually know that gdb would be much better. I've seen post about 'pretty printing' and python scripts, but that doesn't exactly sound like gdb is truly STL aware.
For all its faults, Xcode actually handles this part 'OK'. It is a terrible C++ composition environment, but at least you can debug STL containers.
I'm kind of shaking my head that STL container debugging isn't completely integrated and old hat in Eclipse by now. How long has STL been around? A long time.
So at this point I use Eclipse for C++ composition and Xcode for debug. It seems pretty silly that is what I have to do, but there you have it. CLion is OK, but it isn't free and it has issues too.
If I were in Windows, Visual Studio would 'just work'. But I gave up on Windows when Windows 8 came out and I'm not going back anytime soon.
Re: GDB under High Sierra - no joy![message #1795181 is a reply to message #1795147]Tue, 18 September 2018 04:06
Marc-André Laperle
Messages: 256
Registered: July 2009
You bring up a good point about STL support. I created a bug to track STL support https://bugs.eclipse.org/bugs/show_bug.cgi?id=539168
Most of the debug support in Eclipse was done for Linux and GNU toolchain (GCC, libstdc++ and GDB). With this combination, you can have good support for STL pretty printing and it should work out of the box. The way I understand it, GDB pretty printers are heavily tied to the standard library implementation details, so on macOS the pretty printing support would need to be implemented there for libc++ (I think that's the standard library being used?). I actually don't know how this works in Xcode but it sounds promising and maybe we can add it to lldb-mi support too.
I do understand your pain, I've used Eclipse+Xcode combination and Eclipse+VisualStudio combination for a very long time. Pre-lldb in Xcode, it got to a point where Apple-gdb support was pretty on par (i.e. as bad) as Xcode. In the end, no one in the... thousands of users?... cares enough to make this work as well as on Linux.
Re: GDB under High Sierra - no joy![message #1795187 is a reply to message #1795181]Tue, 18 September 2018 06:32
Andrew Voelkel
Messages: 17
Registered: September 2016
I'm curious about what this 'pretty printing' buys you. With LLDB in either Xcode or CLion, you can dive down into STL containers interactively, looking at individual elements in the containers, and opening them up in a tree view pretty seamlessly. Does pretty printing let you do this? It kinda doesn't sound like it.
I haven't been over to Windows to try this stuff on Visual Studio for a while, not since starting to use STL containers heavily. I'd be surprised if the experience were not at least as good as LLDB with Xcode or Clion, but I really don't know. I would think it would be a decent C++ composition tool also. But it isn't worth running Windows to do it. Not unless I'm hired to do a sizable C++ project on Windows, and I'm not holding my breath on that one.
Without good debug support, using STL containers definitely loses a lot of its appeal! I should be thankful to have it, even if I have to use one IDE for composition and one for debug.
Re: GDB under High Sierra - no joy![message #1795292 is a reply to message #1795187]Thu, 20 September 2018 04:37
Marc-André Laperle
Messages: 256
Registered: July 2009
Quote:
I'm curious about what this 'pretty printing' buys you. With LLDB in either Xcode or CLion, you can dive down into STL containers interactively, looking at individual elements in the containers, and opening them up in a tree view pretty seamlessly. Does pretty printing let you do this? It kinda doesn't sound like it.

Yes, it lets you do that.
Without: https://wiki.eclipse.org/images/3/31/NoPrettyPrint.png
With: https://wiki.eclipse.org/images/8/81/FullPrettyPrint.png
And you can also add your own. In LLVM for example, there are gdb pretty printers for a few base types, right in the repo.
Re: GDB under High Sierra - no joy![message #1795341 is a reply to message #1795292]Thu, 20 September 2018 14:46
Andrew Voelkel
Messages: 17
Registered: September 2016
That's excellent news about STL 'pretty printing'. I'm about to do a cross development project Mac Host / Linux Target. This should make life much better.
It might also motivate me at some point to get gdb working on the Mac target.
Too bad it doesn't work outta the box though!
Re: GDB under High Sierra - no joy![message #1795568 is a reply to message #1793946]Tue, 25 September 2018 11:25
Avarro mickllov
Messages: 2
Registered: September 2018
in my case downgrading to 8.0.1 didn't help.
but the following steps helped.
(i inserted step 12, 'check if it works' because, instead of restarting i've tested gdb and it worked just fine. i didn't follow the steps 12+)
Open Keychain Access
In menu, open Keychain Access > Certificate Assistant > Create a certificate
Give it a name (e.g. gdb-cert)
Identity type: Self Signed Root
Certificate type: Code Signing
Check: let me override defaults
Continue until 'specify a location for...'
Set Keychain location to System
Create certificate and close Certificate Assistant.
Find certificate in System keychain.
Double click the certificate
Expand Trust, set Code signing to always trust
Restart taskgated in terminal: killall taskgated
Codesign gdb using your certificate: codesign -fs gdb-cert /usr/local/bin/gdb FetLifeIMVUCanva
--- CHECK IF IT WORKS ---
Shut down your mac and restart in recovery mode (hold down command-Runtil apple logo appears)
Open terminal window
Modify System Integrity Protection to allow debugging: csrutil enable --without debug
Reboot your Mac
Debugging with gdb should now work as expected.

[Updated on: Wed, 26 September 2018 17:48]

Re: GDB under High Sierra - no joy![message #1795745 is a reply to message #1795568]Thu, 27 September 2018 15:45
Andrew Voelkel
Messages: 17
Registered: September 2016
Does STL pretty printing work for you?
Re: GDB under High Sierra - no joy![message #1795799 is a reply to message #1795745]Sat, 29 September 2018 00:11
Marc-André Laperle
Messages: 256
Registered: July 2009
With GDB on macOS target? No, I don't think it's supposed to work out of the box right now since there would need to be pretty printers installed along with libc++. They are often installed with libstdc++ which is more commonly used on Linux. I did find this however but never tried it: https://libcxx.llvm.org/docs/UsingLibcxx.html#gdb-pretty-printers-for-libc
Re: GDB under High Sierra - no joy![message #1831071 is a reply to message #1795799]Tue, 11 August 2020 06:55
Nala Fx
Messages: 1
Registered: August 2020
It might also motivate me at some point to get gdb working on the Mac target.
Too bad it doesn't work outta the box though!
vivatv cyberflix
https://vivatv.vip/https://cyberflix.cam/

[Updated on: Wed, 12 August 2020 19:54]

Previous Topic:Build might be incomplete
Next Topic:CDTPropertyManager.performOKForced(Object p) - parameter unused
Goto Forum:
[ Syndicate this forum (XML) ] [ ]

Powered by FUDForum. Page generated in 0.02208 seconds