예제 #1
0
    def __init__(self, s):
        token_defaults = {
            'NAME': (()),
            'DESC': '',
            'OBSOLETE': 0,
            'SUP': (()),
            'STRUCTURAL': None,
            'AUXILIARY': None,
            'ABSTRACT': None,
            'MUST': (()),
            'MAY': (),
            'X-ORIGIN': '',
        }

        l = split_tokens(s)
        self.oid = l[1]
        self.tokens = extract_tokens(l, token_defaults)

        self.kind = 0

        if self.tokens['ABSTRACT'] != None:
            self.kind = 1
        elif self.tokens['AUXILIARY'] != None:
            self.kind = 2
        if self.kind == 0 and not self.tokens['SUP'] and self.oid != '2.5.6.0':
            self.tokens['SUP'] = ('top', )
예제 #2
0
def get_locals_or_args(app, do_locals=True):
    if do_locals:
        app.my.gdb.send('info locals')
    else:
        app.my.gdb.send('info args')
    s = app.my.gdb.proc.read_until(app.my.gdb.proc.stdout(), '(gdb) ')
    mylocals = dict()
    for line in s.split('\n'):
        if ' = ' in line:
            k, v = line.split(' = ', 1)
            b = tokenizer.split_tokens(v)
            mv = b[-1]
            if mv.startswith('times>'): mv = b[0]
            if mv[0] == "'" and len(
                    mv) > 3:  # turn gdb's gay octal literals into hex
                charval = mv[1:-1]
                if charval[0] == '\\' and isnumeric(charval[1]):
                    foo = int(charval[1:], 8)
                    mv = "'\\x" + chr(foo).encode('hex') + "'"
            elif mv[0] == '"':
                mv = hexify_string_literal(mv)
            elif isnumeric(mv) and int(mv) > 0xffff:
                mv = hex(int(mv))
            elif 'out of bounds>' in v:
                mv = '<OOB>'
            elif mv == '}':
                mv = v
            mylocals[k] = (mv, v)
    if do_locals:
        app.my.locals.update(mylocals)
    else:
        app.my.args.update(mylocals)
예제 #3
0
    def __init__(self, s=''):
        token_defaults = {
            'NAME': (()),
            'DESC': (None, ),
            'OBSOLETE': None,
            'SUP': (()),
            'EQUALITY': (None, ),
            'ORDERING': (None, ),
            'SUBSTR': (None, ),
            'SYNTAX': (None, ),
            'SINGLE-VALUE': None,
            'COLLECTIVE': None,
            'NO-USER-MODIFICATION': None,
            'USAGE': ('userApplications', ),
            'X-ORIGIN': (None, ),
            'X-ORDERED': (None, ),
            'X-RDBM-ADD': (None, ),
        }

        if s:

            l = split_tokens(s)
            self.oid = l[1]
            self.tokens = extract_tokens(l, token_defaults)

            try:
                syntax = self.tokens['SYNTAX'][0]
            except IndexError:
                self.syntax = None
                self.syntax_len = None
            else:
                if syntax is None:
                    self.syntax = None
                    self.syntax_len = None
                else:
                    try:
                        self.syntax, syntax_len = self.tokens['SYNTAX'][
                            0].split("{")
                    except ValueError:
                        self.syntax = self.tokens['SYNTAX'][0]
                        self.syntax_len = None
                        for i in l:
                            if i.startswith("{") and i.endswith("}"):
                                self.syntax_len = int(i[1:-1])
                    else:
                        self.syntax_len = int(syntax_len[:-1])