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