debug.py revision 11802
15860Snate@binkert.org# Copyright (c) 2008 The Hewlett-Packard Development Company 25860Snate@binkert.org# All rights reserved. 35860Snate@binkert.org# 45860Snate@binkert.org# Redistribution and use in source and binary forms, with or without 55860Snate@binkert.org# modification, are permitted provided that the following conditions are 65860Snate@binkert.org# met: redistributions of source code must retain the above copyright 75860Snate@binkert.org# notice, this list of conditions and the following disclaimer; 85860Snate@binkert.org# redistributions in binary form must reproduce the above copyright 95860Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 105860Snate@binkert.org# documentation and/or other materials provided with the distribution; 115860Snate@binkert.org# neither the name of the copyright holders nor the names of its 125860Snate@binkert.org# contributors may be used to endorse or promote products derived from 135860Snate@binkert.org# this software without specific prior written permission. 145860Snate@binkert.org# 155860Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165860Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175860Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185860Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195860Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205860Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215860Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225860Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235860Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245860Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255860Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265860Snate@binkert.org# 275860Snate@binkert.org# Authors: Nathan Binkert 285860Snate@binkert.org 298269Snate@binkert.orgfrom UserDict import DictMixin 308269Snate@binkert.org 3111802Sandreas.sandberg@arm.comimport _m5.debug 3211802Sandreas.sandberg@arm.comfrom _m5.debug import SimpleFlag, CompoundFlag 3311802Sandreas.sandberg@arm.comfrom _m5.debug import schedBreak, setRemoteGDBPort 348269Snate@binkert.orgfrom m5.util import printList 358232Snate@binkert.org 368232Snate@binkert.orgdef help(): 378232Snate@binkert.org print "Base Flags:" 388269Snate@binkert.org for name in sorted(flags): 398269Snate@binkert.org if name == 'All': 408269Snate@binkert.org continue 418269Snate@binkert.org flag = flags[name] 428269Snate@binkert.org children = [c for c in flag.kids() ] 438269Snate@binkert.org if not children: 448269Snate@binkert.org print " %s: %s" % (name, flag.desc()) 458232Snate@binkert.org print 468232Snate@binkert.org print "Compound Flags:" 478269Snate@binkert.org for name in sorted(flags): 488269Snate@binkert.org if name == 'All': 498232Snate@binkert.org continue 508269Snate@binkert.org flag = flags[name] 518269Snate@binkert.org children = [c for c in flag.kids() ] 528269Snate@binkert.org if children: 538269Snate@binkert.org print " %s: %s" % (name, flag.desc()) 548269Snate@binkert.org printList([ c.name() for c in children ], indent=8) 558269Snate@binkert.org print 568232Snate@binkert.org 578269Snate@binkert.orgclass AllFlags(DictMixin): 588232Snate@binkert.org def __init__(self): 598232Snate@binkert.org self._version = -1 608232Snate@binkert.org self._dict = {} 618232Snate@binkert.org 628232Snate@binkert.org def _update(self): 6311802Sandreas.sandberg@arm.com current_version = _m5.debug.getAllFlagsVersion() 648232Snate@binkert.org if self._version == current_version: 658232Snate@binkert.org return 668232Snate@binkert.org 678232Snate@binkert.org self._dict.clear() 6811802Sandreas.sandberg@arm.com for flag in _m5.debug.getAllFlags(): 698232Snate@binkert.org self._dict[flag.name()] = flag 708232Snate@binkert.org self._version = current_version 718232Snate@binkert.org 728232Snate@binkert.org def __contains__(self, item): 738232Snate@binkert.org self._update() 748232Snate@binkert.org return item in self._dict 758232Snate@binkert.org 768232Snate@binkert.org def __getitem__(self, item): 778232Snate@binkert.org self._update() 788232Snate@binkert.org return self._dict[item] 798232Snate@binkert.org 808232Snate@binkert.org def keys(self): 818232Snate@binkert.org self._update() 828232Snate@binkert.org return self._dict.keys() 838232Snate@binkert.org 848232Snate@binkert.org def values(self): 858232Snate@binkert.org self._update() 868232Snate@binkert.org return self._dict.values() 878232Snate@binkert.org 888232Snate@binkert.org def items(self): 898232Snate@binkert.org self._update() 908232Snate@binkert.org return self._dict.items() 918232Snate@binkert.org 928232Snate@binkert.org def iterkeys(self): 938232Snate@binkert.org self._update() 948232Snate@binkert.org return self._dict.iterkeys() 958232Snate@binkert.org 968232Snate@binkert.org def itervalues(self): 978232Snate@binkert.org self._update() 988232Snate@binkert.org return self._dict.itervalues() 998232Snate@binkert.org 1008232Snate@binkert.org def iteritems(self): 1018232Snate@binkert.org self._update() 1028232Snate@binkert.org return self._dict.iteritems() 1038232Snate@binkert.org 1048232Snate@binkert.orgflags = AllFlags() 105