def load(self, keytype, key): dbg.load('loading key in load', keytype, key) if keytype is None: for f in self.sfs: f.seek(0) sq = SyscallQueue(self.sfs) records = iter(lambda: sq.pop(), None) else: records = self._get_records(keytype, key) #if len(records) > 1000: raise Exception('too many records') dbg.load('loaded records in load', records) # bingo! for kf in self.kfs: kf.seek(0) kq = KprobesQueue(self.kfs) pidd = PidDict() for r in records: try: kq.fix(r) # fix inode gen pidd.fix(r) # fix pid gen fix_r(r) # fix args except EOFError: continue except: try: # fixup fs for f in self.sfs: _fix_f(f) continue except: raise StopIteration yield r
def __init__(self, name, osloader=None): """None for osloader refers to the global static OsLoader instance. If a value is passed in for osloader, it will be used instead.""" super(RegisteredObject, self).__init__(name) if RegisteredObject.name_map.has_key(name): raise Exception('duplicate object', name) RegisteredObject.name_map[name] = self self.osloader = osloader dbg.load('registered object', name)
def _dbget(idx, k): #code.interact(local=locals()) dbg.load('key to dbget: ', repr(k)) for i, c in enumerate(idx): dbg.load('i, c ', i, c) pair = c.get(k, bsddb.db.DB_SET) dbg.load('pair ', pair) while pair is not None: v = struct.unpack("=QHI", pair[1]) #'=QHI': [ # unsigned long long (8), unsigned short (2), # unsigned int(4)] # # This corresponds to this struct from //retro/ctl/retroctl.c: # struct { # size_t offset; # uint16_t nr; # uint32_t sid; # ... # } offset = v[0] nr = v[1] sid = v[2] yield (i, offset, nr, sid) pair = c.next_dup()
def load(self, n, what): # ipopov: # - a handler (loader) for RegisteredObjects, for example. # - called within mgrapi.py # cf: mgrapi.LoaderMap.register_loader('ino' , load) enable_incremental = True type = None key = None if n is not None: if n[0] == 'pid': type = 'pid' if n[2] == 'syscall': key = (n[1], n[3]) else: key = (n[1], None) elif n[0] == 'ino' or n[0] == 'dir': type = 'ino' key = (n[1], n[2]) elif n[0] == 'network': type = 'network' key = (n[1], n[2]) else: raise Exception('no incremental loading for', n) if not enable_incremental: return ## normalize the kinds of "what" we support if what != 'writers': what = 'all' if key: key = key + (what, ) keytrack = (type, key, what) #print keytrack, self.loadset #ivodbg if self.is_loaded(keytrack, self.loadset): dbg.load('skipping dup load request', keytrack) return self.loadset.add(keytrack) dbg.load('loading key', type, key) for r in self.index_loader.load(type, key): dbg.load('record', r.sid, r, what, type) # filter out readers when all we want is to load writers if what == 'writers' and type == 'ino': (read, write) = nrdep.check_rw(r) if not write: continue self.parse_record(r)
def load(h, what): dbg.load('loading name', h) dbf = open(os.path.join(logdir, "db.log")) htf = open(os.path.join(logdir, "httpd.log")) q = {} for l in dbf.readlines(): (pids, tss, type, db_path, dataq) = l.strip().split(' ') pid = int(pids) ts = int(tss) php = PhpActor.get(pid) data = urllib.unquote(dataq) if h: if h[0] == 'php': if h[1] != pid: continue elif h[0] == 'db': if h[1] != db_path: continue else: continue if type == 'query': qname = ('dbq', pid, ts) if mgrapi.RegisteredObject.by_name(qname): q[pid] = None continue q[pid] = DbQueryAction(qname) q[pid].tic = (ts, 2) q[pid].argsnode = mgrutil.BufferNode(q[pid].name + ('args', ), (ts, 2), { 'dir': db_path, 'query': data }) x = PhpDbCall(php, q[pid].argsnode) x.tic = (ts, 1) x.tac = (ts, 2) x.connect() if type == 'query_result' and q[pid]: q[pid].tac = (ts, 2) q[pid].retnode = mgrutil.BufferNode(q[pid].name + ('ret', ), (ts, 2), data) q[pid].connect() x = PhpDbRet(php, q[pid].retnode) x.tic = (ts, 2) x.tac = (ts, 3) x.connect() for l in htf.readlines(): x = l.strip().split(' ') if len(x) == 4: (pids, tss, type, subtype) = x dataq = '' else: (pids, tss, type, subtype, dataq) = x pid = int(pids) ts = int(tss) data = urllib.unquote(dataq) if h: if h[0] != 'php' or h[1] != pid: continue p_actor = PhpActor.get(pid) if type == 'httpreq_start': qname = p_actor.name + ('htargs', ) if mgrapi.RegisteredObject.by_name(qname): q[pid] = None continue q[pid] = {'env': {}, 'post': ''} an = mgrutil.BufferNode(qname, (ts, 2), q[pid]) ph_call = PhpStart(p_actor, an) ph_call.tic = (ts, 5) ph_call.tac = (ts, 6) ph_call.connect() if not q[pid]: continue if type == 'httpreq_env': q[pid]['env'][subtype] = data if subtype == 'HTTP_X_CLIENT_ID': ## XXX: relies on CLIENT_ID coming before PAGE_ID p_actor.clientid = data if subtype == 'HTTP_X_PAGE_ID': p_actor.pageid = data if type == 'httpreq_end': qname = p_actor.name + ('htargs', ) an = mgrapi.RegisteredObject.by_name(qname) p_actor_ts = min(p_actor.actions).tic[0] bp = BrowserPageActor.get(p_actor.clientid, p_actor.pageid, (p_actor_ts, 0)) breq_start = BrowserReqStart(bp, an) breq_start.tic = (p_actor_ts, 3) breq_start.tac = (p_actor_ts, 4) breq_start.connect() breq_start.connect_script() if type == 'httpreq_post': q[pid]['post'] = data if type == 'httpreq_cwd': q[pid]['cwd'] = data if type == 'httpresp': an = mgrutil.BufferNode(p_actor.name + ('htret', ), (ts, 2), data) ht_call = HttpResponse(an) ht_call.tic = (ts, 7) ht_call.tac = (ts, 8) ht_call.connect() ph_call = PhpExit(p_actor, an) ph_call.tic = (ts, 3) ph_call.tac = (ts, 4) ph_call.connect() bp = BrowserPageActor.get(p_actor.clientid, p_actor.pageid, ts) breq_end = BrowserReqExit(bp, an) breq_end.tic = (ts, 5) breq_end.tac = (ts, 6) breq_end.connect()