How to print a null-terminated string with newlines without showing backslash escapes in gdb?

前端 未结 2 1802
夕颜
夕颜 2020-12-24 10:47

I have a variable

char* x = \"asd\\nqwe\\n ... \"

and I want to print it with newlines printed as newlines not backslash n. Is it

相关标签:
2条回答
  • 2020-12-24 11:21

    Use the string specifier:

    print /s x
    
    0 讨论(0)
  • 2020-12-24 11:25

    Update: Why not just use the gdb printf command?

    (gdb) printf "%s", x
    asd
    qwe
    ...
    (gdb)
    

    Old answer: From within the debugger you can execute commands. Just call printf

    (gdb) call printf("%s", x)
    asd
    qwe
    ...
    (gdb)
    
    0 讨论(0)
提交回复
热议问题