How do I print the full value of a long string in gdb?

后端 未结 6 918
栀梦
栀梦 2020-11-28 17:17

I want to print the full length of a C-string in GDB. By default it\'s being abbreviated, how do I force GDB to print the whole string?

6条回答
  •  一向
    一向 (楼主)
    2020-11-28 17:57

    Just to complete it:

    (gdb) p (char[10]) *($ebx)
    $87 =   "asdfasdfe\n"
    

    You must give a length, but may change the representation of that string:

    (gdb) p/x (char[10]) *($ebx)
    $90 =   {0x61,
      0x73,
      0x64,
      0x66,
      0x61,
      0x73,
      0x64,
      0x66,
      0x65,
      0xa}
    

    This may be useful if you want to debug by their values

提交回复
热议问题