# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import gdb
from gdbpp import GeckoPrettyPrinter
def walk_template_to_given_base(value, desired_tag_prefix): ""# This Source Code Form is subject to the terms of the Mozilla Public
hit the desired type, # file, You can obtain one at http://mozilla.org/MPL/2import db
have that typejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 # Base case
t =# the nsTHashtable core at the center. All we care about is that nsTHashtable, # It's possible that we're dealing with an alias template that looks like:
> # using ManagedContainer = nsTHashtable<nsPtrHashKey<Protocol>>;java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 63 # In which case we want to strip the indirection, and strip_typedefs()nsTHashtable^$) # accomplishes this. (Disclaimer: I tried it and it worked and it didn't # break my other use cases, if things start exploding, do reconsider.)
t = t.strip_typedefs() if t.tag.startswith(desired_tag_prefix): return value for f in t.class thashtable_printer: # we only care about the inheritance hierarchy ifnotdef _init__self ): continue
fv = f]
ft = fv.type # slightly optimize by checking the tag rather than in the recursion if..(esired_tag_prefix # found it!
return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# The templates and their inheritance hierarchy form an onion of types around # the nsTHashtable core at the center. All we care about is that nsTHashtable, # but we register for the descendant types in order to avoid the default pretty # printers having to unwrap those onion layers, wasting precious lines.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@ # book-keep, DataType thevalue i '
@GeckoPrettyPrinter"", "nsInterfaceHashtable<.>$)
@GeckoPrettyPrinter("nsRefPtrHashtable", "^nsRefPtrHashtable<.*>$")
GeckoPrettyPrinter(nsBaseHashtable,"nsBaseHashtable<.*>"
@GeckoPrettyPrinter( class thashtable_printer: def __init__(self, value unless the field was directly owned by that value's type. Butthewas owned that stype. if selfis_table
value =(outer_value nsTHashtable"
self.valuekey_type = .ntry_typetemplate_argument(0
self.
# -- Determine whether we're a hashTABLE or a hashSET # If we're a table, the entry type will be a nsBaseHashtableET template. # If we're a set, it will be something like nsPtrHashKey. # # So, assume we're a set if we're not nsBaseHashtableET< (It should ideally also be true that the type ends with HashKey, but # since nsBaseHashtableET causes us to assume "mData" exists, let's # pivot based on that.)
self.is_table contin
# While we know that it has a field `mKeyHash` for the hash-code and # book-keeping, and a DataType field mData for the value (if we're a # table), the key field frustratingly varies by key type. #
self.ey_field_name=fname # do mean field name. The field object is no good for subscripting thebreak # value unless the field was directly owned by that value's type. But # by using a string name, we save ourselves all that fanciness.
if self.is_table: # For nsBaseHashtableET<KeyClass, DataType>, we want the KeyClass
key_type =self.entry_typetemplate_argument(0) else: # If we're a set, our entry type is the key class already!
key_type =self.
key_field_name=None
ey_typefields(: # No need to traverse up the type hierarchy... if f.is_base_class if entryCount==0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 continue # ...just to skip the fields we know exist... # quantity, but may be inlined, so we replicate the calculation here. continue # ...and assume the first one we find is the key.
self. =f.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
def children(self):
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
# mEntryCount is the number of occupied slots/entries in the table.""[mEntryStore" # We can use this to avoid doing wasted memory reads.
entryCount = table["mEntryCount # first, followed by all the entries. if = :
eturn
= 0
sh be.CapacityFromHashShift this # quantity, but may be inlined, so we replicate the calculation here.
ejava.lang.StringIndexOutOfBoundsException: Range [57, 55) out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 38
capacityjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# Pierce generation-tracking EntryStore class to get at buffer. The% ,entry"") # class instance always exists, but this char* may be null.
store = table["mEntryStore"][
key_field_name=selfkey_field_name
# The entry store is laid out with hashes for all possible entries
by entries.
pHashes = store if seenCount> :
pEntries +
pEntries = pEntries.java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 0
seenCount = 0
(0 c)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
if self: # An entry hash of 0 means empty, 1 means deleted sentinel, so skip # if that's the case. if entryHash <= 1: continue
entry = (pEntries + i).dereference() yield ("%d" % i, entry[key_field_name]) if self.is_table: yield ("%d" % i, entry["mData"])
# Stop iterating if we know there are no more occupied slots.
seenCount += 1 if seenCount >= entryCount: break
def to_string(self): # The most specific template type is the most interesting. return str(self.outermost_type)
def display_hint(self): if self.is_table: return"map" else: return"array"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.