https://github.com/llvm/llvm-project/pull/165996 is adding a Clang dependency to Target because we're moving some of the functionality of the VerboseTrapFrameRecognizer into libClang. To avoid adding this dependency this patch moves VerboseTrapFrameRecognizer into the CPPLanguageRuntime. Most of the frame recognizers already live in the various runtime plugins. An alternative discussed was to create a common `CLanguageRuntime` whose currently sole responsibility was to register the `VerboseTrapFrameRecognizer` and `AssertStackFrameRecognizer`. The main issue I ran into here was frame recognizers aren't uniqued in the target. Currently this only manifests when re-running a target, which re-triggers all the recognizer registration (added a test with a FIXME for this). If we had a common `CLanguageRuntime` that `CPPLanguageRuntime` and `ObjCLanguageRuntime` inherited from, I didn't find a great way to avoid registering the recognizer multiple times. We can't just call_once on it because we do want the recognisers to be re-registered for new targets in the same debugger session. If the recognisers were stored in something like a UniqueVector in the Target, then we wouldn't have that issue. But currently that's not the case, and it would take a bit of refactoring to de-dupe the recognisers. There may very well be solutions I haven't considered, but all the things I've tried so far I wasn't very happy with. So in the end I just moved this to the C++ runtime for now in order to unblock https://github.com/llvm/llvm-project/pull/165996. The C++ language runtime is always available (even for C targets) if the C++ language plugin is available. Which it should also be unless someone is using an LLDB with the C++ plugin compiled out. But at that point numerous things wouldn't work when even debugging just C.
48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
//===-- VerboseTrapFrameRecognizer.h --------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H
|
|
#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H
|
|
|
|
#include "lldb/Target/StackFrameRecognizer.h"
|
|
|
|
namespace lldb_private {
|
|
|
|
void RegisterVerboseTrapFrameRecognizer(Process &process);
|
|
|
|
/// Holds the stack frame that caused the Verbose trap and the inlined stop
|
|
/// reason message.
|
|
class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame {
|
|
public:
|
|
VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp,
|
|
std::string stop_desc);
|
|
|
|
lldb::StackFrameSP GetMostRelevantFrame() override;
|
|
|
|
private:
|
|
lldb::StackFrameSP m_most_relevant_frame;
|
|
};
|
|
|
|
/// When a thread stops, it checks the current frame contains a
|
|
/// Verbose Trap diagnostic. If so, it returns a \a
|
|
/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason
|
|
/// description with and the parent frame as the most relavant frame.
|
|
class VerboseTrapFrameRecognizer : public StackFrameRecognizer {
|
|
public:
|
|
std::string GetName() override {
|
|
return "Verbose Trap StackFrame Recognizer";
|
|
}
|
|
|
|
lldb::RecognizedStackFrameSP
|
|
RecognizeFrame(lldb::StackFrameSP frame) override;
|
|
};
|
|
|
|
} // namespace lldb_private
|
|
|
|
#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H
|