def autofill(*autofill_fields):
    """
    Decorator to automatically fill in extra useful fields
    that aren't stored in the db.
    """
    def wrap( reader ):
        def wrapped_reader( *args, **kw ):
            rec = reader( *args, **kw )
            if rec is not None:
                for field in autofill_fields:
                    if field == "opcode" and 'opcode' not in rec.keys():
                        assert 'op' in rec.keys(), "BUG: record is missing 'op'"
                        rec['opcode'] = op_get_opcode_name(rec['op'])
                    else:
                        raise Exception("Unknown autofill field '%s'" % field)

            return rec
        return wrapped_reader
    return wrap
Decorator to automatically fill in extra useful fields
    that aren't stored in the db.