|
|
e7106e |
From 0cf4ab66e9927e101a51dd9fa9adc6c8dc56b5e7 Mon Sep 17 00:00:00 2001
|
|
|
e7106e |
From: Petr Machata <pmachata@redhat.com>
|
|
|
e7106e |
Date: Thu, 21 Nov 2013 20:25:53 +0100
|
|
|
e7106e |
Subject: [PATCH] Consider exec and exit events an end of outstanding calls
|
|
|
e7106e |
|
|
|
e7106e |
- This cleans up a lot of stuff. The actual substance is addition of
|
|
|
e7106e |
account_current_callstack in handle_event.c (which however uses
|
|
|
e7106e |
those cleaned-up interfaces).
|
|
|
e7106e |
|
|
|
e7106e |
- trace-exec.exp was extended to check that the exec syscall can be
|
|
|
e7106e |
seen in -c output. That's one of the symptoms of what this fixes.
|
|
|
e7106e |
---
|
|
|
e7106e |
Makefile.am | 8 +-
|
|
|
e7106e |
common.h | 2 -
|
|
|
e7106e |
forward.h | 1 +
|
|
|
e7106e |
handle_event.c | 225 ++++++++++++++++++++-------------
|
|
|
e7106e |
libltrace.c | 5 +-
|
|
|
e7106e |
options.h | 8 +-
|
|
|
e7106e |
output.c | 86 +++----------
|
|
|
e7106e |
output.h | 5 +-
|
|
|
e7106e |
proc.h | 2 +-
|
|
|
e7106e |
summary.c | 89 +++++++++++++-
|
|
|
e7106e |
summary.h | 35 +++++
|
|
|
e7106e |
testsuite/ltrace.minor/trace-exec.exp | 16 ++-
|
|
|
e7106e |
12 files changed, 299 insertions(+), 183 deletions(-)
|
|
|
e7106e |
create mode 100644 summary.h
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/Makefile.am b/Makefile.am
|
|
|
e7106e |
index d711aec..efcf18a 100644
|
|
|
e7106e |
--- a/Makefile.am
|
|
|
e7106e |
+++ b/Makefile.am
|
|
|
e7106e |
@@ -54,10 +54,10 @@ ltrace_LDADD = \
|
|
|
e7106e |
|
|
|
e7106e |
noinst_HEADERS = bits.h backend.h breakpoint.h common.h debug.h \
|
|
|
e7106e |
defs.h demangle.h dict.h forward.h ltrace-elf.h ltrace.h \
|
|
|
e7106e |
- options.h output.h proc.h read_config_file.h library.h \
|
|
|
e7106e |
- filter.h glob.h vect.h type.h value.h value_dict.h callback.h \
|
|
|
e7106e |
- expr.h fetch.h vect.h param.h printf.h zero.h lens.h \
|
|
|
e7106e |
- lens_default.h lens_enum.h memstream.h prototype.h
|
|
|
e7106e |
+ options.h output.h proc.h read_config_file.h summary.h \
|
|
|
e7106e |
+ library.h filter.h glob.h vect.h type.h value.h value_dict.h \
|
|
|
e7106e |
+ callback.h expr.h fetch.h vect.h param.h printf.h zero.h \
|
|
|
e7106e |
+ lens.h lens_default.h lens_enum.h memstream.h prototype.h
|
|
|
e7106e |
|
|
|
e7106e |
dist_man1_MANS = ltrace.1
|
|
|
e7106e |
dist_man5_MANS = ltrace.conf.5
|
|
|
e7106e |
diff --git a/common.h b/common.h
|
|
|
e7106e |
index a53c5db..7259ba4 100644
|
|
|
e7106e |
--- a/common.h
|
|
|
e7106e |
+++ b/common.h
|
|
|
e7106e |
@@ -54,8 +54,6 @@ extern void handle_event(Event * event);
|
|
|
e7106e |
|
|
|
e7106e |
extern pid_t execute_program(const char * command, char ** argv);
|
|
|
e7106e |
|
|
|
e7106e |
-extern void show_summary(void);
|
|
|
e7106e |
-
|
|
|
e7106e |
struct breakpoint;
|
|
|
e7106e |
struct library_symbol;
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/forward.h b/forward.h
|
|
|
e7106e |
index 8641213..58d8f05 100644
|
|
|
e7106e |
--- a/forward.h
|
|
|
e7106e |
+++ b/forward.h
|
|
|
e7106e |
@@ -34,6 +34,7 @@ struct param_enum;
|
|
|
e7106e |
struct process;
|
|
|
e7106e |
struct protolib;
|
|
|
e7106e |
struct prototype;
|
|
|
e7106e |
+struct timedelta;
|
|
|
e7106e |
struct value;
|
|
|
e7106e |
struct value_dict;
|
|
|
e7106e |
struct vect;
|
|
|
e7106e |
diff --git a/handle_event.c b/handle_event.c
|
|
|
e7106e |
index 9ed62a2..6fa7e98 100644
|
|
|
e7106e |
--- a/handle_event.c
|
|
|
e7106e |
+++ b/handle_event.c
|
|
|
e7106e |
@@ -32,7 +32,6 @@
|
|
|
e7106e |
#include <stdio.h>
|
|
|
e7106e |
#include <stdlib.h>
|
|
|
e7106e |
#include <string.h>
|
|
|
e7106e |
-#include <sys/time.h>
|
|
|
e7106e |
#include <stdbool.h>
|
|
|
e7106e |
|
|
|
e7106e |
#include "backend.h"
|
|
|
e7106e |
@@ -41,8 +40,9 @@
|
|
|
e7106e |
#include "fetch.h"
|
|
|
e7106e |
#include "library.h"
|
|
|
e7106e |
#include "proc.h"
|
|
|
e7106e |
-#include "value_dict.h"
|
|
|
e7106e |
#include "prototype.h"
|
|
|
e7106e |
+#include "summary.h"
|
|
|
e7106e |
+#include "value_dict.h"
|
|
|
e7106e |
|
|
|
e7106e |
static void handle_signal(Event *event);
|
|
|
e7106e |
static void handle_exit(Event *event);
|
|
|
e7106e |
@@ -419,32 +419,11 @@ handle_signal(Event *event) {
|
|
|
e7106e |
continue_after_signal(event->proc->pid, event->e_un.signum);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
-static void
|
|
|
e7106e |
-handle_exit(Event *event) {
|
|
|
e7106e |
- debug(DEBUG_FUNCTION, "handle_exit(pid=%d, status=%d)", event->proc->pid, event->e_un.ret_val);
|
|
|
e7106e |
- if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
- output_line(event->proc, "+++ exited (status %d) +++",
|
|
|
e7106e |
- event->e_un.ret_val);
|
|
|
e7106e |
- }
|
|
|
e7106e |
- remove_process(event->proc);
|
|
|
e7106e |
-}
|
|
|
e7106e |
-
|
|
|
e7106e |
-static void
|
|
|
e7106e |
-handle_exit_signal(Event *event) {
|
|
|
e7106e |
- debug(DEBUG_FUNCTION, "handle_exit_signal(pid=%d, signum=%d)", event->proc->pid, event->e_un.signum);
|
|
|
e7106e |
- if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
- output_line(event->proc, "+++ killed by %s +++",
|
|
|
e7106e |
- shortsignal(event->proc, event->e_un.signum));
|
|
|
e7106e |
- }
|
|
|
e7106e |
- remove_process(event->proc);
|
|
|
e7106e |
-}
|
|
|
e7106e |
-
|
|
|
e7106e |
-static void
|
|
|
e7106e |
-output_syscall(struct process *proc, const char *name, enum tof tof,
|
|
|
e7106e |
- void (*output)(enum tof, struct process *,
|
|
|
e7106e |
- struct library_symbol *))
|
|
|
e7106e |
+static int
|
|
|
e7106e |
+init_syscall_symbol(struct library_symbol *libsym, const char *name)
|
|
|
e7106e |
{
|
|
|
e7106e |
static struct library syscall_lib;
|
|
|
e7106e |
+
|
|
|
e7106e |
if (syscall_lib.protolib == NULL) {
|
|
|
e7106e |
struct protolib *protolib
|
|
|
e7106e |
= protolib_cache_load(&g_protocache, "syscalls", 0, 1);
|
|
|
e7106e |
@@ -475,10 +454,91 @@ output_syscall(struct process *proc, const char *name, enum tof tof,
|
|
|
e7106e |
syscall_lib.protolib = protolib;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
+ if (library_symbol_init(libsym, 0, name, 0, LS_TOPLT_NONE) < 0)
|
|
|
e7106e |
+ return -1;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ libsym->lib = &syscall_lib;
|
|
|
e7106e |
+ return 0;
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+/* Account the unfinished functions on the call stack. */
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+account_current_callstack(struct process *proc)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ if (! options.summary)
|
|
|
e7106e |
+ return;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ struct timedelta spent[proc->callstack_depth];
|
|
|
e7106e |
+
|
|
|
e7106e |
+ size_t i;
|
|
|
e7106e |
+ for (i = 0; i < proc->callstack_depth; ++i) {
|
|
|
e7106e |
+ struct callstack_element *elem = &proc->callstack[i];
|
|
|
e7106e |
+ spent[i] = calc_time_spent(elem->enter_time);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ for (i = 0; i < proc->callstack_depth; ++i) {
|
|
|
e7106e |
+ struct callstack_element *elem = &proc->callstack[i];
|
|
|
e7106e |
+ struct library_symbol syscall, *libsym = NULL;
|
|
|
e7106e |
+ if (elem->is_syscall) {
|
|
|
e7106e |
+ const char *name = sysname(proc, elem->c_un.syscall);
|
|
|
e7106e |
+ if (init_syscall_symbol(&syscall, name) >= 0)
|
|
|
e7106e |
+ libsym = &syscall;
|
|
|
e7106e |
+
|
|
|
e7106e |
+ } else {
|
|
|
e7106e |
+ libsym = elem->c_un.libfunc;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (libsym != NULL) {
|
|
|
e7106e |
+ summary_account_call(libsym, spent[i]);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (elem->is_syscall)
|
|
|
e7106e |
+ library_symbol_destroy(&syscall);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+handle_exit(Event *event) {
|
|
|
e7106e |
+ debug(DEBUG_FUNCTION, "handle_exit(pid=%d, status=%d)", event->proc->pid, event->e_un.ret_val);
|
|
|
e7106e |
+ if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
+ output_line(event->proc, "+++ exited (status %d) +++",
|
|
|
e7106e |
+ event->e_un.ret_val);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ account_current_callstack(event->proc);
|
|
|
e7106e |
+ remove_process(event->proc);
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+handle_exit_signal(Event *event) {
|
|
|
e7106e |
+ debug(DEBUG_FUNCTION, "handle_exit_signal(pid=%d, signum=%d)", event->proc->pid, event->e_un.signum);
|
|
|
e7106e |
+ if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
+ output_line(event->proc, "+++ killed by %s +++",
|
|
|
e7106e |
+ shortsignal(event->proc, event->e_un.signum));
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ account_current_callstack(event->proc);
|
|
|
e7106e |
+ remove_process(event->proc);
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+output_syscall(struct process *proc, const char *name, enum tof tof,
|
|
|
e7106e |
+ bool left, struct timedelta *spent)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ if (left)
|
|
|
e7106e |
+ assert(spent == NULL);
|
|
|
e7106e |
+
|
|
|
e7106e |
struct library_symbol syscall;
|
|
|
e7106e |
- if (library_symbol_init(&syscall, 0, name, 0, LS_TOPLT_NONE) >= 0) {
|
|
|
e7106e |
- syscall.lib = &syscall_lib;
|
|
|
e7106e |
- (*output)(tof, proc, &syscall);
|
|
|
e7106e |
+ if (init_syscall_symbol(&syscall, name) >= 0) {
|
|
|
e7106e |
+ if (left) {
|
|
|
e7106e |
+ if (! options.summary)
|
|
|
e7106e |
+ output_left(tof, proc, &syscall);
|
|
|
e7106e |
+ } else if (options.summary) {
|
|
|
e7106e |
+ summary_account_call(&syscall, *spent);
|
|
|
e7106e |
+ } else {
|
|
|
e7106e |
+ output_right(tof, proc, &syscall, spent);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
library_symbol_destroy(&syscall);
|
|
|
e7106e |
}
|
|
|
e7106e |
}
|
|
|
e7106e |
@@ -486,17 +546,19 @@ output_syscall(struct process *proc, const char *name, enum tof tof,
|
|
|
e7106e |
static void
|
|
|
e7106e |
output_syscall_left(struct process *proc, const char *name)
|
|
|
e7106e |
{
|
|
|
e7106e |
- output_syscall(proc, name, LT_TOF_SYSCALL, &output_left);
|
|
|
e7106e |
+ output_syscall(proc, name, LT_TOF_SYSCALL, true, NULL);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
static void
|
|
|
e7106e |
-output_syscall_right(struct process *proc, const char *name)
|
|
|
e7106e |
+output_syscall_right(struct process *proc, const char *name,
|
|
|
e7106e |
+ struct timedelta *spent)
|
|
|
e7106e |
{
|
|
|
e7106e |
- output_syscall(proc, name, LT_TOF_SYSCALLR, &output_right);
|
|
|
e7106e |
+ output_syscall(proc, name, LT_TOF_SYSCALLR, false, spent);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
static void
|
|
|
e7106e |
-handle_syscall(Event *event) {
|
|
|
e7106e |
+handle_syscall(Event *event)
|
|
|
e7106e |
+{
|
|
|
e7106e |
debug(DEBUG_FUNCTION, "handle_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);
|
|
|
e7106e |
if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
callstack_push_syscall(event->proc, event->e_un.sysnum);
|
|
|
e7106e |
@@ -526,6 +588,8 @@ handle_exec(Event *event)
|
|
|
e7106e |
}
|
|
|
e7106e |
output_line(proc, "--- Called exec() ---");
|
|
|
e7106e |
|
|
|
e7106e |
+ account_current_callstack(proc);
|
|
|
e7106e |
+
|
|
|
e7106e |
if (process_exec(proc) < 0) {
|
|
|
e7106e |
fprintf(stderr,
|
|
|
e7106e |
"couldn't reinitialize process %d after exec\n", pid);
|
|
|
e7106e |
@@ -549,74 +613,58 @@ handle_arch_syscall(Event *event) {
|
|
|
e7106e |
continue_process(event->proc->pid);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
-struct timeval current_time_spent;
|
|
|
e7106e |
-
|
|
|
e7106e |
static void
|
|
|
e7106e |
-calc_time_spent(struct process *proc)
|
|
|
e7106e |
+handle_x_sysret(Event *event, char *(*name_cb)(struct process *, int))
|
|
|
e7106e |
{
|
|
|
e7106e |
- struct timeval tv;
|
|
|
e7106e |
- struct timezone tz;
|
|
|
e7106e |
- struct timeval diff;
|
|
|
e7106e |
- struct callstack_element *elem;
|
|
|
e7106e |
-
|
|
|
e7106e |
- debug(DEBUG_FUNCTION, "calc_time_spent(pid=%d)", proc->pid);
|
|
|
e7106e |
- elem = &proc->callstack[proc->callstack_depth - 1];
|
|
|
e7106e |
-
|
|
|
e7106e |
- gettimeofday(&tv, &tz;;
|
|
|
e7106e |
+ debug(DEBUG_FUNCTION, "handle_x_sysret(pid=%d, sysnum=%d)",
|
|
|
e7106e |
+ event->proc->pid, event->e_un.sysnum);
|
|
|
e7106e |
|
|
|
e7106e |
- diff.tv_sec = tv.tv_sec - elem->time_spent.tv_sec;
|
|
|
e7106e |
- if (tv.tv_usec >= elem->time_spent.tv_usec) {
|
|
|
e7106e |
- diff.tv_usec = tv.tv_usec - elem->time_spent.tv_usec;
|
|
|
e7106e |
- } else {
|
|
|
e7106e |
- diff.tv_sec--;
|
|
|
e7106e |
- diff.tv_usec = 1000000 + tv.tv_usec - elem->time_spent.tv_usec;
|
|
|
e7106e |
- }
|
|
|
e7106e |
- current_time_spent = diff;
|
|
|
e7106e |
-}
|
|
|
e7106e |
+ unsigned d = event->proc->callstack_depth;
|
|
|
e7106e |
+ assert(d > 0);
|
|
|
e7106e |
+ struct callstack_element *elem = &event->proc->callstack[d - 1];
|
|
|
e7106e |
+ assert(elem->is_syscall);
|
|
|
e7106e |
|
|
|
e7106e |
-static void
|
|
|
e7106e |
-handle_sysret(Event *event) {
|
|
|
e7106e |
- debug(DEBUG_FUNCTION, "handle_sysret(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);
|
|
|
e7106e |
if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
- if (opt_T || options.summary) {
|
|
|
e7106e |
- calc_time_spent(event->proc);
|
|
|
e7106e |
- }
|
|
|
e7106e |
+ struct timedelta spent = calc_time_spent(elem->enter_time);
|
|
|
e7106e |
if (options.syscalls)
|
|
|
e7106e |
output_syscall_right(event->proc,
|
|
|
e7106e |
- sysname(event->proc,
|
|
|
e7106e |
- event->e_un.sysnum));
|
|
|
e7106e |
+ name_cb(event->proc,
|
|
|
e7106e |
+ event->e_un.sysnum),
|
|
|
e7106e |
+ &spent);
|
|
|
e7106e |
|
|
|
e7106e |
- assert(event->proc->callstack_depth > 0);
|
|
|
e7106e |
- unsigned d = event->proc->callstack_depth - 1;
|
|
|
e7106e |
- assert(event->proc->callstack[d].is_syscall);
|
|
|
e7106e |
callstack_pop(event->proc);
|
|
|
e7106e |
}
|
|
|
e7106e |
continue_after_syscall(event->proc, event->e_un.sysnum, 1);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
static void
|
|
|
e7106e |
-handle_arch_sysret(Event *event) {
|
|
|
e7106e |
- debug(DEBUG_FUNCTION, "handle_arch_sysret(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);
|
|
|
e7106e |
- if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
- if (opt_T || options.summary) {
|
|
|
e7106e |
- calc_time_spent(event->proc);
|
|
|
e7106e |
- }
|
|
|
e7106e |
- if (options.syscalls)
|
|
|
e7106e |
- output_syscall_right(event->proc,
|
|
|
e7106e |
- arch_sysname(event->proc,
|
|
|
e7106e |
- event->e_un.sysnum));
|
|
|
e7106e |
- callstack_pop(event->proc);
|
|
|
e7106e |
- }
|
|
|
e7106e |
- continue_process(event->proc->pid);
|
|
|
e7106e |
+handle_sysret(Event *event)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ handle_x_sysret(event, &sysname);
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+handle_arch_sysret(Event *event)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ handle_x_sysret(event, &arch_sysname);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
static void
|
|
|
e7106e |
output_right_tos(struct process *proc)
|
|
|
e7106e |
{
|
|
|
e7106e |
size_t d = proc->callstack_depth;
|
|
|
e7106e |
+ assert(d > 0);
|
|
|
e7106e |
struct callstack_element *elem = &proc->callstack[d - 1];
|
|
|
e7106e |
- if (proc->state != STATE_IGNORED)
|
|
|
e7106e |
- output_right(LT_TOF_FUNCTIONR, proc, elem->c_un.libfunc);
|
|
|
e7106e |
+ assert(! elem->is_syscall);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (proc->state != STATE_IGNORED) {
|
|
|
e7106e |
+ struct timedelta spent = calc_time_spent(elem->enter_time);
|
|
|
e7106e |
+ if (options.summary)
|
|
|
e7106e |
+ summary_account_call(elem->c_un.libfunc, spent);
|
|
|
e7106e |
+ else
|
|
|
e7106e |
+ output_right(LT_TOF_FUNCTIONR, proc, elem->c_un.libfunc,
|
|
|
e7106e |
+ &spent);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
#ifndef ARCH_HAVE_SYMBOL_RET
|
|
|
e7106e |
@@ -645,14 +693,8 @@ handle_breakpoint(Event *event)
|
|
|
e7106e |
|
|
|
e7106e |
for (i = event->proc->callstack_depth - 1; i >= 0; i--) {
|
|
|
e7106e |
if (brk_addr == event->proc->callstack[i].return_addr) {
|
|
|
e7106e |
- for (j = event->proc->callstack_depth - 1; j > i; j--) {
|
|
|
e7106e |
+ for (j = event->proc->callstack_depth - 1; j > i; j--)
|
|
|
e7106e |
callstack_pop(event->proc);
|
|
|
e7106e |
- }
|
|
|
e7106e |
- if (event->proc->state != STATE_IGNORED) {
|
|
|
e7106e |
- if (opt_T || options.summary) {
|
|
|
e7106e |
- calc_time_spent(event->proc);
|
|
|
e7106e |
- }
|
|
|
e7106e |
- }
|
|
|
e7106e |
|
|
|
e7106e |
struct library_symbol *libsym =
|
|
|
e7106e |
event->proc->callstack[i].c_un.libfunc;
|
|
|
e7106e |
@@ -705,11 +747,14 @@ handle_breakpoint(Event *event)
|
|
|
e7106e |
/* breakpoint_on_hit may delete its own breakpoint, so we have
|
|
|
e7106e |
* to look it up again. */
|
|
|
e7106e |
if ((sbp = address2bpstruct(leader, brk_addr)) != NULL) {
|
|
|
e7106e |
+
|
|
|
e7106e |
if (event->proc->state != STATE_IGNORED
|
|
|
e7106e |
&& sbp->libsym != NULL) {
|
|
|
e7106e |
event->proc->stack_pointer = get_stack_pointer(event->proc);
|
|
|
e7106e |
callstack_push_symfunc(event->proc, sbp);
|
|
|
e7106e |
- output_left(LT_TOF_FUNCTION, event->proc, sbp->libsym);
|
|
|
e7106e |
+ if (! options.summary)
|
|
|
e7106e |
+ output_left(LT_TOF_FUNCTION, event->proc,
|
|
|
e7106e |
+ sbp->libsym);
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
breakpoint_on_continue(sbp, event->proc);
|
|
|
e7106e |
@@ -743,7 +788,7 @@ callstack_push_syscall(struct process *proc, int sysnum)
|
|
|
e7106e |
proc->callstack_depth++;
|
|
|
e7106e |
if (opt_T || options.summary) {
|
|
|
e7106e |
struct timezone tz;
|
|
|
e7106e |
- gettimeofday(&elem->time_spent, &tz;;
|
|
|
e7106e |
+ gettimeofday(&elem->enter_time, &tz;;
|
|
|
e7106e |
}
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
@@ -781,7 +826,7 @@ callstack_push_symfunc(struct process *proc, struct breakpoint *bp)
|
|
|
e7106e |
|
|
|
e7106e |
if (opt_T || options.summary) {
|
|
|
e7106e |
struct timezone tz;
|
|
|
e7106e |
- gettimeofday(&elem->time_spent, &tz;;
|
|
|
e7106e |
+ gettimeofday(&elem->enter_time, &tz;;
|
|
|
e7106e |
}
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/libltrace.c b/libltrace.c
|
|
|
e7106e |
index 2d910a1..0112c9f 100644
|
|
|
e7106e |
--- a/libltrace.c
|
|
|
e7106e |
+++ b/libltrace.c
|
|
|
e7106e |
@@ -32,11 +32,12 @@
|
|
|
e7106e |
#include <string.h>
|
|
|
e7106e |
#include <unistd.h>
|
|
|
e7106e |
|
|
|
e7106e |
+#include "backend.h"
|
|
|
e7106e |
#include "common.h"
|
|
|
e7106e |
#include "proc.h"
|
|
|
e7106e |
-#include "read_config_file.h"
|
|
|
e7106e |
-#include "backend.h"
|
|
|
e7106e |
#include "prototype.h"
|
|
|
e7106e |
+#include "read_config_file.h"
|
|
|
e7106e |
+#include "summary.h"
|
|
|
e7106e |
|
|
|
e7106e |
char *command = NULL;
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/options.h b/options.h
|
|
|
e7106e |
index 6c28ed9..d0df3a7 100644
|
|
|
e7106e |
--- a/options.h
|
|
|
e7106e |
+++ b/options.h
|
|
|
e7106e |
@@ -1,6 +1,6 @@
|
|
|
e7106e |
/*
|
|
|
e7106e |
* This file is part of ltrace.
|
|
|
e7106e |
- * Copyright (C) 2012 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
+ * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
* Copyright (C) 2009,2010 Joe Damato
|
|
|
e7106e |
* Copyright (C) 1998,2002,2008 Juan Cespedes
|
|
|
e7106e |
* Copyright (C) 2006 Ian Wienand
|
|
|
e7106e |
@@ -103,12 +103,6 @@ int parse_colon_separated_list(const char *paths, struct vect *vec);
|
|
|
e7106e |
/* Vector of struct opt_F_t. */
|
|
|
e7106e |
extern struct vect opt_F;
|
|
|
e7106e |
|
|
|
e7106e |
-struct opt_c_struct {
|
|
|
e7106e |
- int count;
|
|
|
e7106e |
- struct timeval tv;
|
|
|
e7106e |
-};
|
|
|
e7106e |
-extern struct dict *dict_opt_c;
|
|
|
e7106e |
-
|
|
|
e7106e |
extern char **process_options(int argc, char **argv);
|
|
|
e7106e |
|
|
|
e7106e |
#endif /* _OPTIONS_H_ */
|
|
|
e7106e |
diff --git a/output.c b/output.c
|
|
|
e7106e |
index edf4522..82b6a5e 100644
|
|
|
e7106e |
--- a/output.c
|
|
|
e7106e |
+++ b/output.c
|
|
|
e7106e |
@@ -44,16 +44,12 @@
|
|
|
e7106e |
#include "param.h"
|
|
|
e7106e |
#include "proc.h"
|
|
|
e7106e |
#include "prototype.h"
|
|
|
e7106e |
+#include "summary.h"
|
|
|
e7106e |
#include "type.h"
|
|
|
e7106e |
#include "value.h"
|
|
|
e7106e |
#include "value_dict.h"
|
|
|
e7106e |
|
|
|
e7106e |
-/* TODO FIXME XXX: include in common.h: */
|
|
|
e7106e |
-extern struct timeval current_time_spent;
|
|
|
e7106e |
-
|
|
|
e7106e |
-struct dict *dict_opt_c = NULL;
|
|
|
e7106e |
-
|
|
|
e7106e |
-static struct process *current_proc = 0;
|
|
|
e7106e |
+static struct process *current_proc = NULL;
|
|
|
e7106e |
static size_t current_depth = 0;
|
|
|
e7106e |
static int current_column = 0;
|
|
|
e7106e |
|
|
|
e7106e |
@@ -498,9 +494,8 @@ void
|
|
|
e7106e |
output_left(enum tof type, struct process *proc,
|
|
|
e7106e |
struct library_symbol *libsym)
|
|
|
e7106e |
{
|
|
|
e7106e |
- if (options.summary) {
|
|
|
e7106e |
- return;
|
|
|
e7106e |
- }
|
|
|
e7106e |
+ assert(! options.summary);
|
|
|
e7106e |
+
|
|
|
e7106e |
if (current_proc) {
|
|
|
e7106e |
fprintf(options.output, " <unfinished ...>\n");
|
|
|
e7106e |
current_column = 0;
|
|
|
e7106e |
@@ -572,70 +567,21 @@ output_left(enum tof type, struct process *proc,
|
|
|
e7106e |
stel->out.need_delim = need_delim;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
-static void
|
|
|
e7106e |
-free_stringp_cb(const char **stringp, void *data)
|
|
|
e7106e |
-{
|
|
|
e7106e |
- free((char *)*stringp);
|
|
|
e7106e |
-}
|
|
|
e7106e |
-
|
|
|
e7106e |
void
|
|
|
e7106e |
-output_right(enum tof type, struct process *proc, struct library_symbol *libsym)
|
|
|
e7106e |
+output_right(enum tof type, struct process *proc, struct library_symbol *libsym,
|
|
|
e7106e |
+ struct timedelta *spent)
|
|
|
e7106e |
{
|
|
|
e7106e |
+ assert(! options.summary);
|
|
|
e7106e |
+
|
|
|
e7106e |
struct prototype *func = lookup_symbol_prototype(proc, libsym);
|
|
|
e7106e |
if (func == NULL)
|
|
|
e7106e |
return;
|
|
|
e7106e |
|
|
|
e7106e |
-again:
|
|
|
e7106e |
- if (options.summary) {
|
|
|
e7106e |
- if (dict_opt_c == NULL) {
|
|
|
e7106e |
- dict_opt_c = malloc(sizeof(*dict_opt_c));
|
|
|
e7106e |
- if (dict_opt_c == NULL) {
|
|
|
e7106e |
- oom:
|
|
|
e7106e |
- fprintf(stderr,
|
|
|
e7106e |
- "Can't allocate memory for "
|
|
|
e7106e |
- "keeping track of -c.\n");
|
|
|
e7106e |
- free(dict_opt_c);
|
|
|
e7106e |
- options.summary = 0;
|
|
|
e7106e |
- goto again;
|
|
|
e7106e |
- }
|
|
|
e7106e |
- DICT_INIT(dict_opt_c, char *, struct opt_c_struct,
|
|
|
e7106e |
- dict_hash_string, dict_eq_string, NULL);
|
|
|
e7106e |
- }
|
|
|
e7106e |
-
|
|
|
e7106e |
- struct opt_c_struct *st
|
|
|
e7106e |
- = DICT_FIND_REF(dict_opt_c, &libsym->name,
|
|
|
e7106e |
- struct opt_c_struct);
|
|
|
e7106e |
- if (st == NULL) {
|
|
|
e7106e |
- const char *na = strdup(libsym->name);
|
|
|
e7106e |
- struct opt_c_struct new_st = {.count = 0, .tv = {0, 0}};
|
|
|
e7106e |
- if (na == NULL
|
|
|
e7106e |
- || DICT_INSERT(dict_opt_c, &na, &new_st) < 0) {
|
|
|
e7106e |
- free((char *)na);
|
|
|
e7106e |
- DICT_DESTROY(dict_opt_c, const char *,
|
|
|
e7106e |
- struct opt_c_struct,
|
|
|
e7106e |
- free_stringp_cb, NULL, NULL);
|
|
|
e7106e |
- goto oom;
|
|
|
e7106e |
- }
|
|
|
e7106e |
- st = DICT_FIND_REF(dict_opt_c, &libsym->name,
|
|
|
e7106e |
- struct opt_c_struct);
|
|
|
e7106e |
- assert(st != NULL);
|
|
|
e7106e |
- }
|
|
|
e7106e |
-
|
|
|
e7106e |
- if (st->tv.tv_usec + current_time_spent.tv_usec > 1000000) {
|
|
|
e7106e |
- st->tv.tv_usec += current_time_spent.tv_usec - 1000000;
|
|
|
e7106e |
- st->tv.tv_sec++;
|
|
|
e7106e |
- } else {
|
|
|
e7106e |
- st->tv.tv_usec += current_time_spent.tv_usec;
|
|
|
e7106e |
- }
|
|
|
e7106e |
- st->count++;
|
|
|
e7106e |
- st->tv.tv_sec += current_time_spent.tv_sec;
|
|
|
e7106e |
- return;
|
|
|
e7106e |
- }
|
|
|
e7106e |
-
|
|
|
e7106e |
- if (current_proc && (current_proc != proc ||
|
|
|
e7106e |
- current_depth != proc->callstack_depth)) {
|
|
|
e7106e |
+ if (current_proc != NULL
|
|
|
e7106e |
+ && (current_proc != proc
|
|
|
e7106e |
+ || current_depth != proc->callstack_depth)) {
|
|
|
e7106e |
fprintf(options.output, " <unfinished ...>\n");
|
|
|
e7106e |
- current_proc = 0;
|
|
|
e7106e |
+ current_proc = NULL;
|
|
|
e7106e |
}
|
|
|
e7106e |
if (current_proc != proc) {
|
|
|
e7106e |
begin_of_line(proc, type == LT_TOF_FUNCTIONR, 1);
|
|
|
e7106e |
@@ -689,10 +635,12 @@ again:
|
|
|
e7106e |
value_destroy(&retval);
|
|
|
e7106e |
|
|
|
e7106e |
if (opt_T) {
|
|
|
e7106e |
+ assert(spent != NULL);
|
|
|
e7106e |
fprintf(options.output, " <%lu.%06d>",
|
|
|
e7106e |
- (unsigned long)current_time_spent.tv_sec,
|
|
|
e7106e |
- (int)current_time_spent.tv_usec);
|
|
|
e7106e |
+ (unsigned long) spent->tm.tv_sec,
|
|
|
e7106e |
+ (int) spent->tm.tv_usec);
|
|
|
e7106e |
}
|
|
|
e7106e |
+
|
|
|
e7106e |
fprintf(options.output, "\n");
|
|
|
e7106e |
|
|
|
e7106e |
#if defined(HAVE_LIBUNWIND)
|
|
|
e7106e |
@@ -746,7 +694,7 @@ again:
|
|
|
e7106e |
}
|
|
|
e7106e |
#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
e7106e |
|
|
|
e7106e |
- current_proc = 0;
|
|
|
e7106e |
+ current_proc = NULL;
|
|
|
e7106e |
current_column = 0;
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
diff --git a/output.h b/output.h
|
|
|
e7106e |
index b9f0518..2e74d61 100644
|
|
|
e7106e |
--- a/output.h
|
|
|
e7106e |
+++ b/output.h
|
|
|
e7106e |
@@ -1,6 +1,6 @@
|
|
|
e7106e |
/*
|
|
|
e7106e |
* This file is part of ltrace.
|
|
|
e7106e |
- * Copyright (C) 2011, 2012 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
+ * Copyright (C) 2011, 2012, 2013 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
* Copyright (C) 2009 Juan Cespedes
|
|
|
e7106e |
*
|
|
|
e7106e |
* This program is free software; you can redistribute it and/or
|
|
|
e7106e |
@@ -28,7 +28,8 @@ void output_line(struct process *proc, const char *fmt, ...);
|
|
|
e7106e |
void output_left(enum tof type, struct process *proc,
|
|
|
e7106e |
struct library_symbol *libsym);
|
|
|
e7106e |
void output_right(enum tof type, struct process *proc,
|
|
|
e7106e |
- struct library_symbol *libsym);
|
|
|
e7106e |
+ struct library_symbol *libsym,
|
|
|
e7106e |
+ struct timedelta *spent);
|
|
|
e7106e |
|
|
|
e7106e |
/* This function is for emitting lists of comma-separated strings.
|
|
|
e7106e |
*
|
|
|
e7106e |
diff --git a/proc.h b/proc.h
|
|
|
e7106e |
index e8032fa..64f8fe2 100644
|
|
|
e7106e |
--- a/proc.h
|
|
|
e7106e |
+++ b/proc.h
|
|
|
e7106e |
@@ -66,7 +66,7 @@ struct callstack_element {
|
|
|
e7106e |
} c_un;
|
|
|
e7106e |
int is_syscall;
|
|
|
e7106e |
arch_addr_t return_addr;
|
|
|
e7106e |
- struct timeval time_spent;
|
|
|
e7106e |
+ struct timeval enter_time;
|
|
|
e7106e |
struct fetch_context *fetch_context;
|
|
|
e7106e |
struct value_dict *arguments;
|
|
|
e7106e |
struct output_state out;
|
|
|
e7106e |
diff --git a/summary.c b/summary.c
|
|
|
e7106e |
index 9e22086..9103f71 100644
|
|
|
e7106e |
--- a/summary.c
|
|
|
e7106e |
+++ b/summary.c
|
|
|
e7106e |
@@ -22,11 +22,15 @@
|
|
|
e7106e |
|
|
|
e7106e |
#include "config.h"
|
|
|
e7106e |
|
|
|
e7106e |
+#include <sys/time.h>
|
|
|
e7106e |
#include <stdio.h>
|
|
|
e7106e |
#include <stdlib.h>
|
|
|
e7106e |
-#include <sys/time.h>
|
|
|
e7106e |
+#include <string.h>
|
|
|
e7106e |
|
|
|
e7106e |
-#include "common.h"
|
|
|
e7106e |
+#include "summary.h"
|
|
|
e7106e |
+#include "dict.h"
|
|
|
e7106e |
+#include "library.h"
|
|
|
e7106e |
+#include "options.h"
|
|
|
e7106e |
|
|
|
e7106e |
struct entry_st {
|
|
|
e7106e |
const char *name;
|
|
|
e7106e |
@@ -40,6 +44,32 @@ struct fill_struct_data {
|
|
|
e7106e |
unsigned long tot_usecs;
|
|
|
e7106e |
};
|
|
|
e7106e |
|
|
|
e7106e |
+struct opt_c_struct {
|
|
|
e7106e |
+ int count;
|
|
|
e7106e |
+ struct timeval tv;
|
|
|
e7106e |
+};
|
|
|
e7106e |
+
|
|
|
e7106e |
+static struct dict *dict_opt_c;
|
|
|
e7106e |
+
|
|
|
e7106e |
+struct timedelta
|
|
|
e7106e |
+calc_time_spent(struct timeval start)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ struct timeval tv;
|
|
|
e7106e |
+ gettimeofday(&tv, NULL);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ struct timeval diff;
|
|
|
e7106e |
+ diff.tv_sec = tv.tv_sec - start.tv_sec;
|
|
|
e7106e |
+ if (tv.tv_usec >= start.tv_usec) {
|
|
|
e7106e |
+ diff.tv_usec = tv.tv_usec - start.tv_usec;
|
|
|
e7106e |
+ } else {
|
|
|
e7106e |
+ diff.tv_sec--;
|
|
|
e7106e |
+ diff.tv_usec = 1000000 + tv.tv_usec - start.tv_usec;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ struct timedelta ret = { diff };
|
|
|
e7106e |
+ return ret;
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
static enum callback_status
|
|
|
e7106e |
fill_struct(const char **namep, struct opt_c_struct *st, void *u)
|
|
|
e7106e |
{
|
|
|
e7106e |
@@ -114,3 +144,58 @@ show_summary(void)
|
|
|
e7106e |
|
|
|
e7106e |
vect_destroy(&cdata.entries, NULL, NULL);
|
|
|
e7106e |
}
|
|
|
e7106e |
+
|
|
|
e7106e |
+static void
|
|
|
e7106e |
+free_stringp_cb(const char **stringp, void *data)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ free((char *)*stringp);
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
+void
|
|
|
e7106e |
+summary_account_call(struct library_symbol *libsym, struct timedelta spent)
|
|
|
e7106e |
+{
|
|
|
e7106e |
+ assert(options.summary);
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (dict_opt_c == NULL) {
|
|
|
e7106e |
+ dict_opt_c = malloc(sizeof(*dict_opt_c));
|
|
|
e7106e |
+ if (dict_opt_c == NULL) {
|
|
|
e7106e |
+ oom:
|
|
|
e7106e |
+ fprintf(stderr,
|
|
|
e7106e |
+ "Can't allocate memory for "
|
|
|
e7106e |
+ "keeping track of -c.\n");
|
|
|
e7106e |
+ free(dict_opt_c);
|
|
|
e7106e |
+ options.summary = 0;
|
|
|
e7106e |
+ return;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ DICT_INIT(dict_opt_c, char *, struct opt_c_struct,
|
|
|
e7106e |
+ dict_hash_string, dict_eq_string, NULL);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ struct opt_c_struct *st = DICT_FIND_REF(dict_opt_c, &libsym->name,
|
|
|
e7106e |
+ struct opt_c_struct);
|
|
|
e7106e |
+ if (st == NULL) {
|
|
|
e7106e |
+ const char *na = strdup(libsym->name);
|
|
|
e7106e |
+ struct opt_c_struct new_st = {.count = 0, .tv = {0, 0}};
|
|
|
e7106e |
+ if (na == NULL
|
|
|
e7106e |
+ || DICT_INSERT(dict_opt_c, &na, &new_st) < 0) {
|
|
|
e7106e |
+ free((char *) na);
|
|
|
e7106e |
+ DICT_DESTROY(dict_opt_c, const char *,
|
|
|
e7106e |
+ struct opt_c_struct,
|
|
|
e7106e |
+ free_stringp_cb, NULL, NULL);
|
|
|
e7106e |
+ goto oom;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ st = DICT_FIND_REF(dict_opt_c, &libsym->name,
|
|
|
e7106e |
+ struct opt_c_struct);
|
|
|
e7106e |
+ assert(st != NULL);
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+
|
|
|
e7106e |
+ if (st->tv.tv_usec + spent.tm.tv_usec > 1000000) {
|
|
|
e7106e |
+ st->tv.tv_usec += spent.tm.tv_usec - 1000000;
|
|
|
e7106e |
+ st->tv.tv_sec++;
|
|
|
e7106e |
+ } else {
|
|
|
e7106e |
+ st->tv.tv_usec += spent.tm.tv_usec;
|
|
|
e7106e |
+ }
|
|
|
e7106e |
+ st->count++;
|
|
|
e7106e |
+ st->tv.tv_sec += spent.tm.tv_sec;
|
|
|
e7106e |
+ return;
|
|
|
e7106e |
+}
|
|
|
e7106e |
diff --git a/summary.h b/summary.h
|
|
|
e7106e |
new file mode 100644
|
|
|
e7106e |
index 0000000..f680ef9
|
|
|
e7106e |
--- /dev/null
|
|
|
e7106e |
+++ b/summary.h
|
|
|
e7106e |
@@ -0,0 +1,35 @@
|
|
|
e7106e |
+/*
|
|
|
e7106e |
+ * This file is part of ltrace.
|
|
|
e7106e |
+ * Copyright (C) 2013 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
+ *
|
|
|
e7106e |
+ * This program is free software; you can redistribute it and/or
|
|
|
e7106e |
+ * modify it under the terms of the GNU General Public License as
|
|
|
e7106e |
+ * published by the Free Software Foundation; either version 2 of the
|
|
|
e7106e |
+ * License, or (at your option) any later version.
|
|
|
e7106e |
+ *
|
|
|
e7106e |
+ * This program is distributed in the hope that it will be useful, but
|
|
|
e7106e |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e7106e |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e7106e |
+ * General Public License for more details.
|
|
|
e7106e |
+ *
|
|
|
e7106e |
+ * You should have received a copy of the GNU General Public License
|
|
|
e7106e |
+ * along with this program; if not, write to the Free Software
|
|
|
e7106e |
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
e7106e |
+ * 02110-1301 USA
|
|
|
e7106e |
+ */
|
|
|
e7106e |
+
|
|
|
e7106e |
+#ifndef _SUMMARY_H_
|
|
|
e7106e |
+#define _SUMMARY_H_
|
|
|
e7106e |
+
|
|
|
e7106e |
+#include "forward.h"
|
|
|
e7106e |
+
|
|
|
e7106e |
+struct timedelta {
|
|
|
e7106e |
+ struct timeval tm;
|
|
|
e7106e |
+};
|
|
|
e7106e |
+
|
|
|
e7106e |
+struct timedelta calc_time_spent(struct timeval start);
|
|
|
e7106e |
+void summary_account_call(struct library_symbol *libsym,
|
|
|
e7106e |
+ struct timedelta spent);
|
|
|
e7106e |
+void show_summary(void);
|
|
|
e7106e |
+
|
|
|
e7106e |
+#endif /* _SUMMARY_H_ */
|
|
|
e7106e |
diff --git a/testsuite/ltrace.minor/trace-exec.exp b/testsuite/ltrace.minor/trace-exec.exp
|
|
|
e7106e |
index 7a953de..57260f8 100644
|
|
|
e7106e |
--- a/testsuite/ltrace.minor/trace-exec.exp
|
|
|
e7106e |
+++ b/testsuite/ltrace.minor/trace-exec.exp
|
|
|
e7106e |
@@ -1,5 +1,5 @@
|
|
|
e7106e |
# This file is part of ltrace.
|
|
|
e7106e |
-# Copyright (C) 2012 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
+# Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
|
|
|
e7106e |
#
|
|
|
e7106e |
# This program is free software; you can redistribute it and/or
|
|
|
e7106e |
# modify it under the terms of the GNU General Public License as
|
|
|
e7106e |
@@ -16,22 +16,30 @@
|
|
|
e7106e |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
e7106e |
# 02110-1301 USA
|
|
|
e7106e |
|
|
|
e7106e |
-ltraceMatch [ltraceRun -xmain -- [ltraceCompile {} [ltraceSource c {
|
|
|
e7106e |
+set bin1 [ltraceCompile {} [ltraceSource c {
|
|
|
e7106e |
#include <unistd.h>
|
|
|
e7106e |
#include <stdlib.h>
|
|
|
e7106e |
int main(int argc, char ** argv) {
|
|
|
e7106e |
execl(argv[1], argv[1], NULL);
|
|
|
e7106e |
abort();
|
|
|
e7106e |
}
|
|
|
e7106e |
-}]] [ltraceCompile {} [ltraceSource c {
|
|
|
e7106e |
+}]]
|
|
|
e7106e |
+
|
|
|
e7106e |
+set bin2 [ltraceCompile {} [ltraceSource c {
|
|
|
e7106e |
#include <stdio.h>
|
|
|
e7106e |
int main(void) {
|
|
|
e7106e |
return puts("Hello, World.");
|
|
|
e7106e |
}
|
|
|
e7106e |
-}]]] {
|
|
|
e7106e |
+}]]
|
|
|
e7106e |
+
|
|
|
e7106e |
+ltraceMatch [ltraceRun -xmain -- $bin1 $bin2] {
|
|
|
e7106e |
{{^execl\(} == 1}
|
|
|
e7106e |
{{^puts\(.*\) .*= 14} == 1}
|
|
|
e7106e |
{{^main\(} == 2}
|
|
|
e7106e |
}
|
|
|
e7106e |
|
|
|
e7106e |
+ltraceMatch [ltraceRun -c -- $bin1 $bin2] {
|
|
|
e7106e |
+ {{exec} > 0}
|
|
|
e7106e |
+}
|
|
|
e7106e |
+
|
|
|
e7106e |
ltraceDone
|
|
|
e7106e |
--
|
|
|
e7106e |
1.7.6.5
|
|
|
e7106e |
|