gdb's TUI mode broke on macOS When I try to scroll the source window with the arrow keys, the previously outputted lines are not properly overwritten, resulting in a weird looking:



My ~/.gdbinit only contains set startup-with-shell off.

I installed gdb by brew install gdb. Here is the version info:

[sunqingyao@192.168.0.111 ~/Projects/play_ground]$ gdb --version
GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin16.6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;.
Find the GDB manual and other documentation resources online at:
&lt;http://www.gnu.org/software/gdb/documentation/&gt;.
For help, type "help".
Type "apropos word" to search for commands related to "word".


I'm using iTerm2 under Sierra 10.12.6 (16G29), if it's relevant.
Yes, I came with the same problem. 
TUI is useless when debugging with gdb and src layout. It's a bug of iterm2 which can't fully support complicate output. Sometimes, TUI crashes too when using vim and multi-windows setting. 
Apple likely has left gcc and gdb behind. So my suggestion is switching to clang and lldb. Both work fine so far on Mac command line and they are advanced tools. At the mean time, switching wouldn't cost you much time if you could use gdb well. 
Good luck. And by the way, Xcode is a gread tool for your peace of mind.