Humanity

Edit the world by your favorite way

macOS Mojave で Vim のソースコード (C 言語) のデバッグをする (clang, lldb)

  1. src/MakefileCC, CFLAGS を変更
diff --git a/src/Makefile b/src/Makefile
index 9c4a42893..d62c21b59 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -586,14 +586,14 @@ CClink = $(CC)
 # again.
 #CC = cc
 #CC = gcc
-#CC = clang
+CC = clang
 
 # COMPILER FLAGS - change as you please. Either before running {{{1
 # configure or afterwards. For examples see below.
 # When using -g with some older versions of Linux you might get a
 # statically linked executable.
 # When not defined, configure will try to use -O2 -g for gcc and -O for cc.
-#CFLAGS = -g
+CFLAGS = -g
 #CFLAGS = -O
 
 # Optimization limits - depends on the compiler.  Automatic check in configure

2. make clean distclean all で再度ビルド 3. lldb ./vim して r --clean で実行

$ lldb ./vim
(lldb) target create "./vim"
Current executable set to './vim' (x86_64).
(lldb) r --clean

TODO: leak detector 試す