Skip to content

lldb interferes with some stdin input #152935

@markpizz

Description

@markpizz

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
    # 

lldb_demo.c.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions