-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
Description
Using lldb to debug an application which reads raw characters from stdin has unexpected behavior when Enter (aka ^M or \r) is entered. The character that read returns is newline (aka ^J or \n).
Running the same program without the debugger or under gdb does not have this problem. I have observed this on macOS and various Linux distros.
The attached program demonstrates the problem:
% clang -g lldb_demo.c -o lldb_demo
mark@marks-mac-mini ~ % sudo bash
Password:
# lldb ./lldb_demo
(lldb) target create "./lldb_demo"
Current executable set to '/Users/mark/lldb_demo' (arm64).
(lldb) run
Process 41466 launched: '/Users/mark/lldb_demo' (arm64)
Type to see what happens. See what ^M (aka Enter) produces
Exit with ^D
Character read was: '^J' - 0x0A
Character read was: '^D' - 0x04
Exiting
Process 41466 exited with status = 0 (0x00000000)
(lldb) q
#