// Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later namespace SharpEmu.Core.Cpu.Debugging; /// The kind of execution stall the backend detected. public enum CpuStallKind { /// /// The guest is repeatedly re-dispatching the same import with no forward /// progress — most commonly a spin on a mutex lock/unlock pair. /// ImportLoop, } /// /// Details of a detected stall handed to . /// Reported from the emulation thread at the point the backend recognises the /// livelock, before it forces the guest out of the loop. /// public readonly struct CpuStallInfo { public CpuStallInfo( CpuStallKind kind, string? nid, ulong instructionPointer, long dispatchIndex, ulong argument0, ulong argument1, string detail, string? libraryName = null, string? functionName = null) { Kind = kind; Nid = nid; InstructionPointer = instructionPointer; DispatchIndex = dispatchIndex; Argument0 = argument0; Argument1 = argument1; Detail = detail ?? string.Empty; LibraryName = libraryName; FunctionName = functionName; } public CpuStallKind Kind { get; } /// The NID of the import being spun on, when known. public string? Nid { get; } /// The guest return address of the looping import dispatch. public ulong InstructionPointer { get; } /// The import dispatch counter at detection time. public long DispatchIndex { get; } /// The first two guest ABI arguments at stall detection. public ulong Argument0 { get; } public ulong Argument1 { get; } /// The resolved HLE export, when the NID is registered. public string? LibraryName { get; } public string? FunctionName { get; } public bool IsResolved => !string.IsNullOrWhiteSpace(FunctionName); /// A human-readable one-line summary of the stall. public string Detail { get; } }