antirez / kilo

A text editor in less than 1000 LOC with syntax highlight and search.
BSD 2-Clause "Simplified" License
7.34k stars 807 forks source link

How can I debug the program using GDB? #59

Open yichuan66 opened 5 years ago

yichuan66 commented 5 years ago

I tried to debug the program using GDB and VS Code, but since the code uses escape sequences on Terminal for display, it can interfere with GDB output. For example, when a program calls write(1, "\x1b[6n" , 4) GDB will just hang there and not continue. How can I debug in this case? Thanks!

EyLinGer commented 4 years ago
  1. You should compile the 'kilo.c' file with -g option if you are using gcc compiler.
  2. Type command gdb kilo
  3. (gdb)set args <filename>
  4. (gdb)run
  5. Kill process which named 'kilo' by your task manager or by typing command in your terminal.
  6. Now you can do things like print E to see the data in it.