From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f54.google.com (mail-it0-f54.google.com [209.85.214.54]) by dpdk.org (Postfix) with ESMTP id 363E356A1 for ; Mon, 27 Jun 2016 17:42:15 +0200 (CEST) Received: by mail-it0-f54.google.com with SMTP id h190so65718748ith.1 for ; Mon, 27 Jun 2016 08:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infinite-io.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tMKWzkfhuHLGB8DiiPuL3wL7JDomx3bt+cfzVKOiRRM=; b=Vy7zthXC9VtXjVWMGHKAHa6dfiaj+QhR9A0liJq7tEJ2I03hktqCd0XgJN982rJX9w SNay9aH2SC5PQ++/LmlJFyAj4EYLoq3U48eFvzNrsVN4GZugIDFk0bBPUVGzllwW+FF8 C3Ewu/USNUGXR9dDoaoZHnE8dn8fe8PMO3WHZ+taRobTqHXxY6Tb23bAElpKTGznx2I9 atkdkxaOa0j+E2dw1RcQuz4+6arhdXEM1KmrQdFf1BsAcDxdZ4VK1kZe2sfJJJRe7z9b /xfZr3oLOzO+xaQ7PhqEdYG2Hw198olK9FFTfyjFgDSYY4TZgQmJDSp6aU+9//qXyRzd glLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tMKWzkfhuHLGB8DiiPuL3wL7JDomx3bt+cfzVKOiRRM=; b=Fu6PjvwQXKWj96NLLLNHyRk+r0vC/8k7N3OHeRIwSLD5xlMEdRSFDJZZ9JEGuGceoM m3TAHmsRhbEsfLxpJjhsLG7Dq1cKMy0cI+KDh3yjghNpuFsRDmEVpmLUuwThkWaPtX1W 73gzdU2E0hYtorw1mrmA67faUQT9dD5XEtGvDmVjUTLsy+mkzFHRR1n14k9+SRJxqYgx Ip0KwtiRC0YWgIazeD0C8nYAHwOXVRq/sHZuzYQ+NIHjBweMNxAy/x0KdruMdvUHp/Kq ocGNwbtABHbTE05z/KLqIyENa1saosFqoT4qLduxM2x2GTXIkA1ZTcixndMH9V6dYZYo uRWQ== X-Gm-Message-State: ALyK8tKJkR3jIpwOloYWLnHktp7SKSw0YXJZwqvQXuqyUupeFk6IH5nVSuFyBxnq9H9LbIipBDvOiMlJwfAUXA== X-Received: by 10.36.4.210 with SMTP id 201mr9802171itb.1.1467042134610; Mon, 27 Jun 2016 08:42:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.137.97 with HTTP; Mon, 27 Jun 2016 08:42:14 -0700 (PDT) In-Reply-To: <9B0331B6EBBD0E4684FBFAEDA55776F92CD6F0DF@HASMSX110.ger.corp.intel.com> References: <3EB4FA525960D640B5BDFFD6A3D8912647A0C78F@IRSMSX108.ger.corp.intel.com> <1678929.kjLRgJKAHP@xps13> <20160624104607.3648e62f@samsung9> <9B0331B6EBBD0E4684FBFAEDA55776F92CD6F0DF@HASMSX110.ger.corp.intel.com> From: Matt Laswell Date: Mon, 27 Jun 2016 10:42:14 -0500 Message-ID: To: "Rosen, Rami" Cc: Stephen Hemminger , Thomas Monjalon , Catalin Vasile , "dev@dpdk.org" , "Dumitrescu, Cristian" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] backtracing from within the code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2016 15:42:15 -0000 I've done something similar to what's described in the link below. But it's worth pointing out that it's using printf() inside a signal handler, which isn't safe. If your use case is catching SIGSEGV, for example, solutions built on printf() will usually work, but can deadlock. One way around the problem is to call write() directly, passing it stdout's file handle. For example, I have this in my code: #define WRITE_STRING(fd, s) write (fd, s, strlen (s)) In my signal handlers, I use the above like this: WRITE_STRING(STDOUT_FILENO, "Stack trace:\n"); This approach is a little bit more cumbersome to code, but safer. The last time that I looked the DPDK rte_dump_stack() is using vfprintf(), which isn't safe in a signal handler. However, it's been several DPDK releases since I peeked at the details. -- Matt Laswell Principal Software Engineer infinite io, inc. laswell@infinite.io On Sat, Jun 25, 2016 at 9:07 AM, Rosen, Rami wrote: > Hi, > If you are willing to skip static methods and use the GCC backtrace, you > can > try this example (it worked for me, but it was quite a time ago): > http://www.helicontech.co.il/?id=linuxbt > > Regards, > Rami Rosen > Intel Corporation > > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > Sent: Friday, June 24, 2016 8:46 PM > To: Thomas Monjalon > Cc: Catalin Vasile ; dev@dpdk.org; Dumitrescu, > Cristian > Subject: Re: [dpdk-dev] backtracing from within the code > > On Fri, 24 Jun 2016 12:05:26 +0200 > Thomas Monjalon wrote: > > > 2016-06-24 09:25, Dumitrescu, Cristian: > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Catalin Vasile > > > > I'm trying to add a feature to DPDK and I'm having a hard time > printing a > > > > backtrace. > > > > I tried using this[1] functions for printing, but it does not print > more than one > > > > function. Maybe it lacks the symbols it needs. > > [...] > > > It eventually calls rte_dump_stack() in file > lib/lirte_eal/linuxapp/eal/eal_debug.c, which calls backtrace(), which is > probably what you are looking for. > > > > Example: > > 5: [build/app/testpmd(_start+0x29) [0x416f69]] > > 4: [/usr/lib/libc.so.6(__libc_start_main+0xf0) [0x7eff3b757610]] > > 3: [build/app/testpmd(main+0x2ff) [0x416b3f]] > > 2: [build/app/testpmd(init_port_config+0x88) [0x419a78]] > > 1: [build/lib/librte_eal.so.2.1(rte_dump_stack+0x18) [0x7eff3c126488]] > > > > Please tell us if you have some cases where rte_dump_stack() does not > work. > > I do not remember what are the constraints to have it working. > > Your binary is not stripped? > > The GCC backtrace doesn't work well because it can't find static functions. > I ended up using libunwind to get a better back trace. >