Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs 24 and GDB 6.3 on Mac OS X

I've been trying out Emacs 24 (pretest 24.0.95.1) on OS X Lion for the past few days but am running into some issues with the new gdb/MI interface.

With GDB 6.3 that comes with Xcode, but the gdb/MI interface doesn't seem to load at all. It appears to try to start the GDB GUD mode, but no commands actually work.

I also attempted installing GDB-7.4 via Homebrew. That gets me partly there. the gdb-many-windows interface shows up, but the gdb prompt never arrives. Emacs just sits there eating up 100% CPU, but yet doesn't become unresponsive. I can still open files, etc. I just can't do anything with GDB.

Has anyone else run into similar issues? Were you able to resolve them, and if so, how?


Edit: 2012-06-10: I just tried again with the newly released Emacs 24.1. The behavior with GDB 6.3 (via Xcode) remains the same. GDB-7.4 is slightly worse in that it starts up GDB, and emacs uses up 100% CPU but now I'm unable to do anything else. Emacs if frozen :/

like image 817
Grant Limberg Avatar asked Apr 19 '12 03:04

Grant Limberg


People also ask

Can I use Emacs on Mac?

Emacs is a text editing tool that comes out-of-the-box with Linux and macOS. As a (less popular) cousin of Vim, Emacs also offers powerful capabilities with easy-to-install language support, and can even help you navigate faster in macOS with the same keybindings.

Is Emacs pre installed on Mac?

OS X comes with a preinstalled version of Emacs, but alas it is the outdated Emacs 22. Fortunately, obtaining a newer release is really simple. There are several popular ways to do it.

How do I install Emacs on my Macbook Pro?

Mostly simply, download and run the emacs- version -installer.exe which will install Emacs and create shortcuts for you. Alternately, download emacs- version . zip then unzip, preserving the directory structure.


Video Answer


2 Answers

I tried to use the way of modify certification by Keychain.app from

http://sourceware.org/gdb/wiki/BuildingOnDarwin

It still complains about certification..

GNU gdb (GDB) 7.4
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin11.3.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/hanfei/Documents/mis/mis...Reading symbols from /Users/hanfei/Documents/mis/mis.dSYM/Contents/Resources/DWARF/mis...done.
done.
(gdb) r
Starting program: /Users/hanfei/Documents/mis/mis 
Unable to find Mach task port for process-id 52327: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

Then I tried:

$ sudo chgrp procmod /yourpath/gdb
$ sudo chmod g+s /yourpath/gdb

And it works for me now.

like image 134
Hanfei Sun Avatar answered Sep 23 '22 13:09

Hanfei Sun


I'm using Emacs 24.1 that I built myself on Mac OSX Lion (10.7.4) from the sources in Savannah git. The build is based on the emacs-24.1 tag and have a patch for Lion fullscreen support applied.

Gdb 6.3 works weirdly for me. It complains about the -i=mi flag and it keeps printing a weird timestamp before each command prompt, pushing the (gdb) far to the right and making it really hard to use. Completions don't work as well and there could be other stuff broken that I didn't bother investigating much further.

Using the gdb 7.4 from homebrew/dupes tap, when trying to run gdb from Emacs got the same error described in the link that Firegun mentioned, http://sourceware.org/gdb/wiki/BuildingOnDarwin:

Starting program: /x/y/foo
Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))

However, I followed every step described in there to create a certificate and sign gdb and now it runs fine. I start gdb using M-x gdb and then load the app that I want to debug by using the file command. When I type run it prompts for my password to let Developer Tools take control of another process. After giving my password it runs fine. It stops on breakpoints, it follows the code with arrows in the fringe, and if go to the Gud > GDB-MI > Display Other Windows it shows the other windows with info.

like image 23
Kao Félix Avatar answered Sep 20 '22 13:09

Kao Félix