Monthly Archives: June 2017

gdb – enable gdb on mac os

Mac OS X 10.10.2 does not come with gdb pre installed. It is available on homebrew:

$ brew tap homebrew/dupes
$ brew install gdb
The binary is installed on /usr/local/bin

When initializing gdb on a program (a.out) it will produce the following error:

Starting program: a.out
Unable to find Mach task port for process-id XXXXX: (os/kern) failure (0x5).
(please check gdb is codesigned – see taskgated(8))
Start Keychain Access application (/Applications/Utilities/Keychain Access.app)
This error occurs because OSX implements a pid access policy which requires a digital signature for binaries to access other processes pids. To enable gdb access to other processes, we must first code sign the binary. This signature depends on a particular certificate, which the user must create and register with the system.

To create a code signing certificate, open the Keychain Access application. Choose menu Keychain Access -> Certificate Assistant -> Create a Certificate…

Choose a name for the certificate (e.g., gdb-cert), set Identity Type to Self Signed Root, set Certificate Type to Code Signing and select the Let me override defaults. Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System.

Double click on the certificate, open Trust section, and set Code Signing to Always Trust. Exit Keychain Access application.

Restart the taskagted service, and sign the binary.

$ sudo killall taskgated
$ codesign -fs gdb-cert /usr/local/bin/gdb

update:
mac os sierra, gdb will show following error.
During startup program terminated with signal ?, Unknown signal.

touch ~/.gdbinit
vim ~/.gdbinit
copy “set startup-with-shell off” into the file and save

spacemacs – working with previous emacs config

1. fork from branch https://github.com/syl20bnr/spacemacs.git to you own github account

the reason why we should fork is to commit code changes for spacemacs in future.

move ~/.emacs to ~/.emacs1 as backup file

2. open ~/.emacs.d/init.el, at the end of buffer, add code to load .emacs file

in my computer, I put all .emacs configure into another file named .emacs_mac

;; move these code into the end of init.el
(if (>= emacs-major-version 25)
(load-file \”~/emacs/.emacs_mac_25\”)
(load-file \”~/emacs/.emacs_mac\”))

3. “M-x toggle-debug-on-error” is helpful command when error occurs. since spacemacs may connect to network and some server are not ready.

4. disable ‘M-x’ ‘C-x C-f’ because windows size changes too often.

in following picture you could see three windows, especially last one, when M-x key is press, it will become very large, later on it will be one line only.
spacemacs

here are steps for disabling them.
<1>open ~/.emacs.d/layers/+completion/helm/packages.el
<2>in function “helm/init-helm” search ‘global-set-key’ statement and comment out.

<3>after comment out everything , add following code into ~/.emacs.d/init.el

1
2
(ido-mode 0)
(helm-mode 0)