예제 #1
0
파일: query.py 프로젝트: fwugist/gdb-heap
def do_query(args):
    from heap import fmt_addr, Table
    from heap.parser import parse_query

    if args == '':
        # if no query supplied, select everything:
        filter_ = Constant(True)
    else:
        filter_ = parse_query(args)

    if False:
        print args
        print filter_

    columns = [
        Column('Start', lambda u: u.start, fmt_addr),
        Column('End', lambda u: u.start + u.size - 1, fmt_addr),
        Column('Domain', lambda u: u.category.domain, None),
        Column('Kind', lambda u: u.category.kind, None),
        Column('Detail', lambda u: u.category.detail, None),
        Column('Hexdump', lambda u: u.hexdump, None),
    ]

    t = Table([col.name for col in columns])

    for u in Query(filter_):
        u.ensure_hexdump()
        u.ensure_category()

        if u.category:
            domain = u.category.domain
            kind = u.category.kind
            detail = u.category.detail
            if not detail:
                detail = ''
        else:
            domain = ''
            kind = ''
            detail = ''

        t.add_row([
            fmt_addr(u.start),
            fmt_addr(u.start + u.size - 1), domain, kind, detail, u.hd
        ])

    t.write(sys.stdout)
    print
예제 #2
0
파일: query.py 프로젝트: PMickael/gdb-heap
def do_query(args):
    from heap import fmt_addr, Table
    from heap.parser import parse_query

    if args == '':
        # if no query supplied, select everything:
        filter_ = Constant(True)
    else:
        filter_ = parse_query(args)

    if False:
        print(args)
        print(filter_)

    columns = [Column('Start',
                      lambda u: u.start,
                      fmt_addr),
               Column('End',
                      lambda u: u.start + u.size - 1,
                      fmt_addr
                      ),
               Column('Domain',
                      lambda u: u.category.domain,
                      None),
               Column('Kind',
                      lambda u: u.category.kind,
                      None),
               Column('Detail',
                      lambda u: u.category.detail,
                      None),
               Column('Hexdump',
                      lambda u: u.hexdump,
                      None),
               ]

    t = Table([col.name for col in columns])

    for u in Query(filter_):
        u.ensure_hexdump()
        u.ensure_category()

        if u.category:
            domain = u.category.domain
            kind = u.category.kind
            detail = u.category.detail
            if not detail:
                detail = ''
        else:
            domain = ''
            kind = ''
            detail = ''

        t.add_row([fmt_addr(u.start),
                   fmt_addr(u.start + u.size - 1),
                   domain,
                   kind,
                   detail,
                   u.hd])

    t.write(sys.stdout)
    print()
예제 #3
0
 def assertParsesTo(self, s, result):
     self.assertEquals(parse_query(s), result)
예제 #4
0
 def assertParsesTo(self, s, result):
     self.assertEquals(parse_query(s), result)