-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systop: Fix wrong context between enter and exit
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
118 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "231110" | ||
__revision__ = "231113" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -954,7 +954,7 @@ class ConfigMgr(object): | |
"audit_read", | ||
] | ||
|
||
# syscall prototypes # | ||
# defferable syscall prototypes # | ||
SYSCALL_DEFFERABLE = { | ||
"clock_gettime": 0, | ||
"clone": 0, | ||
|
@@ -979,6 +979,11 @@ class ConfigMgr(object): | |
"recvmsg": 0, | ||
} | ||
|
||
# defferable syscall return prototypes # | ||
SYSCALL_DEFFERABLE_RET = { | ||
"ppoll": 0, | ||
} | ||
|
||
# syscall prototypes # | ||
SYSCALL_PROTOTYPES = { | ||
"accept": ( | ||
|
@@ -5753,18 +5758,41 @@ class ConfigMgr(object): | |
] | ||
|
||
# fcntl command flags # | ||
FCNTL_TYPE = [ | ||
"F_DUPFD", | ||
"F_GETFD", | ||
"F_SETFD", | ||
"F_GETFL", | ||
"F_SETFL", | ||
"F_GETOWN", | ||
"F_SETOWN", | ||
"F_GETLK", | ||
"F_SETLK", | ||
"F_SETLKW", | ||
] | ||
FCNTL_TYPE = { | ||
0: "F_DUPFD", | ||
1: "F_GETFD", | ||
2: "F_SETFD", | ||
3: "F_GETFL", | ||
4: "F_SETFL", | ||
5: "F_GETOWN", | ||
6: "F_SETOWN", | ||
7: "F_GETLK", | ||
8: "F_SETLK", | ||
9: "F_SETLKW", | ||
10: "F_SETOWN", | ||
11: "F_GETOWN", | ||
12: "F_SETSIG", | ||
13: "F_GETSIG", | ||
14: "F_GETLK64", | ||
15: "F_SETLK64", | ||
16: "F_SETLKW64", | ||
17: "F_SETOWNEX", | ||
18: "F_GETOWNEX", | ||
19: "F_GETOWNERUIDS", | ||
1024: "F_SETLEASE", | ||
1025: "F_GETLEASE", | ||
1026: "F_NOTIFY", | ||
1029: "F_CANCELLK", | ||
1030: "F_DUPFD_CLOEXEC", | ||
1031: "F_SETPIPE_SZ", | ||
1032: "F_GETPIPE_SZ", | ||
1033: "F_ADD_SEALS", | ||
1034: "F_GET_SEALS", | ||
1035: "F_GET_RW_HINT", | ||
1036: "F_SET_RW_HINT", | ||
1037: "F_GET_FILE_RW_HINT", | ||
1038: "F_SET_FILE_RW_HINT", | ||
} | ||
|
||
# ipc call flags # | ||
IPC_TYPE = { | ||
|
@@ -85883,6 +85911,48 @@ def readIoVec(self, addr, cnt, baseAddr=False): | |
def readFdPath(self, fd): | ||
return os.readlink("%s/%s/fd/%s" % (SysMgr.procPath, self.pid, fd)) | ||
|
||
def readTimespec(self, addr): | ||
if not addr: | ||
return None | ||
|
||
ret = self.readMem(addr, 8) | ||
if not ret: | ||
return None | ||
|
||
ret = struct.unpack("ll", ret) | ||
|
||
return "{tv_sec=%s, tv_nsec=%s}" % (ret[0], ret[1]) | ||
|
||
def readPollFds(self, addr, nfds): | ||
if not addr: | ||
return None | ||
|
||
retList = [] | ||
for n in xrange(nfds): | ||
ret = self.readMem(addr, 8) | ||
addr += 8 | ||
if not ret: | ||
continue | ||
|
||
items = struct.unpack("ihh", ret) | ||
if not items: | ||
continue | ||
|
||
fd, reqe, rete = items | ||
path = self.readFdPath(fd) | ||
reqe = UtilMgr.getFlagString(reqe, ConfigMgr.EPOLL_EVENT_TYPE) | ||
rete = UtilMgr.getFlagString(rete, ConfigMgr.EPOLL_EVENT_TYPE) | ||
retList.append( | ||
"{fd=%s%s%s}" | ||
% ( | ||
path, | ||
(", events=%s" % reqe) if reqe else "", | ||
(", revents=%s" % rete) if rete else "", | ||
) | ||
) | ||
|
||
return "[%s]" % ", ".join(retList) | ||
|
||
def readMsgHdr(self, addr=None, obj=None): | ||
if not addr and not obj: | ||
return None | ||
|
@@ -86129,6 +86199,8 @@ def convSyscallParam( | |
value = value & 0xF | ||
if value < len(ConfigMgr.FUTEX_TYPE): | ||
return ConfigMgr.FUTEX_TYPE[value] + "_PRIVATE" | ||
elif argname == "val3" and value == -1: | ||
return "FUTEX_BITSET_MATCH_ANY" | ||
elif syscall == "ptrace" and argname == "request": | ||
try: | ||
return ConfigMgr.PTRACE_TYPE[value] | ||
|
@@ -86368,6 +86440,13 @@ def convSyscallParam( | |
) | ||
return value | ||
|
||
if argtype.startswith("struct pollfd *"): | ||
nfds = self.values[1] | ||
return self.readPollFds(value, nfds) | ||
|
||
if argtype.startswith("struct timespec *"): | ||
return self.readTimespec(value) | ||
|
||
if argname == "resource": | ||
return ConfigMgr.RLIMIT_TYPE[value] | ||
|
||
|
@@ -86391,7 +86470,7 @@ def convSyscallParam( | |
size = self.values[2] | ||
|
||
# handle read buffer # | ||
if syscall in ConfigMgr.SYSCALL_DEFFERABLE: | ||
if self.isDeferCall(syscall): | ||
if retval == 0: | ||
return "" | ||
elif Debugger.dbusEnable: | ||
|
@@ -91559,10 +91638,10 @@ def convSyscallArgs(self, retval=None): | |
return args | ||
|
||
def isDeferCall(self, name): | ||
if name in ConfigMgr.SYSCALL_DEFFERABLE: | ||
return True | ||
else: | ||
return False | ||
return name in ConfigMgr.SYSCALL_DEFFERABLE | ||
|
||
def isDeferRetCall(self, name): | ||
return name in ConfigMgr.SYSCALL_DEFFERABLE_RET | ||
|
||
def addTimelineRet(self, sym, diff, bts, gid=-1, sid=-1): | ||
if not Debugger.envFlags["TIMELINE"] or Debugger.envFlags["INTERCALL"]: | ||
|
@@ -92039,6 +92118,11 @@ def handleSyscall(self): | |
|
||
# get return value from register # | ||
retval = self.getRet() | ||
if retval < 0: | ||
# check wrong context using ENOSYS and syscall number # | ||
if retval == -38 and self.getNrSyscall() > 0: | ||
self.handleSyscall() | ||
return | ||
|
||
# check wait condition # | ||
if self.wait: | ||
|
@@ -92173,6 +92257,21 @@ def handleSyscall(self): | |
diffStr += convColor(interdiffStr, "CYAN") | ||
self.interDiff = 0 | ||
|
||
# print args after return # | ||
if SysMgr.showAll and self.isDeferRetCall(name): | ||
self.args = [] | ||
self.updateSyscallArgs() | ||
|
||
# convert numbers # | ||
args = [ | ||
hex(arg[2]).rstrip("L") | ||
if type(arg[2]) is long | ||
else str(arg[2]) | ||
for arg in self.args | ||
] | ||
argstr = " (%s)" % ", ".join(args) | ||
diffStr += argstr | ||
|
||
# add newline after backtrace # | ||
if self.btStr or self.prevBtStr: | ||
newline = "\n " + (" " * self.indentLen) | ||
|