0

I am debugging a C++ application in ddd.

I have a char * variable null-terminated string which is so long that ddd truncates when displaying it. I want to examine this string in an external application, so how can I copy it to the clipboard, or otherwise export it from gdb?

EDIT: to clarify because some commentators seem confused -- this is not a clipboard API question. It seems an obvious useful feature that a debugger allow one to capture and examine arbitrary strings in a debugged program's memory. So, can it be done in gdb, and how?

spraff
  • 32,570
  • 22
  • 121
  • 229

1 Answers1

1

I have a char * variable null-terminated string which is so long that ddd truncates when displaying it.

It is not ddd that truncates long string, it's gdb. By default gdb truncates all strings to 200 chars when displaying them. You can set your own limit or set it to zero to print unlimited strings like this:

(gdb) set print elements 0

See also this question.

Community
  • 1
  • 1
ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Thanks, although I don't want to print it, I want to export it. This string is many thousands of characters long, I don't want to handle it in gdb/ddd. – spraff Mar 06 '16 at 13:35
  • 1
    You can save it to a file (gdb.txt by default): `(gdb) set logging on` `(gdb) print str` – ks1322 Mar 06 '16 at 13:46