What does repeat n times mean in gdb debugger?

For example:

bool plugin::checkQuality(string &text)
    string temp = normalizeContent(text, 1);
    map<string, int> mapWords;
    matchWords(temp.c_str(), mapWords);

Once gdb enter this function, I can see the value as:

plugin::checkQuality (this=0x7fffffffd9c0, 
    text="This is a test", ' ' <repeats 20 times>, "c,,,,")
    at /mod/filter/plugin.cpp:59

What does the 2nd argument <repeats 20 times> means? And what’s the 3rd argument "c,,,,"?
Isn’t the function only have one argument?

>Solution :

This is just the default behavior of how GDB prints more than 10 consecutive identical elements in an array. From the 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.

So in your example, the value of the parameter text appears to be

"This is a test                    c,,,,"

You can set the threshold for how many characters need to be repeated before this is printed with

set print repeats <number-of-repeats>

Leave a Reply