gdb, btrace: diagnose double and failed enable
GDB silently ignores attempts to enable branch tracing on a thread that is
already recorded. This shouldn't happen as recording is enabled exactly
once:
- when the btrace record target is opened for existing threads
- when a new thread is added while the btrace record target is pushed
GDB also silently ignores if recording is disabled on threads that were not
recorded. This shouldn't happen, either, since when stopping recording,
we only disable recording on threads that were recorded.
GDB further silently ignores if recording was not enabled by the
corresponding target method. Also this shouldn't happen since the target
is supposed to already throw an error if recording cannot be enabled.
This new error in btrace_enable catches cases where the target silently
failed to enable recording.
Throw an error in those cases.
This allows us to detect an actual issue more easily. It will be
addressed in the next patch.
gdb/ChangeLog:
2020-03-19 Markus Metzger <markus.t.metzger@intel.com>
* btrace.c (btrace_enable): Throw an error on double enables and
when enabling recording fails.
(btrace_disable): Throw an error if the thread is not recorded.