[lldb] Add Guarded<T, Mutex> to Locked.h (#219421)

LLDB's code base has many variables that have an associated mutex that
needs to be locked to safely access that variable from multiple threads.
However, this locking scheme is currently not enforced by the compiler
and code sometimes accesses these variables without aquiring the
respective mutex first.

This patch introduces a `Guarded` class that strictly enforces that some
memory is only accessed after the respective mutex has been aquired.
This class hands out `Locked` objects for every access which guarentee
that the mutex is held as long as the variable is in scope.

GitOrigin-RevId: bcf0cd177d79935537bdebb3313d85c0ea207890
2 files changed