# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/depend.py
# def decodeDependencySet(text):
#     if not text:
#         return DependencySet()
#     r, w = text.split("->")
#     reads = set(x.strip() for x in r.split(","))
#     writes = set(x.strip() for x in w.split(","))
#     return DependencySet(splitRegisters(reads), splitRegisters(writes))
# 
# def encodeDependencySet(depset):
#     return ", ".join(str(x) for x in joinRegisters(depset.reads)) + " -> " + ", ".join(str(x) for x in joinRegisters(depset.writes))
# 
# def unknownDependencySet():
#     return DependencySet(ALL_REGS - set(['FZ', 'FC', 'FN', 'FH']), ALL_REGS - set(['ROMBANK']))
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# Path: awake/textrenderer.py
# class HtmlRenderer(Renderer):
#     def __init__(self, database):
#         super(HtmlRenderer, self).__init__(database)
#         self.content = []
# 
#     def getContents(self):
#         return '<pre>' + (''.join(self.content)) + '</pre>'
# 
#     def _add(self, text, klass=None, url=None):
#         text = str(text)
#         if klass:
#             text = '<span class="{1}">{0}</span>'.format(text, klass)
#         if url:
#             text = '<a href="{1}">{0}</a>'.format(text, url)
#         self.content.append(text)


import sqlite3
        import Image
from contextlib import closing
from awake import address
from awake.depend import decodeDependencySet, encodeDependencySet, unknownDependencySet
from awake.operand import ProcAddress
from awake.textrenderer import HtmlRenderer
        self.tail_calls = set()
        c.execute('select destination, type from calls where source=?', (addr,))
        for dest, calltype in c.fetchall():
            if calltype == 'tail':
                self.tail_calls.add(dest)
            else:
                self.calls.add(dest)

        self.memreads = set()
        self.memwrites = set()
        c.execute('select addr, type from memref where proc=?', (addr,))
        for address, reftype in c.fetchall():
            if reftype == 'read':
                self.memreads.add(address)
            else:
                self.memwrites.add(address)

        self.callers = set()
        c.execute('select source from calls where destination=?', (addr,))
        for src, in c.fetchall():
            self.callers.add(src)

        c.close()

    def save(self, connection):
        c = connection.cursor()
        c.execute('select addr from procs where addr=?', (self.addr,))
        if not c.fetchone():
            c.execute('insert into procs(addr) values (?)', (self.addr,))
        c.execute('update procs set type=?, depset=?, has_switch=?, suspicious_switch=?, has_suspicious_instr=? , has_nop=?, has_ambig_calls=?, length=? where addr=?',

# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/depend.py
# def decodeDependencySet(text):
#     if not text:
#         return DependencySet()
#     r, w = text.split("->")
#     reads = set(x.strip() for x in r.split(","))
#     writes = set(x.strip() for x in w.split(","))
#     return DependencySet(splitRegisters(reads), splitRegisters(writes))
# 
# def encodeDependencySet(depset):
#     return ", ".join(str(x) for x in joinRegisters(depset.reads)) + " -> " + ", ".join(str(x) for x in joinRegisters(depset.writes))
# 
# def unknownDependencySet():
#     return DependencySet(ALL_REGS - set(['FZ', 'FC', 'FN', 'FH']), ALL_REGS - set(['ROMBANK']))
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# Path: awake/textrenderer.py
# class HtmlRenderer(Renderer):
#     def __init__(self, database):
#         super(HtmlRenderer, self).__init__(database)
#         self.content = []
# 
#     def getContents(self):
#         return '<pre>' + (''.join(self.content)) + '</pre>'
# 
#     def _add(self, text, klass=None, url=None):
#         text = str(text)
#         if klass:
#             text = '<span class="{1}">{0}</span>'.format(text, klass)
#         if url:
#             text = '<a href="{1}">{0}</a>'.format(text, url)
#         self.content.append(text)


# Path: awake/database.py
import sqlite3
        import Image
from contextlib import closing
from awake import address
from awake.depend import decodeDependencySet, encodeDependencySet, unknownDependencySet
from awake.operand import ProcAddress
from awake.textrenderer import HtmlRenderer

        self.tail_calls = set()
        c.execute('select destination, type from calls where source=?', (addr,))
        for dest, calltype in c.fetchall():
            if calltype == 'tail':
                self.tail_calls.add(dest)
            else:
                self.calls.add(dest)

        self.memreads = set()
        self.memwrites = set()
        c.execute('select addr, type from memref where proc=?', (addr,))
        for address, reftype in c.fetchall():
            if reftype == 'read':
                self.memreads.add(address)
            else:
                self.memwrites.add(address)

        self.callers = set()
        c.execute('select source from calls where destination=?', (addr,))
        for src, in c.fetchall():
            self.callers.add(src)

        c.close()

    def save(self, connection):
        c = connection.cursor()
        c.execute('select addr from procs where addr=?', (self.addr,))
        if not c.fetchone():
            c.execute('insert into procs(addr) values (?)', (self.addr,))
        c.execute('update procs set type=?, depset=?, has_switch=?, suspicious_switch=?, has_suspicious_instr=? , has_nop=?, has_ambig_calls=?, length=? where addr=?',

                  (self.type, encodeDependencySet(self.depset), int(self.has_switch), int(self.suspicious_switch), int(self.has_suspicious_instr), int(self.has_nop), int(self.has_ambig_calls), self.length, self.addr))