From 44de39e5d1d6910030f17a159e564874b7fb1618 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Apr 08 2015 13:10:37 +0000 Subject: Fix tracing of multi-threaded processes without -f --- diff --git a/ltrace-0.7.91-multithread-no-f-1.patch b/ltrace-0.7.91-multithread-no-f-1.patch new file mode 100644 index 0000000..0589f5e --- /dev/null +++ b/ltrace-0.7.91-multithread-no-f-1.patch @@ -0,0 +1,175 @@ +From 4724bd5a4a19db117a1d280b9d1a3508fd4e03fa Mon Sep 17 00:00:00 2001 +From: Petr Machata +Date: Wed, 8 Apr 2015 07:11:52 -0400 +Subject: [PATCH 1/2] Convert main-threaded test case to new style + +--- + testsuite/ltrace.main/Makefile.am | 4 +- + testsuite/ltrace.main/main-threaded.c | 30 ---------- + testsuite/ltrace.main/main-threaded.exp | 103 ++++++++++++++++++++------------ + 3 files changed, 66 insertions(+), 71 deletions(-) + delete mode 100644 testsuite/ltrace.main/main-threaded.c + +diff --git a/testsuite/ltrace.main/Makefile.am b/testsuite/ltrace.main/Makefile.am +index 23ab8ab..06ad613 100644 +--- a/testsuite/ltrace.main/Makefile.am ++++ b/testsuite/ltrace.main/Makefile.am +@@ -1,4 +1,4 @@ +-# Copyright (C) 1992 - 2001, 2012, 2013 Free Software Foundation, Inc. ++# Copyright (C) 1992 - 2001, 2012, 2013, 2015 Free Software Foundation, Inc. + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by +@@ -17,7 +17,7 @@ + + EXTRA_DIST = branch_func.c branch_func.exp filters.exp hello-vfork.c \ + hello-vfork.exp main.c main.exp main-internal.exp main-lib.c \ +- main-threaded.c main-threaded.exp main-vfork.c main-vfork.exp \ ++ main-threaded.exp main-vfork.c main-vfork.exp \ + parameters.c parameters.conf parameters.exp parameters-lib.c \ + parameters2.exp parameters3.exp signals.c signals.exp \ + system_calls.c system_calls.exp system_call_params.exp +diff --git a/testsuite/ltrace.main/main-threaded.c b/testsuite/ltrace.main/main-threaded.c +deleted file mode 100644 +index 2992d1e..0000000 +--- a/testsuite/ltrace.main/main-threaded.c ++++ /dev/null +@@ -1,29 +0,0 @@ +-#include +- +-extern void print (char *); +- +-#define PRINT_LOOP 10 +- +-void * +-th_main (void *arg) +-{ +- int i; +- for (i=0; i. ++# This file is part of ltrace. ++# Copyright (C) 2011, 2015 Petr Machata, Red Hat Inc. ++# Copyright (C) 2006 Yao Qi . ++# ++# This program is free software; you can redistribute it and/or ++# modify it under the terms of the GNU General Public License as ++# published by the Free Software Foundation; either version 2 of the ++# License, or (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++# 02110-1301 USA ++ ++set libprint [ltraceCompile libprint.so [ltraceSource c { ++ #include ++ ++ void ++ print(char* s) ++ { ++ printf("%s\n",s); ++ } ++}]] ++ ++set bin [ltraceCompile {} $libprint -lpthread [ltraceSource c { ++ #include ++ ++ extern void print (char *); ++ ++ #define PRINT_LOOP 10 ++ ++ void * ++ th_main (void *arg) ++ { ++ int i; ++ for (i=0; i +Date: Wed, 8 Apr 2015 07:14:10 -0400 +Subject: [PATCH 2/2] Fix tracing multi-threaded processes without -f + +- In handle_syscall, we avoid touching stack of ignored processes. + But in handle_sysret, we require a sysret-like stack entry even + for ignored processes, even though we then go ahead to not act + on that stack entry. Instead, for ignored processes, avoid looking + at stack trace at all. +--- + handle_event.c | 10 +++++----- + testsuite/ltrace.main/main-threaded.exp | 1 + + 2 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/handle_event.c b/handle_event.c +index 6fa7e98..c2550ad 100644 +--- a/handle_event.c ++++ b/handle_event.c +@@ -619,12 +619,12 @@ handle_x_sysret(Event *event, char *(*name_cb)(struct process *, int)) + debug(DEBUG_FUNCTION, "handle_x_sysret(pid=%d, sysnum=%d)", + event->proc->pid, event->e_un.sysnum); + +- unsigned d = event->proc->callstack_depth; +- assert(d > 0); +- struct callstack_element *elem = &event->proc->callstack[d - 1]; +- assert(elem->is_syscall); +- + if (event->proc->state != STATE_IGNORED) { ++ unsigned d = event->proc->callstack_depth; ++ assert(d > 0); ++ struct callstack_element *elem = &event->proc->callstack[d - 1]; ++ assert(elem->is_syscall); ++ + struct timedelta spent = calc_time_spent(elem->enter_time); + if (options.syscalls) + output_syscall_right(event->proc, +diff --git a/testsuite/ltrace.main/main-threaded.exp b/testsuite/ltrace.main/main-threaded.exp +index cead82d..aca7afd 100644 +--- a/testsuite/ltrace.main/main-threaded.exp ++++ b/testsuite/ltrace.main/main-threaded.exp +@@ -60,5 +60,6 @@ set bin [ltraceCompile {} $libprint -lpthread [ltraceSource c { + }]] + + ltraceMatch1 [ltraceRun -f -l libprint.so -- $bin] {print\(} == 30 ++ltraceMatch1 [ltraceRun -L -- $bin] exited == 1 + + ltraceDone +-- +2.1.0 diff --git a/ltrace.spec b/ltrace.spec index fec1494..6524ace 100644 --- a/ltrace.spec +++ b/ltrace.spec @@ -1,7 +1,7 @@ Summary: Tracks runtime library calls from dynamically linked executables Name: ltrace Version: 0.7.91 -Release: 13%{?dist} +Release: 14%{?dist} URL: http://ltrace.alioth.debian.org/ License: GPLv2+ Group: Development/Debuggers @@ -79,6 +79,12 @@ Patch18: ltrace-0.7.91-x86-unused_label.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1170315 Patch19: ltrace-0.7.91-unwind-elfutils.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1208351 +# http://anonscm.debian.org/cgit/collab-maint/ltrace.git/commit/?id=4724bd5a4a19db117a1d280b9d1a3508fd4e03fa +# http://anonscm.debian.org/cgit/collab-maint/ltrace.git/commit/?id=72ee29639c55b5942bc07c8ed0013005f8fc5a97 +Patch20: ltrace-0.7.91-multithread-no-f-1.patch +Patch21: ltrace-0.7.91-multithread-no-f-2.patch + %description Ltrace is a debugging program which runs a specified command until the command exits. While the command is executing, ltrace intercepts and @@ -110,6 +116,8 @@ execution of processes. %patch17 -p1 %patch18 -p1 %patch19 -p1 +%patch20 -p1 +%patch21 -p1 %build autoreconf -i