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 2912563Sgabeblack@google.comfrom __future__ import print_function 3012563Sgabeblack@google.com 3113673Sandreas.sandberg@arm.comfrom collections import Mapping 328269Snate@binkert.org 3311802Sandreas.sandberg@arm.comimport _m5.debug 3411802Sandreas.sandberg@arm.comfrom _m5.debug import SimpleFlag, CompoundFlag 3511802Sandreas.sandberg@arm.comfrom _m5.debug import schedBreak, setRemoteGDBPort 368269Snate@binkert.orgfrom m5.util import printList 378232Snate@binkert.org 388232Snate@binkert.orgdef help(): 3912563Sgabeblack@google.com print("Base Flags:") 408269Snate@binkert.org for name in sorted(flags): 418269Snate@binkert.org if name == 'All': 428269Snate@binkert.org continue 438269Snate@binkert.org flag = flags[name] 448269Snate@binkert.org children = [c for c in flag.kids() ] 458269Snate@binkert.org if not children: 4612563Sgabeblack@google.com print(" %s: %s" % (name, flag.desc())) 4712563Sgabeblack@google.com print() 4812563Sgabeblack@google.com print("Compound Flags:") 498269Snate@binkert.org for name in sorted(flags): 508269Snate@binkert.org if name == 'All': 518232Snate@binkert.org continue 528269Snate@binkert.org flag = flags[name] 538269Snate@binkert.org children = [c for c in flag.kids() ] 548269Snate@binkert.org if children: 5512563Sgabeblack@google.com print(" %s: %s" % (name, flag.desc())) 568269Snate@binkert.org printList([ c.name() for c in children ], indent=8) 5712563Sgabeblack@google.com print() 588232Snate@binkert.org 5913673Sandreas.sandberg@arm.comclass AllFlags(Mapping): 608232Snate@binkert.org def __init__(self): 618232Snate@binkert.org self._version = -1 628232Snate@binkert.org self._dict = {} 638232Snate@binkert.org 648232Snate@binkert.org def _update(self): 6511802Sandreas.sandberg@arm.com current_version = _m5.debug.getAllFlagsVersion() 668232Snate@binkert.org if self._version == current_version: 678232Snate@binkert.org return 688232Snate@binkert.org 698232Snate@binkert.org self._dict.clear() 7012008Sandreas.sandberg@arm.com for name, flag in _m5.debug.allFlags().items(): 7112008Sandreas.sandberg@arm.com self._dict[name] = flag 728232Snate@binkert.org self._version = current_version 738232Snate@binkert.org 748232Snate@binkert.org def __contains__(self, item): 758232Snate@binkert.org self._update() 768232Snate@binkert.org return item in self._dict 778232Snate@binkert.org 788232Snate@binkert.org def __getitem__(self, item): 798232Snate@binkert.org self._update() 808232Snate@binkert.org return self._dict[item] 818232Snate@binkert.org 8213673Sandreas.sandberg@arm.com def __iter__(self): 8313673Sandreas.sandberg@arm.com self._update() 8413673Sandreas.sandberg@arm.com return iter(self._dict) 8513673Sandreas.sandberg@arm.com 8613673Sandreas.sandberg@arm.com def __len__(self): 8713673Sandreas.sandberg@arm.com self._update() 8813673Sandreas.sandberg@arm.com return len(self._dict) 8913673Sandreas.sandberg@arm.com 908232Snate@binkert.org def keys(self): 918232Snate@binkert.org self._update() 928232Snate@binkert.org return self._dict.keys() 938232Snate@binkert.org 948232Snate@binkert.org def values(self): 958232Snate@binkert.org self._update() 968232Snate@binkert.org return self._dict.values() 978232Snate@binkert.org 988232Snate@binkert.org def items(self): 998232Snate@binkert.org self._update() 1008232Snate@binkert.org return self._dict.items() 1018232Snate@binkert.org 1028232Snate@binkert.orgflags = AllFlags() 103