WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

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.17 KB
Newer Older
1
2
3
package uvm.refimpl.itpr

import uvm.refimpl._
4
import scala.collection.mutable.HashSet
5

6
class TrapManager(implicit microVM: MicroVM) {
7
8
  var trapHandler: TrapHandler = DefaultTrapHandler

9
10
11
12
13
14
15
16
  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)

17
  object DefaultTrapHandler extends TrapHandler {
Kunshan Wang's avatar
Kunshan Wang committed
18
19
    def handleTrap(ctx: MuCtx, thread: MuThreadRefValue, stack: MuStackRefValue, watchPointID: Int): TrapHandlerResult = {
      val thrID = thread.vb.asInstanceOf[BoxThread].thread.get.id
Kunshan Wang's avatar
Kunshan Wang committed
20
21
22
23
24
25
26
27
      val staID = stack.vb.asInstanceOf[BoxStack].stack.get.id
      val cursor = ctx.newCursor(stack)
      val curFuncID = ctx.curFunc(cursor)
      val curFuncVerID = ctx.curFuncVer(cursor)
      val curInstID = ctx.curInst(cursor)
      ctx.closeCursor(cursor)
      throw new UvmRuntimeException("Unhandled trap. thread %d, stack: %d, func: %d, funcver: %d, inst %d, watch point ID %d".format(
        thrID, staID, curFuncID, curFuncVerID, curInstID, watchPointID))
28
29
30
31
    }
  }

}