C 在GDB中将多行值设置为一个变量

C 在GDB中将多行值设置为一个变量,c,debugging,testing,gdb,C,Debugging,Testing,Gdb,我有一个字符数组x,我需要给它一个跨多行的输入 GDB接受像x:=value这样的输入,但是我如何使它接受像x:=value这样的值呢 x := "this is a multiple lines input. We are now in second line" 这里的问题不是让GDB识别\n而是让我的脚本在输入很长的字符串时可读 ex:而不是x=这是一个很长的文本输入。很长的输入。超长输入 我需要给x=这是一个非常复杂的问题 长文本输入。 很长的输入。 非常长的输入我希望嵌入式换

我有一个字符数组x,我需要给它一个跨多行的输入

GDB接受像x:=value这样的输入,但是我如何使它接受像x:=value这样的值呢

x := "this is a multiple lines
     input. We are now in second line"
这里的问题不是让GDB识别\n而是让我的脚本在输入很长的字符串时可读

ex:而不是x=这是一个很长的文本输入。很长的输入。超长输入 我需要给x=这是一个非常复杂的问题 长文本输入。 很长的输入。
非常长的输入

我希望嵌入式换行符能够工作:

gdb$ set var x = "this is a long\nstring with\nmultiple lines\in it!"

但是我现在没有访问gdb的权限来尝试它。

用反斜杠结束这一行,然后继续下一行

$ gdb s
(gdb) list
1   #include <stdio.h>
2   
3   char buf[512];
4   
5   main()
6   {
7       printf("%s\n", buf);
8   }
(gdb) break main
Breakpoint 1 at 0x80483bd: file s.c, line 7.
(gdb) run
Starting program: s 

Breakpoint 1, main () at s.c:7
7       printf("%s\n", buf);
(gdb) set buf="I have always wished for my computer to be as easy to use \
as my telephone; my wish has come true because I can no longer figure out \
how to use my telephone. --Bjarne Stroustrup."
(gdb) cont
Continuing.
I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone. --Bjarne Stroustrup.

Program exited with code 0262.
(gdb)