> For the complete documentation index, see [llms.txt](https://bankde.gitbook.io/gdbtutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bankde.gitbook.io/gdbtutorial/preparation.md).

# Preparation

ก่อนอื่นให้ติดตั้ง program GCC และ GDB ครับ

**For Linux**

```
sudo apt install gcc gdb
```

**For OS X** (ต้องไปแก้ certificate ด้วยครับ)

```
brew install gcc gdb
```

แนะนำว่าใช้ linux เลยง่ายกว่า เดี๋ยวสะดวกจะมาเพิ่มวิธี config ใน OSX ให้อีกที

จากนั้นก็ clone repo [GDBTutorial](https://github.com/Bankde/GDBTutorial.git) นี้ แล้ว compile executable สำหรับรันบนเครื่องครับ

```
git clone https://github.com/Bankde/GDBTutorial.git
cd GDBTutorial
gcc example.c -o example.o -g
```

gcc ตรงไปตรงมานะครับ ส่วน -g เป็น flag สำหรับ debug เพื่อให้ตอนเสียบ GDB เข้าไปเนี่ย จะอ่านง่าย และมี code ให้เทียบได้ ถ้าไม่มีโค้ดส่วนนี้ตอนเสียบ GDB จะเห็นเป็น assembly ล้วน ๆ เลย เพื่อความง่ายและพื้นฐาน เราจะใช้ flag -g ไปก่อน
