proj: Add pid to msg()
This commit is contained in:
@@ -602,7 +602,7 @@ static void msg(const char *fmt, ...) {
|
||||
|
||||
struct timespec spec;
|
||||
clock_gettime(CLOCK_REALTIME, &spec);
|
||||
size_t offset = snprintf(buf, sizeof(buf), "%li.%09li ", spec.tv_sec, spec.tv_nsec);
|
||||
size_t offset = snprintf(buf, sizeof(buf), "%li.%09li %i ", spec.tv_sec, spec.tv_nsec, getpid());
|
||||
for (char ch, state = 0; (ch = *fmt) != 0 && offset < sizeof(buf); fmt++) {
|
||||
if (state == '%') {
|
||||
if (ch == '%') {
|
||||
|
||||
@@ -38,7 +38,7 @@ class Handler(StreamRequestHandler):
|
||||
|
||||
def handle(self):
|
||||
first = self.rfile.readline()
|
||||
meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 1)[1].strip().split(b';')]}
|
||||
meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 2)[2].strip().split(b';')]}
|
||||
self.pid = int(meta['PID']) if 'PID' in meta else None
|
||||
self.path = meta['PATH'] if 'PATH' in meta else None
|
||||
self.stack = []
|
||||
@@ -163,7 +163,7 @@ class Handler(StreamRequestHandler):
|
||||
return tuple(args), idx
|
||||
|
||||
def handle_msg(self, msg: bytes):
|
||||
timestamp, data = msg.rstrip(b'\n').split(b' ', 1)
|
||||
timestamp, pid, data = msg.rstrip(b'\n').split(b' ', 2)
|
||||
if not data.startswith(b'return ') and not data == b'return':
|
||||
call = data.decode('utf-8')
|
||||
print(f'[{self.pid}] {call}')
|
||||
|
||||
@@ -21,7 +21,10 @@ def main() -> None:
|
||||
t1 = threading.Thread(target=socket_thread, args=(socket_name,))
|
||||
t1.daemon = True
|
||||
t1.start()
|
||||
subprocess.run(extra, env={'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so', 'INTERCEPT': 'unix:' + socket_name})
|
||||
subprocess.run(extra, env={
|
||||
'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so',
|
||||
'INTERCEPT': 'unix:' + socket_name,
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -21,7 +21,11 @@ def main() -> None:
|
||||
t1 = threading.Thread(target=socket_thread, args=(socket_name,))
|
||||
t1.daemon = True
|
||||
t1.start()
|
||||
subprocess.run(extra, env={'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so', 'INTERCEPT': 'unix:' + socket_name})
|
||||
subprocess.run(extra, env={
|
||||
'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so',
|
||||
'INTERCEPT': 'unix:' + socket_name,
|
||||
'INTERCEPT_FUNCTIONS': ','.join(['malloc', 'calloc', 'realloc', 'reallocarray', 'free']),
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -32,7 +32,10 @@ def main() -> None:
|
||||
while ctx['state'] != 'finished':
|
||||
if stdin:
|
||||
stdin.seek(0, 0)
|
||||
subprocess.run(extra, stdin=stdin, env={'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so', 'INTERCEPT': 'unix:' + socket_name})
|
||||
subprocess.run(extra, stdin=stdin, env={
|
||||
'LD_PRELOAD': os.getcwd() + '/../../intercept/intercept.so',
|
||||
'INTERCEPT': 'unix:' + socket_name,
|
||||
})
|
||||
for i, name in enumerate(ctx['call_sequence']):
|
||||
errors = [r[1] for r in ctx['results'] if r[0] == i]
|
||||
results = [ctx['results'][(i, e)] for e in errors]
|
||||
|
||||
Reference in New Issue
Block a user