在 gdb 调试器中重复 n 次意味着什么?
What does repeat n times mean in gdb debugger?
例如:
bool plugin::checkQuality(string &text)
{
string temp = normalizeContent(text, 1);
map<string, int> mapWords;
matchWords(temp.c_str(), mapWords);
...
}
一旦 gdb 进入这个函数,我可以看到值如下:
plugin::checkQuality (this=0x7fffffffd9c0,
text="This is a test", ' ' <repeats 20 times>, "c,,,,")
at /mod/filter/plugin.cpp:59
第二个参数是什么意思?第三个参数“c,”是什么?
函数不是只有一个参数吗?
这只是 GDB 在数组中打印超过 10 个连续相同元素的默认行为。来自 docs
When the number of consecutive identical elements of an array exceeds the threshold, GDB prints the string "<repeats n times>", where n is the number of identical repetitions, instead of displaying the identical elements themselves.
因此在您的示例中,参数 text
的值似乎是
"This is a test c,,,,"
您可以设置打印前需要重复多少个字符的阈值
set print repeats <number-of-repeats>
例如:
bool plugin::checkQuality(string &text)
{
string temp = normalizeContent(text, 1);
map<string, int> mapWords;
matchWords(temp.c_str(), mapWords);
...
}
一旦 gdb 进入这个函数,我可以看到值如下:
plugin::checkQuality (this=0x7fffffffd9c0,
text="This is a test", ' ' <repeats 20 times>, "c,,,,")
at /mod/filter/plugin.cpp:59
第二个参数
这只是 GDB 在数组中打印超过 10 个连续相同元素的默认行为。来自 docs
When the number of consecutive identical elements of an array exceeds the threshold, GDB prints the string "<repeats n times>", where n is the number of identical repetitions, instead of displaying the identical elements themselves.
因此在您的示例中,参数 text
的值似乎是
"This is a test c,,,,"
您可以设置打印前需要重复多少个字符的阈值
set print repeats <number-of-repeats>