繁体   English   中英

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

[英]Setting multiple line values to a variable in GDB

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

GDB接受x:="value"类的输入,但是如何使它接受诸如x:="value"

x := "this is a multiple lines
     input. We are now in second line"

这里的问题不是让GDB识别\\ n而是当我输入很长的字符串输入时使我的脚本可读。

例如:代替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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM