From MAILER-DAEMON Fri Jul 12 11:00:31 2013 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Uxepj-0000K0-H9 for mharc-libunwind-devel@gnu.org; Fri, 12 Jul 2013 11:00:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxeU3-0007qN-97 for libunwind-devel@nongnu.org; Fri, 12 Jul 2013 10:38:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxeTt-0000Ll-JD for libunwind-devel@nongnu.org; Fri, 12 Jul 2013 10:38:07 -0400 Received: from mail-ve0-x236.google.com ([2607:f8b0:400c:c01::236]:34246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxeRb-000862-3m for libunwind-devel@nongnu.org; Fri, 12 Jul 2013 10:35:35 -0400 Received: by mail-ve0-f182.google.com with SMTP id ox1so8191873veb.41 for ; Fri, 12 Jul 2013 07:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:organization:user-agent :mime-version:content-transfer-encoding:content-type; bh=S7/iKTbRAzG+zg2EfojjfahzQypFelhHXKDeXmWBYZ4=; b=kl8RWI7LdCLwoXivlw5D2GlhbVOSJx9t3Wtfgu18yqQ8mdefxhh0hjNv9nyV7jz/LM /TQD5Tx6EgQW3CfTilrJz9rf9SBFSjw9EtD5cfEpEx54OsV4YS1eu3qMRZkoQwB5LfcZ xcoRYfy/TCWOj67L2N+Tz2KZ4Lb0/pRPEHnuVBr/aUKXLaLjHrA692gUYSEIxPq82ztC GL6ZQJB7TNIwgIerB+hdtZK5wAWYVRqGW4aCb4f7/TFgUeX0eW22gfzn4NCz3CQyJmUi EIXmt16d0kKZdyzd+ZdeCz9Oii8DVbDAC3O/3jJPDA1LHRhejaEFNX+SAvgbJ5eIiVKD upTA== X-Received: by 10.58.118.200 with SMTP id ko8mr24522462veb.94.1373639734161; Fri, 12 Jul 2013 07:35:34 -0700 (PDT) Received: from diva.localnet (adsl-70-253-161-26.dsl.stlsmo.swbell.net. [70.253.161.26]) by mx.google.com with ESMTPSA id aw3sm26412535vdc.2.2013.07.12.07.35.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Jul 2013 07:35:33 -0700 (PDT) From: Tim Holy To: libunwind-devel@nongnu.org Date: Fri, 12 Jul 2013 09:35:30 -0500 Message-ID: <2949054.mhC7Wi1s8q@diva> Organization: Washington University in St. Louis User-Agent: KMail/4.8.5 (Linux/3.2.0-49-generic; KDE/4.8.5; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::236 X-Mailman-Approved-At: Fri, 12 Jul 2013 11:00:28 -0400 Subject: [Libunwind-devel] Request for help with libunwind-dynamic X-BeenThere: libunwind-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Developer's mailing list for libunwind List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 14:38:14 -0000 Hello, I'm a user and contributor to a relatively new LLVM-based dynamic language, Julia. We use libunwind for our backtraces, and I've also used libunwind to develop a sampling profiler for Julia. Occasionally I've seen "truncated" backtraces (more detail below), where unw_step returns 0 when it shouldn't. My impression (which could, of course, be entirely mistaken---I'm only recently self-educated on frames, registers, etc.) is that these truncated backtraces may occur because we are not providing sufficient unwind information, and I'm wondering whether we need to be explicitly using libunwind-dynamic. I am having a bit of trouble understanding just how much I have to do to use it. In particular, the examples I've seen almost all derive from Gtest-dyn1.c, in which "fake dynamic" code is generated by memcpying a function, and the various parameters for interacting with libunwind-dynamic are hard-coded. The documentation on "dynamic unwind directives" seems to suggest that any operation involving a register requires a directive? Wouldn't that mean I'd have to go through the LLVM-produced assembly instruction-by-instruction and check it? I've tried supplying just _U_dyn_op_stop or the alias/stop combination that one finds in Gtest-dyn1.c; with either one, the best I've been able to achieve is a segfault on program launch. Here's my current best attempt, in case that's useful. The LLVM Function* is f, and the address (returned by getPointerToFunction()) is fptr. unw_dyn_region_info_t *region; unw_dyn_info_t di; region = (unw_dyn_region_info_t *) alloca(_U_dyn_region_info_size(2)); region->op_count = 2; region->next = NULL; // Count the number of instructions int insn_count = 0; for (Function::iterator i = f->begin(); i != f->end(); i++) insn_count += i->size(); region->insn_count = insn_count+4; // +4 for prologue/epilogue printf("%lx\n", fptr); printf("nisn = %d\n", insn_count); // _U_dyn_op_alias(®ion->op[0], 0, -1, fptr); _U_dyn_op_stop(®ion->op[0]); memset(&di, 0, sizeof(di)); di.start_ip = fptr; di.end_ip = di.start_ip+16*region->insn_count/3; di.format = UNW_INFO_FORMAT_DYNAMIC; di.u.pi.name_ptr = (unw_word_t) "A test"; di.u.pi.regions = region; _U_dyn_register (&di); The segfault can be avoided by commenting out the U_dyn_register step. Not sure whether you can help, but in any event thanks for taking the time to read this. Best, --Tim On the truncated backtraces: using a Julia function which is equivalent to the C function: int64_t unsafe_iceil(double x) { ix = (int64_t) x; return ix + (x > ix); } and which generated the following assembly: Filename: /tmp/unrooted.jl Source line: 4 push RBP mov RBP, RSP Source line: 4 cvttsd2si RCX, XMM0 Source line: 5 cvtsi2sd XMM1, RCX ucomisd XMM0, XMM1 Source line: 6 seta AL movzx EAX, AL add RAX, RCX pop RBP ret When calling this from a higher-level function, I got 2 types of backtraces, ones of length 3 and 19. The length-3 backtraces are truncated (the first two steps are generated by the signal handler and OS). On one trial, the address of the function entry was 0x00007f3788531d90. For truncated backtraces, the third frame pointer was always one of the following: 0x00007f3788531d99 0x00007f3788531d9e 0x00007f3788531da2 0x00007f3788531da5 0x00007f3788531da8 0x00007f3788531dab The length-19 backtraces were always one of the following (note that some of these may not have been inside unsafe_iceil): 0x00007f3788531d90 0x00007f3788531d91 0x00007f3788531dac 0x00007f378afc1bb0 0x00007f378afc1bba Note that these are intermingled---the length-19 backtraces start at function entry, and then there is a somewhat-curious gap of 9 bytes, followed by truncated backtraces. From MAILER-DAEMON Tue Jul 30 00:18:24 2013 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V41OB-0006WT-Vb for mharc-libunwind-devel@gnu.org; Tue, 30 Jul 2013 00:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V41O5-0006Uc-GV for libunwind-devel@nongnu.org; Tue, 30 Jul 2013 00:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V41O0-0004aM-Uj for libunwind-devel@nongnu.org; Tue, 30 Jul 2013 00:18:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V41O0-0004aB-LQ for libunwind-devel@nongnu.org; Tue, 30 Jul 2013 00:18:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6U4IBR7012617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Jul 2013 00:18:12 -0400 Received: from localhost (dhcp-193-227.nrt.redhat.com [10.64.193.227]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r6U45YJO003402 for ; Tue, 30 Jul 2013 00:05:35 -0400 Date: Tue, 30 Jul 2013 13:05:33 +0900 (JST) Message-Id: <20130730.130533.587066588601341417.yamato@redhat.com> To: libunwind-devel@nongnu.org From: Masatake YAMATO Organization: Red Hat Japan, Inc. Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Libunwind-devel] [PATCH] Missing -llzma in libunwind.pc X-BeenThere: libunwind-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Developer's mailing list for libunwind List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2013 04:18:22 -0000 liblzuma used in decoding MiniDebuginfo is not listed in libunwind.pc. Signed-off-by: Masatake YAMATO --- configure.ac | 4 +++- src/Makefile.am | 2 +- src/unwind/libunwind.pc.in | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8e7a12a..4e2fd23 100644 --- a/configure.ac +++ b/configure.ac @@ -255,19 +255,21 @@ if test x$enable_msabi_support = xyes; then fi AC_MSG_RESULT([$enable_msabi_support]) +LIBLZMA= AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables]) AC_ARG_ENABLE(minidebuginfo, AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto]) AC_MSG_RESULT([$enable_minidebuginfo]) if test x$enable_minidebuginfo != xno; then AC_CHECK_LIB([lzma], [lzma_mf_is_supported], - [AC_SUBST([LIBLZMA], [-lzma]) + [LIBLZMA=-llzma AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma]) enable_minidebuginfo=yes], [if test x$enable_minidebuginfo = xyes; then AC_MSG_FAILURE([liblzma not found]) fi]) fi +AC_SUBST([LIBLZMA]) AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes) LIBUNWIND___THREAD diff --git a/src/Makefile.am b/src/Makefile.am index 8c0c098..9881c32 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -612,7 +612,7 @@ libunwind_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -XCClinker -nostdlib \ $(LDFLAGS_STATIC_LIBCXA) -version-info $(SOVERSION) libunwind_la_LIBADD += -lc $(LIBCRTS) if HAVE_LZMA - libunwind_la_LIBADD += -llzma + libunwind_la_LIBADD += $(LIBLZMA) endif AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/tdep-$(arch) -I. diff --git a/src/unwind/libunwind.pc.in b/src/unwind/libunwind.pc.in index c2799ea..de061c4 100644 --- a/src/unwind/libunwind.pc.in +++ b/src/unwind/libunwind.pc.in @@ -6,4 +6,4 @@ includedir=@includedir@ Name: libunwind Description: libunwind base library Version: @VERSION@ -Libs: -L${libdir} -lunwind +Libs: -L${libdir} -lunwind @LIBLZMA@ -- 1.8.3.1