How can I print long character string in gdb? (gdb inside ddd)

34 Views Asked by At

Please see ADD(solved) below.

While debugging linux booting on a qemu virtual machine, I wanted to print the log buffer at some point. (printk write to the buffer called __log_buf and the contents are flushed out to serial port when serial port is available). At a point where the buffer has many characters (more than 500 hundreds ) I tried printing the __log_buf.

(gdb) p __log_buf $1 = "\200\377\377\377\000\000\000\000Booting Linux on physical CPU 0x0000000000 [0x000f0510]\000\201\377\377\377\000\000\000\000Linux version 5.10.0-rc5 (ckim@ckim-ubuntu) (aarch64-none-elf-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (ar"...
(gdb) p __log_buf[0]@500 $4 = "\200\377\377\377\000\000\000\000Booting Linux on physical CPU 0x0000000000 [0x000f0510]\000\201\377\377\377\000\000\000\000Linux version 5.10.0-rc5 (ckim@ckim-ubuntu) (aarch64-none-elf-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (ar"...

Note the \000 means 0x00 value. I counted the charaters. It's only 202 characters. I searched the gdb options but couldn't find any. I tried 'set max-completions 500'(I don't understand what max-completion is). How can increase the number of printed characters?

ADD (solved) - a little different from the duplicate Q&A :
(solved) I found doing set print elements 0 and doing p __log_buf does the job. The printf didn't work for me maybe I'm using gdb inside ddd. I'' redirect my question to the proposed answer by Ajay with this info added in the question. Thanks all!
p.s. : if you are using ddd (data-display-debugger) and if the ddd hangs after start. Edit ~/.ddd/init and change set extended_prompt not set \n\ to set extended_prompt (gdb) \n\ and things will be ok again.

0

There are 0 best solutions below