Fix get_core_register_section leak, introduce thread_section_name
This plugs a leak introduced in the previous change to
get_core_register_section, which removed an xfree call that is
actually necessary because the 'section_name' local is static.
From [1] it looks like the reason the variable was made static to
begin with, was just "laziness" to avoid having to think about freeing
it on every function return path:
https://sourceware.org/ml/gdb-patches/2005-03/msg00237.html
The easiest to fix that nowadays is to use a std::string.
I don't see a need to xstrdup the section name in the single-threaded
case though, and also there's more than one place that computes a
multi-threaded section name in the same way. So put the section name
computation in a wrapper class with state.
gdb/ChangeLog:
2017-05-04 Pedro Alves <palves@redhat.com>
* corelow.c (thread_section_name): New class.
(get_core_register_section, get_core_siginfo): Use it.