def add_tid_fd(self, event, cpu): ret = event["ret"] t = self.tids[cpu.current_tid] # if it's a thread, we want the parent if t.pid != -1 and t.tid != t.pid: t = self.tids[t.pid] current_syscall = self.tids[cpu.current_tid].current_syscall name = current_syscall["filename"] if name not in sv.SyscallConsts.GENERIC_NAMES \ and name in t.closed_fds.keys(): fd = t.closed_fds[name] fd.open += 1 else: fd = sv.FD() fd.filename = name if current_syscall["name"] in sv.SyscallConsts.NET_OPEN_SYSCALLS: fd.family = current_syscall["family"] if fd.family in sv.SyscallConsts.INET_FAMILIES: fd.fdtype = sv.FDType.net fd.open = 1 if ret >= 0: fd.fd = ret else: return if "cloexec" in current_syscall.keys(): fd.cloexec = 1 t.fds[fd.fd] = fd
def get_fd(self, proc, fd): if fd not in proc.fds.keys(): f = sv.FD() f.fd = fd f.filename = "unknown (origin not found)" proc.fds[fd] = f else: f = proc.fds[fd] return f
def _process_lttng_statedump_file_descriptor(self, event): pid = event["pid"] fd = event["fd"] filename = event["filename"] if pid not in self.tids: p = sv.Process() p.pid = pid p.tid = pid self.tids[pid] = p else: p = self.tids[pid] if fd not in p.fds.keys(): newfile = sv.FD() newfile.filename = filename newfile.fd = fd # FIXME: we don't have the info, just assume for now newfile.cloexec = 1 p.fds[fd] = newfile else: # just fix the filename p.fds[fd].filename = filename
def dup_fd(self, fd): f = sv.FD() f.filename = fd.filename f.fd = fd.fd f.fdtype = fd.fdtype return f