package breakcfg import ( "reflect" "git.elyanpoujol.fr/elyan/central-arch/pkg/events" ) type BreakableEventId uint /* const ( // CPU events CPU_FETCH_INSTR_BEGIN BreakableEventId = iota CPU_FETCH_INSTR_END CPU_DECODED_INSTR CPU_EXECUTED_INSTR CPU_READ_MEM_REQUEST CPU_WRITE_MEM_REQUEST CPU_MODE_TRANSITION // MMU events MMU_TLB_NEXT_ENTRY MMU_TLB_HIT MMU_TLB_MISS MMU_TLB_EVICT_ENTRY MMU_TLB_NEW_ENTRY MMU_WALK_NEXT_ENTRY MMU_WALK_NEXT_LEVEL MMU_WALK_HIT MMU_WALK_MISS // Cache events CACHE_STEP_NEXT_ENTRY CACHE_STEP_HIT CACHE_STEP_MISS CACHE_EVICT_ENTRY CACHE_NEW_ENTRY // Memory events MEMORY_READ MEMORY_WRITE MEMORY_UNALIGNED_READ MEMORY_UNALIGNED_WRITE // Event count, not a real event BREAKABLE_EVENT_ID_COUNT ) */ type SteppingType uint8 const ( ALLOW_BREAK SteppingType = iota // Default value, allow breakpoints for a given event type ALWAYS_BREAK // Always break even if no breakpoints were set for the event type IGNORE_BREAK // Ignore the breakpoints for the event type ) type BreakableEventConfig struct { eventSteppingTypes map[reflect.Type]SteppingType } func New() *BreakableEventConfig { cfg := &BreakableEventConfig{ eventSteppingTypes: make(map[reflect.Type]SteppingType), } cfg.init() return cfg } func SetSteppingType[T events.SimEvent](cfg *BreakableEventConfig, st SteppingType) { cfg.eventSteppingTypes[key[T]()] = st } func GetSteppingType[T events.SimEvent](cfg *BreakableEventConfig) SteppingType { return cfg.eventSteppingTypes[key[T]()] } func (cfg *BreakableEventConfig) init() { // TODO Add all breakable events SetSteppingType[events.CpuFetchBeginEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuFetchEndEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuDecodedEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuExecuteEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuReadMemoryBeginEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuReadMemoryEndEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuWriteMemoryBeginEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuWriteMemoryEndEvent](cfg, ALLOW_BREAK) SetSteppingType[events.CpuModeTransitionEvent](cfg, ALLOW_BREAK) } func key[T events.SimEvent]() reflect.Type { return reflect.TypeFor[T]() }