To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

TrapManager.scala 1.47 KB
Newer Older
1
2
3
package uvm.refimpl.itpr

import uvm.refimpl._
4
import scala.collection.mutable.HashSet
5
6
7
8
9

class TrapManager(microVM: MicroVM) {
  var trapHandler: TrapHandler = DefaultTrapHandler
  var undefinedFunctionHandler: UndefinedFunctionHandler = DefaultUndefinedFunctionHandler

10
11
12
13
14
15
16
17
  private val enabledWatchPoints = new HashSet[Int]()

  def isWatchPointEnabled(wpID: Int): Boolean = enabledWatchPoints.contains(wpID)

  def enableWatchPoint(wpID: Int): Unit = enabledWatchPoints.add(wpID)

  def disableWatchPoint(wpID: Int): Unit = enabledWatchPoints.remove(wpID)

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  object DefaultTrapHandler extends TrapHandler {
    def handleTrap(ca: ClientAgent, thread: Handle, stack: Handle, watchPointID: Int): TrapHandlerResult = {
      val thr = thread.vb.asInstanceOf[BoxThread].thread.get
      val thrID = thr.id
      val funcVerID = ca.currentFuncVer(stack, 0)
      val funcVer = microVM.globalBundle.funcVerNs(funcVerID)
      val instID = ca.currentInstruction(stack, 0)
      val inst = microVM.globalBundle.varNs(instID)
      throw new UvmRuntimeException("Unhandled trap. Thread %d, funcver %s, trap inst %s, watch point ID %d".format(
        thr.id, funcVer.repr, inst.repr, watchPointID))
    }
  }

  object DefaultUndefinedFunctionHandler extends UndefinedFunctionHandler {
    def handleUndefinedFunction(functionID: Int): Unit = {
      val func = microVM.globalBundle.funcNs(functionID)
      throw new UvmRuntimeException("Unhandled undefined function. Function %s.".format(func.repr))
    }
  }
}