# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: Repository.py
# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
# The above named program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License version 2 as published by the Free Software Foundation.
# The above named program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public
# License along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# ========== Copyright Header End ============================================
"""repository for focus object, breakpoints, watchpoints, etc.
msghead_dbx
= "DBX-" + msghead
# a global id counter to generate unique ids for watchpoints, breakpoints,
# etc. Use Repository.nextid() to receive the next available id.
"""function used to generate a unique id for watchpoints, breakpoints, etc.
"""class that serves as repository for shared data
globals - top level globals(), so that we can eval() expression in
other places as they are at top level.
# the current focus module, in original string
# the corresponding riesling backend module
# 1 means in rioesling interpreter mode, otherwise in normal python
# 1 means output message will be printed
# pointer (as uint64_t) to backend system object
# array to cpu/core/strand objects
# used in sam mode to indicate whether blaze is running or not,
# blaze must be in 'stop" mode when conduct breakpoint operaiton.
# this variable remains as 0 when not in sam mode.
# keep track of blaze numcpu and corresponding pmask
# indicate the type of cpu architecture, e.g., n2, etc
def addBreakpoint (self
, breakpoint
):
if self
.breakpoints
.has_key(breakpoint
.id):
raise KeyError, "duplicated breakpoint id %d" % breakpoint
.id
self
.breakpoints
[breakpoint
.id] = breakpoint
def deleteBreakpoint (self
, id):
if self
.breakpoints
.has_key(idstr
):
del self
.breakpoints
[idstr
]
raise KeyError, "does not have breakpoint with id=%s" % idstr
def showBreakpoint (self
, focus
=None):
ids
= self
.breakpoints
.keys()
bpoint
= self
.breakpoints
[id]
if (focus
== None) or (focus
== bpoint
.modSrc
):
result
.append("id=%s, mod=%s, cmd='%s', action=%s" % (bpoint
.id, bpoint
.modSrc
, bpoint
.src
, bpoint
.action
))
def addWatchpoint (self
, watchpoint
):
if self
.watchpoints
.has_key(watchpoint
.id):
raise KeyError, "duplicated watchpoint id %d" % watchpoint
.id
self
.watchpoints
[watchpoint
.id] = watchpoint
def showWatchpoint (self
):
ids
= self
.watchpoints
.keys()
wpoint
= self
.watchpoints
[id]
result
.append("id=%s, disable=%d, cmd='%s', watch='%s', action=%s" % (wpoint
.id, wpoint
.disable
, wpoint
.src
, wpoint
.watch
, wpoint
.action
))
result
.append("DBX: id=%s, watchExpr=%s" % (wpoint
.id, wpoint
.watchExpr
)) #dbx
if __name__
== "__main__":