From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17991 invoked by alias); 6 Apr 2010 20:03:17 -0000 Received: (qmail 17918 invoked by uid 22791); 6 Apr 2010 20:03:16 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SARE_MSGID_LONG45 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Apr 2010 20:03:11 +0000 Received: by fg-out-1718.google.com with SMTP id d23so1108638fga.12 for ; Tue, 06 Apr 2010 13:03:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.239.172.199 with HTTP; Tue, 6 Apr 2010 13:03:08 -0700 (PDT) In-Reply-To: <20100405155102.GA23667@caradoc.them.org> References: <737ad3551003271055o91a78i3f5ff305b927e441@mail.gmail.com> <20100405155102.GA23667@caradoc.them.org> Date: Tue, 06 Apr 2010 20:03:00 -0000 Received: by 10.239.166.79 with SMTP id a15mr724921hbe.171.1270584188994; Tue, 06 Apr 2010 13:03:08 -0700 (PDT) Message-ID: Subject: Re: patch: fix stack unwind through uClibc syscall() on mips From: =?UTF-8?B?SsOhbiBTdGFuxI1law==?= To: =?UTF-8?B?SsOhbiBTdGFuxI1law==?= , gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00108.txt.bz2 On Mon, Apr 5, 2010 at 5:51 PM, Daniel Jacobowitz wr= ote: > On Sat, Mar 27, 2010 at 06:55:18PM +0100, J=C3=A1n Stan=C4=8Dek wrote: >> uClibc syscall() is macro which modifies stack before syscall >> instruction, gdb is only looking at function prologue and misses the >> stack modification made in syscall(). Because of this unwind doesn't >> work. Attached is a patch, which is looking at actual $pc and $pc-4, >> and in case of syscall it modifies $sp, so mip32_scan_prologue finds >> correct values. >> >> Description of bug is also available here: >> http://www.listware.net/201003/gnu-gdb/26893.html > > Have you considered just annotating the syscall routine with DWARF-2 > tables? =C2=A0That's how GLIBC solves this problem. =C2=A0And it doesn't = take up > any space in a stripped binary. No, I haven't. I'm not sure I understand how this can be done. Also I assume this wouldn't help with existing core files made with unmodified uClibc. > > [Hmm, good wiki topic?] > > It looks like this patch detects the syscall instruction followed by a > single instruction that adjusts sp. =C2=A0It will break if the opposite > SP adjustment was already found by the prologue analyzer. Isn't the opposite SP adjustment found each time? The loop goes from start_pc to current pc (syscall instruction), so the opposite SP adjustment should be found. As I understand it, the register offsets are saved using current SP: set_reg_offset (gdbarch, this_cache, reg, sp + low_word); and all SP adjustments don't really have any effect on these. SP adjustments affect only frame_offset (this_cache->base). > > -- > Daniel Jacobowitz > CodeSourcery >