How to print a line with a terminating null character with newline characters without showing a backslash in gdb?

I have a variable

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

and I want to print it with newlines printed as newlines, not the backslash n. Is it possible?

+44
c debugging gdb
Oct 07 '09 at 10:23
source share
2 answers

Update: Why not just use the gdb printf command?

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



Old answer: Inside the debugger, you can execute commands. Just call printf

 (gdb) call printf("%s", x) asd qwe ... (gdb) 
+75
07 Oct '09 at 10:30
source share

Use the string specifier:

 print /sx 
+17
Jan 08
source share



All Articles