Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading