Re: [PATCH 4/4] gdb: change regcache list to be a map

Simon Marchi
2020-07-30T17:03:49Z

On 2020-07-30 12:58 p.m., Simon Marchi wrote:
> It's down to:
>
> for (auto it = regcaches.begin (); it != regcaches.end ();)
> {
> if (it->second->target () == target)
> it = regcaches.erase (it);
> else
> it++;
> }

Ah, I see that you've provided me a patch for that too (I thought you only
did the multi-level map thing). Your code is:

for (auto it = regcaches.begin (); it != regcaches.end ();)
{
if (it->second->target () == target)
{
delete it->second;
it = regcaches.erase (it);
}
}

I think you are missing an it++ in the else? Otherwise, when the target doesn't
match, we'll get into an infinite loop I presume.

Simon