如何打印没有这种格式的东西:GDB环境中的$ [num] = [value]?

时间:2015-11-23 02:48:35

标签: gdb

我想要的是:

(gdb) define mynext
Redefine command "mynext"? (y or n) y
Type commands for definition of "mynext".
End with a line saying just "end".
>print "------"
>print Location:
>where
>print "-------------"
>print Code:
>list
>print "---------------------"
>print Next:
>next
>end

这就是输出:

$1 = "-----"
....

我期待:

-----
....

我也使用了printf(" opopo"),但它打印了" opopo"的返回值。这就是5.就像这样:$ 4 = 5

我的问题是:如何在没有以下格式的情况下打印:$ [num] = [value]。

1 个答案:

答案 0 :(得分:1)

如您所见, - (void) test { Car *c1; NSData *actualOutput = [c1 f1]; //Reading from file NSBundle* bundle = [NSBundle bundleForClass:[self class]]; NSURL* fileName1 = [bundle URLForResource:@"expected" withExtension:@"txt"]; NSData *expectedData = [NSData dataWithContentsOfFile:[fileName1.path stringByExpandingTildeInPath]]; XCTAssertEqualObjects(actualOutput, expectedOutput); } 将打印值放入值历史记录中。 gdb提供了两种避免这种情况的方法。

一个是print。这有点像C函数,但是是一个gdb命令。使用它像:

printf

另一个是(gdb) printf "whatever you like\n" whatever you like (gdb) 。这有点像output命令,但不会将值输入值历史记录。

print

您可以从中看到(gdb) output 5 5(gdb) 也不会发出尾随换行符。你必须自己添加。