$ gdb a.out
run
또는 r
l
b 라인넘버
n
s
p 변수이름
또는 p {변수1, 변수2, 변수3, ...}
c
q
finish
fin
gdb를 사용하려면 gcc 에서 -g
옵션으로 컴파일 되어야함. 아래와 같이 Makefile작성 뒤 $ make debug
명령 수행하면 -g 옵션으로 컴파일 됨.
CC = gcc
CCFLAGS =
all : hashtable
debug : CCFLAGS += -g
debug : hashtable
hash.o : hash.c hashtable.h
$(CC) $(CCFLAGS) -c hash.c -o hash.o
main.o : main.c hashtable.h
$(CC) $(CCFLAGS) -c main.c -o main.o
hashtable : hash.o main.o
$(CC) $(CCFLAGS) hash.o main.o -o hashtable
$ vi
dyld: Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python
Referenced from: /usr/local/bin/vi
Reason: image not found
Abort trap: 6
Removing: /usr/local/Cellar/python/3.6.5... (5,588 files, 109.4MB)
Error: Directory not empty @ dir_s_rmdir - /usr/local/Cellar/python/3.6.5
run 할때 아래와 같이 에러
(gdb) r
Starting program: /Users/jihuun/project/apue2/hashtable/hashtable
Unable to find Mach task port for process-id 28525: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
sudo gdb a.out
으로 함.
GDB to LLDB command map
https://lldb.llvm.org/use/map.html