[lldb][AArch64] Use unique_ptr instead of statics in RegisterTypeDetector (#214515)
Fixes #214264.
I used static variables for the created types, on the assumption
that only one detector would be used and that the host's
features would not change.
That is true for an lldb-server on a real Linux/FreeBSD system.
It is not true when we use the detector with core files. In the
same LLDB session you might load several files that came from
systems with different features.
The result was that the first detection sets up the static variables
and future detections do not update them. So subsequent core
files can have incorrect types.
(and in future if types vary per-process, we could have the same
issue in lldb-server)
To address this I am changing where the types are stored so that
each instance of the detector has its own set of types for which
it manages the lifetime.
* There is a vector of unique pointers to types. This vector
is a member, so is per instance of the detector class.
* As new types are added to this vector, it may reallocate,
but the location of the RegisterTypes themselves will stay
the same, this is important.
* Detector functions use MakeType to create types, and MakeType
handles managing the vector. Nothing else accesses the vector
directly.
* MakeType returns a raw pointer to the type.
* Detector functions return a raw pointer to the top level
type for the register. For example if it has flags that
have enums for their fields, the flags type is the top level
type.
* These top level raw pointers are given to the rest of LLDB.
* We assume that the lifetime of the dector is > that of anyone
using the raw pointers.
* When the detector destructs, the unique pointers destruct and
the RegisterTypes are freed.
This handing out of raw pointers is likely a bad idea, but I
want to keep the changes here within the detector.
All existing tests pass, and I have added a test that loads 2
core files with different features. That test fails without
these changes because the STORE_ONLY feature is detected
incorrectly.