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

Łukasz Lew picture Łukasz Lew · Oct 7, 2009 · Viewed 83.8k times · Source

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 possible?

Answer

ezpz picture ezpz · Oct 7, 2009

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)