Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for unfinished and resumed operations. #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions villoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ def parse_ltrace(ltrace):

match_call = re.compile(r"^([A-z_\.]+->)?([A-z_]+)\((.*)\) += (.*)$")
match_err = re.compile(r"^([A-z_\.]+->)?([A-z_]+)\((.*) <no return \.\.\.>")
match_unfinished = re.compile(r"^([A-z_\.]+->)?([A-z_]+)\((.*) <unfinished \.\.\.>")
match_resumed = re.compile(r"^<\.\.\. (.*) resumed> \) += (.*)$")

# for multithreaded applications
unfinished_calls = {}
for line in ltrace:

# if the trace file contains PID (for ltrace -f)
Expand All @@ -237,6 +241,7 @@ def parse_ltrace(ltrace):

try:
_, func, args, ret = match_call.findall(line)[0]

if not func in operations:
continue
except Exception:
Expand All @@ -248,10 +253,32 @@ def parse_ltrace(ltrace):
continue
ret = None
except Exception:
print("ignoring line: %s" % line, file=sys.stderr)
continue

try:
# maybe this is an unfinished operation
_, func, args = match_unfinished.findall(line)[0]
unfinished_calls[head] = (func, args)

continue

except Exception:
try:
# or a resumed operation
if len(unfinished_calls) > 0:
func, ret = match_resumed.findall(line)[0]

if not unfinished_calls[head][0] == func:
continue
args = unfinished_calls[head][1]
unfinished_calls.pop(head)

except Exception:
print("ignoring line: %s" % line, file=sys.stderr)
continue

print("%s" % (line.strip(),), file=sys.stderr)
if type(args) == list:
args = ''.join(args)
args = list(map(sanitize, args.split(", ")))
ret = sanitize(ret)

Expand Down